1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.module.purap.document.validation.impl;
17
18 import org.kuali.ole.module.purap.PurapPropertyConstants;
19 import org.kuali.ole.module.purap.document.AccountsPayableDocumentBase;
20 import org.kuali.ole.sys.OLEParameterKeyConstants;
21 import org.kuali.ole.sys.businessobject.Bank;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.ole.sys.document.AccountingDocument;
24 import org.kuali.ole.sys.document.validation.GenericValidation;
25 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
26 import org.kuali.ole.sys.document.validation.impl.BankCodeValidation;
27 import org.kuali.rice.core.api.parameter.ParameterEvaluator;
28 import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
29
30 public class AccountsPayableBankCodeValidation extends GenericValidation {
31 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountsPayableBankCodeValidation.class);
32
33 private AccountingDocument accountingDocumentForValidation;
34
35
36
37
38 public boolean validate(AttributedDocumentEvent event) {
39 LOG.debug("validate start");
40
41 AccountsPayableDocumentBase apDocument = (AccountsPayableDocumentBase) accountingDocumentForValidation;
42
43 boolean isValid = true;
44 if (isDocumentTypeUsingBankCode(apDocument)) {
45 isValid = BankCodeValidation.validate(apDocument, apDocument.getBankCode(), PurapPropertyConstants.BANK_CODE, false, true);
46 }
47
48 return isValid;
49 }
50
51
52
53
54
55
56
57 private boolean isDocumentTypeUsingBankCode(AccountsPayableDocumentBase apDocument) {
58 String documentTypeName = apDocument.getDocumentHeader().getWorkflowDocument().getDocumentTypeName();
59 ParameterEvaluator evaluator = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator(Bank.class, OLEParameterKeyConstants.BANK_CODE_DOCUMENT_TYPES, documentTypeName);
60 return evaluator.evaluationSucceeds();
61 }
62
63
64
65
66
67
68
69 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
70 this.accountingDocumentForValidation = accountingDocumentForValidation;
71 }
72
73
74
75
76
77
78 public AccountingDocument getAccountingDocumentForValidation() {
79 return accountingDocumentForValidation;
80 }
81 }