1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.validation.impl;
17
18 import org.kuali.ole.module.purap.businessobject.InvoiceItem;
19 import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
20 import org.kuali.ole.sys.document.validation.GenericValidation;
21 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
22 import org.kuali.rice.krad.util.ObjectUtils;
23
24 public class InvoiceProcessAccountValidation extends GenericValidation {
25
26 private PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation;
27 private PurchasingAccountsPayableAccountPercentValidation accountPercentValidation;
28 private InvoiceAccountTotalValidation accountTotalValidation;
29 private PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation;
30 private InvoiceItem itemForValidation;
31 private PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation;
32 private PurchasingAccountingLineAmountValidation accountLineAmountValidation;
33
34 @Override
35 public boolean validate(AttributedDocumentEvent event) {
36 boolean valid = true;
37
38 if (ObjectUtils.isNull(itemForValidation)) {
39 return valid;
40 }
41
42 hasAccountsValidation.setItemForValidation(itemForValidation);
43 valid &= hasAccountsValidation.validate(event);
44
45 if (valid) {
46 accountPercentValidation.setItemForValidation(itemForValidation);
47 valid &= accountPercentValidation.validate(event);
48 }
49
50 if (valid) {
51 accountTotalValidation.setItemForValidation(itemForValidation);
52 valid &= accountTotalValidation.validate(event);
53 }
54
55 accountingStringsValidation.setItemForValidation(itemForValidation);
56 valid &= accountingStringsValidation.validate(event);
57
58 if (valid) {
59 getAccountHasAtlestOnePercentValidation().setItemForValidation(itemForValidation);
60 valid &= getAccountHasAtlestOnePercentValidation().validate(event);
61 }
62
63 if (valid) {
64 for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
65 getAccountLineAmountValidation().setUpdatedAccountingLine(account);
66 valid &= getAccountLineAmountValidation().validate(event);
67 if (!valid) {
68 break;
69 }
70 }
71 }
72
73 return valid;
74 }
75
76 public PurchasingAccountsPayableHasAccountsValidation getHasAccountsValidation() {
77 return hasAccountsValidation;
78 }
79
80 public void setHasAccountsValidation(PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation) {
81 this.hasAccountsValidation = hasAccountsValidation;
82 }
83
84
85 public InvoiceAccountTotalValidation getAccountTotalValidation() {
86 return accountTotalValidation;
87 }
88
89 public void setAccountTotalValidation(InvoiceAccountTotalValidation accountTotalValidation) {
90 this.accountTotalValidation = accountTotalValidation;
91 }
92
93
94 public PurchasingAccountsPayableUniqueAccountingStringsValidation getAccountingStringsValidation() {
95 return accountingStringsValidation;
96 }
97
98 public void setAccountingStringsValidation(PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation) {
99 this.accountingStringsValidation = accountingStringsValidation;
100 }
101
102 public InvoiceItem getItemForValidation() {
103 return itemForValidation;
104 }
105
106 public void setItemForValidation(InvoiceItem itemForValidation) {
107 this.itemForValidation = itemForValidation;
108 }
109
110
111
112
113
114 public PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation getAccountHasAtlestOnePercentValidation() {
115 return accountHasAtleastOnePercentValidation;
116 }
117
118
119
120
121
122
123
124 public void setAccountHasAtleastOnePercentValidation(PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation) {
125 this.accountHasAtleastOnePercentValidation = accountHasAtleastOnePercentValidation;
126 }
127
128
129
130
131
132
133
134 public PurchasingAccountingLineAmountValidation getAccountLineAmountValidation() {
135 return accountLineAmountValidation;
136 }
137
138
139
140
141
142
143 public void setAccountLineAmountValidation(PurchasingAccountingLineAmountValidation accountLineAmountValidation) {
144 this.accountLineAmountValidation = accountLineAmountValidation;
145 }
146
147 public PurchasingAccountsPayableAccountPercentValidation getAccountPercentValidation() {
148 return accountPercentValidation;
149 }
150
151 public void setAccountPercentValidation(PurchasingAccountsPayableAccountPercentValidation accountPercentValidation) {
152 this.accountPercentValidation = accountPercentValidation;
153 }
154
155 }