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.apache.commons.lang.StringUtils;
19 import org.kuali.ole.fp.businessobject.DisbursementVoucherPayeeDetail;
20 import org.kuali.ole.fp.businessobject.DisbursementVoucherWireTransfer;
21 import org.kuali.ole.fp.document.DisbursementVoucherConstants;
22 import org.kuali.ole.fp.document.DisbursementVoucherDocument;
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.OLEKeyConstants;
25 import org.kuali.ole.sys.OLEPropertyConstants;
26 import org.kuali.ole.sys.context.SpringContext;
27 import org.kuali.ole.sys.document.AccountingDocument;
28 import org.kuali.ole.sys.document.validation.GenericValidation;
29 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
30 import org.kuali.rice.kns.service.DictionaryValidationService;
31 import org.kuali.rice.krad.util.GlobalVariables;
32 import org.kuali.rice.krad.util.MessageMap;
33
34 public class DisbursementVoucherWireTransferValidation extends GenericValidation implements DisbursementVoucherConstants {
35 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementVoucherWireTransferValidation.class);
36
37 private AccountingDocument accountingDocumentForValidation;
38
39
40
41
42 public boolean validate(AttributedDocumentEvent event) {
43 LOG.debug("validate start");
44 boolean isValid = true;
45
46 DisbursementVoucherDocument document = (DisbursementVoucherDocument) accountingDocumentForValidation;
47 DisbursementVoucherPayeeDetail payeeDetail = document.getDvPayeeDetail();
48 DisbursementVoucherWireTransfer wireTransfer = document.getDvWireTransfer();
49
50 if (!PAYMENT_METHOD_WIRE.equals(document.getDisbVchrPaymentMethodCode())) {
51 return isValid;
52 }
53
54 MessageMap errors = GlobalVariables.getMessageMap();
55 errors.addToErrorPath(OLEPropertyConstants.DOCUMENT);
56 errors.addToErrorPath(OLEPropertyConstants.DV_WIRE_TRANSFER);
57
58 SpringContext.getBean(DictionaryValidationService.class).validateBusinessObject(wireTransfer);
59
60 if (OLEConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getDisbVchrBankCountryCode()) && StringUtils.isBlank(wireTransfer.getDisbVchrBankRoutingNumber())) {
61 errors.putError(OLEPropertyConstants.DISB_VCHR_BANK_ROUTING_NUMBER, OLEKeyConstants.ERROR_DV_BANK_ROUTING_NUMBER);
62 isValid = false;
63 }
64
65 if (OLEConstants.COUNTRY_CODE_UNITED_STATES.equals(wireTransfer.getDisbVchrBankCountryCode()) && StringUtils.isBlank(wireTransfer.getDisbVchrBankStateCode())) {
66 errors.putError(OLEPropertyConstants.DISB_VCHR_BANK_STATE_CODE, OLEKeyConstants.ERROR_REQUIRED, "Bank State");
67 isValid = false;
68 }
69
70
71 if (document.isDisbVchrAttachmentCode()) {
72 errors.putErrorWithoutFullErrorPath(OLEPropertyConstants.DOCUMENT + "." + OLEPropertyConstants.DISB_VCHR_ATTACHMENT_CODE, OLEKeyConstants.ERROR_DV_WIRE_ATTACHMENT);
73 isValid = false;
74 }
75
76 errors.removeFromErrorPath(OLEPropertyConstants.DV_WIRE_TRANSFER);
77 errors.removeFromErrorPath(OLEPropertyConstants.DOCUMENT);
78
79 return isValid;
80 }
81
82
83
84
85
86 public AccountingDocument getAccountingDocumentForValidation() {
87 return accountingDocumentForValidation;
88 }
89
90
91
92
93
94
95 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
96 this.accountingDocumentForValidation = accountingDocumentForValidation;
97 }
98 }