1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.batch.service.impl;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.gl.GeneralLedgerConstants;
23 import org.kuali.ole.gl.batch.service.VerifyTransaction;
24 import org.kuali.ole.gl.businessobject.Transaction;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.OLEKeyConstants;
27 import org.kuali.ole.sys.Message;
28 import org.kuali.rice.core.api.config.property.ConfigurationService;
29
30
31
32
33 public class VerifyTransactionImpl implements VerifyTransaction {
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(VerifyTransactionImpl.class);
35 private ConfigurationService kualiConfigurationService;
36
37
38
39
40 public VerifyTransactionImpl() {
41 super();
42 }
43
44
45
46
47
48
49
50
51 public List<Message> verifyTransaction(Transaction t) {
52 LOG.debug("verifyTransaction() started");
53
54
55 List<Message> errors = new ArrayList();
56
57
58 if (t.getChart() == null) {
59 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_CHART_NOT_FOUND), Message.TYPE_FATAL));
60 }
61
62
63 if (t.getAccount() == null) {
64 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_ACCOUNT_NOT_FOUND), Message.TYPE_FATAL));
65 }
66
67
68 if (t.getObjectType() == null) {
69 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_OBJECT_TYPE_NOT_FOUND), Message.TYPE_FATAL));
70 }
71
72
73 if (t.getBalanceType() == null) {
74 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_BALANCE_TYPE_NOT_FOUND), Message.TYPE_FATAL));
75 }
76
77
78 if (t.getOption() == null) {
79 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_UNIV_FISCAL_YR_NOT_FOUND), Message.TYPE_FATAL));
80 }
81
82
83 if (t.getTransactionDebitCreditCode() == null) {
84 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_DEDIT_CREDIT_CODE_NOT_BE_NULL), Message.TYPE_FATAL));
85 }
86 else {
87 if (t.getBalanceType() != null) {
88 if (t.getBalanceType().isFinancialOffsetGenerationIndicator()) {
89 if ((!OLEConstants.GL_DEBIT_CODE.equals(t.getTransactionDebitCreditCode())) && (!OLEConstants.GL_CREDIT_CODE.equals(t.getTransactionDebitCreditCode()))) {
90 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.MSG_DEDIT_CREDIT_CODE_MUST_BE) + " '" + OLEConstants.GL_DEBIT_CODE + " or " + OLEConstants.GL_CREDIT_CODE + kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.MSG_FOR_BALANCE_TYPE), Message.TYPE_FATAL));
91 }
92 }
93 else {
94 if (!OLEConstants.GL_BUDGET_CODE.equals(t.getTransactionDebitCreditCode())) {
95 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.MSG_DEDIT_CREDIT_CODE_MUST_BE) + OLEConstants.GL_BUDGET_CODE + kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.MSG_FOR_BALANCE_TYPE), Message.TYPE_FATAL));
96 }
97 }
98 }
99 }
100
101
102 if ((t.getSubAccountNumber() == null) || (t.getSubAccountNumber().trim().length() == 0)) {
103 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_SUB_ACCOUNT_NOT_BE_NULL), Message.TYPE_FATAL));
104 }
105 if ((t.getFinancialObjectCode() == null) || (t.getFinancialObjectCode().trim().length() == 0)) {
106 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_OBJECT_CODE_NOT_BE_NULL), Message.TYPE_FATAL));
107 }
108 if ((t.getFinancialSubObjectCode() == null) || (t.getFinancialSubObjectCode().trim().length() == 0)) {
109 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_SUB_OBJECT_CODE_NOT_BE_NULL), Message.TYPE_FATAL));
110 }
111 if ((t.getUniversityFiscalPeriodCode() == null) || (t.getUniversityFiscalPeriodCode().trim().length() == 0)) {
112 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_FISCAL_PERIOD_CODE_NOT_BE_NULL), Message.TYPE_FATAL));
113 }
114 if ((t.getFinancialDocumentTypeCode() == null) || (t.getFinancialDocumentTypeCode().trim().length() == 0)) {
115 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_DOCUMENT_TYPE_NOT_BE_NULL), Message.TYPE_FATAL));
116 }
117 if ((t.getFinancialSystemOriginationCode() == null) || (t.getFinancialSystemOriginationCode().trim().length() == 0)) {
118 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_ORIGIN_CODE_NOT_BE_NULL), Message.TYPE_FATAL));
119 }
120 if ((t.getDocumentNumber() == null) || (t.getDocumentNumber().trim().length() == 0)) {
121 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_DOCUMENT_NUMBER_NOT_BE_NULL), Message.TYPE_FATAL));
122 }
123
124
125
126
127
128
129 if (t.getBalanceType() != null && t.getBalanceType().isFinBalanceTypeEncumIndicator() && !t.getObjectType().isFundBalanceIndicator()){
130 if (t.getTransactionEncumbranceUpdateCode().trim().equals(GeneralLedgerConstants.EMPTY_CODE)){
131 errors.add(new Message(kualiConfigurationService.getPropertyValueAsString(OLEKeyConstants.ERROR_ENCUMBRANCE_UPDATE_CODE_CANNOT_BE_BLANK_FOR_BALANCE_TYPE) + " " + t.getFinancialBalanceTypeCode(), Message.TYPE_FATAL));
132 }
133 }
134
135
136 if ((StringUtils.isNotBlank(t.getTransactionEncumbranceUpdateCode())) && (!" ".equals(t.getTransactionEncumbranceUpdateCode())) && (!OLEConstants.ENCUMB_UPDT_NO_ENCUMBRANCE_CD.equals(t.getTransactionEncumbranceUpdateCode())) && (!OLEConstants.ENCUMB_UPDT_REFERENCE_DOCUMENT_CD.equals(t.getTransactionEncumbranceUpdateCode())) && (!OLEConstants.ENCUMB_UPDT_DOCUMENT_CD.equals(t.getTransactionEncumbranceUpdateCode()))) {
137 errors.add(new Message("Invalid Encumbrance Update Code (" + t.getTransactionEncumbranceUpdateCode() + ")", Message.TYPE_FATAL));
138 }
139
140
141
142 return errors;
143 }
144
145
146
147
148
149
150 public void setConfigurationService(ConfigurationService kualiConfigurationService) {
151 this.kualiConfigurationService = kualiConfigurationService;
152 }
153 }