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 static org.kuali.ole.sys.OLEConstants.ACCOUNTING_LINE_ERRORS;
19 import static org.kuali.ole.sys.OLEKeyConstants.AuxiliaryVoucher.ERROR_DIFFERENT_CHARTS;
20
21 import java.util.List;
22
23 import org.kuali.ole.sys.businessobject.AccountingLine;
24 import org.kuali.ole.sys.document.AccountingDocument;
25 import org.kuali.ole.sys.document.validation.GenericValidation;
26 import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
27 import org.kuali.rice.krad.util.GlobalVariables;
28
29
30
31
32 public class AuxiliaryVoucherSingleChartUsedValidation 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 baseChartCode = null;
44 int index = 0;
45
46 List<AccountingLine> lines = accountingDocumentForValidation.getSourceAccountingLines();
47 for (AccountingLine line : lines) {
48 if (index == 0) {
49 baseChartCode = line.getChartOfAccountsCode();
50 }
51 else {
52 String currentChartCode = line.getChartOfAccountsCode();
53 if (!currentChartCode.equals(baseChartCode)) {
54 GlobalVariables.getMessageMap().putError(ACCOUNTING_LINE_ERRORS, ERROR_DIFFERENT_CHARTS, new String[] {});
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 }