001: /*
002: * Copyright 2006-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.test.fixtures;
017:
018: import static org.kuali.kfs.KFSConstants.GL_CREDIT_CODE;
019: import static org.kuali.kfs.KFSConstants.GL_DEBIT_CODE;
020:
021: import org.kuali.core.util.KualiDecimal;
022: import org.kuali.kfs.bo.AccountingLine;
023: import org.kuali.kfs.bo.SourceAccountingLine;
024: import org.kuali.kfs.bo.TargetAccountingLine;
025: import org.kuali.kfs.document.AccountingDocument;
026:
027: public enum AccountingLineFixture {
028: LINE(2004, 1, "BL", "1031400", "AC", "ADV", "5000", "SSS", "KUL",
029: "Y", "IN", "ONE", "01", "1", "blah", GL_DEBIT_CODE, "2.50"), LINE1(
030: 2004, null, "BA", "6044900", null, null, "1697", null,
031: null, null, "IN", null, null, null, null, null, "1000.00"), LINE2(
032: 2004, null, "BL", "1031400", null, "ADV", "5000", "SSS",
033: "KUL", null, "IN", "ONE", null, null, null, null, "1.10"), LINE3(
034: 2004, null, "BA", "6044900", null, null, "4008", "POL",
035: null, null, "IN", "TWO", null, null, null, null, "1.10"), LINE4(
036: 2004, null, "UA", "1912201", null, null, "5033", null,
037: null, null, "EX", null, null, "123", null, null, "1.10"), LINE5(
038: 2004, null, "BL", "1031400", "AC", "ADV", "5000", "SSS",
039: "KUL", null, "AS", "ONE", null, null, null, GL_DEBIT_CODE,
040: "1.10"), LINE6(2004, null, "BL", "1031400", "PE", "ADV",
041: "5000", "SSS", "KUL", null, "IN", "ONE", null, "123", null,
042: GL_DEBIT_CODE, "1.10"), LINE7(2004, null, "BA", "6044900",
043: null, null, "4061", null, null, null, "IN", null, null,
044: null, null, null, "1.10"), LINE8(2004, null, "UA",
045: "1912201", "AC", null, "9980", null, "KUL", "F", "TI",
046: null, "01", "2004", "blah", GL_DEBIT_CODE, "1.10"), LINE9(
047: 2004, null, "UA", "1912201", "AC", null, "9980", null,
048: "KUL", "F", "FB", null, "01", "2004", null, GL_DEBIT_CODE,
049: "1.10"), LINE10(2004, null, "UA", "1912201", "AC", null,
050: "8160", null, "KUL", "F", "TI", null, "01", "2004", "blah",
051: GL_DEBIT_CODE, "1.10"), LINE11(2004, null, "UA", "1912201",
052: "AC", null, "9980", null, "KUL", "F", "TI", null, null,
053: null, null, GL_DEBIT_CODE, "1.10"), LINE12(2004, null,
054: "UA", "1912201", "AC", null, "9897", null, "KUL", "F",
055: "TI", null, null, null, null, GL_DEBIT_CODE, "1.10"), LINE13(
056: 2004, null, "UA", "1912201", "AC", null, "9899", null,
057: "KUL", "F", "TI", null, null, null, null, GL_DEBIT_CODE,
058: "1.10"), LINE14(2004, null, "UA", "1912201", null, null,
059: "5033", null, null, null, "EX", null, null, "123", null,
060: GL_DEBIT_CODE, "1.10"), LINE15(2004, null, "UA", "1912201",
061: null, null, "5033", null, null, null, "EX", null, null,
062: "123", null, GL_CREDIT_CODE, "1.10"), LINE16(2004, null,
063: "UA", "1912201", "AC", null, "1175", null, "KUL", "F",
064: "IC", null, "01", "2004", null, GL_DEBIT_CODE, "1.10"), LINE17(
065: 2004, null, "UA", "1912201", "AC", null, "7600", null,
066: "KUL", "F", "AM", null, "01", "2004", null, GL_DEBIT_CODE,
067: "1.10"), LINE18(2004, null, "BL", "1031400", null, null,
068: "5000", null, null, null, null, null, null, null, null,
069: null, "1.10"),
070:
071: APO_LINE1(2004, null, "BL", "0212007", null, null, "4000", null,
072: null, null, null, null, null, null, null, GL_DEBIT_CODE,
073: "995.00"), APO_LINE2(2004, null, "BL", "0212007", null,
074: null, "4000", null, null, null, null, null, null, null,
075: null, GL_DEBIT_CODE, "120.00"), APO_LINE3(2004, null, "BL",
076: "0212008", null, null, "4000", null, null, null, null,
077: null, null, null, null, GL_DEBIT_CODE, "119.99"), APO_LINE4(
078: 2004, null, "BL", "0212009", null, null, "4000", null,
079: null, null, null, null, null, null, null, GL_DEBIT_CODE,
080: "12.49"),
081:
082: GEC_LINE1(2004, null, "BL", "1031400", null, "ADV", "5000", "SSS",
083: "KUL", null, "EX", null, "01", "123", null, null, "1.10"), ICA_LINE(
084: 2004, null, "BL", "5431400", null, null, "5500", null,
085: null, null, null, null, null, null, null, null, "1.10"), EXPENSE_GEC_LINE(
086: 2004, null, "BA", "6044900", "AC", null, "1940", null,
087: "KUL", "F", null, null, "01", "123", null, null, "1.10"),
088:
089: DOCUMENT_SERVICE_TEST_LINE(null, null, "BL", "1031400", null,
090: "ADV", "5000", "SSS", "KUL", "Y", "AS", null, null, null,
091: null, GL_DEBIT_CODE, "2.50"), PFIP_SUB_FUND_LINE(2004,
092: null, "BA", "9544900", "AC", null, "9900", null, null,
093: null, null, null, null, "2004", null, null, "1000.00"), SOURCE_LINE(
094: 2004, null, "UA", "1912201", "AC", null, "9980", null,
095: "KUL", "F", "AS", null, "01", "2004", "blah",
096: GL_DEBIT_CODE, "1000.00"), EXPENSE_LINE(2004, null, "UA",
097: "1912201", "AC", "BEER", "9900", null, "KUL", "F", "EX",
098: null, "01", "2004", "blah", GL_DEBIT_CODE, "1000.00"), EXPENSE_LINE2(
099: 2004, null, "BL", "1031400", "AC", "BLDG", "9900", null,
100: "KUL", "F", "EX", null, null, null, null, GL_DEBIT_CODE,
101: "1000.00"), EXTERNAL_ENCUMBRANCE_LINE(2004, null, "BL",
102: "1031400", "EX", "BLDG", "9900", null, "KUL", "F", "EX",
103: null, "01", "2004", "PE", GL_DEBIT_CODE, "1000.00"),
104:
105: FLEXIBLE_EXPENSE_LINE(2004, null, "BL", "2231401", "AC", null,
106: "9900", null, "KUL", "F", "EX", null, "01", "1", "blah",
107: GL_DEBIT_CODE, "1000.00"), CASH_LINE(2004, null, "BA",
108: "6044900", null, null, "8000", null, "BOB", null, "ES",
109: null, null, null, null, null, "1000.00"), LOSSS_ON_RETIRE_LINE(
110: 2004, null, "BA", "6044900", null, null, "5137", "CF",
111: "KUL", null, "ES", null, null, null, null, null, "1000.00"), ACCRUED_INCOME_LINE(
112: 2004, null, "BA", "6044900", null, null, "8111", null,
113: "KUL", null, "ES", null, "01", "2004", null, null,
114: "1000.00"), ACCRUED_SICK_PAY_LINE(2004, null, "UA",
115: "1912201", null, null, "2998", null, "KUL", null, "ES",
116: null, null, "01", "2004", null, "1000.00"), FUND_BALANCE_LINE(
117: 2004, null, "BA", "6044900", null, null, "9899", null,
118: "KUL", null, null, null, null, "01", "2004", GL_DEBIT_CODE,
119: "1000.00"), LINE2_TOF(2004, null, "BL", "1031400", null,
120: null, "1697", null, null, null, "TI", null, null, null,
121: null, null, "1.10"), REQ_ACCOUNT_MULTI_QUANTITY(2004, //postingYear
122: null, //sequenceNumber
123: "BL", //chartOfAccountsCode
124: "1023200", //accountNumber
125: null, //balanceTypeCode
126: null, //subAccountNumber
127: "4100", //financialObjectCode
128: null, //financialSubObjectCode
129: null, //projectCode
130: null, //encumbranceUpdateCode
131: null, //objectTypeCode
132: null, //organizationReferenceId
133: null, // referenceOriginCode
134: null, //referenceNumber
135: null, //referenceTypeCode
136: GL_DEBIT_CODE, //debitCreditCode
137: "100"), // amount
138: REQ_ACCOUNT_MULTI_NON_QUANTITY(2004, //postingYear
139: null, //sequenceNumber
140: "BL", //chartOfAccountsCode
141: "1023200", //accountNumber
142: null, //balanceTypeCode
143: null, //subAccountNumber
144: "4078", //financialObjectCode
145: null, //financialSubObjectCode
146: null, //projectCode
147: null, //encumbranceUpdateCode
148: null, //objectTypeCode
149: null, //organizationReferenceId
150: null, // referenceOriginCode
151: null, //referenceNumber
152: null, //referenceTypeCode
153: GL_DEBIT_CODE, //debitCreditCode
154: "100"), // amount
155: ;
156:
157: public final String accountNumber;
158: public final String balanceTypeCode;
159: public final String chartOfAccountsCode;
160: public final String debitCreditCode;
161: public final String encumbranceUpdateCode;
162: public final String financialObjectCode;
163: public final String financialSubObjectCode;
164: public final String objectTypeCode;
165: public final String organizationReferenceId;
166: public final String projectCode;
167: public final String referenceOriginCode;
168: public final String referenceNumber;
169: public final String referenceTypeCode;
170: public final String subAccountNumber;
171: public final KualiDecimal amount;
172: public final Integer postingYear;
173: public final Integer sequenceNumber;
174:
175: AccountingLineFixture(Integer postingYear, Integer sequenceNumber,
176: String chartOfAccountsCode, String accountNumber,
177: String balanceTypeCode, String subAccountNumber,
178: String financialObjectCode, String financialSubObjectCode,
179: String projectCode, String encumbranceUpdateCode,
180: String objectTypeCode, String organizationReferenceId,
181: String referenceOriginCode, String referenceNumber,
182: String referenceTypeCode, String debitCreditCode,
183: String amount) {
184:
185: this .postingYear = postingYear;
186: this .sequenceNumber = sequenceNumber;
187: this .accountNumber = accountNumber;
188: this .balanceTypeCode = balanceTypeCode;
189: this .chartOfAccountsCode = chartOfAccountsCode;
190: this .debitCreditCode = debitCreditCode;
191: this .encumbranceUpdateCode = encumbranceUpdateCode;
192: this .financialObjectCode = financialObjectCode;
193: this .financialSubObjectCode = financialSubObjectCode;
194: this .objectTypeCode = objectTypeCode;
195: this .organizationReferenceId = organizationReferenceId;
196: this .projectCode = projectCode;
197: this .referenceOriginCode = referenceOriginCode;
198: this .referenceNumber = referenceNumber;
199: this .referenceTypeCode = referenceTypeCode;
200: this .subAccountNumber = subAccountNumber;
201: this .amount = new KualiDecimal(amount);
202: }
203:
204: private <T extends AccountingLine> T createAccountingLine(
205: Class<T> lineClass) throws InstantiationException,
206: IllegalAccessException {
207: return createAccountingLine(lineClass, null, this .postingYear,
208: this .sequenceNumber);
209: }
210:
211: public <T extends AccountingLine> T createAccountingLine(
212: Class<T> lineClass, String debitCreditCode)
213: throws InstantiationException, IllegalAccessException {
214: T line = createAccountingLine(lineClass, null,
215: this .postingYear, this .sequenceNumber);
216: line.setDebitCreditCode(debitCreditCode);
217: return line;
218: }
219:
220: public <T extends AccountingLine> T createAccountingLine(
221: Class<T> lineClass, String documentNumber,
222: Integer postingYear, Integer sequenceNumber)
223: throws InstantiationException, IllegalAccessException {
224: T line = createLine(lineClass);
225:
226: line.setDocumentNumber(documentNumber);
227: line.setPostingYear(postingYear);
228: line.setSequenceNumber(sequenceNumber);
229:
230: line.refresh();
231: return line;
232: }
233:
234: private <T extends AccountingLine> T createLine(Class<T> lineClass)
235: throws InstantiationException, IllegalAccessException {
236: T line = (T) lineClass.newInstance();
237: line.setAccountNumber(this .accountNumber);
238: line.setAmount(this .amount);
239: line.setBalanceTypeCode(this .balanceTypeCode);
240: line.setChartOfAccountsCode(this .chartOfAccountsCode);
241: line.setDebitCreditCode(this .debitCreditCode);
242: line.setEncumbranceUpdateCode(this .encumbranceUpdateCode);
243: line.setFinancialObjectCode(this .financialObjectCode);
244: line.setFinancialSubObjectCode(this .financialSubObjectCode);
245: line.setObjectTypeCode(this .objectTypeCode);
246: line.setOrganizationReferenceId(this .organizationReferenceId);
247: line.setProjectCode(this .projectCode);
248: line.setReferenceOriginCode(this .referenceOriginCode);
249: line.setReferenceNumber(this .referenceNumber);
250: line.setReferenceTypeCode(this .referenceTypeCode);
251: line.setSubAccountNumber(this .subAccountNumber);
252:
253: return line;
254: }
255:
256: public SourceAccountingLine createSourceAccountingLine()
257: throws InstantiationException, IllegalAccessException {
258: return createAccountingLine(SourceAccountingLine.class);
259: }
260:
261: public TargetAccountingLine createTargetAccountingLine()
262: throws InstantiationException, IllegalAccessException {
263: return createAccountingLine(TargetAccountingLine.class);
264: }
265:
266: public void addAsSourceTo(AccountingDocument document)
267: throws IllegalAccessException, InstantiationException {
268: document.addSourceAccountingLine(createAccountingLine(
269: SourceAccountingLine.class, document
270: .getDocumentNumber(),
271: document.getPostingYear(), document
272: .getNextSourceLineNumber()));
273: }
274:
275: public void addAsTargetTo(AccountingDocument document)
276: throws IllegalAccessException, InstantiationException {
277: document.addTargetAccountingLine(createAccountingLine(
278: TargetAccountingLine.class, document
279: .getDocumentNumber(),
280: document.getPostingYear(), document
281: .getNextTargetLineNumber()));
282: }
283: }
|