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.document.validation.impl.AccountingDocumentRuleBaseConstants.ERROR_PATH.DOCUMENT_ERROR_PREFIX;
19
20 import org.kuali.ole.fp.document.CashReceiptDocument;
21 import org.kuali.ole.fp.document.CashReceiptFamilyBase;
22 import org.kuali.ole.sys.OLEKeyConstants;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.document.validation.GenericValidation;
25 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26 import org.kuali.rice.core.api.util.type.KualiDecimal;
27 import org.kuali.rice.krad.util.GlobalVariables;
28
29
30
31
32 public class CashReceiptFamilyDocumentTotalValidation extends GenericValidation {
33 private CashReceiptFamilyBase cashReceiptFamilyDocumentForValidation;
34
35
36
37
38
39
40
41 public boolean validate(AttributedDocumentEvent event) {
42
43 boolean isValid = getCashReceiptFamilyDocumentForValidation().getTotalDollarAmount().compareTo(KualiDecimal.ZERO) > 0;
44 if (!isValid) {
45 GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX + OLEPropertyConstants.SUM_TOTAL_AMOUNT, OLEKeyConstants.CashReceipt.ERROR_DOCUMENT_CASH_RECEIPT_NO_CASH_RECONCILIATION_TOTAL);
46 }
47
48 if (isValid) {
49
50 isValid = getCashReceiptFamilyDocumentForValidation().getSourceTotal().compareTo(getCashReceiptFamilyDocumentForValidation().getTotalDollarAmount().subtract(
51 ((CashReceiptDocument)getCashReceiptFamilyDocumentForValidation()).getTotalChangeAmount())) == 0;
52
53 if (!isValid) {
54 GlobalVariables.getMessageMap().putError(DOCUMENT_ERROR_PREFIX + OLEPropertyConstants.SUM_TOTAL_AMOUNT, OLEKeyConstants.CashReceipt.ERROR_DOCUMENT_CASH_RECEIPT_BALANCE);
55 }
56 }
57
58 return isValid;
59 }
60
61
62
63
64
65 public CashReceiptFamilyBase getCashReceiptFamilyDocumentForValidation() {
66 return cashReceiptFamilyDocumentForValidation;
67 }
68
69
70
71
72
73 public void setCashReceiptFamilyDocumentForValidation(CashReceiptFamilyBase cashReceiptFamilyDocumentForValidation) {
74 this.cashReceiptFamilyDocumentForValidation = cashReceiptFamilyDocumentForValidation;
75 }
76 }