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.document.DisbursementVoucherConstants;
20 import org.kuali.ole.fp.document.DisbursementVoucherDocument;
21 import org.kuali.ole.sys.OLEKeyConstants;
22 import org.kuali.ole.sys.OLEPropertyConstants;
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.rice.krad.util.GlobalVariables;
27 import org.kuali.rice.krad.util.MessageMap;
28
29 public class DisbursementVoucherForeignDraftValidation extends GenericValidation implements DisbursementVoucherConstants {
30 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DisbursementVoucherEmployeeInformationValidation.class);
31
32 private AccountingDocument accountingDocumentForValidation;
33
34
35
36
37 public boolean validate(AttributedDocumentEvent event) {
38 LOG.debug("validate start");
39 boolean isValid = true;
40
41 DisbursementVoucherDocument document = (DisbursementVoucherDocument) accountingDocumentForValidation;
42 if (!PAYMENT_METHOD_DRAFT.equals(document.getDisbVchrPaymentMethodCode())) {
43 return true;
44 }
45
46 MessageMap errors = GlobalVariables.getMessageMap();
47 errors.addToErrorPath(OLEPropertyConstants.DOCUMENT);
48 errors.addToErrorPath(OLEPropertyConstants.DV_WIRE_TRANSFER);
49
50
51 if (StringUtils.isBlank(document.getDvWireTransfer().getDisbursementVoucherForeignCurrencyTypeCode())) {
52 errors.putError(OLEPropertyConstants.DISB_VCHR_FD_CURRENCY_TYPE_CODE, OLEKeyConstants.ERROR_DV_CURRENCY_TYPE_CODE);
53 isValid = false;
54 }
55
56
57 if (StringUtils.isBlank(document.getDvWireTransfer().getDisbursementVoucherForeignCurrencyTypeName())) {
58 errors.putError(OLEPropertyConstants.DISB_VCHR_FD_CURRENCY_TYPE_NAME, OLEKeyConstants.ERROR_DV_CURRENCY_TYPE_NAME);
59 isValid = false;
60 }
61
62 errors.removeFromErrorPath(OLEPropertyConstants.DV_WIRE_TRANSFER);
63 errors.removeFromErrorPath(OLEPropertyConstants.DOCUMENT);
64
65 return isValid;
66 }
67
68
69
70
71
72
73 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
74 this.accountingDocumentForValidation = accountingDocumentForValidation;
75 }
76
77
78
79
80
81 public AccountingDocument getAccountingDocumentForValidation() {
82 return accountingDocumentForValidation;
83 }
84 }