001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.module.gl.batch.poster.impl;
017:
018: import java.util.ArrayList;
019: import java.util.List;
020:
021: import org.kuali.core.service.KualiConfigurationService;
022: import org.kuali.kfs.KFSConstants;
023: import org.kuali.kfs.KFSKeyConstants;
024: import org.kuali.module.gl.batch.poster.VerifyTransaction;
025: import org.kuali.module.gl.bo.Transaction;
026:
027: /**
028: * A general use implementation of VerifyTransaction
029: */
030: public class VerifyTransactionImpl implements VerifyTransaction {
031: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
032: .getLogger(VerifyTransactionImpl.class);
033: private KualiConfigurationService kualiConfigurationService;
034:
035: /**
036: * Constructs a VerifyTransactionImpl instance
037: */
038: public VerifyTransactionImpl() {
039: super ();
040: }
041:
042: /**
043: * Determines if the given transaction qualifies for posting
044: *
045: * @param t the transaction to verify
046: * @return a List of String error messages
047: * @see org.kuali.module.gl.batch.poster.VerifyTransaction#verifyTransaction(org.kuali.module.gl.bo.Transaction)
048: */
049: public List verifyTransaction(Transaction t) {
050: LOG.debug("verifyTransaction() started");
051:
052: // List of error messages for the current transaction
053: List errors = new ArrayList();
054:
055: // Check the chart of accounts code
056: if (t.getChart() == null) {
057: errors
058: .add(kualiConfigurationService
059: .getPropertyString(KFSKeyConstants.ERROR_CHART_NOT_FOUND));
060: }
061:
062: // Check the account
063: if (t.getAccount() == null) {
064: errors
065: .add(kualiConfigurationService
066: .getPropertyString(KFSKeyConstants.ERROR_ACCOUNT_NOT_FOUND));
067: }
068:
069: // Check the object type
070: if (t.getObjectType() == null) {
071: errors
072: .add(kualiConfigurationService
073: .getPropertyString(KFSKeyConstants.ERROR_OBJECT_TYPE_NOT_FOUND));
074: }
075:
076: // Check the balance type
077: if (t.getBalanceType() == null) {
078: errors
079: .add(kualiConfigurationService
080: .getPropertyString(KFSKeyConstants.ERROR_BALANCE_TYPE_NOT_FOUND));
081: }
082:
083: // Check the fiscal year
084: if (t.getOption() == null) {
085: errors
086: .add(kualiConfigurationService
087: .getPropertyString(KFSKeyConstants.ERROR_UNIV_FISCAL_YR_NOT_FOUND));
088: }
089:
090: // Check the debit/credit code (only if we have a valid balance type code)
091: if (t.getTransactionDebitCreditCode() == null) {
092: errors
093: .add(kualiConfigurationService
094: .getPropertyString(KFSKeyConstants.ERROR_DEDIT_CREDIT_CODE_NOT_BE_NULL));
095: } else {
096: if (t.getBalanceType() != null) {
097: if (t.getBalanceType()
098: .isFinancialOffsetGenerationIndicator()) {
099: if ((!KFSConstants.GL_DEBIT_CODE.equals(t
100: .getTransactionDebitCreditCode()))
101: && (!KFSConstants.GL_CREDIT_CODE.equals(t
102: .getTransactionDebitCreditCode()))) {
103: errors
104: .add(kualiConfigurationService
105: .getPropertyString(KFSKeyConstants.MSG_DEDIT_CREDIT_CODE_MUST_BE)
106: + KFSConstants.GL_DEBIT_CODE
107: + " or "
108: + KFSConstants.GL_CREDIT_CODE
109: + kualiConfigurationService
110: .getPropertyString(KFSKeyConstants.MSG_FOR_BALANCE_TYPE));
111: }
112: } else {
113: if (!KFSConstants.GL_BUDGET_CODE.equals(t
114: .getTransactionDebitCreditCode())) {
115: errors
116: .add(kualiConfigurationService
117: .getPropertyString(KFSKeyConstants.MSG_DEDIT_CREDIT_CODE_MUST_BE)
118: + KFSConstants.GL_BUDGET_CODE
119: + kualiConfigurationService
120: .getPropertyString(KFSKeyConstants.MSG_FOR_BALANCE_TYPE));
121: }
122: }
123: }
124: }
125:
126: // KULGL-58 Make sure all GL entry primary key fields are not null
127: if ((t.getSubAccountNumber() == null)
128: || (t.getSubAccountNumber().trim().length() == 0)) {
129: errors
130: .add(kualiConfigurationService
131: .getPropertyString(KFSKeyConstants.ERROR_SUB_ACCOUNT_NOT_BE_NULL));
132: }
133: if ((t.getFinancialObjectCode() == null)
134: || (t.getFinancialObjectCode().trim().length() == 0)) {
135: errors
136: .add(kualiConfigurationService
137: .getPropertyString(KFSKeyConstants.ERROR_OBJECT_CODE_NOT_BE_NULL));
138: }
139: if ((t.getFinancialSubObjectCode() == null)
140: || (t.getFinancialSubObjectCode().trim().length() == 0)) {
141: errors
142: .add(kualiConfigurationService
143: .getPropertyString(KFSKeyConstants.ERROR_SUB_OBJECT_CODE_NOT_BE_NULL));
144: }
145: if ((t.getUniversityFiscalPeriodCode() == null)
146: || (t.getUniversityFiscalPeriodCode().trim().length() == 0)) {
147: errors
148: .add(kualiConfigurationService
149: .getPropertyString(KFSKeyConstants.ERROR_FISCAL_PERIOD_CODE_NOT_BE_NULL));
150: }
151: if ((t.getFinancialDocumentTypeCode() == null)
152: || (t.getFinancialDocumentTypeCode().trim().length() == 0)) {
153: errors
154: .add(kualiConfigurationService
155: .getPropertyString(KFSKeyConstants.ERROR_DOCUMENT_TYPE_NOT_BE_NULL));
156: }
157: if ((t.getFinancialSystemOriginationCode() == null)
158: || (t.getFinancialSystemOriginationCode().trim()
159: .length() == 0)) {
160: errors
161: .add(kualiConfigurationService
162: .getPropertyString(KFSKeyConstants.ERROR_ORIGIN_CODE_NOT_BE_NULL));
163: }
164: if ((t.getDocumentNumber() == null)
165: || (t.getDocumentNumber().trim().length() == 0)) {
166: errors
167: .add(kualiConfigurationService
168: .getPropertyString(KFSKeyConstants.ERROR_DOCUMENT_NUMBER_NOT_BE_NULL));
169: }
170: if (t.getTransactionLedgerEntrySequenceNumber() == null) {
171: errors
172: .add(kualiConfigurationService
173: .getPropertyString(KFSKeyConstants.ERROR_SEQUENCE_NUMBER_NOT_BE_NULL));
174: }
175:
176: return errors;
177: }
178:
179: /**
180: * Sets the kualiConfigurationService attribute value.
181: *
182: * @param kualiConfigurationService The kualiConfigurationService to set.
183: */
184: public void setKualiConfigurationService(
185: KualiConfigurationService kualiConfigurationService) {
186: this.kualiConfigurationService = kualiConfigurationService;
187: }
188: }
|