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.AdvanceDepositDetail;
19 import org.kuali.ole.sys.OLEKeyConstants;
20 import org.kuali.ole.sys.OLEPropertyConstants;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.ole.sys.document.validation.GenericValidation;
23 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24 import org.kuali.ole.sys.document.validation.impl.BankCodeValidation;
25 import org.kuali.rice.kns.service.DataDictionaryService;
26 import org.kuali.rice.krad.util.GlobalVariables;
27
28
29
30
31 public class AdvanceDepositValidation extends GenericValidation {
32 protected AdvanceDepositDetail advanceDepositDetailForValidation;
33
34
35
36 public boolean validate(AttributedDocumentEvent event) {
37
38 AdvanceDepositDetail advanceDeposit = getAdvanceDepositDetailForValidation();
39 boolean isValid = true;
40
41
42 if (isValid) {
43 isValid = !advanceDeposit.getFinancialDocumentAdvanceDepositAmount().isZero();
44 if (!isValid) {
45 String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(AdvanceDepositDetail.class, OLEPropertyConstants.ADVANCE_DEPOSIT_AMOUNT);
46 GlobalVariables.getMessageMap().putError(OLEPropertyConstants.ADVANCE_DEPOSIT_AMOUNT, OLEKeyConstants.AdvanceDeposit.ERROR_DOCUMENT_ADVANCE_DEPOSIT_ZERO_AMOUNT, label);
47 }
48 }
49
50 if (isValid) {
51 isValid = BankCodeValidation.validate(advanceDeposit.getFinancialDocumentBankCode(), OLEPropertyConstants.FINANCIAL_DOCUMENT_BANK_CODE, true, false);
52 }
53
54 return isValid;
55 }
56
57
58
59
60 public AdvanceDepositDetail getAdvanceDepositDetailForValidation() {
61 return advanceDepositDetailForValidation;
62 }
63
64
65
66
67 public void setAdvanceDepositDetailForValidation(AdvanceDepositDetail advanceDepositDetailForValidation) {
68 this.advanceDepositDetailForValidation = advanceDepositDetailForValidation;
69 }
70 }