1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document.validation.impl;
17
18 import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
19 import org.kuali.ole.module.purap.document.validation.impl.*;
20 import org.kuali.ole.select.businessobject.OleCreditMemoItem;
21 import org.kuali.ole.sys.document.validation.GenericValidation;
22 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
23 import org.kuali.rice.krad.util.ObjectUtils;
24
25 public class OleVendorCreditMemoProcessAccountValidation extends GenericValidation {
26 private PurchasingAccountsPayableHasAccountsValidation hasAccountsValidation;
27 private PurchasingAccountsPayableAccountPercentValidation accountPercentValidation;
28 private PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation;
29 private OleCreditMemoItem itemForValidation;
30 private PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation;
31 private PurchasingAccountingLineAmountValidation accountLineAmountValidation;
32 private OleVendorCreditMemoAccountTotalValidation 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(
99 PurchasingAccountsPayableUniqueAccountingStringsValidation accountingStringsValidation) {
100 this.accountingStringsValidation = accountingStringsValidation;
101 }
102
103 public OleCreditMemoItem getItemForValidation() {
104 return itemForValidation;
105 }
106
107 public void setItemForValidation(OleCreditMemoItem itemForValidation) {
108 this.itemForValidation = itemForValidation;
109 }
110
111
112
113
114
115 public PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation getAccountHasAtlestOnePercentValidation() {
116 return accountHasAtleastOnePercentValidation;
117 }
118
119
120
121
122
123
124
125 public void setAccountHasAtleastOnePercentValidation(
126 PurchasingAccountsPayableAccountAtleastOneLineHasPercentValidation accountHasAtleastOnePercentValidation) {
127 this.accountHasAtleastOnePercentValidation = accountHasAtleastOnePercentValidation;
128 }
129
130
131
132
133
134
135
136 public PurchasingAccountingLineAmountValidation getAccountLineAmountValidation() {
137 return accountLineAmountValidation;
138 }
139
140
141
142
143
144
145 public void setAccountLineAmountValidation(PurchasingAccountingLineAmountValidation accountLineAmountValidation) {
146 this.accountLineAmountValidation = accountLineAmountValidation;
147 }
148
149 public OleVendorCreditMemoAccountTotalValidation getAccountTotalValidation() {
150 return accountTotalValidation;
151 }
152
153 public void setAccountTotalValidation(OleVendorCreditMemoAccountTotalValidation accountTotalValidation) {
154 this.accountTotalValidation = accountTotalValidation;
155 }
156
157
158 }