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.impl.BankCodeValidation;
23 import org.kuali.rice.kns.service.DataDictionaryService;
24 import org.kuali.rice.kns.service.DictionaryValidationService;
25 import org.kuali.rice.krad.util.GlobalVariables;
26 import org.kuali.rice.krad.util.MessageMap;
27
28
29
30
31 public class AdvanceDepositDocumentRuleUtil {
32
33
34
35
36
37
38
39
40 public static boolean validateAdvanceDeposit(AdvanceDepositDetail advanceDeposit) {
41 MessageMap errorMap = GlobalVariables.getMessageMap();
42 int originalErrorCount = errorMap.getErrorCount();
43
44
45 SpringContext.getBean(DictionaryValidationService.class).validateBusinessObject(advanceDeposit);
46 boolean isValid = (errorMap.getErrorCount() == originalErrorCount);
47
48
49 if (isValid) {
50 isValid = !advanceDeposit.getFinancialDocumentAdvanceDepositAmount().isZero();
51 if (!isValid) {
52 String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(AdvanceDepositDetail.class, OLEPropertyConstants.ADVANCE_DEPOSIT_AMOUNT);
53 errorMap.putError(OLEPropertyConstants.ADVANCE_DEPOSIT_AMOUNT, OLEKeyConstants.AdvanceDeposit.ERROR_DOCUMENT_ADVANCE_DEPOSIT_ZERO_AMOUNT, label);
54 }
55 }
56
57 if (isValid) {
58 isValid = BankCodeValidation.validate(advanceDeposit.getFinancialDocumentBankCode(), OLEPropertyConstants.FINANCIAL_DOCUMENT_BANK_CODE, true, false);
59 }
60
61 return isValid;
62 }
63 }