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.businessobject.PurApItem;
20 import org.kuali.ole.module.purap.document.validation.impl.PurchasingAccountsPayableAccountTotalValidation;
21 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
22
23 import java.math.BigDecimal;
24
25 public class OlePurchasingAccountsPayableAccountTotalValidation extends PurchasingAccountsPayableAccountTotalValidation {
26
27 private PurApItem itemForValidation;
28
29
30
31
32 @Override
33 public boolean validate(AttributedDocumentEvent event) {
34 boolean valid = true;
35
36
37 BigDecimal totalAmount = BigDecimal.ZERO;
38 BigDecimal desiredAmount =
39 (itemForValidation.getTotalAmount() == null) ? new BigDecimal(0) : itemForValidation.getTotalAmount().bigDecimalValue();
40 for (PurApAccountingLine account : itemForValidation.getSourceAccountingLines()) {
41 if (account.getAmount() != null) {
42 totalAmount = totalAmount.add(account.getAmount().bigDecimalValue());
43 } else {
44 totalAmount = totalAmount.add(BigDecimal.ZERO);
45 }
46 }
47
48
49
50
51
52
53
54
55
56 return valid;
57 }
58
59 public PurApItem getItemForValidation() {
60 return itemForValidation;
61 }
62
63 public void setItemForValidation(PurApItem itemForValidation) {
64 this.itemForValidation = itemForValidation;
65 }
66
67 }