1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.fp.businessobject;
18
19 import static org.kuali.ole.sys.OLEPropertyConstants.ACCOUNT_NUMBER;
20 import static org.kuali.ole.sys.OLEPropertyConstants.AMOUNT;
21 import static org.kuali.ole.sys.OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE;
22 import static org.kuali.ole.sys.OLEPropertyConstants.CREDIT;
23 import static org.kuali.ole.sys.OLEPropertyConstants.DEBIT;
24 import static org.kuali.ole.sys.OLEPropertyConstants.FINANCIAL_OBJECT_CODE;
25 import static org.kuali.ole.sys.OLEPropertyConstants.FINANCIAL_SUB_OBJECT_CODE;
26 import static org.kuali.ole.sys.OLEPropertyConstants.OBJECT_TYPE_CODE;
27 import static org.kuali.ole.sys.OLEPropertyConstants.ORGANIZATION_REFERENCE_ID;
28 import static org.kuali.ole.sys.OLEPropertyConstants.PROJECT_CODE;
29 import static org.kuali.ole.sys.OLEPropertyConstants.REFERENCE_NUMBER;
30 import static org.kuali.ole.sys.OLEPropertyConstants.REFERENCE_ORIGIN_CODE;
31 import static org.kuali.ole.sys.OLEPropertyConstants.REFERENCE_TYPE_CODE;
32 import static org.kuali.ole.sys.OLEPropertyConstants.SUB_ACCOUNT_NUMBER;
33
34 import java.util.Map;
35
36 import org.apache.commons.lang.StringUtils;
37 import org.kuali.ole.coa.service.BalanceTypeService;
38 import org.kuali.ole.sys.OLEConstants;
39 import org.kuali.ole.sys.businessobject.SourceAccountingLine;
40 import org.kuali.ole.sys.context.SpringContext;
41
42
43
44
45 public class JournalVoucherAccountingLineParser extends AuxiliaryVoucherAccountingLineParser {
46 private String balanceTypeCode;
47 protected static final String[] NON_OFFSET_FORMAT = { CHART_OF_ACCOUNTS_CODE, ACCOUNT_NUMBER, SUB_ACCOUNT_NUMBER, FINANCIAL_OBJECT_CODE, OBJECT_TYPE_CODE, FINANCIAL_SUB_OBJECT_CODE, PROJECT_CODE, ORGANIZATION_REFERENCE_ID, AMOUNT };
48 protected static final String[] OFFSET_FORMAT = { CHART_OF_ACCOUNTS_CODE, ACCOUNT_NUMBER, SUB_ACCOUNT_NUMBER, FINANCIAL_OBJECT_CODE, OBJECT_TYPE_CODE, FINANCIAL_SUB_OBJECT_CODE, PROJECT_CODE, ORGANIZATION_REFERENCE_ID, DEBIT, CREDIT };
49 protected static final String[] ENCUMBRANCE_FORMAT = { CHART_OF_ACCOUNTS_CODE, ACCOUNT_NUMBER, SUB_ACCOUNT_NUMBER, FINANCIAL_OBJECT_CODE, OBJECT_TYPE_CODE, FINANCIAL_SUB_OBJECT_CODE, PROJECT_CODE, ORGANIZATION_REFERENCE_ID, REFERENCE_ORIGIN_CODE, REFERENCE_TYPE_CODE, REFERENCE_NUMBER, DEBIT, CREDIT };
50
51
52
53
54
55
56 public JournalVoucherAccountingLineParser(String balanceTypeCode) {
57 super();
58 this.balanceTypeCode = balanceTypeCode;
59 }
60
61
62
63
64
65 @Override
66 protected void performCustomSourceAccountingLinePopulation(Map<String, String> attributeValueMap, SourceAccountingLine sourceAccountingLine, String accountingLineAsString) {
67
68 boolean isFinancialOffsetGeneration = SpringContext.getBean(BalanceTypeService.class).getBalanceTypeByCode(balanceTypeCode).isFinancialOffsetGenerationIndicator();
69 if (isFinancialOffsetGeneration || StringUtils.equals(balanceTypeCode, OLEConstants.BALANCE_TYPE_EXTERNAL_ENCUMBRANCE)) {
70 super.performCustomSourceAccountingLinePopulation(attributeValueMap, sourceAccountingLine, accountingLineAsString);
71 }
72 sourceAccountingLine.setBalanceTypeCode(balanceTypeCode);
73 }
74
75
76
77
78 @Override
79 public String[] getSourceAccountingLineFormat() {
80 return removeChartFromFormatIfNeeded(selectFormat());
81 }
82
83
84
85
86
87
88 private String[] selectFormat() {
89 if (StringUtils.equals(balanceTypeCode, OLEConstants.BALANCE_TYPE_EXTERNAL_ENCUMBRANCE)) {
90 return ENCUMBRANCE_FORMAT;
91 }
92 else if (SpringContext.getBean(BalanceTypeService.class).getBalanceTypeByCode(balanceTypeCode).isFinancialOffsetGenerationIndicator()) {
93 return OFFSET_FORMAT;
94 }
95 else {
96 return NON_OFFSET_FORMAT;
97 }
98 }
99 }