1 /* 2 * Copyright 2006 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 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.ole.fp.document; 18 19 import static org.kuali.ole.fp.document.validation.impl.TransferOfFundsDocumentRuleConstants.YEAR_END_TRANSFER_OF_FUNDS_DOC_TYPE_CODE; 20 21 import org.kuali.ole.fp.document.service.YearEndPendingEntryService; 22 import org.kuali.ole.sys.businessobject.AccountingLine; 23 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry; 24 import org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail; 25 import org.kuali.ole.sys.context.SpringContext; 26 import org.kuali.ole.sys.document.OLEAccountingDocument; 27 import org.kuali.ole.sys.service.UniversityDateService; 28 29 30 /** 31 * Year End version of the <code>BudgetAdjustmentDocument</code> 32 */ 33 public class YearEndBudgetAdjustmentDocument extends BudgetAdjustmentDocument implements YearEndDocument { 34 35 /** 36 * Constructs a YearEndBudgetAdjustmentDocument. 37 */ 38 public YearEndBudgetAdjustmentDocument() { 39 super(); 40 } 41 42 /** 43 * set posting year to previous fiscal year 44 */ 45 public void initiateDocument() { 46 Integer previousYearParam = new Integer(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().intValue() - 1); 47 setPostingYear(previousYearParam); 48 } 49 50 /** 51 * This method calls the super class's overridden method to perform the general customization actions, then calls the 52 * YearEndDocumentUtil matching method to perform year end specific customization activities. 53 * 54 * @param accountingDocument The accounting document containing the general ledger pending entries being customized. 55 * @param accountingLine The accounting line the explicit general ledger pending entry was generated from. 56 * @param explicitEntry The explicit general ledger pending entry to be customized. 57 * 58 * @see org.kuali.ole.fp.document.validation.impl.BudgetAdjustmentDocumentRule#customizeExplicitGeneralLedgerPendingEntry(org.kuali.rice.krad.document.AccountingDocument, 59 * org.kuali.rice.krad.bo.AccountingLine, org.kuali.module.gl.bo.GeneralLedgerPendingEntry) 60 * @see YearEndDocumentUtil#customizeExplicitGeneralLedgerPendingEntry(TransactionalDocument, AccountingLine, 61 * GeneralLedgerPendingEntry) 62 */ 63 @Override 64 public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) { 65 super.customizeExplicitGeneralLedgerPendingEntry(postable, explicitEntry); 66 AccountingLine accountingLine = (AccountingLine)postable; 67 SpringContext.getBean(YearEndPendingEntryService.class).customizeExplicitGeneralLedgerPendingEntry(this, accountingLine, explicitEntry); 68 } 69 70 /** 71 * Overridden to populate object code from last year's offset definition 72 * @see org.kuali.ole.sys.document.AccountingDocumentBase#customizeOffsetGeneralLedgerPendingEntry(org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntrySourceDetail, org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry, org.kuali.ole.sys.businessobject.GeneralLedgerPendingEntry) 73 */ 74 @Override 75 public boolean customizeOffsetGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail accountingLine, GeneralLedgerPendingEntry explicitEntry, GeneralLedgerPendingEntry offsetEntry) { 76 boolean success = super.customizeOffsetGeneralLedgerPendingEntry(accountingLine, explicitEntry, offsetEntry); 77 success &= SpringContext.getBean(YearEndPendingEntryService.class).customizeOffsetGeneralLedgerPendingEntry(this, accountingLine, explicitEntry, offsetEntry); 78 return success; 79 } 80 81 /** 82 * This method retrieves the year end transfer of funds document type code, which is defined as a constant in 83 * TransferOfFundsDocumentRuleConstants. 84 * 85 * @return The value defined in the constants class for year end transfer of funds document type code. 86 * 87 * @see org.kuali.ole.fp.document.validation.impl.BudgetAdjustmentDocumentRule#getTransferDocumentType() 88 * @see org.kuali.ole.fp.document.validation.impl.TransferOfFundsDocumentRuleConstants#YEAR_END_TRANSFER_OF_FUNDS_DOC_TYPE_CODE 89 */ 90 @Override 91 protected String getTransferDocumentType() { 92 return YEAR_END_TRANSFER_OF_FUNDS_DOC_TYPE_CODE; 93 } 94 95 @Override 96 public Class<? extends OLEAccountingDocument> getDocumentClassForAccountingLineValueAllowedValidation() { 97 return BudgetAdjustmentDocument.class; 98 } 99 }