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 org.kuali.ole.fp.businessobject.BudgetAdjustmentAccountingLine;
19 import org.kuali.ole.sys.OLEKeyConstants;
20 import org.kuali.ole.sys.OLEPropertyConstants;
21 import org.kuali.ole.sys.document.OLEAccountingDocument;
22 import org.kuali.ole.sys.document.service.DebitDeterminerService;
23 import org.kuali.ole.sys.document.validation.GenericValidation;
24 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
25 import org.kuali.rice.core.api.util.type.KualiDecimal;
26 import org.kuali.rice.krad.util.GlobalVariables;
27
28
29
30
31 public class BudgetAdjustmentAccountingLineAmountValidation extends GenericValidation {
32 private BudgetAdjustmentAccountingLine accountingLineForValidation;
33 private OLEAccountingDocument accountingDocumentForValidation;
34 private DebitDeterminerService debitDeterminerService;
35
36
37
38
39
40
41 public boolean validate(AttributedDocumentEvent event) {
42 boolean amountValid = true;
43
44
45 if (getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount().isZero() && getAccountingLineForValidation().getBaseBudgetAdjustmentAmount().isZero()) {
46 GlobalVariables.getMessageMap().putError(OLEPropertyConstants.BASE_BUDGET_ADJUSTMENT_AMOUNT, OLEKeyConstants.ERROR_BA_AMOUNT_ZERO);
47 amountValid = false;
48 }
49
50
51 if (!debitDeterminerService.isErrorCorrection(getAccountingDocumentForValidation())) {
52 amountValid &= checkAmountSign(getAccountingLineForValidation().getCurrentBudgetAdjustmentAmount(), OLEPropertyConstants.CURRENT_BUDGET_ADJUSTMENT_AMOUNT, "Current");
53 amountValid &= checkAmountSign(getAccountingLineForValidation().getBaseBudgetAdjustmentAmount(), OLEPropertyConstants.BASE_BUDGET_ADJUSTMENT_AMOUNT, "Base");
54 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth1LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_1_LINE_AMOUNT, "Month 1");
55 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth2LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_2_LINE_AMOUNT, "Month 2");
56 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth3LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_3_LINE_AMOUNT, "Month 3");
57 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth4LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_4_LINE_AMOUNT, "Month 4");
58 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth5LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_5_LINE_AMOUNT, "Month 5");
59 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth6LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_6_LINE_AMOUNT, "Month 6");
60 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth7LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_7_LINE_AMOUNT, "Month 7");
61 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth8LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_8_LINE_AMOUNT, "Month 8");
62 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth8LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_9_LINE_AMOUNT, "Month 9");
63 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth10LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_10_LINE_AMOUNT, "Month 10");
64 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth10LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_11_LINE_AMOUNT, "Month 11");
65 amountValid &= checkAmountSign(getAccountingLineForValidation().getFinancialDocumentMonth12LineAmount(), OLEPropertyConstants.FINANCIAL_DOCUMENT_MONTH_12_LINE_AMOUNT, "Month 12");
66 }
67 return amountValid;
68 }
69
70
71
72
73
74
75
76
77
78 protected boolean checkAmountSign(KualiDecimal amount, String propertyName, String label) {
79 boolean correctSign = true;
80
81 if (amount.isNegative()) {
82 GlobalVariables.getMessageMap().putError(propertyName, OLEKeyConstants.ERROR_BA_AMOUNT_NEGATIVE, label);
83 correctSign = false;
84 }
85
86 return correctSign;
87 }
88
89
90
91
92
93
94 public BudgetAdjustmentAccountingLine getAccountingLineForValidation() {
95 return accountingLineForValidation;
96 }
97
98
99
100
101
102 public void setAccountingLineForValidation(BudgetAdjustmentAccountingLine accountingLineForValidation) {
103 this.accountingLineForValidation = accountingLineForValidation;
104 }
105
106
107
108
109
110 public OLEAccountingDocument getAccountingDocumentForValidation() {
111 return accountingDocumentForValidation;
112 }
113
114
115
116
117
118 public void setAccountingDocumentForValidation(OLEAccountingDocument accountingDocumentForValidation) {
119 this.accountingDocumentForValidation = accountingDocumentForValidation;
120 }
121
122
123
124
125
126 public DebitDeterminerService getDebitDeterminerService() {
127 return debitDeterminerService;
128 }
129
130
131
132
133
134 public void setDebitDeterminerService(DebitDeterminerService debitDeterminerService) {
135 this.debitDeterminerService = debitDeterminerService;
136 }
137 }