0001: /*
0002: * Copyright 2006-2007 The Kuali Foundation.
0003: *
0004: * Licensed under the Educational Community License, Version 1.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.opensource.org/licenses/ecl1.php
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package org.kuali.module.gl.service;
0017:
0018: import java.math.BigDecimal;
0019: import java.text.SimpleDateFormat;
0020: import java.util.Calendar;
0021: import java.util.Date;
0022: import java.util.List;
0023: import java.util.Map;
0024:
0025: import org.apache.commons.lang.StringUtils;
0026: import org.kuali.core.dbplatform.RawSQL;
0027: import org.kuali.core.util.Guid;
0028: import org.kuali.kfs.context.SpringContext;
0029: import org.kuali.module.gl.OriginEntryTestBase;
0030: import org.kuali.module.gl.bo.OriginEntrySource;
0031: import org.kuali.test.ConfigureContext;
0032:
0033: /**
0034: * Tests the PosterService
0035: */
0036: @ConfigureContext
0037: @RawSQL
0038: public class PosterServiceTest extends OriginEntryTestBase {
0039: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
0040: .getLogger(PosterServiceTest.class);
0041:
0042: private PosterService posterService;
0043:
0044: /**
0045: *
0046: * @see org.kuali.module.gl.OriginEntryTestBase#setUp()
0047: */
0048: @Override
0049: protected void setUp() throws Exception {
0050: super .setUp();
0051:
0052: Calendar c = Calendar.getInstance();
0053: c.set(Calendar.DAY_OF_MONTH, 1);
0054: c.set(Calendar.MONTH, Calendar.JANUARY);
0055: c.set(Calendar.YEAR, 2004);
0056:
0057: // because of the cutoff time implementation, assume a specific time of day after the cutoff (10:00 am, see RunDateService
0058: // for details)
0059: c.set(Calendar.HOUR_OF_DAY, 23);
0060: c.set(Calendar.MINUTE, 50);
0061: c.set(Calendar.SECOND, 0);
0062: date = c.getTime();
0063:
0064: // Set the run date of the job
0065: dateTimeService.setCurrentDate(date);
0066:
0067: posterService = SpringContext.getBean(PosterService.class);
0068: posterService.setDateTimeService(dateTimeService);
0069: }
0070:
0071: ///**
0072: // * Check invalid entries
0073: // *
0074: // * @throws Exception
0075: // */
0076: //
0077: // This test succeeds in Eclipse, but fails in Anthill
0078: // public void testInvalidEntries() throws Exception {
0079: // LOG.debug("testInvalidEntries() started");
0080: //
0081: // /*
0082: // * These transactions are invalid for one reason or another:
0083: // * 0 - bad chartOfAccountsCode
0084: // * 1 - bad accountNumber
0085: // * 2 - bad objectTypeCode
0086: // * 3 - bad balanceTypeCode
0087: // * 4 - bad univFiscalYear
0088: // * 5 - bad debitCreditCode
0089: // * 6 - bad debitCreditCode
0090: // * 7 - 19 empty key field
0091: // */
0092: // String[] inputTransactions = {
0093: // "2007XX6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0094: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0095: // "2007BA9999999-----8000---ACAS07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0096: // 1445.00C2006-01-05ABCDEFGHIG----------12345678 ",
0097: // "2007BA6044900-----8000---ACZZ07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0098: // 1445.00C2006-01-05ABCDEFGHIG----------12345678 ",
0099: // "2007BA6044900-----8000---ZZEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0100: // 1445.00C2006-01-05ABCDEFGHIG----------12345678 ",
0101: // "9999BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0102: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0103: // "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC. 1445.00
0104: // 2006-01-05ABCDEFGHIJ----------12345678 ",
0105: // "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0106: // 1445.00X2006-01-05ABCDEFGHIJ----------12345678 ",
0107: //
0108: // " BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0109: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0110: // "2007 6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0111: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0112: // "2007BA -----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0113: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0114: // "2007BA6044900 5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0115: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0116: // "2007BA6044900----- ---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0117: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0118: // "2007BA6044900-----5300 ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0119: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0120: // "2007BA6044900-----5300--- EE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0121: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0122: // "2007BA6044900-----5300---AC 07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0123: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0124: // "2007BA6044900-----5300---ACEE CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0125: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0126: // "2007BA6044900-----5300---ACEE07 PDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0127: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0128: // "2007BA6044900-----5300---ACEE07CHKD BLANKFISC 12345214090047 EVERETT J PRESCOTT INC.
0129: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0130: // "2007BA6044900-----5300---ACEE07CHKDPD 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678
0131: // ",
0132: // "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 00000214090047 EVERETT J PRESCOTT INC.
0133: // 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ", };
0134: //
0135: // EntryHolder[] outputTransactions = new EntryHolder[] {
0136: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007XX6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0137: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0138: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA9999999-----8000---ACAS07CHKDPDBLANKFISC 12345214090047 EVERETT J
0139: // PRESCOTT INC. 1445.00C2006-01-05ABCDEFGHIG----------12345678 "),
0140: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----8000---ACZZ07CHKDPDBLANKFISC 12345214090047 EVERETT J
0141: // PRESCOTT INC. 1445.00C2006-01-05ABCDEFGHIG----------12345678 "),
0142: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0143: // PRESCOTT INC. 1445.00 2006-01-05ABCDEFGHIJ----------12345678 "),
0144: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "9999BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0145: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0146: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----8000---ZZEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0147: // PRESCOTT INC. 1445.00C2006-01-05ABCDEFGHIG----------12345678 "),
0148: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0149: // PRESCOTT INC. 1445.00X2006-01-05ABCDEFGHIJ----------12345678 "),
0150: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007 6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0151: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0152: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900 5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0153: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0154: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 00000214090047 EVERETT J
0155: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0156: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE07CHKDPD 12345214090047 EVERETT J PRESCOTT
0157: // INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0158: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE07CHKD BLANKFISC 12345214090047 EVERETT J
0159: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0160: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE07 PDBLANKFISC 12345214090047 EVERETT J
0161: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0162: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---ACEE CHKDPDBLANKFISC 12345214090047 EVERETT J
0163: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0164: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300---AC 07CHKDPDBLANKFISC 12345214090047 EVERETT J
0165: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0166: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300--- EE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0167: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0168: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900-----5300 ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0169: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0170: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA6044900----- ---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0171: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0172: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, "2007BA -----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT
0173: // INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0174: // new EntryHolder(OriginEntrySource.SCRUBBER_VALID, " BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0175: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0176: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007XX6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0177: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0178: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007 6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0179: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0180: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0181: // PRESCOTT INC. 1445.00X2006-01-05ABCDEFGHIJ----------12345678 "),
0182: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---AC 07CHKDPDBLANKFISC 12345214090047 EVERETT J
0183: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0184: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----8000---ACZZ07CHKDPDBLANKFISC 12345214090047 EVERETT J
0185: // PRESCOTT INC. 1445.00C2006-01-05ABCDEFGHIG----------12345678 "),
0186: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "9999BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0187: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0188: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA -----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0189: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0190: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA9999999-----8000---ACAS07CHKDPDBLANKFISC 12345214090047 EVERETT J
0191: // PRESCOTT INC. 1445.00C2006-01-05ABCDEFGHIG----------12345678 "),
0192: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900 5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0193: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0194: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300--- EE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0195: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0196: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----8000---ZZEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0197: // PRESCOTT INC. 1445.00C2006-01-05ABCDEFGHIG----------12345678 "),
0198: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE CHKDPDBLANKFISC 12345214090047 EVERETT J
0199: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0200: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, " BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0201: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0202: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900----- ---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0203: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0204: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300 ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0205: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0206: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 00000214090047 EVERETT J
0207: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0208: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE07CHKDPDBLANKFISC 12345214090047 EVERETT J
0209: // PRESCOTT INC. 1445.00 2006-01-05ABCDEFGHIJ----------12345678 "),
0210: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE07CHKDPD 12345214090047 EVERETT J PRESCOTT
0211: // INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0212: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE07CHKD BLANKFISC 12345214090047 EVERETT J
0213: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0214: // new EntryHolder(OriginEntrySource.MAIN_POSTER_ERROR, "2007BA6044900-----5300---ACEE07 PDBLANKFISC 12345214090047 EVERETT J
0215: // PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "), };
0216: //
0217: // clearOriginEntryTables();
0218: // loadInputTransactions(OriginEntrySource.SCRUBBER_VALID, inputTransactions);
0219: //
0220: // posterService.postMainEntries();
0221: //
0222: // assertOriginEntries(3, outputTransactions);
0223: // }
0224:
0225: /**
0226: * Covers the posting of GL entries
0227: *
0228: * @throws Exception thrown if any exception is encountered for any reason
0229: */
0230: public void testPostGlEntry() throws Exception {
0231: LOG.debug("testPostGlEntry() started");
0232:
0233: String[] inputTransactions = {
0234: "2007BA6044909-----5300---ACEX07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0235: "2007BA6044909-----5300---ACEX07CHKDPDBLANKFISC 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 " };
0236:
0237: EntryHolder[] outputTransactions = {
0238: new EntryHolder(OriginEntrySource.SCRUBBER_VALID,
0239: inputTransactions[0]),
0240: new EntryHolder(OriginEntrySource.SCRUBBER_VALID,
0241: inputTransactions[1]),
0242: new EntryHolder(OriginEntrySource.MAIN_POSTER_VALID,
0243: inputTransactions[0]),
0244: new EntryHolder(OriginEntrySource.MAIN_POSTER_VALID,
0245: inputTransactions[1]) };
0246:
0247: clearOriginEntryTables();
0248: clearGlEntryTable("BA", "6044909");
0249: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0250: inputTransactions);
0251:
0252: posterService.postMainEntries();
0253:
0254: assertOriginEntries(3, outputTransactions);
0255:
0256: List glEntries = unitTestSqlDao
0257: .sqlSelect("select * from gl_entry_t where fin_coa_cd = 'BA' and account_nbr = '6044909'");
0258: assertEquals("Should be 2 GL entries", 2, glEntries.size());
0259: Map glEntry = (Map) glEntries.get(0);
0260:
0261: BigDecimal ufy = (BigDecimal) glEntry.get("UNIV_FISCAL_YR");
0262: assertEquals("univ_fiscal_yr wrong", 2007, ufy.intValue());
0263: assertEquals("fin_coa_cd wrong", "BA", (String) glEntry
0264: .get("FIN_COA_CD"));
0265: assertEquals("account_nbr wrong", "6044909", (String) glEntry
0266: .get("ACCOUNT_NBR"));
0267: assertEquals("sub_acct_nbr wrong", "-----", (String) glEntry
0268: .get("SUB_ACCT_NBR"));
0269: assertEquals("fin_object_cd wrong", "5300", (String) glEntry
0270: .get("FIN_OBJECT_CD"));
0271: assertEquals("fin_sub_obj_cd wrong", "---", (String) glEntry
0272: .get("FIN_SUB_OBJ_CD"));
0273: assertEquals("FIN_BALANCE_TYP_CD wrong", "AC", (String) glEntry
0274: .get("FIN_BALANCE_TYP_CD"));
0275: assertEquals("FIN_OBJ_TYP_CD wrong", "EX", (String) glEntry
0276: .get("FIN_OBJ_TYP_CD"));
0277: assertEquals("UNIV_FISCAL_PRD_CD wrong", "07", (String) glEntry
0278: .get("UNIV_FISCAL_PRD_CD"));
0279: assertEquals("FDOC_TYP_CD wrong", "CHKD", (String) glEntry
0280: .get("FDOC_TYP_CD"));
0281: assertEquals("FS_ORIGIN_CD wrong", "PD", (String) glEntry
0282: .get("FS_ORIGIN_CD"));
0283: assertEquals("FDOC_NBR wrong", "BLANKFISC", (String) glEntry
0284: .get("FDOC_NBR"));
0285: BigDecimal tesq = (BigDecimal) glEntry.get("TRN_ENTR_SEQ_NBR");
0286: assertEquals("TRN_ENTR_SEQ_NBR wrong", 1, tesq.intValue());
0287: assertEquals("TRN_LDGR_ENTR_DESC wrong",
0288: "214090047 EVERETT J PRESCOTT INC.", (String) glEntry
0289: .get("TRN_LDGR_ENTR_DESC"));
0290: assertEquals("TRN_LDGR_ENTR_AMT wrong", 1445.00, getAmount(
0291: glEntry, "TRN_LDGR_ENTR_AMT"), 0.01);
0292: assertEquals("TRN_DEBIT_CRDT_CD wrong", "D", (String) glEntry
0293: .get("TRN_DEBIT_CRDT_CD"));
0294: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
0295: assertEquals("TRANSACTION_DT wrong", "2006-01-05", sdf
0296: .format((Date) glEntry.get("TRANSACTION_DT")));
0297: assertEquals("ORG_DOC_NBR wrong", "ABCDEFGHIJ",
0298: (String) glEntry.get("ORG_DOC_NBR"));
0299: assertEquals("PROJECT_CD wrong", "----------", (String) glEntry
0300: .get("PROJECT_CD"));
0301: assertEquals("ORG_REFERENCE_ID wrong", "12345678",
0302: (String) glEntry.get("ORG_REFERENCE_ID"));
0303: assertTrue("FDOC_REF_TYP_CD is not blank, was: '"
0304: + glEntry.get("FDOC_REF_TYP_CD") + "'", StringUtils
0305: .isEmpty((String) glEntry.get("FDOC_REF_TYP_CD")));
0306: assertTrue("FS_REF_ORIGIN_CD is not blank, was: '"
0307: + glEntry.get("FS_REF_ORIGIN_CD") + "'", StringUtils
0308: .isEmpty((String) glEntry.get("FS_REF_ORIGIN_CD")));
0309: assertTrue("FDOC_REF_NBR is not blank, was: '"
0310: + glEntry.get("FDOC_REF_NBR") + "'", StringUtils
0311: .isEmpty((String) glEntry.get("FDOC_REF_NBR")));
0312: assertNull("FDOC_REVERSAL_DT is not null, was: '"
0313: + glEntry.get("FDOC_REVERSAL_DT") + "'", glEntry
0314: .get("FDOC_REVERSAL_DT"));
0315: assertEquals("TRN_ENCUM_UPDT_CD wrong", " ", (String) glEntry
0316: .get("TRN_ENCUM_UPDT_CD"));
0317:
0318: // The 2nd one should have a different sequence number
0319: glEntry = (Map) glEntries.get(1);
0320: tesq = (BigDecimal) glEntry.get("TRN_ENTR_SEQ_NBR");
0321: assertEquals("TRN_ENTR_SEQ_NBR wrong", 2, tesq.intValue());
0322: }
0323:
0324: /**
0325: * Check valid and invalid reversal posting
0326: *
0327: * @throws Exception thrown if any exception is encountered for any reason
0328: */
0329: public void testPostReversal() throws Exception {
0330: LOG.debug("testPostReversal() started");
0331:
0332: // if this test fails, ensure that the cutoff time is set to 10am.
0333:
0334: String[] inputTransactions = {
0335: "2007BA6044900-----5300---ACEX07CHKDPDREVTEST01 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2006-03-01 ",
0336: "2007BA6044900-----5300---ACEX07CHKDPDREVTEST01 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2006-03-01 ",
0337: "2007BA6044900-----5300---ACEX07CHKDPDREVTEST02 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 " };
0338:
0339: EntryHolder[] outputTransactions = {
0340: new EntryHolder(OriginEntrySource.SCRUBBER_VALID,
0341: inputTransactions[0]),
0342: new EntryHolder(OriginEntrySource.SCRUBBER_VALID,
0343: inputTransactions[1]),
0344: new EntryHolder(OriginEntrySource.SCRUBBER_VALID,
0345: inputTransactions[2]),
0346: new EntryHolder(OriginEntrySource.MAIN_POSTER_VALID,
0347: inputTransactions[0]),
0348: new EntryHolder(OriginEntrySource.MAIN_POSTER_VALID,
0349: inputTransactions[1]),
0350: new EntryHolder(OriginEntrySource.MAIN_POSTER_VALID,
0351: inputTransactions[2]) };
0352:
0353: clearOriginEntryTables();
0354: clearReversalTable();
0355: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0356: inputTransactions);
0357:
0358: posterService.postMainEntries();
0359:
0360: assertOriginEntries(3, outputTransactions);
0361:
0362: List reversalEntries = unitTestSqlDao
0363: .sqlSelect("select * from gl_reversal_t");
0364: assertEquals("Should be 1 reversal row", 2, reversalEntries
0365: .size());
0366: Map reversalEntry = (Map) reversalEntries.get(0);
0367:
0368: SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
0369: assertEquals("FDOC_REVERSAL_DT wrong", "2006-03-01", sdf
0370: .format((Date) reversalEntry.get("FDOC_REVERSAL_DT")));
0371: }
0372:
0373: /**
0374: * Covers entry posting's effects on balances
0375: *
0376: * @throws Exception thrown if any exception is encountered for any reason
0377: */
0378: public void testPostBalance() throws Exception {
0379: LOG.debug("testPostBalance() started");
0380:
0381: String[] inputTransactions = {
0382: "2007BA6044900-----4166---ACEX01CHKDPDBALTEST01 12345214090047 EVERETT J PRESCOTT INC. 10.01D2006-01-05ABCDEFGHIJ----------12345678 ",
0383: "2007BA6044900-----4166---ACEX02CHKDPDBALTEST02 12345214090047 EVERETT J PRESCOTT INC. 20.02D2006-01-05ABCDEFGHIJ----------12345678 ",
0384: "2007BA6044900-----4166---ACEX03CHKDPDBALTEST03 12345214090047 EVERETT J PRESCOTT INC. 30.03D2006-01-05ABCDEFGHIJ----------12345678 ",
0385: "2007BA6044900-----4166---ACEX04CHKDPDBALTEST04 12345214090047 EVERETT J PRESCOTT INC. 40.04D2006-01-05ABCDEFGHIJ----------12345678 ",
0386: "2007BA6044900-----4166---ACEX05CHKDPDBALTEST05 12345214090047 EVERETT J PRESCOTT INC. 50.05D2006-01-05ABCDEFGHIJ----------12345678 ",
0387: "2007BA6044900-----4166---ACEX06CHKDPDBALTEST06 12345214090047 EVERETT J PRESCOTT INC. 60.06D2006-01-05ABCDEFGHIJ----------12345678 ",
0388: "2007BA6044900-----4166---ACEX07CHKDPDBALTEST07 12345214090047 EVERETT J PRESCOTT INC. 70.07D2006-01-05ABCDEFGHIJ----------12345678 ",
0389: "2007BA6044900-----4166---ACEX08CHKDPDBALTEST08 12345214090047 EVERETT J PRESCOTT INC. 80.08D2006-01-05ABCDEFGHIJ----------12345678 ",
0390: "2007BA6044900-----4166---ACEX09CHKDPDBALTEST09 12345214090047 EVERETT J PRESCOTT INC. 90.09D2006-01-05ABCDEFGHIJ----------12345678 ",
0391: "2007BA6044900-----4166---ACEX10CHKDPDBALTEST10 12345214090047 EVERETT J PRESCOTT INC. 100.10D2006-01-05ABCDEFGHIJ----------12345678 ",
0392: "2007BA6044900-----4166---ACEX11CHKDPDBALTEST11 12345214090047 EVERETT J PRESCOTT INC. 110.11D2006-01-05ABCDEFGHIJ----------12345678 ",
0393: "2007BA6044900-----4166---ACEX12CHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 120.12D2006-01-05ABCDEFGHIJ----------12345678 ",
0394: "2007BA6044900-----4166---ACEX13CHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 130.13D2006-01-05ABCDEFGHIJ----------12345678 ",
0395: "2007BA6044900-----4166---ACEXABCHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 140.14D2006-01-05ABCDEFGHIJ----------12345678 ",
0396: "2007BA6044900-----4166---ACEXBBCHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 150.15D2006-01-05ABCDEFGHIJ----------12345678 ",
0397: "2007BA6044900-----4166---ACEXCBCHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 160.16D2006-01-05ABCDEFGHIJ----------12345678 " };
0398:
0399: EntryHolder[] outputTransactions = new EntryHolder[inputTransactions.length * 2];
0400: for (int i = 0; i < inputTransactions.length; i++) {
0401: outputTransactions[i] = new EntryHolder(
0402: OriginEntrySource.SCRUBBER_VALID,
0403: inputTransactions[i]);
0404: outputTransactions[i + inputTransactions.length] = new EntryHolder(
0405: OriginEntrySource.MAIN_POSTER_VALID,
0406: inputTransactions[i]);
0407: }
0408:
0409: clearOriginEntryTables();
0410: clearGlBalanceTable();
0411: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0412: inputTransactions);
0413:
0414: posterService.postMainEntries();
0415:
0416: assertOriginEntries(3, outputTransactions);
0417:
0418: List balances = unitTestSqlDao
0419: .sqlSelect("select * from gl_balance_t");
0420: assertEquals("Should be 1 row", 1, balances.size());
0421: Map balance = (Map) balances.get(0);
0422:
0423: BigDecimal a = (BigDecimal) balance.get("UNIV_FISCAL_YR");
0424: assertEquals("UNIV_FISCAL_YR is wrong", 2007, a.intValue());
0425: assertEquals("FIN_COA_CD is wrong", "BA", balance
0426: .get("FIN_COA_CD"));
0427: assertEquals("ACCOUNT_NBR is wrong", "6044900", balance
0428: .get("ACCOUNT_NBR"));
0429: assertEquals("SUB_ACCT_NBR is wrong", "-----", balance
0430: .get("SUB_ACCT_NBR"));
0431: assertEquals("FIN_OBJECT_CD is wrong", "4166", balance
0432: .get("FIN_OBJECT_CD"));
0433: assertEquals("FIN_SUB_OBJ_CD is wrong", "---", balance
0434: .get("FIN_SUB_OBJ_CD"));
0435: assertEquals("FIN_BALANCE_TYP_CD is wrong", "AC", balance
0436: .get("FIN_BALANCE_TYP_CD"));
0437: assertEquals("FIN_OBJ_TYP_CD is wrong", "EX", balance
0438: .get("FIN_OBJ_TYP_CD"));
0439: assertEquals("ACLN_ANNL_BAL_AMT is wrong", 1051.05, getAmount(
0440: balance, "ACLN_ANNL_BAL_AMT"), 0.01);
0441: assertEquals("FIN_BEG_BAL_LN_AMT is wrong", 150.15, getAmount(
0442: balance, "FIN_BEG_BAL_LN_AMT"), 0.01);
0443: assertEquals("CONTR_GR_BB_AC_AMT is wrong", 160.16, getAmount(
0444: balance, "CONTR_GR_BB_AC_AMT"), 0.01);
0445: assertEquals("MO1_ACCT_LN_AMT is wrong", 10.01, getAmount(
0446: balance, "MO1_ACCT_LN_AMT"), 0.01);
0447: assertEquals("MO2_ACCT_LN_AMT is wrong", 20.02, getAmount(
0448: balance, "MO2_ACCT_LN_AMT"), 0.01);
0449: assertEquals("MO3_ACCT_LN_AMT is wrong", 30.03, getAmount(
0450: balance, "MO3_ACCT_LN_AMT"), 0.01);
0451: assertEquals("MO4_ACCT_LN_AMT is wrong", 40.04, getAmount(
0452: balance, "MO4_ACCT_LN_AMT"), 0.01);
0453: assertEquals("MO5_ACCT_LN_AMT is wrong", 50.05, getAmount(
0454: balance, "MO5_ACCT_LN_AMT"), 0.01);
0455: assertEquals("MO6_ACCT_LN_AMT is wrong", 60.06, getAmount(
0456: balance, "MO6_ACCT_LN_AMT"), 0.01);
0457: assertEquals("MO7_ACCT_LN_AMT is wrong", 70.07, getAmount(
0458: balance, "MO7_ACCT_LN_AMT"), 0.01);
0459: assertEquals("MO8_ACCT_LN_AMT is wrong", 80.08, getAmount(
0460: balance, "MO8_ACCT_LN_AMT"), 0.01);
0461: assertEquals("MO9_ACCT_LN_AMT is wrong", 90.09, getAmount(
0462: balance, "MO9_ACCT_LN_AMT"), 0.01);
0463: assertEquals("MO10_ACCT_LN_AMT is wrong", 100.10, getAmount(
0464: balance, "MO10_ACCT_LN_AMT"), 0.01);
0465: assertEquals("MO11_ACCT_LN_AMT is wrong", 110.11, getAmount(
0466: balance, "MO11_ACCT_LN_AMT"), 0.01);
0467: assertEquals("MO12_ACCT_LN_AMT is wrong", 120.12, getAmount(
0468: balance, "MO12_ACCT_LN_AMT"), 0.01);
0469: assertEquals("MO13_ACCT_LN_AMT is wrong", 130.13, getAmount(
0470: balance, "MO13_ACCT_LN_AMT"), 0.01);
0471:
0472: String[] inputTransactions2 = {
0473: "2007BA6044900-----4166---ACEX01CHKDPDBALTEST01 12345214090047 EVERETT J PRESCOTT INC. 0.01C2006-01-05ABCDEFGHIJ----------12345678 ",
0474: "2007BA6044900-----4166---ACEX02CHKDPDBALTEST02 12345214090047 EVERETT J PRESCOTT INC. 0.02C2006-01-05ABCDEFGHIJ----------12345678 ",
0475: "2007BA6044900-----4166---ACEX03CHKDPDBALTEST03 12345214090047 EVERETT J PRESCOTT INC. 0.03C2006-01-05ABCDEFGHIJ----------12345678 ",
0476: "2007BA6044900-----4166---ACEX04CHKDPDBALTEST04 12345214090047 EVERETT J PRESCOTT INC. 0.04C2006-01-05ABCDEFGHIJ----------12345678 ",
0477: "2007BA6044900-----4166---ACEX05CHKDPDBALTEST05 12345214090047 EVERETT J PRESCOTT INC. 0.05C2006-01-05ABCDEFGHIJ----------12345678 ",
0478: "2007BA6044900-----4166---ACEX06CHKDPDBALTEST06 12345214090047 EVERETT J PRESCOTT INC. 0.06C2006-01-05ABCDEFGHIJ----------12345678 ",
0479: "2007BA6044900-----4166---ACEX07CHKDPDBALTEST07 12345214090047 EVERETT J PRESCOTT INC. 0.07C2006-01-05ABCDEFGHIJ----------12345678 ",
0480: "2007BA6044900-----4166---ACEX08CHKDPDBALTEST08 12345214090047 EVERETT J PRESCOTT INC. 0.08C2006-01-05ABCDEFGHIJ----------12345678 ",
0481: "2007BA6044900-----4166---ACEX09CHKDPDBALTEST09 12345214090047 EVERETT J PRESCOTT INC. 0.09C2006-01-05ABCDEFGHIJ----------12345678 ",
0482: "2007BA6044900-----4166---ACEX10CHKDPDBALTEST10 12345214090047 EVERETT J PRESCOTT INC. 0.10C2006-01-05ABCDEFGHIJ----------12345678 ",
0483: "2007BA6044900-----4166---ACEX11CHKDPDBALTEST11 12345214090047 EVERETT J PRESCOTT INC. 0.11C2006-01-05ABCDEFGHIJ----------12345678 ",
0484: "2007BA6044900-----4166---ACEX12CHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 0.12C2006-01-05ABCDEFGHIJ----------12345678 ",
0485: "2007BA6044900-----4166---ACEX13CHKDPDBALTEST12 12345214090047 EVERETT J PRESCOTT INC. 0.13C2006-01-05ABCDEFGHIJ----------12345678 ", };
0486:
0487: EntryHolder[] outputTransactions2 = new EntryHolder[inputTransactions2.length * 2];
0488: for (int i = 0; i < inputTransactions2.length; i++) {
0489: outputTransactions2[i] = new EntryHolder(
0490: OriginEntrySource.SCRUBBER_VALID,
0491: inputTransactions2[i]);
0492: outputTransactions2[i + inputTransactions2.length] = new EntryHolder(
0493: OriginEntrySource.MAIN_POSTER_VALID,
0494: inputTransactions2[i]);
0495: }
0496:
0497: clearOriginEntryTables();
0498: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0499: inputTransactions2);
0500:
0501: posterService.postMainEntries();
0502:
0503: assertOriginEntries(3, outputTransactions2);
0504:
0505: balances = unitTestSqlDao
0506: .sqlSelect("select * from gl_balance_t");
0507: assertEquals("Should be 1 row", 1, balances.size());
0508: balance = (Map) balances.get(0);
0509:
0510: a = (BigDecimal) balance.get("UNIV_FISCAL_YR");
0511: assertEquals("2 UNIV_FISCAL_YR is wrong", 2007, a.intValue());
0512: assertEquals("2 FIN_COA_CD is wrong", "BA", balance
0513: .get("FIN_COA_CD"));
0514: assertEquals("2 ACCOUNT_NBR is wrong", "6044900", balance
0515: .get("ACCOUNT_NBR"));
0516: assertEquals("2 SUB_ACCT_NBR is wrong", "-----", balance
0517: .get("SUB_ACCT_NBR"));
0518: assertEquals("2 FIN_OBJECT_CD is wrong", "4166", balance
0519: .get("FIN_OBJECT_CD"));
0520: assertEquals("2 FIN_SUB_OBJ_CD is wrong", "---", balance
0521: .get("FIN_SUB_OBJ_CD"));
0522: assertEquals("2 FIN_BALANCE_TYP_CD is wrong", "AC", balance
0523: .get("FIN_BALANCE_TYP_CD"));
0524: assertEquals("2 FIN_OBJ_TYP_CD is wrong", "EX", balance
0525: .get("FIN_OBJ_TYP_CD"));
0526: assertEquals("2 ACLN_ANNL_BAL_AMT is wrong", 1050.14,
0527: getAmount(balance, "ACLN_ANNL_BAL_AMT"), 0.01);
0528: assertEquals("2 FIN_BEG_BAL_LN_AMT is wrong", 150.15,
0529: getAmount(balance, "FIN_BEG_BAL_LN_AMT"), 0.01);
0530: assertEquals("2 CONTR_GR_BB_AC_AMT is wrong", 160.16,
0531: getAmount(balance, "CONTR_GR_BB_AC_AMT"), 0.01);
0532: assertEquals("2 MO1_ACCT_LN_AMT is wrong", 10.00, getAmount(
0533: balance, "MO1_ACCT_LN_AMT"), 0.01);
0534: assertEquals("2 MO2_ACCT_LN_AMT is wrong", 20.00, getAmount(
0535: balance, "MO2_ACCT_LN_AMT"), 0.01);
0536: assertEquals("2 MO3_ACCT_LN_AMT is wrong", 30.00, getAmount(
0537: balance, "MO3_ACCT_LN_AMT"), 0.01);
0538: assertEquals("2 MO4_ACCT_LN_AMT is wrong", 40.00, getAmount(
0539: balance, "MO4_ACCT_LN_AMT"), 0.01);
0540: assertEquals("2 MO5_ACCT_LN_AMT is wrong", 50.00, getAmount(
0541: balance, "MO5_ACCT_LN_AMT"), 0.01);
0542: assertEquals("2 MO6_ACCT_LN_AMT is wrong", 60.00, getAmount(
0543: balance, "MO6_ACCT_LN_AMT"), 0.01);
0544: assertEquals("2 MO7_ACCT_LN_AMT is wrong", 70.00, getAmount(
0545: balance, "MO7_ACCT_LN_AMT"), 0.01);
0546: assertEquals("2 MO8_ACCT_LN_AMT is wrong", 80.00, getAmount(
0547: balance, "MO8_ACCT_LN_AMT"), 0.01);
0548: assertEquals("2 MO9_ACCT_LN_AMT is wrong", 90.00, getAmount(
0549: balance, "MO9_ACCT_LN_AMT"), 0.01);
0550: assertEquals("2 MO10_ACCT_LN_AMT is wrong", 100.00, getAmount(
0551: balance, "MO10_ACCT_LN_AMT"), 0.01);
0552: assertEquals("2 MO11_ACCT_LN_AMT is wrong", 110.00, getAmount(
0553: balance, "MO11_ACCT_LN_AMT"), 0.01);
0554: assertEquals("2 MO12_ACCT_LN_AMT is wrong", 120.00, getAmount(
0555: balance, "MO12_ACCT_LN_AMT"), 0.01);
0556: assertEquals("2 MO13_ACCT_LN_AMT is wrong", 130.00, getAmount(
0557: balance, "MO13_ACCT_LN_AMT"), 0.01);
0558: }
0559:
0560: /**
0561: * Covers entry posting's effects on encumbrances
0562: *
0563: * @throws Exception thrown if any exception is encountered for any reason
0564: */
0565: public void testPostEncumbrance() throws Exception {
0566: LOG.debug("testPostEncumbrance() started");
0567:
0568: String[] inputTransactions = {
0569: "2007BA6044900-----4166---IEEX06CHKDPDENCTEST01 12345214090047 EVERETT J PRESCOTT INC. 100.01D2006-01-05ABCDEFGHIJ----------12345678 D ",
0570: "2007BA6044900-----5215---IEEX06CHKDPDENCTEST01 12345214090047 EVERETT J PRESCOTT INC. 200.02D2006-01-05ABCDEFGHIJ----------12345678 D ",
0571: "2007BA6044900-----4166---IEEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 50.00C2006-01-05ABCDEFGHIJ----------12345678CHKDPDENCTEST01 R ",
0572: "2007BA6044900-----5215---IEEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 60.00C2006-01-05ABCDEFGHIJ----------12345678CHKDPDENCTEST01 R ",
0573: "2007BA6044900-----5215---ACEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 60.00C2006-01-05ABCDEFGHIJ----------12345678 ", };
0574:
0575: EntryHolder[] outputTransactions = new EntryHolder[] {
0576: new EntryHolder(
0577: OriginEntrySource.SCRUBBER_VALID,
0578: "2007BA6044900-----4166---IEEX06CHKDPDENCTEST01 12345214090047 EVERETT J PRESCOTT INC. 100.01D2006-01-05ABCDEFGHIJ----------12345678 D "),
0579: new EntryHolder(
0580: OriginEntrySource.SCRUBBER_VALID,
0581: "2007BA6044900-----5215---IEEX06CHKDPDENCTEST01 12345214090047 EVERETT J PRESCOTT INC. 200.02D2006-01-05ABCDEFGHIJ----------12345678 D "),
0582: new EntryHolder(
0583: OriginEntrySource.SCRUBBER_VALID,
0584: "2007BA6044900-----4166---IEEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 50.00C2006-01-05ABCDEFGHIJ----------12345678CHKDPDENCTEST01 R "),
0585: new EntryHolder(
0586: OriginEntrySource.SCRUBBER_VALID,
0587: "2007BA6044900-----5215---IEEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 60.00C2006-01-05ABCDEFGHIJ----------12345678CHKDPDENCTEST01 R "),
0588: new EntryHolder(
0589: OriginEntrySource.SCRUBBER_VALID,
0590: "2007BA6044900-----5215---ACEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 60.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0591:
0592: new EntryHolder(
0593: OriginEntrySource.MAIN_POSTER_VALID,
0594: "2007BA6044900-----4166---IEEX06CHKDPDENCTEST01 12345214090047 EVERETT J PRESCOTT INC. 100.01D2006-01-05ABCDEFGHIJ----------12345678 D "),
0595: new EntryHolder(
0596: OriginEntrySource.MAIN_POSTER_VALID,
0597: "2007BA6044900-----5215---IEEX06CHKDPDENCTEST01 12345214090047 EVERETT J PRESCOTT INC. 200.02D2006-01-05ABCDEFGHIJ----------12345678 D "),
0598: new EntryHolder(
0599: OriginEntrySource.MAIN_POSTER_VALID,
0600: "2007BA6044900-----5215---ACEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 60.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0601: new EntryHolder(
0602: OriginEntrySource.MAIN_POSTER_VALID,
0603: "2007BA6044900-----4166---IEEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 50.00C2006-01-05ABCDEFGHIJ----------12345678CHKDPDENCTEST01 R "),
0604: new EntryHolder(
0605: OriginEntrySource.MAIN_POSTER_VALID,
0606: "2007BA6044900-----5215---IEEX06CHKDPDENCTEST02 12345214090047 EVERETT J PRESCOTT INC. 60.00C2006-01-05ABCDEFGHIJ----------12345678CHKDPDENCTEST01 R "), };
0607:
0608: clearOriginEntryTables();
0609: clearEncumbranceTable();
0610: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0611: inputTransactions);
0612:
0613: posterService.postMainEntries();
0614:
0615: assertOriginEntries(3, outputTransactions);
0616:
0617: List encumbrances = unitTestSqlDao
0618: .sqlSelect("select * from gl_encumbrance_t order by fin_object_cd");
0619: assertEquals("Should be 2 encumbrances", 2, encumbrances.size());
0620: Map enc4166 = (Map) encumbrances.get(0);
0621: Map enc5215 = (Map) encumbrances.get(1);
0622:
0623: BigDecimal a = (BigDecimal) enc4166.get("UNIV_FISCAL_YR");
0624: assertEquals("UNIV_FISCAL_YR is wrong", 2007, a.intValue());
0625: assertEquals("FIN_COA_CD is wrong", "BA", enc4166
0626: .get("FIN_COA_CD"));
0627: assertEquals("ACCOUNT_NBR is wrong", "6044900", enc4166
0628: .get("ACCOUNT_NBR"));
0629: assertEquals("SUB_ACCT_NBR is wrong", "-----", enc4166
0630: .get("SUB_ACCT_NBR"));
0631: assertEquals("FIN_OBJECT_CD is wrong", "4166", enc4166
0632: .get("FIN_OBJECT_CD"));
0633: assertEquals("FIN_SUB_OBJ_CD is wrong", "---", enc4166
0634: .get("FIN_SUB_OBJ_CD"));
0635: assertEquals("FIN_BALANCE_TYP_CD is wrong", "IE", enc4166
0636: .get("FIN_BALANCE_TYP_CD"));
0637: assertEquals("FDOC_TYP_CD is wrong", "CHKD", enc4166
0638: .get("FDOC_TYP_CD"));
0639: assertEquals("FS_ORIGIN_CD is wrong", "PD", enc4166
0640: .get("FS_ORIGIN_CD"));
0641: assertEquals("FDOC_NBR is wrong", "ENCTEST01", enc4166
0642: .get("FDOC_NBR"));
0643: assertEquals("TRN_ENCUM_DESC is wrong",
0644: "214090047 EVERETT J PRESCOTT INC.", enc4166
0645: .get("TRN_ENCUM_DESC"));
0646: assertEquals("ACLN_ENCUM_AMT is wrong", 100.01, getAmount(
0647: enc4166, "ACLN_ENCUM_AMT"), 0.01);
0648: assertEquals("ACLN_ENCUM_CLS_AMT is wrong", 50, getAmount(
0649: enc4166, "ACLN_ENCUM_CLS_AMT"), 0.01);
0650:
0651: a = (BigDecimal) enc5215.get("UNIV_FISCAL_YR");
0652: assertEquals("UNIV_FISCAL_YR is wrong", 2007, a.intValue());
0653: assertEquals("FIN_COA_CD is wrong", "BA", enc5215
0654: .get("FIN_COA_CD"));
0655: assertEquals("ACCOUNT_NBR is wrong", "6044900", enc5215
0656: .get("ACCOUNT_NBR"));
0657: assertEquals("SUB_ACCT_NBR is wrong", "-----", enc5215
0658: .get("SUB_ACCT_NBR"));
0659: assertEquals("FIN_OBJECT_CD is wrong", "5215", enc5215
0660: .get("FIN_OBJECT_CD"));
0661: assertEquals("FIN_SUB_OBJ_CD is wrong", "---", enc5215
0662: .get("FIN_SUB_OBJ_CD"));
0663: assertEquals("FIN_BALANCE_TYP_CD is wrong", "IE", enc5215
0664: .get("FIN_BALANCE_TYP_CD"));
0665: assertEquals("FDOC_TYP_CD is wrong", "CHKD", enc5215
0666: .get("FDOC_TYP_CD"));
0667: assertEquals("FS_ORIGIN_CD is wrong", "PD", enc5215
0668: .get("FS_ORIGIN_CD"));
0669: assertEquals("FDOC_NBR is wrong", "ENCTEST01", enc5215
0670: .get("FDOC_NBR"));
0671: assertEquals("TRN_ENCUM_DESC is wrong",
0672: "214090047 EVERETT J PRESCOTT INC.", enc5215
0673: .get("TRN_ENCUM_DESC"));
0674: assertEquals("ACLN_ENCUM_AMT is wrong", 200.02, getAmount(
0675: enc5215, "ACLN_ENCUM_AMT"), 0.01);
0676: assertEquals("ACLN_ENCUM_CLS_AMT is wrong", 60, getAmount(
0677: enc5215, "ACLN_ENCUM_CLS_AMT"), 0.01);
0678: }
0679:
0680: /**
0681: * Covers posting entry's effects on account balances
0682: *
0683: * @throws Exception thrown if any exception is encountered for any reason
0684: */
0685: public void testPostGlAccountBalance() throws Exception {
0686: LOG.debug("testPostGlAccountBalance() started");
0687:
0688: String[] inputTransactions = {
0689: "2007BA6044900-----4166---TREX07CHKDPDGLACCTBA1 12345DESCRIPTION 123.45D2006-01-05ABCDEFGHIJ----------12345678 ",
0690: "2007BA6044900-----4166---ACEX07CHKDPDGLACCTBA1 12345DESCRIPTION 1445.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0691: "2007BA6044900-----4166---EXEX07CHKDPDGLACCTBA1 12345DESCRIPTION 345.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0692: "2007BA6044900-----4166---CBEX07CHKDPDGLACCTBA1 12345DESCRIPTION 222.00 2006-01-05ABCDEFGHIJ----------12345678 ",
0693: "2007BA6044900-----4166---ACEX07CHKDPDGLACCTBA1 12345DESCRIPTION 5.00C2006-01-05ABCDEFGHIJ----------12345678 ",
0694: "2007BA6044900-----4166---EXEX07CHKDPDGLACCTBA1 12345DESCRIPTION 5.00C2006-01-05ABCDEFGHIJ----------12345678 ",
0695: "2007BA6044900-----4166---CBEX07CHKDPDGLACCTBA1 12345DESCRIPTION -2.00 2006-01-05ABCDEFGHIJ----------12345678 " };
0696:
0697: EntryHolder[] outputTransactions = new EntryHolder[] {
0698: new EntryHolder(
0699: OriginEntrySource.SCRUBBER_VALID,
0700: "2007BA6044900-----4166---TREX07CHKDPDGLACCTBA1 12345DESCRIPTION 123.45D2006-01-05ABCDEFGHIJ----------12345678 "),
0701: new EntryHolder(
0702: OriginEntrySource.SCRUBBER_VALID,
0703: "2007BA6044900-----4166---ACEX07CHKDPDGLACCTBA1 12345DESCRIPTION 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0704: new EntryHolder(
0705: OriginEntrySource.SCRUBBER_VALID,
0706: "2007BA6044900-----4166---EXEX07CHKDPDGLACCTBA1 12345DESCRIPTION 345.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0707: new EntryHolder(
0708: OriginEntrySource.SCRUBBER_VALID,
0709: "2007BA6044900-----4166---CBEX07CHKDPDGLACCTBA1 12345DESCRIPTION 222.00 2006-01-05ABCDEFGHIJ----------12345678 "),
0710: new EntryHolder(
0711: OriginEntrySource.SCRUBBER_VALID,
0712: "2007BA6044900-----4166---ACEX07CHKDPDGLACCTBA1 12345DESCRIPTION 5.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0713: new EntryHolder(
0714: OriginEntrySource.SCRUBBER_VALID,
0715: "2007BA6044900-----4166---EXEX07CHKDPDGLACCTBA1 12345DESCRIPTION 5.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0716: new EntryHolder(
0717: OriginEntrySource.SCRUBBER_VALID,
0718: "2007BA6044900-----4166---CBEX07CHKDPDGLACCTBA1 12345DESCRIPTION -2.00 2006-01-05ABCDEFGHIJ----------12345678 "),
0719:
0720: new EntryHolder(
0721: OriginEntrySource.MAIN_POSTER_VALID,
0722: "2007BA6044900-----4166---ACEX07CHKDPDGLACCTBA1 12345DESCRIPTION 5.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0723: new EntryHolder(
0724: OriginEntrySource.MAIN_POSTER_VALID,
0725: "2007BA6044900-----4166---ACEX07CHKDPDGLACCTBA1 12345DESCRIPTION 1445.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0726: new EntryHolder(
0727: OriginEntrySource.MAIN_POSTER_VALID,
0728: "2007BA6044900-----4166---CBEX07CHKDPDGLACCTBA1 12345DESCRIPTION -2.00 2006-01-05ABCDEFGHIJ----------12345678 "),
0729: new EntryHolder(
0730: OriginEntrySource.MAIN_POSTER_VALID,
0731: "2007BA6044900-----4166---CBEX07CHKDPDGLACCTBA1 12345DESCRIPTION 222.00 2006-01-05ABCDEFGHIJ----------12345678 "),
0732: new EntryHolder(
0733: OriginEntrySource.MAIN_POSTER_VALID,
0734: "2007BA6044900-----4166---EXEX07CHKDPDGLACCTBA1 12345DESCRIPTION 5.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0735: new EntryHolder(
0736: OriginEntrySource.MAIN_POSTER_VALID,
0737: "2007BA6044900-----4166---EXEX07CHKDPDGLACCTBA1 12345DESCRIPTION 345.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0738: new EntryHolder(
0739: OriginEntrySource.MAIN_POSTER_VALID,
0740: "2007BA6044900-----4166---TREX07CHKDPDGLACCTBA1 12345DESCRIPTION 123.45D2006-01-05ABCDEFGHIJ----------12345678 "), };
0741:
0742: clearOriginEntryTables();
0743: clearGlAccountBalanceTable();
0744: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0745: inputTransactions);
0746: posterService.postMainEntries();
0747:
0748: assertOriginEntries(3, outputTransactions);
0749:
0750: List balances = unitTestSqlDao
0751: .sqlSelect("select * from gl_acct_balances_t");
0752: assertEquals("Should be 1 balance", 1, balances.size());
0753: Map bal = (Map) balances.get(0);
0754:
0755: BigDecimal a = (BigDecimal) bal.get("UNIV_FISCAL_YR");
0756: assertEquals("UNIV_FISCAL_YR is wrong", 2007, a.intValue());
0757: assertEquals("FIN_COA_CD is wrong", "BA", bal.get("FIN_COA_CD"));
0758: assertEquals("ACCOUNT_NBR is wrong", "6044900", bal
0759: .get("ACCOUNT_NBR"));
0760: assertEquals("SUB_ACCT_NBR is wrong", "-----", bal
0761: .get("SUB_ACCT_NBR"));
0762: assertEquals("FIN_OBJECT_CD is wrong", "4166", bal
0763: .get("FIN_OBJECT_CD"));
0764: assertEquals("FIN_SUB_OBJ_CD is wrong", "---", bal
0765: .get("FIN_SUB_OBJ_CD"));
0766: assertEquals("CURR_BDLN_BAL_AMT is wrong", 220.00, getAmount(
0767: bal, "CURR_BDLN_BAL_AMT"), 0.01);
0768: assertEquals("ACLN_ACTLS_BAL_AMT is wrong", 1440.00, getAmount(
0769: bal, "ACLN_ACTLS_BAL_AMT"), 0.01);
0770: assertEquals("ACLN_ENCUM_BAL_AMT is wrong", 340.00, getAmount(
0771: bal, "ACLN_ENCUM_BAL_AMT"), 0.01);
0772: }
0773:
0774: /**
0775: * Covers posting entry's effects on expenditure transactions
0776: *
0777: * @throws Exception thrown if any exception is encountered for any reason
0778: */
0779: // @RelatesTo(RelatesTo.JiraIssue.KULRNE4797)
0780: public void testPostExpenditureTransaction() throws Exception {
0781: LOG.debug("testPostExpenditureTransaction() started");
0782:
0783: String[] inputTransactions = {
0784: // Not posted because icr type cd = 10
0785: "2007BL2231499-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 11000.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0786:
0787: // Not posted because icr type cd is null
0788: "2007BA9019993-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 11000.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0789:
0790: // Not posted because the period code is AB, BB or CB
0791: "2007BL4031407-----4166---ACEXABCHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0792: "2007BL4031407-----4166---ACEXBBCHKDPDET0000011 12345DESCRIPTION 0.12C2006-01-05ABCDEFGHIJ----------12345678 ",
0793: "2007BL4031407-----4166---ACEXCBCHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0794:
0795: // Posted
0796: "2007BL4031407-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0797: "2007BL4031407-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 0.12C2006-01-05ABCDEFGHIJ----------12345678 ",
0798:
0799: // Posted
0800: "2007BL4131406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 12.00C2006-01-05ABCDEFGHIJ----------12345678 ",
0801: "2007BL4131406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 2.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0802:
0803: // Not posted - excluded account
0804: "2007BL4431406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 33.00C2006-01-05ABCDEFGHIJ----------12345678 ",
0805: "2007BL4431406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 4.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0806:
0807: // Not posted - excluded type (23)
0808: "2007BL4431407-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 44.00C2006-01-05ABCDEFGHIJ----------12345678 ",
0809: "2007BL4431407-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 5.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0810:
0811: // Posted, non-CS sub acct
0812: "2007BL4631464XXX 4166---ACEX07CHKDPDET0000021 12345DESCRIPTION 25.00D2006-01-05ABCDEFGHIJ----------12345678 ",
0813: "2007BL4631464XXX 4166---ACEX07CHKDPDET0000021 12345DESCRIPTION 2.00C2006-01-05ABCDEFGHIJ----------12345678 ", };
0814:
0815: EntryHolder[] outputTransactions = new EntryHolder[] {
0816: new EntryHolder(
0817: OriginEntrySource.SCRUBBER_VALID,
0818: "2007BL2231499-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 11000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0819: new EntryHolder(
0820: OriginEntrySource.SCRUBBER_VALID,
0821: "2007BA9019993-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 11000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0822: new EntryHolder(
0823: OriginEntrySource.SCRUBBER_VALID,
0824: "2007BL4031407-----4166---ACEXABCHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0825: new EntryHolder(
0826: OriginEntrySource.SCRUBBER_VALID,
0827: "2007BL4031407-----4166---ACEXBBCHKDPDET0000011 12345DESCRIPTION 0.12C2006-01-05ABCDEFGHIJ----------12345678 "),
0828: new EntryHolder(
0829: OriginEntrySource.SCRUBBER_VALID,
0830: "2007BL4031407-----4166---ACEXCBCHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0831: new EntryHolder(
0832: OriginEntrySource.SCRUBBER_VALID,
0833: "2007BL4031407-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0834: new EntryHolder(
0835: OriginEntrySource.SCRUBBER_VALID,
0836: "2007BL4031407-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 0.12C2006-01-05ABCDEFGHIJ----------12345678 "),
0837: new EntryHolder(
0838: OriginEntrySource.SCRUBBER_VALID,
0839: "2007BL4131406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 12.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0840: new EntryHolder(
0841: OriginEntrySource.SCRUBBER_VALID,
0842: "2007BL4131406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 2.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0843: new EntryHolder(
0844: OriginEntrySource.SCRUBBER_VALID,
0845: "2007BL4431406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 33.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0846: new EntryHolder(
0847: OriginEntrySource.SCRUBBER_VALID,
0848: "2007BL4431406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 4.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0849: new EntryHolder(
0850: OriginEntrySource.SCRUBBER_VALID,
0851: "2007BL4431407-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 44.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0852: new EntryHolder(
0853: OriginEntrySource.SCRUBBER_VALID,
0854: "2007BL4431407-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 5.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0855: new EntryHolder(
0856: OriginEntrySource.SCRUBBER_VALID,
0857: "2007BL4631464XXX 4166---ACEX07CHKDPDET0000021 12345DESCRIPTION 25.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0858: new EntryHolder(
0859: OriginEntrySource.SCRUBBER_VALID,
0860: "2007BL4631464XXX 4166---ACEX07CHKDPDET0000021 12345DESCRIPTION 2.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0861:
0862: new EntryHolder(
0863: OriginEntrySource.MAIN_POSTER_VALID,
0864: "2007BA9019993-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 11000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0865: new EntryHolder(
0866: OriginEntrySource.MAIN_POSTER_VALID,
0867: "2007BL2231499-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 11000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0868: new EntryHolder(
0869: OriginEntrySource.MAIN_POSTER_VALID,
0870: "2007BL4031407-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 0.12C2006-01-05ABCDEFGHIJ----------12345678 "),
0871: new EntryHolder(
0872: OriginEntrySource.MAIN_POSTER_VALID,
0873: "2007BL4031407-----4166---ACEX07CHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0874: new EntryHolder(
0875: OriginEntrySource.MAIN_POSTER_VALID,
0876: "2007BL4031407-----4166---ACEXABCHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0877: new EntryHolder(
0878: OriginEntrySource.MAIN_POSTER_VALID,
0879: "2007BL4031407-----4166---ACEXBBCHKDPDET0000011 12345DESCRIPTION 0.12C2006-01-05ABCDEFGHIJ----------12345678 "),
0880: new EntryHolder(
0881: OriginEntrySource.MAIN_POSTER_VALID,
0882: "2007BL4031407-----4166---ACEXCBCHKDPDET0000011 12345DESCRIPTION 12000.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0883: new EntryHolder(
0884: OriginEntrySource.MAIN_POSTER_VALID,
0885: "2007BL4131406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 2.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0886: new EntryHolder(
0887: OriginEntrySource.MAIN_POSTER_VALID,
0888: "2007BL4131406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 12.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0889: new EntryHolder(
0890: OriginEntrySource.MAIN_POSTER_VALID,
0891: "2007BL4431406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 4.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0892: new EntryHolder(
0893: OriginEntrySource.MAIN_POSTER_VALID,
0894: "2007BL4431406-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 33.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0895: new EntryHolder(
0896: OriginEntrySource.MAIN_POSTER_VALID,
0897: "2007BL4431407-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 5.00D2006-01-05ABCDEFGHIJ----------12345678 "),
0898: new EntryHolder(
0899: OriginEntrySource.MAIN_POSTER_VALID,
0900: "2007BL4431407-----2400---EXEX07CHKDPDET0000011 12345DESCRIPTION 44.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0901: new EntryHolder(
0902: OriginEntrySource.MAIN_POSTER_VALID,
0903: "2007BL4631464XXX 4166---ACEX07CHKDPDET0000021 12345DESCRIPTION 2.00C2006-01-05ABCDEFGHIJ----------12345678 "),
0904: new EntryHolder(
0905: OriginEntrySource.MAIN_POSTER_VALID,
0906: "2007BL4631464XXX 4166---ACEX07CHKDPDET0000021 12345DESCRIPTION 25.00D2006-01-05ABCDEFGHIJ----------12345678 "), };
0907:
0908: clearOriginEntryTables();
0909: clearExpenditureTable();
0910:
0911: // Add sub account for testing
0912: unitTestSqlDao
0913: .sqlCommand("delete from ca_sub_acct_t where fin_coa_cd = 'BL' and account_nbr = '4631464' and sub_acct_nbr = 'XXX'");
0914: unitTestSqlDao
0915: .sqlCommand("delete from ca_a21_sub_acct_t where fin_coa_cd = 'BL' and account_nbr = '4631464' and sub_acct_nbr = 'XXX'");
0916: unitTestSqlDao
0917: .sqlCommand("insert into ca_sub_acct_t (FIN_COA_CD,ACCOUNT_NBR,SUB_ACCT_NBR,OBJ_ID,VER_NBR,SUB_ACCT_NM,SUB_ACCT_ACTV_CD,FIN_RPT_CHRT_CD,FIN_RPT_ORG_CD,FIN_RPT_CD) values ('BL','4631464','XXX','"
0918: + new Guid().toString()
0919: + "',1,'XXX','N',null,null,null)");
0920: unitTestSqlDao
0921: .sqlCommand("INSERT INTO CA_A21_SUB_ACCT_T (FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, OBJ_ID, VER_NBR, SUB_ACCT_TYP_CD, ICR_TYP_CD, FIN_SERIES_ID, ICR_FIN_COA_CD, ICR_ACCOUNT_NBR, OFF_CMP_CD, CST_SHR_COA_CD, CST_SHRSRCACCT_NBR, CST_SRCSUBACCT_NBR) VALUES ('BL','4631464','XXX','"
0922: + new Guid().toString()
0923: + "',1,'EX',null,'000',null,null,null,'BL','1031400',null)");
0924:
0925: // Modify account for testing
0926: unitTestSqlDao
0927: .sqlCommand("update ca_account_t set fin_series_id = '11' where account_nbr = '9019993'");
0928:
0929: // Exclude account
0930: unitTestSqlDao
0931: .sqlCommand("delete from ca_icr_excl_acct_t where account_nbr = '4431406'");
0932: unitTestSqlDao
0933: .sqlCommand("insert into CA_ICR_EXCL_ACCT_T (FIN_COA_CD, ACCOUNT_NBR, FIN_OBJ_COA_CD, FIN_OBJECT_CD, OBJ_ID, VER_NBR) values ('BL','4431406','BL','2400','"
0934: + new Guid().toString() + "',1)");
0935:
0936: // Exclude type
0937: unitTestSqlDao
0938: .sqlCommand("delete from ca_icr_excl_type_t where acct_icr_typ_cd = '23' and fin_coa_cd = 'BL'");
0939: unitTestSqlDao
0940: .sqlCommand("insert into CA_ICR_EXCL_TYPE_T (ACCT_ICR_TYP_CD, FIN_COA_CD, FIN_OBJECT_CD, OBJ_ID, VER_NBR) values ('23','BL','2401','"
0941: + new Guid().toString() + "',1)");
0942:
0943: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0944: inputTransactions);
0945: posterService.postMainEntries();
0946:
0947: assertOriginEntries(3, outputTransactions);
0948:
0949: List trans = unitTestSqlDao
0950: .sqlSelect("select * from GL_EXPEND_TRN_T order by account_nbr");
0951:
0952: assertEquals("Wrong number of transactions", 4, trans.size());
0953: Map acct4031407 = (Map) trans.get(0);
0954: assertEquals("Account wrong", "4031407", acct4031407
0955: .get("ACCOUNT_NBR"));
0956: assertEquals("Amount wrong", 11999.88, getAmount(acct4031407,
0957: "ACCT_OBJ_DCST_AMT"), 0.01);
0958: Map acct4131406 = (Map) trans.get(1);
0959: assertEquals("Account wrong", "4131406", acct4131406
0960: .get("ACCOUNT_NBR"));
0961: assertEquals("Amount wrong", -10.00, getAmount(acct4131406,
0962: "ACCT_OBJ_DCST_AMT"), 0.01);
0963: Map acct4631464 = (Map) trans.get(3);
0964: assertEquals("Account wrong", "4631464", acct4631464
0965: .get("ACCOUNT_NBR"));
0966: assertEquals("Amount wrong", 23.00, getAmount(acct4631464,
0967: "ACCT_OBJ_DCST_AMT"), 0.01);
0968: }
0969:
0970: /**
0971: * Covers the reversal poster
0972: *
0973: * @throws Exception thrown if any exception is encountered for any reason
0974: */
0975: public void testReversalPoster() throws Exception {
0976: LOG.debug("testPostReversalPosting() started");
0977:
0978: // First post these entries to the reversal table
0979: String[] inputTransactions = {
0980: "2007BL2231408-----5300---ACEX07CHKDPDREVTEST01 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2003-10-01 ",
0981: "2007BL2231408-----5300---ACEX07CHKDPDREVTEST02 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2003-12-31 ",
0982: "2007BL2231408-----5300---ACEX07CHKDPDREVTEST03 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2004-01-01 ",
0983: "2007BL2231408-----5300---ACEX07CHKDPDREVTEST04 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2004-01-02 ",
0984: "2007BL2231408-----5300---ACEX07CHKDPDREVTEST05 12345214090047 EVERETT J PRESCOTT INC. 1445.00D2006-01-05ABCDEFGHIJ----------12345678 2005-03-01 " };
0985:
0986: clearOriginEntryTables();
0987: clearReversalTable();
0988: loadInputTransactions(OriginEntrySource.SCRUBBER_VALID,
0989: inputTransactions);
0990: posterService.postMainEntries();
0991:
0992: unitTestSqlDao.clearCache();
0993:
0994: // Now post the reversal entries
0995: clearGlEntryTable("BL", "2231408");
0996: posterService.postReversalEntries();
0997:
0998: List results = unitTestSqlDao
0999: .sqlSelect("select * from gl_entry_t where account_nbr = '2231408' order by fdoc_nbr");
1000: assertEquals("Wrong number of posted entries", 3, results
1001: .size());
1002: Map row1 = (Map) results.get(0);
1003: Map row2 = (Map) results.get(1);
1004: Map row3 = (Map) results.get(2);
1005:
1006: assertEquals("Wrong doc nbr", "REVTEST01", row1.get("FDOC_NBR"));
1007: assertEquals("Wrong doc nbr", "REVTEST02", row2.get("FDOC_NBR"));
1008: assertEquals("Wrong doc nbr", "REVTEST03", row3.get("FDOC_NBR"));
1009: }
1010:
1011: /**
1012: * Covers poster ICR generation
1013: *
1014: * @throws Exception thrown if any exception is encountered for any reason
1015: */
1016: public void testIcrGeneration() throws Exception {
1017: LOG.debug("testIcrGeneration() started");
1018: // Load the expenditure table
1019: unitTestSqlDao.sqlCommand("delete from gl_expend_trn_t");
1020:
1021: // This one shouldn't generate any entries
1022: unitTestSqlDao
1023: .sqlCommand("INSERT INTO GL_EXPEND_TRN_T (UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, FIN_OBJECT_CD, FIN_SUB_OBJ_CD, FIN_BALANCE_TYP_CD, FIN_OBJ_TYP_CD, UNIV_FISCAL_PRD_CD, PROJECT_CD, ORG_REFERENCE_ID, ACCT_OBJ_DCST_AMT) VALUES ('2004', 'BL', '1031400', '-----', '4166', '---', 'AC', 'EX', '07', '----------', '12345678', 10000)");
1024:
1025: // This one is fin_series_id 001 3.13% to 1 account (2 gl entries)
1026: unitTestSqlDao
1027: .sqlCommand("INSERT INTO GL_EXPEND_TRN_T (UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, FIN_OBJECT_CD, FIN_SUB_OBJ_CD, FIN_BALANCE_TYP_CD, FIN_OBJ_TYP_CD, UNIV_FISCAL_PRD_CD, PROJECT_CD, ORG_REFERENCE_ID, ACCT_OBJ_DCST_AMT) VALUES ('2004', 'BL', '4531407', '-----', '4166', '---', 'AC', 'EX', '07', '----------', '12345678', 10000)");
1028:
1029: // This one is fin_series_id 002 3.8% to 2 accounts (2.0% & 1.8%)
1030: unitTestSqlDao
1031: .sqlCommand("INSERT INTO GL_EXPEND_TRN_T (UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, FIN_OBJECT_CD, FIN_SUB_OBJ_CD, FIN_BALANCE_TYP_CD, FIN_OBJ_TYP_CD, UNIV_FISCAL_PRD_CD, PROJECT_CD, ORG_REFERENCE_ID, ACCT_OBJ_DCST_AMT) VALUES ('2004', 'BL', '4531408', '-----', '4166', '---', 'AC', 'EX', '07', '----------', '12345678', 10000)");
1032:
1033: // Clear origin entry & origin entry group
1034: clearOriginEntryTables();
1035:
1036: posterService.generateIcrTransactions();
1037:
1038: List results = unitTestSqlDao
1039: .sqlSelect("select * from gl_expend_trn_t");
1040: assertEquals("Should be no expenditure rows left", 0, results
1041: .size());
1042:
1043: results = unitTestSqlDao
1044: .sqlSelect("select * from gl_origin_entry_t order by origin_entry_id");
1045: assertEquals("Wrong number of transactions generated", 10,
1046: results.size());
1047:
1048: Map row = (Map) results.get(0);
1049: assertEquals("0 account number wrong", "4531407", row
1050: .get("ACCOUNT_NBR"));
1051: assertEquals("0 object code wrong", "5500", row
1052: .get("FIN_OBJECT_CD"));
1053: assertEquals("0 amount wrong", 313.0, getAmount(row,
1054: "TRN_LDGR_ENTR_AMT"), 0.01);
1055:
1056: row = (Map) results.get(1);
1057: assertEquals("1 account number wrong", "4531407", row
1058: .get("ACCOUNT_NBR"));
1059: assertEquals("1 object code wrong", "8000", row
1060: .get("FIN_OBJECT_CD"));
1061: assertEquals("1 amount wrong", 313.0, getAmount(row,
1062: "TRN_LDGR_ENTR_AMT"), 0.01);
1063:
1064: row = (Map) results.get(2);
1065: assertEquals("2 account number wrong", "1023287", row
1066: .get("ACCOUNT_NBR"));
1067: assertEquals("2 object code wrong", "1803", row
1068: .get("FIN_OBJECT_CD"));
1069: assertEquals("2 amount wrong", 313.0, getAmount(row,
1070: "TRN_LDGR_ENTR_AMT"), 0.01);
1071:
1072: row = (Map) results.get(3);
1073: assertEquals("3 account number wrong", "1023287", row
1074: .get("ACCOUNT_NBR"));
1075: assertEquals("3 object code wrong", "8000", row
1076: .get("FIN_OBJECT_CD"));
1077: assertEquals("3 amount wrong", 313.0, getAmount(row,
1078: "TRN_LDGR_ENTR_AMT"), 0.01);
1079:
1080: row = (Map) results.get(4);
1081: assertEquals("4 account number wrong", "4531408", row
1082: .get("ACCOUNT_NBR"));
1083: assertEquals("4 object code wrong", "5500", row
1084: .get("FIN_OBJECT_CD"));
1085: assertEquals("4 amount wrong", 380.0, getAmount(row,
1086: "TRN_LDGR_ENTR_AMT"), 0.01);
1087:
1088: row = (Map) results.get(5);
1089: assertEquals("5 account number wrong", "4531408", row
1090: .get("ACCOUNT_NBR"));
1091: assertEquals("5 object code wrong", "8000", row
1092: .get("FIN_OBJECT_CD"));
1093: assertEquals("5 amount wrong", 380.0, getAmount(row,
1094: "TRN_LDGR_ENTR_AMT"), 0.01);
1095:
1096: row = (Map) results.get(6);
1097: assertEquals("6 account number wrong", "1023287", row
1098: .get("ACCOUNT_NBR"));
1099: assertEquals("6 object code wrong", "1803", row
1100: .get("FIN_OBJECT_CD"));
1101: assertEquals("6 amount wrong", 200.0, getAmount(row,
1102: "TRN_LDGR_ENTR_AMT"), 0.01);
1103:
1104: row = (Map) results.get(7);
1105: assertEquals("7 account number wrong", "1023287", row
1106: .get("ACCOUNT_NBR"));
1107: assertEquals("7 object code wrong", "8000", row
1108: .get("FIN_OBJECT_CD"));
1109: assertEquals("7 amount wrong", 200.0, getAmount(row,
1110: "TRN_LDGR_ENTR_AMT"), 0.01);
1111:
1112: row = (Map) results.get(8);
1113: assertEquals("8 account number wrong", "1031400", row
1114: .get("ACCOUNT_NBR"));
1115: assertEquals("8 object code wrong", "1803", row
1116: .get("FIN_OBJECT_CD"));
1117: assertEquals("8 amount wrong", 180.0, getAmount(row,
1118: "TRN_LDGR_ENTR_AMT"), 0.01);
1119:
1120: row = (Map) results.get(9);
1121: assertEquals("9 account number wrong", "1031400", row
1122: .get("ACCOUNT_NBR"));
1123: assertEquals("9 object code wrong", "8000", row
1124: .get("FIN_OBJECT_CD"));
1125: assertEquals("9 amount wrong", 180.0, getAmount(row,
1126: "TRN_LDGR_ENTR_AMT"), 0.01);
1127: }
1128:
1129: /**
1130: * Converts an amount in a Map to a double (to make it easier to compare)
1131: *
1132: * @param map the Map with values in it
1133: * @param field the key of the Map with a double in it
1134: * @return a double from that map
1135: */
1136: private double getAmount(Map map, String field) {
1137: BigDecimal amt = (BigDecimal) map.get(field);
1138: if (amt == null) {
1139: return Double.NaN;
1140: } else {
1141: return amt.doubleValue();
1142: }
1143: }
1144: }
|