001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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
017 package org.kuali.kfs.fp.document;
018
019 import static org.kuali.kfs.fp.document.validation.impl.TransferOfFundsDocumentRuleConstants.YEAR_END_TRANSFER_OF_FUNDS_DOC_TYPE_CODE;
020
021 import org.kuali.kfs.fp.document.service.YearEndPendingEntryService;
022 import org.kuali.kfs.sys.businessobject.AccountingLine;
023 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
024 import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
025 import org.kuali.kfs.sys.context.SpringContext;
026 import org.kuali.kfs.sys.document.AccountingDocument;
027 import org.kuali.kfs.sys.service.UniversityDateService;
028
029
030 /**
031 * Year End version of the <code>BudgetAdjustmentDocument</code>
032 */
033 public class YearEndBudgetAdjustmentDocument extends BudgetAdjustmentDocument implements YearEndDocument {
034
035 /**
036 * Constructs a YearEndBudgetAdjustmentDocument.
037 */
038 public YearEndBudgetAdjustmentDocument() {
039 super();
040 }
041
042 /**
043 * set posting year to previous fiscal year
044 */
045 public void initiateDocument() {
046 Integer previousYearParam = new Integer(SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear().intValue() - 1);
047 setPostingYear(previousYearParam);
048 }
049
050 /**
051 * This method calls the super class's overridden method to perform the general customization actions, then calls the
052 * YearEndDocumentUtil matching method to perform year end specific customization activities.
053 *
054 * @param accountingDocument The accounting document containing the general ledger pending entries being customized.
055 * @param accountingLine The accounting line the explicit general ledger pending entry was generated from.
056 * @param explicitEntry The explicit general ledger pending entry to be customized.
057 *
058 * @see org.kuali.kfs.fp.document.validation.impl.BudgetAdjustmentDocumentRule#customizeExplicitGeneralLedgerPendingEntry(org.kuali.rice.kns.document.AccountingDocument,
059 * org.kuali.rice.kns.bo.AccountingLine, org.kuali.module.gl.bo.GeneralLedgerPendingEntry)
060 * @see YearEndDocumentUtil#customizeExplicitGeneralLedgerPendingEntry(TransactionalDocument, AccountingLine,
061 * GeneralLedgerPendingEntry)
062 */
063 @Override
064 public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) {
065 super.customizeExplicitGeneralLedgerPendingEntry(postable, explicitEntry);
066 AccountingLine accountingLine = (AccountingLine)postable;
067 SpringContext.getBean(YearEndPendingEntryService.class).customizeExplicitGeneralLedgerPendingEntry(this, accountingLine, explicitEntry);
068 }
069
070 /**
071 * Overridden to populate object code from last year's offset definition
072 * @see org.kuali.kfs.sys.document.AccountingDocumentBase#customizeOffsetGeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)
073 */
074 @Override
075 public boolean customizeOffsetGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail accountingLine, GeneralLedgerPendingEntry explicitEntry, GeneralLedgerPendingEntry offsetEntry) {
076 boolean success = super.customizeOffsetGeneralLedgerPendingEntry(accountingLine, explicitEntry, offsetEntry);
077 success &= SpringContext.getBean(YearEndPendingEntryService.class).customizeOffsetGeneralLedgerPendingEntry(this, accountingLine, explicitEntry, offsetEntry);
078 return success;
079 }
080
081 /**
082 * This method retrieves the year end transfer of funds document type code, which is defined as a constant in
083 * TransferOfFundsDocumentRuleConstants.
084 *
085 * @return The value defined in the constants class for year end transfer of funds document type code.
086 *
087 * @see org.kuali.kfs.fp.document.validation.impl.BudgetAdjustmentDocumentRule#getTransferDocumentType()
088 * @see org.kuali.kfs.fp.document.validation.impl.TransferOfFundsDocumentRuleConstants#YEAR_END_TRANSFER_OF_FUNDS_DOC_TYPE_CODE
089 */
090 @Override
091 protected String getTransferDocumentType() {
092 return YEAR_END_TRANSFER_OF_FUNDS_DOC_TYPE_CODE;
093 }
094
095 @Override
096 public Class<? extends AccountingDocument> getDocumentClassForAccountingLineValueAllowedValidation() {
097 return BudgetAdjustmentDocument.class;
098 }
099 }