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.document.AdvanceDepositDocument;
19 import org.kuali.ole.sys.OLEConstants;
20 import org.kuali.ole.sys.OLEKeyConstants;
21 import org.kuali.ole.sys.businessobject.AccountingLine;
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.service.ElectronicPaymentClaimingService;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27
28
29
30
31 public class AdvanceDepositIfAnyElectronicFundAccountingLineAllElectronicFundValidation extends GenericValidation {
32 private AdvanceDepositDocument advanceDepositDocumentForValidation;
33 private ElectronicPaymentClaimingService electronicPaymentClaimingService;
34
35
36
37
38
39 public boolean validate(AttributedDocumentEvent event) {
40 boolean result = true;
41 if (anyAccountingLinesRepresentElectronicPayments() && !allAccountingLinesRepresentElectronicPayments()) {
42 GlobalVariables.getMessageMap().putError(OLEConstants.ACCOUNTING_LINE_ERRORS, OLEKeyConstants.AdvanceDeposit.ERROR_DOCUMENT_ADVANCE_DEPOSIT_INCORRECT_ELECTRONIC_PAYMENT_STATE, new String[] {});
43 result = false;
44 }
45 return result;
46 }
47
48
49
50
51
52 protected boolean anyAccountingLinesRepresentElectronicPayments() {
53 for (Object accountingLineAsObject : getAdvanceDepositDocumentForValidation().getSourceAccountingLines()) {
54 final AccountingLine accountingLine = (AccountingLine)accountingLineAsObject;
55 if (getElectronicPaymentClaimingService().representsElectronicFundAccount(accountingLine)) {
56 return true;
57 }
58 }
59 return false;
60 }
61
62
63
64
65
66 protected boolean allAccountingLinesRepresentElectronicPayments() {
67 for (Object accountingLineAsObject : getAdvanceDepositDocumentForValidation().getSourceAccountingLines()) {
68 final AccountingLine accountingLine = (AccountingLine)accountingLineAsObject;
69 if (!getElectronicPaymentClaimingService().representsElectronicFundAccount(accountingLine)) {
70 return false;
71 }
72 }
73 return true;
74 }
75
76
77
78
79
80 public AdvanceDepositDocument getAdvanceDepositDocumentForValidation() {
81 return advanceDepositDocumentForValidation;
82 }
83
84
85
86
87
88 public void setAdvanceDepositDocumentForValidation(AdvanceDepositDocument documentForValidation) {
89 this.advanceDepositDocumentForValidation = documentForValidation;
90 }
91
92
93
94
95
96 public ElectronicPaymentClaimingService getElectronicPaymentClaimingService() {
97 return electronicPaymentClaimingService;
98 }
99
100
101
102
103
104 public void setElectronicPaymentClaimingService(ElectronicPaymentClaimingService electronicPaymentClaimingService) {
105 this.electronicPaymentClaimingService = electronicPaymentClaimingService;
106 }
107 }