1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.validation.impl;
17
18 import static org.kuali.ole.sys.OLEConstants.ACCOUNTING_LINE_ERRORS;
19 import static org.kuali.ole.sys.OLEKeyConstants.ERROR_DOCUMENT_BALANCE_CONSIDERING_CREDIT_AND_DEBIT_AMOUNTS;
20
21 import org.kuali.ole.fp.document.AuxiliaryVoucherDocument;
22 import org.kuali.ole.sys.document.validation.GenericValidation;
23 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24 import org.kuali.rice.core.api.util.type.KualiDecimal;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27
28
29
30
31 public class AuxiliaryVoucherAccountingLinesBalanceValidation extends GenericValidation {
32 private AuxiliaryVoucherDocument auxiliaryVoucherDocumentForValidation;
33
34
35
36
37
38 public boolean validate(AttributedDocumentEvent event) {
39 KualiDecimal creditAmount = getAuxiliaryVoucherDocumentForValidation().getCreditTotal();
40 KualiDecimal debitAmount = getAuxiliaryVoucherDocumentForValidation().getDebitTotal();
41
42 boolean balanced = debitAmount.equals(creditAmount);
43 if (!balanced) {
44 String errorParams[] = { creditAmount.toString(), debitAmount.toString() };
45 GlobalVariables.getMessageMap().putError(ACCOUNTING_LINE_ERRORS, ERROR_DOCUMENT_BALANCE_CONSIDERING_CREDIT_AND_DEBIT_AMOUNTS, errorParams);
46 }
47 return balanced;
48 }
49
50
51
52
53
54 public AuxiliaryVoucherDocument getAuxiliaryVoucherDocumentForValidation() {
55 return auxiliaryVoucherDocumentForValidation;
56 }
57
58
59
60
61
62 public void setAuxiliaryVoucherDocumentForValidation(AuxiliaryVoucherDocument accountingDocumentForValidation) {
63 this.auxiliaryVoucherDocumentForValidation = accountingDocumentForValidation;
64 }
65 }