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.apache.commons.lang.ObjectUtils;
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.ole.fp.businessobject.NonResidentAlienTaxPercent;
21 import org.kuali.ole.module.purap.PurapConstants;
22 import org.kuali.ole.module.purap.PurapConstants.InvoiceStatuses;
23 import org.kuali.ole.module.purap.PurapKeyConstants;
24 import org.kuali.ole.module.purap.PurapPropertyConstants;
25 import org.kuali.ole.module.purap.document.InvoiceDocument;
26 import org.kuali.ole.sys.document.validation.GenericValidation;
27 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
28 import org.kuali.rice.core.api.util.type.KualiDecimal;
29 import org.kuali.rice.krad.service.BusinessObjectService;
30 import org.kuali.rice.krad.util.GlobalVariables;
31 import org.kuali.rice.krad.util.MessageMap;
32
33 import java.math.BigDecimal;
34 import java.util.ArrayList;
35 import java.util.HashMap;
36 import java.util.List;
37 import java.util.Map;
38
39 public class InvoiceTaxAreaValidation extends GenericValidation {
40
41 private BusinessObjectService businessObjectService;
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94 public boolean validate(AttributedDocumentEvent event) {
95 InvoiceDocument invoice = (InvoiceDocument) event.getDocument();
96
97
98 if (!StringUtils.equals(invoice.getApplicationDocumentStatus(), InvoiceStatuses.APPDOC_AWAITING_TAX_REVIEW))
99 return true;
100
101 MessageMap errorMap = GlobalVariables.getMessageMap();
102 errorMap.clearErrorPath();
103
104 errorMap.addToErrorPath(PurapConstants.PAYMENT_REQUEST_TAX_TAB_ERRORS);
105
106 boolean valid = true;
107 valid &= validateTaxIncomeClass(invoice);
108 valid &= validateTaxRates(invoice);
109 valid &= validateTaxIndicators(invoice);
110
111 errorMap.clearErrorPath();
112 return valid;
113 }
114
115
116
117
118
119
120
121
122
123 protected boolean validateTaxIncomeClass(InvoiceDocument invoice) {
124 boolean valid = true;
125 MessageMap errorMap = GlobalVariables.getMessageMap();
126
127
128 if (StringUtils.isEmpty(invoice.getTaxClassificationCode())) {
129 valid = false;
130 errorMap.putError(PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_REQUIRED, PurapPropertyConstants.TAX_CLASSIFICATION_CODE);
131 }
132
133 else if (StringUtils.equalsIgnoreCase(invoice.getTaxClassificationCode(), "N")) {
134 if (invoice.getTaxFederalPercent() != null && invoice.getTaxFederalPercent().compareTo(new BigDecimal(0)) != 0) {
135 valid = false;
136 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
137 }
138 if (invoice.getTaxStatePercent() != null && invoice.getTaxStatePercent().compareTo(new BigDecimal(0)) != 0) {
139 valid = false;
140 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_STATE_PERCENT);
141 }
142 if (!StringUtils.isEmpty(invoice.getTaxCountryCode())) {
143 valid = false;
144 errorMap.putError(PurapPropertyConstants.TAX_COUNTRY_CODE, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_COUNTRY_CODE);
145 }
146 if (!StringUtils.isEmpty(invoice.getTaxNQIId())) {
147 valid = false;
148 errorMap.putError(PurapPropertyConstants.TAX_NQI_ID, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_NQI_ID);
149 }
150 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new BigDecimal(0)) != 0) {
151 valid = false;
152 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
153 }
154 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
155 valid = false;
156 errorMap.putError(PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR);
157 }
158 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
159 valid = false;
160 errorMap.putError(PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR);
161 }
162 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
163 valid = false;
164 errorMap.putError(PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR);
165 }
166 if (ObjectUtils.equals(invoice.getTaxUSAIDPerDiemIndicator(), true)) {
167 valid = false;
168 errorMap.putError(PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR);
169 }
170 if (ObjectUtils.equals(invoice.getTaxOtherExemptIndicator(), true)) {
171 valid = false;
172 errorMap.putError(PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR);
173 }
174 } else {
175
176 if (invoice.getTaxFederalPercent() == null) {
177 valid = false;
178 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_REQUIRED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
179 }
180 if (invoice.getTaxStatePercent() == null) {
181 valid = false;
182 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_REQUIRED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_STATE_PERCENT);
183 }
184 if (StringUtils.isEmpty(invoice.getTaxCountryCode())) {
185 valid = false;
186 errorMap.putError(PurapPropertyConstants.TAX_COUNTRY_CODE, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_REQUIRED_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_COUNTRY_CODE);
187 }
188 }
189
190 return valid;
191 }
192
193
194
195
196
197
198
199
200 protected boolean validateTaxRates(InvoiceDocument invoice) {
201 boolean valid = true;
202 String code = invoice.getTaxClassificationCode();
203 BigDecimal fedrate = invoice.getTaxFederalPercent();
204 BigDecimal strate = invoice.getTaxStatePercent();
205 MessageMap errorMap = GlobalVariables.getMessageMap();
206
207
208 if (StringUtils.isEmpty(code) || StringUtils.equalsIgnoreCase(code, "N") || fedrate == null || strate == null)
209 return true;
210
211
212 ArrayList<BigDecimal> fedrates = retrieveTaxRates(code, "F");
213 if (!listContainsValue(fedrates, fedrate)) {
214 valid = false;
215 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
216 }
217 ArrayList<BigDecimal> strates = retrieveTaxRates(code, "S");
218 if (!listContainsValue(strates, strate)) {
219 valid = false;
220 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapPropertyConstants.TAX_STATE_PERCENT);
221 }
222
223
224 if (fedrate.compareTo(new BigDecimal(0)) == 0 && strate.compareTo(new BigDecimal(0)) != 0) {
225 valid = false;
226 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapPropertyConstants.TAX_STATE_PERCENT);
227 }
228 boolean hasstrate = code.equalsIgnoreCase("F") || code.equalsIgnoreCase("A") || code.equalsIgnoreCase("O");
229 if (fedrate.compareTo(new BigDecimal(0)) > 0 && strate.compareTo(new BigDecimal(0)) <= 0 && hasstrate) {
230 valid = false;
231 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_NOT_ZERO_IF, PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapPropertyConstants.TAX_STATE_PERCENT);
232 }
233
234 return valid;
235 }
236
237
238
239
240
241
242
243 protected boolean validateTaxIndicators(InvoiceDocument invoice) {
244 boolean valid = true;
245 MessageMap errorMap = GlobalVariables.getMessageMap();
246
247
248 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
249 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
250 valid = false;
251 errorMap.putError(PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR);
252 }
253 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
254 valid = false;
255 errorMap.putError(PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR);
256 }
257 if (ObjectUtils.equals(invoice.getTaxUSAIDPerDiemIndicator(), true)) {
258 valid = false;
259 errorMap.putError(PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR);
260 }
261 if (ObjectUtils.equals(invoice.getTaxOtherExemptIndicator(), true)) {
262 valid = false;
263 errorMap.putError(PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR);
264 }
265 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) != 0) {
266 valid = false;
267 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
268 }
269
270
271
272
273
274
275
276
277
278 }
279
280
281 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
282 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
283 valid = false;
284 errorMap.putError(PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR);
285 }
286 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
287 valid = false;
288 errorMap.putError(PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR);
289 }
290 if (ObjectUtils.equals(invoice.getTaxUSAIDPerDiemIndicator(), true)) {
291 valid = false;
292 errorMap.putError(PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR);
293 }
294 if (ObjectUtils.equals(invoice.getTaxOtherExemptIndicator(), true)) {
295 valid = false;
296 errorMap.putError(PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR);
297 }
298 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) != 0) {
299 valid = false;
300 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
301 }
302 if (invoice.getTaxFederalPercent() == null || invoice.getTaxFederalPercent().compareTo(new BigDecimal(0)) == 0) {
303 valid = false;
304 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_NOT_ZERO_IF, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
305 }
306 }
307
308
309 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
310 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
311 valid = false;
312 errorMap.putError(PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR);
313 }
314 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
315 valid = false;
316 errorMap.putError(PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR);
317 }
318 if (ObjectUtils.equals(invoice.getTaxUSAIDPerDiemIndicator(), true)) {
319 valid = false;
320 errorMap.putError(PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR);
321 }
322 if (ObjectUtils.equals(invoice.getTaxOtherExemptIndicator(), true)) {
323 valid = false;
324 errorMap.putError(PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR);
325 }
326 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) != 0) {
327 valid = false;
328 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
329 }
330 if (invoice.getTaxFederalPercent() != null && invoice.getTaxFederalPercent().compareTo(new BigDecimal(0)) != 0) {
331 valid = false;
332 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
333 }
334 if (invoice.getTaxStatePercent() != null && invoice.getTaxStatePercent().compareTo(new BigDecimal(0)) != 0) {
335 valid = false;
336 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapPropertyConstants.TAX_STATE_PERCENT);
337 }
338 }
339
340
341 if (ObjectUtils.equals(invoice.getTaxUSAIDPerDiemIndicator(), true)) {
342 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
343 valid = false;
344 errorMap.putError(PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR);
345 }
346 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
347 valid = false;
348 errorMap.putError(PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR);
349 }
350 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
351 valid = false;
352 errorMap.putError(PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR);
353 }
354 if (!ObjectUtils.equals(invoice.getTaxOtherExemptIndicator(), true)) {
355 valid = false;
356 errorMap.putError(PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_REQUIRED_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR);
357 }
358 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) != 0) {
359 valid = false;
360 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
361 }
362 if (StringUtils.isEmpty(invoice.getTaxClassificationCode()) || !StringUtils.equalsIgnoreCase(invoice.getTaxClassificationCode(), "F")) {
363 valid = false;
364 errorMap.putError(PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_CLASSIFICATION_CODE);
365 }
366 if (invoice.getTaxFederalPercent() != null && invoice.getTaxFederalPercent().compareTo(new BigDecimal(0)) != 0) {
367 valid = false;
368 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
369 }
370 if (invoice.getTaxStatePercent() != null && invoice.getTaxStatePercent().compareTo(new BigDecimal(0)) != 0) {
371 valid = false;
372 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_USAID_PER_DIEM_INDICATOR, PurapPropertyConstants.TAX_STATE_PERCENT);
373 }
374 }
375
376
377 if (ObjectUtils.equals(invoice.getTaxOtherExemptIndicator(), true)) {
378 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
379 valid = false;
380 errorMap.putError(PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR);
381 }
382 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
383 valid = false;
384 errorMap.putError(PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR);
385 }
386 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
387 valid = false;
388 errorMap.putError(PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR);
389 }
390 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) != 0) {
391 valid = false;
392 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
393 }
394 if (invoice.getTaxFederalPercent() != null && invoice.getTaxFederalPercent().compareTo(new BigDecimal(0)) != 0) {
395 valid = false;
396 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
397 }
398 if (invoice.getTaxStatePercent() != null && invoice.getTaxStatePercent().compareTo(new BigDecimal(0)) != 0) {
399 valid = false;
400 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_OTHER_EXEMPT_INDICATOR, PurapPropertyConstants.TAX_STATE_PERCENT);
401 }
402 }
403
404
405 if (invoice.getTaxSpecialW4Amount() != null && invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) != 0) {
406 if (ObjectUtils.equals(invoice.getTaxExemptTreatyIndicator(), true)) {
407 valid = false;
408 errorMap.putError(PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapPropertyConstants.TAX_EXEMPT_TREATY_INDICATOR);
409 }
410 if (ObjectUtils.equals(invoice.getTaxGrossUpIndicator(), true)) {
411 valid = false;
412 errorMap.putError(PurapPropertyConstants.TAX_GROSS_UP_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapPropertyConstants.TAX_GROSS_UP_INDICATOR);
413 }
414 if (ObjectUtils.equals(invoice.getTaxForeignSourceIndicator(), true)) {
415 valid = false;
416 errorMap.putError(PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_DISALLOWED_IF, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapPropertyConstants.TAX_FOREIGN_SOURCE_INDICATOR);
417 }
418 if (invoice.getTaxSpecialW4Amount().compareTo(new KualiDecimal(0)) < 0) {
419 valid = false;
420 errorMap.putError(PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_MUST_NOT_NEGATIVE, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT);
421 }
422 if (StringUtils.isEmpty(invoice.getTaxClassificationCode()) || !StringUtils.equalsIgnoreCase(invoice.getTaxClassificationCode(), "F")) {
423 valid = false;
424 errorMap.putError(PurapPropertyConstants.TAX_CLASSIFICATION_CODE, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_FIELD_VALUE_INVALID_IF, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapPropertyConstants.TAX_CLASSIFICATION_CODE);
425 }
426 if (invoice.getTaxFederalPercent() != null && invoice.getTaxFederalPercent().compareTo(new BigDecimal(0)) != 0) {
427 valid = false;
428 errorMap.putError(PurapPropertyConstants.TAX_FEDERAL_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapPropertyConstants.TAX_FEDERAL_PERCENT);
429 }
430 if (invoice.getTaxStatePercent() != null && invoice.getTaxStatePercent().compareTo(new BigDecimal(0)) != 0) {
431 valid = false;
432 errorMap.putError(PurapPropertyConstants.TAX_STATE_PERCENT, PurapKeyConstants.ERROR_PAYMENT_REQUEST_TAX_RATE_MUST_ZERO_IF, PurapPropertyConstants.TAX_SPECIAL_W4_AMOUNT, PurapPropertyConstants.TAX_STATE_PERCENT);
433 }
434 }
435
436 return valid;
437 }
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469 public ArrayList<BigDecimal> retrieveTaxRates(String incomeClassCode, String incomeTaxTypeCode) {
470 ArrayList<BigDecimal> rates = new ArrayList<BigDecimal>();
471 Map<String, String> criterion = new HashMap<String, String>();
472 criterion.put("incomeClassCode", incomeClassCode);
473 criterion.put("incomeTaxTypeCode", incomeTaxTypeCode);
474 criterion.put("active", "Y");
475 List<NonResidentAlienTaxPercent> percents = (List<NonResidentAlienTaxPercent>) businessObjectService.findMatching(NonResidentAlienTaxPercent.class, criterion);
476
477 for (NonResidentAlienTaxPercent percent : percents) {
478 rates.add(percent.getIncomeTaxPercent().bigDecimalValue());
479 }
480 return rates;
481 }
482
483
484
485
486
487
488
489 protected boolean listContainsValue(ArrayList<BigDecimal> list, BigDecimal value) {
490 if (list == null || value == null)
491 return false;
492 for (BigDecimal val : list) {
493 if (val.compareTo(value) == 0)
494 return true;
495 }
496 return false;
497 }
498
499 public BusinessObjectService getBusinessObjectService() {
500 return businessObjectService;
501 }
502
503 public void setBusinessObjectService(BusinessObjectService businessObjectService) {
504 this.businessObjectService = businessObjectService;
505 }
506 }