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 java.util.List;
19
20 import org.kuali.ole.sys.OLEConstants;
21 import org.kuali.ole.sys.OLEKeyConstants;
22 import org.kuali.ole.sys.businessobject.AccountingLine;
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
28
29
30
31
32 public class AuxiliaryVoucherSingleSubFundValidation extends GenericValidation {
33 private AccountingDocument accountingDocumentForValidation;
34
35
36
37
38
39
40 public boolean validate(AttributedDocumentEvent event) {
41 boolean valid = true;
42
43 String baseSubFundGroupCode = null;
44 int index = 0;
45
46 List<AccountingLine> lines = getAccountingDocumentForValidation().getSourceAccountingLines();
47 for (AccountingLine line : lines) {
48 if (index == 0) {
49 baseSubFundGroupCode = line.getAccount().getSubFundGroupCode();
50 }
51 else {
52 String currentSubFundGroup = line.getAccount().getSubFundGroupCode();
53 if (!currentSubFundGroup.equals(baseSubFundGroupCode)) {
54 GlobalVariables.getMessageMap().putError(OLEConstants.ACCOUNTING_LINE_ERRORS, OLEKeyConstants.AuxiliaryVoucher.ERROR_DIFFERENT_SUB_FUND_GROUPS);
55 return false;
56 }
57 }
58 index++;
59 }
60 return true;
61 }
62
63
64
65
66
67 public AccountingDocument getAccountingDocumentForValidation() {
68 return accountingDocumentForValidation;
69 }
70
71
72
73
74
75 public void setAccountingDocumentForValidation(AccountingDocument accountingDocumentForValidation) {
76 this.accountingDocumentForValidation = accountingDocumentForValidation;
77 }
78 }