01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.kuali.module.financial.document;
18:
19: import org.kuali.core.document.TransactionalDocument;
20: import org.kuali.kfs.bo.AccountingLine;
21: import org.kuali.kfs.bo.GeneralLedgerPendingEntry;
22: import org.kuali.kfs.context.SpringContext;
23: import org.kuali.module.financial.service.UniversityDateService;
24:
25: /**
26: * utils for <code>YearEndDocument</code>s
27: *
28: * @see org.kuali.module.gl.service.SufficientFundsService
29: */
30: public class YearEndDocumentUtil {
31: private static final String FINAL_ACCOUNTING_PERIOD = "13";
32:
33: /**
34: * @return the previous fiscal year used with all GLPE
35: */
36: public static final Integer getPreviousFiscalYear() {
37: int i = SpringContext.getBean(UniversityDateService.class)
38: .getCurrentFiscalYear().intValue() - 1;
39: return new Integer(i);
40: }
41:
42: /**
43: * @return the accounting period code used with all GLPE
44: */
45: public static final String getFinalAccountingPeriod() {
46: return FINAL_ACCOUNTING_PERIOD;
47: }
48:
49: /**
50: * populates a <code>GeneralLedgerPendingEntry</code> populated with common year end document data into the explicit general
51: * ledger pending entry. currently is the following:
52: * <ol>
53: * <li>fiscal period code = final accounting period code
54: * <li>fiscal year= previous fiscal year
55: * </ol>
56: *
57: * @param transactionalDocument
58: * @param accountingLine
59: * @param explicitEntry
60: */
61: public static final void customizeExplicitGeneralLedgerPendingEntry(
62: TransactionalDocument transactionalDocument,
63: AccountingLine accountingLine,
64: GeneralLedgerPendingEntry explicitEntry) {
65: if (!YearEndDocument.class
66: .isAssignableFrom(transactionalDocument.getClass())) {
67: throw new IllegalArgumentException(
68: "invalid (not a year end document) for class:"
69: + transactionalDocument.getClass());
70: }
71: YearEndDocument yearEndDocument = (YearEndDocument) transactionalDocument;
72: explicitEntry
73: .setUniversityFiscalPeriodCode(getFinalAccountingPeriod());
74: explicitEntry.setUniversityFiscalYear(getPreviousFiscalYear());
75: }
76:
77: /**
78: * Gets the FINAL_ACCOUNTING_PERIOD attribute.
79: *
80: * @return Returns the FINAL_ACCOUNTING_PERIOD.
81: */
82: public static String getFINAL_ACCOUNTING_PERIOD() {
83: return FINAL_ACCOUNTING_PERIOD;
84: }
85: }
|