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.PurApAccountingLine;
19 import org.kuali.ole.module.purap.businessobject.PurApItem;
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 PurchasingAccountsPayableProcessAccountValidation extends GenericValidation {
25
26 private PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation;
27 private PurchasingAccountsPayableAccountPercentValidation accountPercentValidation;
28 private PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation;
29 private PurApItem itemForValidation;
30 private PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation;
31 private PurchasingAccountingLineAmountValidation accountLineAmountValidation;
32 private PurchasingAccountsPayableAccountTotalValidation accountTotalValidation;
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 getAccountHasAtlestOnePercentValidation().setItemForValidation(itemForValidation);
47 valid &= getAccountHasAtlestOnePercentValidation().validate(event);
48 }
49
50 if (valid) {
51 for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
52 getAccountLineAmountValidation().setUpdatedAccountingLine(account);
53 valid &= getAccountLineAmountValidation().validate(event);
54 if (!valid) {
55 break;
56 }
57 }
58 }
59
60 if (valid) {
61 accountPercentValidation.setItemForValidation(itemForValidation);
62 valid &= accountPercentValidation.validate(event);
63 }
64
65 if (valid) {
66 accountTotalValidation.setItemForValidation(itemForValidation);
67 valid &= accountTotalValidation.validate(event);
68 }
69
70 if (valid) {
71 accountingStringsValidation.setItemForValidation(itemForValidation);
72 valid &= accountingStringsValidation.validate(event);
73 }
74
75 return valid;
76 }
77
78 public PurchasingAccountsPayableHasAccountsValidation getHasAccountsValidation() {
79 return hasAccountsValidation;
80 }
81
82 public void setHasAccountsValidation(PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation) {
83 this.hasAccountsValidation = hasAccountsValidation;
84 }
85
86 public PurchasingAccountsPayableAccountPercentValidation getAccountPercentValidation() {
87 return accountPercentValidation;
88 }
89
90 public void setAccountPercentValidation(PurchasingAccountsPayableAccountPercentValidation accountPercentValidation) {
91 this.accountPercentValidation = accountPercentValidation;
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 PurApItem getItemForValidation() {
103 return itemForValidation;
104 }
105
106 public void setItemForValidation(PurApItem 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
148
149
150
151
152
153 public PurchasingAccountsPayableAccountTotalValidation getAccountTotalValidation() {
154 return accountTotalValidation;
155 }
156
157
158
159
160
161
162 public void setAccountTotalValidation(PurchasingAccountsPayableAccountTotalValidation accountTotalValidation) {
163 this.accountTotalValidation = accountTotalValidation;
164 }
165 }