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.util.ArrayList;
0019: import java.util.List;
0020:
0021: import org.kuali.core.dbplatform.RawSQL;
0022: import org.kuali.core.service.DateTimeService;
0023: import org.kuali.core.util.Guid;
0024: import org.kuali.core.util.UnitTestSqlDao;
0025: import org.kuali.kfs.context.KualiTestBase;
0026: import org.kuali.kfs.context.SpringContext;
0027: import org.kuali.module.gl.bo.OriginEntryFull;
0028: import org.kuali.module.gl.util.SufficientFundsItem;
0029: import org.kuali.test.ConfigureContext;
0030:
0031: /**
0032: * Tests the sufficient funds service
0033: * @see org.kuali.module.gl.service.SufficientFundsService
0034: */
0035: @ConfigureContext
0036: @RawSQL
0037: public class SufficientFundsServiceTest extends KualiTestBase {
0038:
0039: private SufficientFundsService sufficientFundsService = null;
0040: private UnitTestSqlDao unitTestSqlDao = null;
0041: private DateTimeService dateTimeService;
0042:
0043: /**
0044: * Initializes the services needed by this test
0045: * @see junit.framework.TestCase#setUp()
0046: */
0047: protected void setUp() throws Exception {
0048: super .setUp();
0049:
0050: sufficientFundsService = SpringContext
0051: .getBean(SufficientFundsService.class);
0052: unitTestSqlDao = SpringContext.getBean(UnitTestSqlDao.class);
0053: dateTimeService = SpringContext.getBean(DateTimeService.class);
0054: }
0055:
0056: /**
0057: * Puts test sufficient funds balances into the database
0058: *
0059: * @param accountNumber the account number for sf balances to use
0060: * @param sfType the type of the sf balance
0061: * @param sfObjCd the object code of the sf balance
0062: * @param budgetAmt the budget amount of the sf balance
0063: * @param actualAmt the actual amount of the sf balance
0064: * @param encAmt the encumbrance amount of the sf balance
0065: * @param createPles true if pending ledger entries should also be created, false otherwise
0066: */
0067: private void prepareSufficientFundsData(String accountNumber,
0068: String sfType, String sfObjCd, Integer budgetAmt,
0069: Integer actualAmt, Integer encAmt, boolean createPles) {
0070: unitTestSqlDao.sqlCommand("delete from gl_pending_entry_t");
0071:
0072: if (createPles)
0073: insertPendingLedgerEntries(accountNumber, sfObjCd);
0074:
0075: unitTestSqlDao
0076: .sqlCommand("delete from gl_sf_balances_t where univ_fiscal_yr = '2007' and fin_coa_cd = 'BL' and account_nbr = '"
0077: + accountNumber + "'");
0078: unitTestSqlDao
0079: .sqlCommand("insert into GL_SF_BALANCES_T (UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, FIN_OBJECT_CD, ACCT_SF_CD, CURR_BDGT_BAL_AMT, ACCT_ACTL_XPND_AMT, ACCT_ENCUM_AMT, TIMESTAMP) values (2007, 'BL', '"
0080: + accountNumber
0081: + "', '"
0082: + sfObjCd
0083: + "', '"
0084: + sfType
0085: + "', "
0086: + budgetAmt
0087: + ", "
0088: + actualAmt
0089: + ", " + encAmt + ", null)");
0090: unitTestSqlDao
0091: .sqlCommand("update ca_account_t set ACCT_SF_CD = '"
0092: + sfType
0093: + "', ACCT_PND_SF_CD = 'Y' where FIN_COA_CD = 'BL' and ACCOUNT_NBR = '"
0094: + accountNumber + "'");
0095:
0096: }
0097:
0098: /**
0099: * Inserts pending ledger entries into the database
0100: *
0101: * @param accountNumber the account number of pending entries to save
0102: * @param sfObjCd the object code of pending entries to save
0103: */
0104: private void insertPendingLedgerEntries(String accountNumber,
0105: String sfObjCd) {
0106: unitTestSqlDao
0107: .sqlCommand("delete from fp_doc_header_t where fdoc_nbr = '1'");
0108: unitTestSqlDao
0109: .sqlCommand("insert into FP_DOC_HEADER_T (FDOC_NBR, OBJ_ID, VER_NBR, FDOC_STATUS_CD, FDOC_DESC, FDOC_TOTAL_AMT, ORG_DOC_NBR, FDOC_IN_ERR_NBR, FDOC_TMPL_NBR, TEMP_DOC_FNL_DT) values ('1','"
0110: + new Guid().toString()
0111: + "', 1, 'A', 'test', 0, '', '', '', "
0112: + unitTestSqlDao.getDbPlatform()
0113: .getCurTimeFunction() + ")");
0114: unitTestSqlDao
0115: .sqlCommand("insert into GL_PENDING_ENTRY_T (FS_ORIGIN_CD, FDOC_NBR, TRN_ENTR_SEQ_NBR, OBJ_ID, VER_NBR, 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_YR, UNIV_FISCAL_PRD_CD, TRN_LDGR_ENTR_DESC, TRN_LDGR_ENTR_AMT, TRN_DEBIT_CRDT_CD, TRANSACTION_DT, FDOC_TYP_CD, ORG_DOC_NBR, PROJECT_CD, ORG_REFERENCE_ID, FDOC_REF_TYP_CD, FS_REF_ORIGIN_CD, FDOC_REF_NBR, FDOC_REVERSAL_DT, TRN_ENCUM_UPDT_CD, FDOC_APPROVED_CD, ACCT_SF_FINOBJ_CD, TRN_ENTR_OFST_CD, TRNENTR_PROCESS_TM) values ('01','1',1,'"
0116: + new Guid().toString()
0117: + "',2,'BL','"
0118: + accountNumber
0119: + "','-----','5000','---','AC','EX',2007,null, 'test',500,'C',"
0120: + unitTestSqlDao.getDbPlatform()
0121: .getCurTimeFunction()
0122: + ",'DI',null,'----------',null,'','','',null,'','N','"
0123: + sfObjCd
0124: + "','N',"
0125: + unitTestSqlDao.getDbPlatform()
0126: .getCurTimeFunction() + ")");
0127: unitTestSqlDao
0128: .sqlCommand("insert into GL_PENDING_ENTRY_T (FS_ORIGIN_CD, FDOC_NBR, TRN_ENTR_SEQ_NBR, OBJ_ID, VER_NBR, 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_YR, UNIV_FISCAL_PRD_CD, TRN_LDGR_ENTR_DESC, TRN_LDGR_ENTR_AMT, TRN_DEBIT_CRDT_CD, TRANSACTION_DT, FDOC_TYP_CD, ORG_DOC_NBR, PROJECT_CD, ORG_REFERENCE_ID, FDOC_REF_TYP_CD, FS_REF_ORIGIN_CD, FDOC_REF_NBR, FDOC_REVERSAL_DT, TRN_ENCUM_UPDT_CD, FDOC_APPROVED_CD, ACCT_SF_FINOBJ_CD, TRN_ENTR_OFST_CD, TRNENTR_PROCESS_TM) values ('01','1',3,'"
0129: + new Guid().toString()
0130: + "',2,'BL','4631638','-----','5000','---','AC','EX',2007,null, 'test',500,'D',"
0131: + unitTestSqlDao.getDbPlatform()
0132: .getCurTimeFunction()
0133: + ",'DI',null,'----------',null,'','','',null,'','N','N/A' ,'N',"
0134: + unitTestSqlDao.getDbPlatform()
0135: .getCurTimeFunction() + ")");
0136: unitTestSqlDao
0137: .sqlCommand("insert into GL_PENDING_ENTRY_T (FS_ORIGIN_CD, FDOC_NBR, TRN_ENTR_SEQ_NBR, OBJ_ID, VER_NBR, 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_YR, UNIV_FISCAL_PRD_CD, TRN_LDGR_ENTR_DESC, TRN_LDGR_ENTR_AMT, TRN_DEBIT_CRDT_CD, TRANSACTION_DT, FDOC_TYP_CD, ORG_DOC_NBR, PROJECT_CD, ORG_REFERENCE_ID, FDOC_REF_TYP_CD, FS_REF_ORIGIN_CD, FDOC_REF_NBR, FDOC_REVERSAL_DT, TRN_ENCUM_UPDT_CD, FDOC_APPROVED_CD, ACCT_SF_FINOBJ_CD, TRN_ENTR_OFST_CD, TRNENTR_PROCESS_TM) values ('01','1',2,'"
0138: + new Guid().toString()
0139: + "',2,'BL','"
0140: + accountNumber
0141: + "','-----','8000','---','AC','AS',2007,null,'TP Generated Offset',500,'D',"
0142: + unitTestSqlDao.getDbPlatform()
0143: .getCurTimeFunction()
0144: + ",'DI',null,'----------',null,'','','',null,'','N','ASST','Y',"
0145: + unitTestSqlDao.getDbPlatform()
0146: .getCurTimeFunction() + ")");
0147: unitTestSqlDao
0148: .sqlCommand("insert into GL_PENDING_ENTRY_T (FS_ORIGIN_CD, FDOC_NBR, TRN_ENTR_SEQ_NBR, OBJ_ID, VER_NBR, 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_YR, UNIV_FISCAL_PRD_CD, TRN_LDGR_ENTR_DESC, TRN_LDGR_ENTR_AMT, TRN_DEBIT_CRDT_CD, TRANSACTION_DT, FDOC_TYP_CD, ORG_DOC_NBR, PROJECT_CD, ORG_REFERENCE_ID, FDOC_REF_TYP_CD, FS_REF_ORIGIN_CD, FDOC_REF_NBR, FDOC_REVERSAL_DT, TRN_ENCUM_UPDT_CD, FDOC_APPROVED_CD, ACCT_SF_FINOBJ_CD, TRN_ENTR_OFST_CD, TRNENTR_PROCESS_TM) values ('01','1',4,'"
0149: + new Guid().toString()
0150: + "',2,'BL','4631638','-----','8000','---','AC','AS',2007,null,'TP Generated Offset',500,'C',"
0151: + unitTestSqlDao.getDbPlatform()
0152: .getCurTimeFunction()
0153: + ",'DI',null,'----------',null,'','','',null,'','N','N/A' ,'Y',"
0154: + unitTestSqlDao.getDbPlatform()
0155: .getCurTimeFunction() + ")");
0156: }
0157:
0158: /**
0159: * Tests the basic consolidation sufficient funds checking
0160: *
0161: * @throws Exception thrown if any exception is encountered for any reason
0162: */
0163: public void testSufficientFunds_ConsolidationSufficientFunds()
0164: throws Exception {
0165:
0166: prepareSufficientFundsData("0211101", "C", "GENX", 1000, 300,
0167: 100, false);
0168:
0169: String[] stringInput = new String[] {
0170: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
0171: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
0172:
0173: List transactions = new ArrayList();
0174:
0175: // Add inputs to expected output ...
0176: for (int i = 0; i < stringInput.length; i++) {
0177: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0178: transactions.add(oe);
0179: }
0180:
0181: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0182: .checkSufficientFunds(transactions);
0183:
0184: assertEquals(0, insufficientFunds.size());
0185:
0186: }
0187:
0188: /**
0189: * Tests consolidation sufficient funds checking on a negative sufficient funds balance and a credit expense transaction
0190: *
0191: * @throws Exception thrown if any exception is encountered for any reason
0192: */
0193: public void testSufficientFunds_ConsolidationNegativeBalanceCreditExpense()
0194: throws Exception {
0195:
0196: prepareSufficientFundsData("0211101", "C", "GENX", 100, 300,
0197: 200, false);
0198:
0199: String[] stringInput = new String[] {
0200: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00C2006-01-05 ---------- ",
0201: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00D2006-01-05 ---------- " };
0202:
0203: List transactions = new ArrayList();
0204:
0205: // Add inputs to expected output ...
0206: for (int i = 0; i < stringInput.length; i++) {
0207: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0208: transactions.add(oe);
0209: }
0210:
0211: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0212: .checkSufficientFunds(transactions);
0213:
0214: assertEquals(0, insufficientFunds.size());
0215:
0216: }
0217:
0218: /**
0219: * Tests consolidation sufficient funds checking on a negative sufficient funds balance and a debit expense transaction
0220: *
0221: * @throws Exception thrown if any exception is encountered for any reason
0222: */
0223: public void testSufficientFunds_ConsolidationNegativeBalanceDebitExpense()
0224: throws Exception {
0225:
0226: prepareSufficientFundsData("0211101", "C", "GENX", -1000, 300,
0227: 200, false);
0228:
0229: String[] stringInput = new String[] {
0230: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
0231: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
0232:
0233: List transactions = new ArrayList();
0234:
0235: // Add inputs to expected output ...
0236: for (int i = 0; i < stringInput.length; i++) {
0237: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0238: transactions.add(oe);
0239: }
0240:
0241: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0242: .checkSufficientFunds(transactions);
0243:
0244: assertEquals(1, insufficientFunds.size());
0245:
0246: }
0247:
0248: /**
0249: * Tests consolidation sufficient funds checking on a positive sufficient funds balance and two transactions that will cancel each other out
0250: *
0251: * @throws Exception thrown if any exception is encountered for any reason
0252: */
0253: public void testSufficientFunds_ConsolidationSameAccountPositiveBalanceNetZeroChange()
0254: throws Exception {
0255:
0256: prepareSufficientFundsData("0211101", "C", "GENX", 1000, 300,
0257: 200, false);
0258:
0259: String[] stringInput = new String[] {
0260: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
0261: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
0262:
0263: List transactions = new ArrayList();
0264:
0265: // Add inputs to expected output ...
0266: for (int i = 0; i < stringInput.length; i++) {
0267: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0268: transactions.add(oe);
0269: }
0270:
0271: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0272: .checkSufficientFunds(transactions);
0273:
0274: assertEquals(0, insufficientFunds.size());
0275:
0276: }
0277:
0278: /**
0279: * Tests consolidation sufficient funds checking on a negative sufficient funds balance and two transactions that will cancel each other out
0280: *
0281: * @throws Exception thrown if any exception is encountered for any reason
0282: */
0283: public void testSufficientFunds_ConsolidationSameAccountNegativeBalanceNetZeroChange()
0284: throws Exception {
0285:
0286: prepareSufficientFundsData("0211101", "C", "GENX", 100, 300,
0287: 200, false);
0288:
0289: String[] stringInput = new String[] {
0290: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
0291: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
0292:
0293: List transactions = new ArrayList();
0294:
0295: // Add inputs to expected output ...
0296: for (int i = 0; i < stringInput.length; i++) {
0297: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0298: transactions.add(oe);
0299: }
0300:
0301: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0302: .checkSufficientFunds(transactions);
0303:
0304: assertEquals(0, insufficientFunds.size());
0305:
0306: }
0307:
0308: /**
0309: * Tests consolidation sufficient funds checking on a sufficient funds balance that do not have sufficient funds for a transaction
0310: *
0311: * @throws Exception thrown if any exception is encountered for any reason
0312: */
0313: public void testSufficientFunds_ConsolidationInsufficientFunds()
0314: throws Exception {
0315:
0316: prepareSufficientFundsData("0211101", "C", "GENX", 1000, 300,
0317: 200, false);
0318:
0319: String[] stringInput = new String[] {
0320: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01D2006-01-05 ---------- ",
0321: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01C2006-01-05 ---------- " };
0322:
0323: List transactions = new ArrayList();
0324:
0325: // Add inputs to expected output ...
0326: for (int i = 0; i < stringInput.length; i++) {
0327: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0328: transactions.add(oe);
0329: }
0330:
0331: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0332: .checkSufficientFunds(transactions);
0333:
0334: assertEquals(1, insufficientFunds.size());
0335:
0336: }
0337:
0338: /**
0339: * Tests consolidation sufficient funds checking on a sufficient funds balance where pending entries will provide sufficient funds for a transaction
0340: *
0341: * @throws Exception thrown if any exception is encountered for any reason
0342: */
0343: public void testSufficientFunds_ConsolidationPendingLedgerEntriesSufficientFunds()
0344: throws Exception {
0345:
0346: prepareSufficientFundsData("0211101", "C", "GENX", 1000, 100,
0347: 100, true);
0348:
0349: String[] stringInput = new String[] {
0350: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00D2006-01-05 ---------- ",
0351: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00C2006-01-05 ---------- " };
0352:
0353: List transactions = new ArrayList();
0354:
0355: // Add inputs to expected output ...
0356: for (int i = 0; i < stringInput.length; i++) {
0357: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0358: transactions.add(oe);
0359: }
0360:
0361: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0362: .checkSufficientFunds(transactions);
0363:
0364: assertEquals(0, insufficientFunds.size());
0365:
0366: }
0367:
0368: /**
0369: * Tests consolidation sufficient funds checking on a sufficient funds balance where pending entries will not provide sufficient funds for a transaction
0370: *
0371: * @throws Exception thrown if any exception is encountered for any reason
0372: */
0373: public void testSufficientFunds_ConsolidationPendingLedgerEntriesInsufficientFunds()
0374: throws Exception {
0375:
0376: prepareSufficientFundsData("0211101", "C", "GENX", 1000, 100,
0377: 100, true);
0378:
0379: String[] stringInput = new String[] {
0380: "2007BL0211101-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01D2006-01-05 ---------- ",
0381: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01C2006-01-05 ---------- " };
0382:
0383: List transactions = new ArrayList();
0384:
0385: // Add inputs to expected output ...
0386: for (int i = 0; i < stringInput.length; i++) {
0387: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0388: transactions.add(oe);
0389: }
0390:
0391: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0392: .checkSufficientFunds(transactions);
0393:
0394: assertEquals(1, insufficientFunds.size());
0395:
0396: }
0397:
0398: /**
0399: * Tests basic cash sufficient funds checking
0400: *
0401: * @throws Exception thrown if any exception is encountered for any reason
0402: */
0403: public void testSufficientFunds_CashSufficientFunds()
0404: throws Exception {
0405:
0406: prepareSufficientFundsData("0211301", "H", " ", 1000, 300,
0407: 200, false);
0408:
0409: String[] stringInput = new String[] {
0410: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- ",
0411: "2007BL4631638-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- " };
0412:
0413: List transactions = new ArrayList();
0414:
0415: // Add inputs to expected output ...
0416: for (int i = 0; i < stringInput.length; i++) {
0417: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0418: transactions.add(oe);
0419: }
0420:
0421: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0422: .checkSufficientFunds(transactions);
0423:
0424: assertEquals(0, insufficientFunds.size());
0425:
0426: }
0427:
0428: /**
0429: * Tests cash sufficient funds checking on a negative sufficient funds balance and a transaction that is a credit expense
0430: *
0431: * @throws Exception thrown if any exception is encountered for any reason
0432: */
0433: public void testSufficientFunds_CashNegativeBalanceCreditExpense()
0434: throws Exception {
0435:
0436: prepareSufficientFundsData("0211301", "H", " ", 100, 300,
0437: 200, false);
0438:
0439: String[] stringInput = new String[] {
0440: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00D2006-01-05 ---------- ",
0441: "2007BL4631638-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00C2006-01-05 ---------- " };
0442:
0443: List transactions = new ArrayList();
0444:
0445: // Add inputs to expected output ...
0446: for (int i = 0; i < stringInput.length; i++) {
0447: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0448: transactions.add(oe);
0449: }
0450:
0451: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0452: .checkSufficientFunds(transactions);
0453:
0454: assertEquals(0, insufficientFunds.size());
0455:
0456: }
0457:
0458: /**
0459: * Tests cash sufficient funds checking on a negative sufficient funds balance and a transaction that is a debit expense
0460: *
0461: * @throws Exception thrown if any exception is encountered for any reason
0462: */
0463: public void testSufficientFunds_CashNegativeBalanceDebitExpense()
0464: throws Exception {
0465:
0466: prepareSufficientFundsData("0211301", "H", " ", -1000, 300,
0467: 200, false);
0468:
0469: String[] stringInput = new String[] {
0470: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- ",
0471: "2007BL4631638-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- " };
0472:
0473: List transactions = new ArrayList();
0474:
0475: // Add inputs to expected output ...
0476: for (int i = 0; i < stringInput.length; i++) {
0477: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0478: transactions.add(oe);
0479: }
0480:
0481: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0482: .checkSufficientFunds(transactions);
0483:
0484: assertEquals(1, insufficientFunds.size());
0485:
0486: }
0487:
0488: /**
0489: * Tests cash sufficient funds checking on a positive sufficient funds balance and two transactions that cancel each other out
0490: *
0491: * @throws Exception thrown if any exception is encountered for any reason
0492: */
0493: public void testSufficientFunds_CashSameAccountPositiveBalanceNetZeroChange()
0494: throws Exception {
0495:
0496: prepareSufficientFundsData("0211301", "H", " ", 1000, 300,
0497: 200, false);
0498:
0499: String[] stringInput = new String[] {
0500: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- ",
0501: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- " };
0502:
0503: List transactions = new ArrayList();
0504:
0505: // Add inputs to expected output ...
0506: for (int i = 0; i < stringInput.length; i++) {
0507: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0508: transactions.add(oe);
0509: }
0510:
0511: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0512: .checkSufficientFunds(transactions);
0513:
0514: assertEquals(0, insufficientFunds.size());
0515:
0516: }
0517:
0518: /**
0519: * Tests cash sufficient funds checking on a negative sufficient funds balance and two transactions that cancel each other out
0520: *
0521: * @throws Exception thrown if any exception is encountered for any reason
0522: */
0523: public void testSufficientFunds_CashSameAccountNegativeBalanceNetZeroChange()
0524: throws Exception {
0525:
0526: prepareSufficientFundsData("0211301", "H", " ", 100, 300,
0527: 200, false);
0528:
0529: String[] stringInput = new String[] {
0530: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- ",
0531: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- " };
0532:
0533: List transactions = new ArrayList();
0534:
0535: // Add inputs to expected output ...
0536: for (int i = 0; i < stringInput.length; i++) {
0537: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0538: transactions.add(oe);
0539: }
0540:
0541: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0542: .checkSufficientFunds(transactions);
0543:
0544: assertEquals(0, insufficientFunds.size());
0545:
0546: }
0547:
0548: /**
0549: * Tests cash sufficient funds checking on a sufficient funds balance with insufficient funds for a transaction
0550: *
0551: * @throws Exception thrown if any exception is encountered for any reason
0552: */
0553: public void testSufficientFunds_CashInsufficientFunds()
0554: throws Exception {
0555:
0556: prepareSufficientFundsData("0211301", "H", " ", 1000, 0,
0557: 500, false);
0558:
0559: String[] stringInput = new String[] {
0560: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01C2006-01-05 ---------- ",
0561: "2007BL4631638-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01D2006-01-05 ---------- " };
0562:
0563: List transactions = new ArrayList();
0564:
0565: // Add inputs to expected output ...
0566: for (int i = 0; i < stringInput.length; i++) {
0567: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0568: transactions.add(oe);
0569: }
0570:
0571: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0572: .checkSufficientFunds(transactions);
0573:
0574: assertEquals(1, insufficientFunds.size());
0575:
0576: }
0577:
0578: /**
0579: * Tests cash sufficient funds checking on a sufficient funds balance where pending entries will provide sufficient funds for a transaction
0580: *
0581: * @throws Exception thrown if any exception is encountered for any reason
0582: */
0583: public void testSufficientFunds_CashPendingLedgerEntriesSufficientFunds()
0584: throws Exception {
0585:
0586: prepareSufficientFundsData("0211301", "H", " ", 1000, 100,
0587: 100, true);
0588:
0589: String[] stringInput = new String[] {
0590: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00C2006-01-05 ---------- ",
0591: "2007BL4631638-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00D2006-01-05 ---------- " };
0592:
0593: List transactions = new ArrayList();
0594:
0595: // Add inputs to expected output ...
0596: for (int i = 0; i < stringInput.length; i++) {
0597: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0598: transactions.add(oe);
0599: }
0600:
0601: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0602: .checkSufficientFunds(transactions);
0603:
0604: assertEquals(0, insufficientFunds.size());
0605:
0606: }
0607:
0608: /**
0609: * Tests cash sufficient funds checking on a sufficient funds balance where pending entries will not provide sufficient funds for a transaction
0610: *
0611: * @throws Exception thrown if any exception is encountered for any reason
0612: */
0613: public void testSufficientFunds_CashPendingLedgerEntriesInsufficientFunds()
0614: throws Exception {
0615:
0616: prepareSufficientFundsData("0211301", "H", " ", 1000, 0,
0617: 200, true);
0618:
0619: String[] stringInput = new String[] {
0620: "2007BL0211301-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01C2006-01-05 ---------- ",
0621: "2007BL4631638-----8000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01D2006-01-05 ---------- " };
0622:
0623: List transactions = new ArrayList();
0624:
0625: // Add inputs to expected output ...
0626: for (int i = 0; i < stringInput.length; i++) {
0627: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0628: transactions.add(oe);
0629: }
0630:
0631: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0632: .checkSufficientFunds(transactions);
0633:
0634: assertEquals(1, insufficientFunds.size());
0635:
0636: }
0637:
0638: /**
0639: * Tests basic level sufficient funds checking
0640: *
0641: * @throws Exception thrown if any exception is encountered for any reason
0642: */
0643: public void testSufficientFunds_LevelSufficientFunds()
0644: throws Exception {
0645:
0646: prepareSufficientFundsData("0211501", "L", "S&E", 1000, 300,
0647: 100, false);
0648:
0649: String[] stringInput = new String[] {
0650: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
0651: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
0652:
0653: List transactions = new ArrayList();
0654:
0655: // Add inputs to expected output ...
0656: for (int i = 0; i < stringInput.length; i++) {
0657: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0658: transactions.add(oe);
0659: }
0660:
0661: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0662: .checkSufficientFunds(transactions);
0663:
0664: assertEquals(0, insufficientFunds.size());
0665:
0666: }
0667:
0668: /**
0669: * Tests level sufficient funds checking on a negative sufficient funds balance and a transaction that is a credit expense
0670: *
0671: * @throws Exception thrown if any exception is encountered for any reason
0672: */
0673: public void testSufficientFunds_LevelNegativeBalanceCreditExpense()
0674: throws Exception {
0675:
0676: prepareSufficientFundsData("0211501", "L", "S&E", 100, 300,
0677: 200, false);
0678:
0679: String[] stringInput = new String[] {
0680: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00C2006-01-05 ---------- ",
0681: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00D2006-01-05 ---------- " };
0682:
0683: List transactions = new ArrayList();
0684:
0685: // Add inputs to expected output ...
0686: for (int i = 0; i < stringInput.length; i++) {
0687: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0688: transactions.add(oe);
0689: }
0690:
0691: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0692: .checkSufficientFunds(transactions);
0693:
0694: assertEquals(0, insufficientFunds.size());
0695:
0696: }
0697:
0698: /**
0699: * Tests level sufficient funds checking on a negative sufficient funds balance and a transaction that is a debit expense
0700: *
0701: * @throws Exception thrown if any exception is encountered for any reason
0702: */
0703: public void testSufficientFunds_LevelNegativeBalanceDebitExpense()
0704: throws Exception {
0705:
0706: prepareSufficientFundsData("0211501", "L", "S&E", -1000, 300,
0707: 200, false);
0708:
0709: String[] stringInput = new String[] {
0710: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
0711: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
0712:
0713: List transactions = new ArrayList();
0714:
0715: // Add inputs to expected output ...
0716: for (int i = 0; i < stringInput.length; i++) {
0717: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0718: transactions.add(oe);
0719: }
0720:
0721: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0722: .checkSufficientFunds(transactions);
0723:
0724: assertEquals(1, insufficientFunds.size());
0725:
0726: }
0727:
0728: /**
0729: * Tests level sufficient funds checking on a positive sufficient funds balance and two transactions that cancel each other out
0730: *
0731: * @throws Exception thrown if any exception is encountered for any reason
0732: */
0733: public void testSufficientFunds_LevelSameAccountPositiveBalanceNetZeroChange()
0734: throws Exception {
0735:
0736: prepareSufficientFundsData("0211501", "L", "S&E", 1000, 300,
0737: 200, false);
0738:
0739: String[] stringInput = new String[] {
0740: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
0741: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
0742:
0743: List transactions = new ArrayList();
0744:
0745: // Add inputs to expected output ...
0746: for (int i = 0; i < stringInput.length; i++) {
0747: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0748: transactions.add(oe);
0749: }
0750:
0751: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0752: .checkSufficientFunds(transactions);
0753:
0754: assertEquals(0, insufficientFunds.size());
0755:
0756: }
0757:
0758: /**
0759: * Tests level sufficient funds checking on a negative sufficient funds balance and two transactions that cancel each other out
0760: *
0761: * @throws Exception thrown if any exception is encountered for any reason
0762: */
0763: public void testSufficientFunds_LevelSameAccountNegativeBalanceNetZeroChange()
0764: throws Exception {
0765:
0766: prepareSufficientFundsData("0211501", "L", "S&E", 100, 300,
0767: 200, false);
0768:
0769: String[] stringInput = new String[] {
0770: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
0771: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
0772:
0773: List transactions = new ArrayList();
0774:
0775: // Add inputs to expected output ...
0776: for (int i = 0; i < stringInput.length; i++) {
0777: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0778: transactions.add(oe);
0779: }
0780:
0781: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0782: .checkSufficientFunds(transactions);
0783:
0784: assertEquals(0, insufficientFunds.size());
0785:
0786: }
0787:
0788: /**
0789: * Tests level sufficient funds checking on a sufficient funds balance with insufficient funds for a transaction
0790: *
0791: * @throws Exception thrown if any exception is encountered for any reason
0792: */
0793: public void testSufficientFunds_LevelInsufficientFunds()
0794: throws Exception {
0795:
0796: prepareSufficientFundsData("0211501", "L", "S&E", 1000, 300,
0797: 200, false);
0798:
0799: String[] stringInput = new String[] {
0800: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01D2006-01-05 ---------- ",
0801: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01C2006-01-05 ---------- " };
0802:
0803: List transactions = new ArrayList();
0804:
0805: // Add inputs to expected output ...
0806: for (int i = 0; i < stringInput.length; i++) {
0807: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0808: transactions.add(oe);
0809: }
0810:
0811: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0812: .checkSufficientFunds(transactions);
0813:
0814: assertEquals(1, insufficientFunds.size());
0815:
0816: }
0817:
0818: /**
0819: * Tests level sufficient funds checking on a sufficient funds balance where pending entries will provide the sufficient funds for a transaction
0820: *
0821: * @throws Exception thrown if any exception is encountered for any reason
0822: */
0823: public void testSufficientFunds_LevelPendingLedgerEntriesSufficientFunds()
0824: throws Exception {
0825:
0826: prepareSufficientFundsData("0211501", "L", "S&E", 1000, 100,
0827: 100, true);
0828:
0829: String[] stringInput = new String[] {
0830: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00D2006-01-05 ---------- ",
0831: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00C2006-01-05 ---------- " };
0832:
0833: List transactions = new ArrayList();
0834:
0835: // Add inputs to expected output ...
0836: for (int i = 0; i < stringInput.length; i++) {
0837: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0838: transactions.add(oe);
0839: }
0840:
0841: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0842: .checkSufficientFunds(transactions);
0843:
0844: assertEquals(0, insufficientFunds.size());
0845:
0846: }
0847:
0848: /**
0849: * Tests level sufficient funds checking on a sufficient funds balance where pending entries will not provide sufficient funds for a transaction
0850: *
0851: * @throws Exception thrown if any exception is encountered for any reason
0852: */
0853: public void testSufficientFunds_LevelPendingLedgerEntriesInsufficientFunds()
0854: throws Exception {
0855:
0856: prepareSufficientFundsData("0211501", "L", "S&E", 1000, 100,
0857: 100, true);
0858:
0859: String[] stringInput = new String[] {
0860: "2007BL0211501-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01D2006-01-05 ---------- ",
0861: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01C2006-01-05 ---------- " };
0862:
0863: List transactions = new ArrayList();
0864:
0865: // Add inputs to expected output ...
0866: for (int i = 0; i < stringInput.length; i++) {
0867: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0868: transactions.add(oe);
0869: }
0870:
0871: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0872: .checkSufficientFunds(transactions);
0873:
0874: assertEquals(1, insufficientFunds.size());
0875:
0876: }
0877:
0878: /**
0879: * Tests basic object sufficient funds checking
0880: *
0881: * @throws Exception thrown if any exception is encountered for any reason
0882: */
0883: public void testSufficientFunds_ObjectSufficientFunds()
0884: throws Exception {
0885:
0886: prepareSufficientFundsData("0211701", "O", "5000", 1000, 300,
0887: 100, false);
0888:
0889: String[] stringInput = new String[] {
0890: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
0891: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
0892:
0893: List transactions = new ArrayList();
0894:
0895: // Add inputs to expected output ...
0896: for (int i = 0; i < stringInput.length; i++) {
0897: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0898: transactions.add(oe);
0899: }
0900:
0901: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0902: .checkSufficientFunds(transactions);
0903:
0904: assertEquals(0, insufficientFunds.size());
0905:
0906: }
0907:
0908: /**
0909: * Tests object sufficient funds checking on a negative sufficient funds balance and a credit expense transaction
0910: *
0911: * @throws Exception thrown if any exception is encountered for any reason
0912: */
0913: public void testSufficientFunds_ObjectNegativeBalanceCreditExpense()
0914: throws Exception {
0915:
0916: prepareSufficientFundsData("0211701", "O", "5000", 100, 300,
0917: 200, false);
0918:
0919: String[] stringInput = new String[] {
0920: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00C2006-01-05 ---------- ",
0921: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00D2006-01-05 ---------- " };
0922:
0923: List transactions = new ArrayList();
0924:
0925: // Add inputs to expected output ...
0926: for (int i = 0; i < stringInput.length; i++) {
0927: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0928: transactions.add(oe);
0929: }
0930:
0931: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0932: .checkSufficientFunds(transactions);
0933:
0934: assertEquals(0, insufficientFunds.size());
0935:
0936: }
0937:
0938: /**
0939: * Tests object sufficient funds checking on a negative sufficient funds balance and a debit expense transaction
0940: *
0941: * @throws Exception thrown if any exception is encountered for any reason
0942: */
0943: public void testSufficientFunds_ObjectNegativeBalanceDebitExpense()
0944: throws Exception {
0945:
0946: prepareSufficientFundsData("0211701", "O", "5000", -1000, 300,
0947: 200, false);
0948:
0949: String[] stringInput = new String[] {
0950: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
0951: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
0952:
0953: List transactions = new ArrayList();
0954:
0955: // Add inputs to expected output ...
0956: for (int i = 0; i < stringInput.length; i++) {
0957: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0958: transactions.add(oe);
0959: }
0960:
0961: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0962: .checkSufficientFunds(transactions);
0963:
0964: assertEquals(1, insufficientFunds.size());
0965:
0966: }
0967:
0968: /**
0969: * Tests object sufficient funds checking on a positive sufficient funds balance and two transactions that cancel each other out
0970: *
0971: * @throws Exception thrown if any exception is encountered for any reason
0972: */
0973: public void testSufficientFunds_ObjectSameAccountPositiveBalanceNetZeroChange()
0974: throws Exception {
0975:
0976: prepareSufficientFundsData("0211701", "O", "5000", 1000, 300,
0977: 200, false);
0978:
0979: String[] stringInput = new String[] {
0980: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
0981: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
0982:
0983: List transactions = new ArrayList();
0984:
0985: // Add inputs to expected output ...
0986: for (int i = 0; i < stringInput.length; i++) {
0987: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
0988: transactions.add(oe);
0989: }
0990:
0991: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
0992: .checkSufficientFunds(transactions);
0993:
0994: assertEquals(0, insufficientFunds.size());
0995:
0996: }
0997:
0998: /**
0999: * Tests object sufficient funds checking on a negative sufficient funds balance and two transactions that cancel each other out
1000: *
1001: * @throws Exception thrown if any exception is encountered for any reason
1002: */
1003: public void testSufficientFunds_ObjectSameAccountNegativeBalanceNetZeroChange()
1004: throws Exception {
1005:
1006: prepareSufficientFundsData("0211701", "O", "5000", 100, 300,
1007: 200, false);
1008:
1009: String[] stringInput = new String[] {
1010: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
1011: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
1012:
1013: List transactions = new ArrayList();
1014:
1015: // Add inputs to expected output ...
1016: for (int i = 0; i < stringInput.length; i++) {
1017: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1018: transactions.add(oe);
1019: }
1020:
1021: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1022: .checkSufficientFunds(transactions);
1023:
1024: assertEquals(0, insufficientFunds.size());
1025:
1026: }
1027:
1028: /**
1029: * Tests object sufficient funds checking on a sufficient funds balance with insufficient funds for a transaction
1030: *
1031: * @throws Exception thrown if any exception is encountered for any reason
1032: */
1033: public void testSufficientFunds_ObjectInsufficientFunds()
1034: throws Exception {
1035:
1036: prepareSufficientFundsData("0211701", "O", "5000", 1000, 300,
1037: 200, false);
1038:
1039: String[] stringInput = new String[] {
1040: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01D2006-01-05 ---------- ",
1041: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01C2006-01-05 ---------- " };
1042:
1043: List transactions = new ArrayList();
1044:
1045: // Add inputs to expected output ...
1046: for (int i = 0; i < stringInput.length; i++) {
1047: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1048: transactions.add(oe);
1049: }
1050:
1051: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1052: .checkSufficientFunds(transactions);
1053:
1054: assertEquals(1, insufficientFunds.size());
1055:
1056: }
1057:
1058: /**
1059: * Tests object sufficient funds checking on a sufficient funds balance where pending entries will provide sufficent funds for a transaction
1060: *
1061: * @throws Exception thrown if any exception is encountered for any reason
1062: */
1063: public void testSufficientFunds_ObjectPendingLedgerEntriesSufficientFunds()
1064: throws Exception {
1065:
1066: prepareSufficientFundsData("0211701", "O", "5000", 1000, 100,
1067: 100, true);
1068:
1069: String[] stringInput = new String[] {
1070: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00D2006-01-05 ---------- ",
1071: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00C2006-01-05 ---------- " };
1072:
1073: List transactions = new ArrayList();
1074:
1075: // Add inputs to expected output ...
1076: for (int i = 0; i < stringInput.length; i++) {
1077: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1078: transactions.add(oe);
1079: }
1080:
1081: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1082: .checkSufficientFunds(transactions);
1083:
1084: assertEquals(0, insufficientFunds.size());
1085:
1086: }
1087:
1088: /**
1089: * Tests object sufficient funds checking on a sufficient funds balance where pending entries will not provide sufficient funds for a transaction
1090: *
1091: * @throws Exception thrown if any exception is encountered for any reason
1092: */
1093: public void testSufficientFunds_ObjectPendingLedgerEntriesInsufficientFunds()
1094: throws Exception {
1095:
1096: prepareSufficientFundsData("0211701", "O", "5000", 1000, 100,
1097: 100, true);
1098:
1099: String[] stringInput = new String[] {
1100: "2007BL0211701-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01D2006-01-05 ---------- ",
1101: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01C2006-01-05 ---------- " };
1102:
1103: List transactions = new ArrayList();
1104:
1105: // Add inputs to expected output ...
1106: for (int i = 0; i < stringInput.length; i++) {
1107: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1108: transactions.add(oe);
1109: }
1110:
1111: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1112: .checkSufficientFunds(transactions);
1113:
1114: assertEquals(1, insufficientFunds.size());
1115:
1116: }
1117:
1118: /**
1119: * Tests basic account sufficient funds checking
1120: *
1121: * @throws Exception thrown if any exception is encountered for any reason
1122: */
1123: public void testSufficientFunds_AccountSufficientFunds()
1124: throws Exception {
1125:
1126: prepareSufficientFundsData("0211901", "A", " ", 1000, 300,
1127: 100, false);
1128:
1129: String[] stringInput = new String[] {
1130: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
1131: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
1132:
1133: List transactions = new ArrayList();
1134:
1135: // Add inputs to expected output ...
1136: for (int i = 0; i < stringInput.length; i++) {
1137: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1138: transactions.add(oe);
1139: }
1140:
1141: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1142: .checkSufficientFunds(transactions);
1143:
1144: assertEquals(0, insufficientFunds.size());
1145:
1146: }
1147:
1148: /**
1149: * Tests account sufficient funds checking on a negative sufficient funds balance and a credit expense transaction
1150: *
1151: * @throws Exception thrown if any exception is encountered for any reason
1152: */
1153: public void testSufficientFunds_AccountNegativeBalanceCreditExpense()
1154: throws Exception {
1155:
1156: prepareSufficientFundsData("0211901", "A", " ", 100, 300,
1157: 200, false);
1158:
1159: String[] stringInput = new String[] {
1160: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00C2006-01-05 ---------- ",
1161: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 300.00D2006-01-05 ---------- " };
1162:
1163: List transactions = new ArrayList();
1164:
1165: // Add inputs to expected output ...
1166: for (int i = 0; i < stringInput.length; i++) {
1167: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1168: transactions.add(oe);
1169: }
1170:
1171: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1172: .checkSufficientFunds(transactions);
1173:
1174: assertEquals(0, insufficientFunds.size());
1175:
1176: }
1177:
1178: /**
1179: * Tests account sufficient funds checking on a negative sufficient funds balance and a debit expense transaction
1180: *
1181: * @throws Exception thrown if any exception is encountered for any reason
1182: */
1183: public void testSufficientFunds_AccountNegativeBalanceDebitExpense()
1184: throws Exception {
1185:
1186: prepareSufficientFundsData("0211901", "A", " ", -1000, 300,
1187: 200, false);
1188:
1189: String[] stringInput = new String[] {
1190: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00D2006-01-05 ---------- ",
1191: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.00C2006-01-05 ---------- " };
1192:
1193: List transactions = new ArrayList();
1194:
1195: // Add inputs to expected output ...
1196: for (int i = 0; i < stringInput.length; i++) {
1197: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1198: transactions.add(oe);
1199: }
1200:
1201: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1202: .checkSufficientFunds(transactions);
1203:
1204: assertEquals(1, insufficientFunds.size());
1205:
1206: }
1207:
1208: /**
1209: * Tests account sufficient funds checking on a positive sufficient funds balance and two transactions that will cancel each other out
1210: *
1211: * @throws Exception thrown if any exception is encountered for any reason
1212: */
1213: public void testSufficientFunds_AccountSameAccountPositiveBalanceNetZeroChange()
1214: throws Exception {
1215:
1216: prepareSufficientFundsData("0211901", "A", " ", 1000, 300,
1217: 200, false);
1218:
1219: String[] stringInput = new String[] {
1220: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
1221: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
1222:
1223: List transactions = new ArrayList();
1224:
1225: // Add inputs to expected output ...
1226: for (int i = 0; i < stringInput.length; i++) {
1227: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1228: transactions.add(oe);
1229: }
1230:
1231: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1232: .checkSufficientFunds(transactions);
1233:
1234: assertEquals(0, insufficientFunds.size());
1235:
1236: }
1237:
1238: /**
1239: * Tests account sufficient funds checking on a negative sufficient funds balance and two transactions that will cancel each other out
1240: *
1241: * @throws Exception thrown if any exception is encountered for any reason
1242: */
1243: public void testSufficientFunds_AccountSameAccountNegativeBalanceNetZeroChange()
1244: throws Exception {
1245:
1246: prepareSufficientFundsData("0211901", "A", " ", 100, 300,
1247: 200, false);
1248:
1249: String[] stringInput = new String[] {
1250: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00D2006-01-05 ---------- ",
1251: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1500.00C2006-01-05 ---------- " };
1252:
1253: List transactions = new ArrayList();
1254:
1255: // Add inputs to expected output ...
1256: for (int i = 0; i < stringInput.length; i++) {
1257: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1258: transactions.add(oe);
1259: }
1260:
1261: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1262: .checkSufficientFunds(transactions);
1263:
1264: assertEquals(0, insufficientFunds.size());
1265:
1266: }
1267:
1268: /**
1269: * Tests account sufficient funds checking on a sufficient funds balance without sufficient funds for a transaction
1270: *
1271: * @throws Exception thrown if any exception is encountered for any reason
1272: */
1273: public void testSufficientFunds_AccountInsufficientFunds()
1274: throws Exception {
1275:
1276: prepareSufficientFundsData("0211901", "A", " ", 1000, 300,
1277: 200, false);
1278:
1279: String[] stringInput = new String[] {
1280: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01D2006-01-05 ---------- ",
1281: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 500.01C2006-01-05 ---------- " };
1282:
1283: List transactions = new ArrayList();
1284:
1285: // Add inputs to expected output ...
1286: for (int i = 0; i < stringInput.length; i++) {
1287: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1288: transactions.add(oe);
1289: }
1290:
1291: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1292: .checkSufficientFunds(transactions);
1293:
1294: assertEquals(1, insufficientFunds.size());
1295:
1296: }
1297:
1298: /**
1299: * Tests account sufficient funds checking on a sufficient funds balance where pending ledger entries will provide sufficient funds for a transaction
1300: *
1301: * @throws Exception thrown if any exception is encountered for any reason
1302: */
1303: public void testSufficientFunds_AccountPendingLedgerEntriesSufficientFunds()
1304: throws Exception {
1305:
1306: prepareSufficientFundsData("0211901", "A", " ", 1000, 100,
1307: 100, true);
1308:
1309: String[] stringInput = new String[] {
1310: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00D2006-01-05 ---------- ",
1311: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.00C2006-01-05 ---------- " };
1312:
1313: List transactions = new ArrayList();
1314:
1315: // Add inputs to expected output ...
1316: for (int i = 0; i < stringInput.length; i++) {
1317: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1318: transactions.add(oe);
1319: }
1320:
1321: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1322: .checkSufficientFunds(transactions);
1323:
1324: assertEquals(0, insufficientFunds.size());
1325:
1326: }
1327:
1328: /**
1329: * Tests account sufficient funds checking on a sufficient funds balance where pending ledger entries will not provide sufficient funds for a transaction
1330: *
1331: * @throws Exception thrown if any exception is encountered for any reason
1332: */
1333: public void testSufficientFunds_AccountPendingLedgerEntriesInsufficientFunds()
1334: throws Exception {
1335:
1336: prepareSufficientFundsData("0211901", "A", " ", 1000, 100,
1337: 100, true);
1338:
1339: String[] stringInput = new String[] {
1340: "2007BL0211901-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01D2006-01-05 ---------- ",
1341: "2007BL4631638-----5000---ACEX07DI 01CSHRTRIN 00000Rite Quality Office Supplies Inc. 1300.01C2006-01-05 ---------- " };
1342:
1343: List transactions = new ArrayList();
1344:
1345: // Add inputs to expected output ...
1346: for (int i = 0; i < stringInput.length; i++) {
1347: OriginEntryFull oe = new OriginEntryFull(stringInput[i]);
1348: transactions.add(oe);
1349: }
1350:
1351: List<SufficientFundsItem> insufficientFunds = sufficientFundsService
1352: .checkSufficientFunds(transactions);
1353:
1354: assertEquals(1, insufficientFunds.size());
1355:
1356: }
1357: }
|