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 java.util.ArrayList;
020    
021    import org.kuali.kfs.fp.businessobject.CapitalAssetInformation;
022    import org.kuali.kfs.fp.document.service.YearEndPendingEntryService;
023    import org.kuali.kfs.integration.cam.CapitalAssetManagementModuleService;
024    import org.kuali.kfs.sys.KFSConstants;
025    import org.kuali.kfs.sys.businessobject.AccountingLine;
026    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
027    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
028    import org.kuali.kfs.sys.context.SpringContext;
029    import org.kuali.kfs.sys.document.AccountingDocument;
030    import org.kuali.kfs.sys.document.AmountTotaling;
031    import org.kuali.kfs.sys.document.ElectronicPaymentClaiming;
032    import org.kuali.rice.kns.exception.ValidationException;
033    import org.kuali.rice.kns.rule.event.KualiDocumentEvent;
034    import org.kuali.rice.kns.rule.event.SaveDocumentEvent;
035    import org.kuali.rice.kns.util.ObjectUtils;
036    
037    
038    /**
039     * Year End version of the <code>DistributionOfIncomeAndExpenseDocument</code> the only functional difference between the YearEnd
040     * version and the non-yearEnd version of a document is the glpe's generation.
041     */
042    public class YearEndDistributionOfIncomeAndExpenseDocument extends DistributionOfIncomeAndExpenseDocument implements YearEndDocument, AmountTotaling, ElectronicPaymentClaiming, CapitalAssetEditable {
043        /**
044         * Constructs a YearEndDistributionOfIncomeAndExpenseDocument.java.
045         */
046        public YearEndDistributionOfIncomeAndExpenseDocument() {
047            super();
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.module.financial.rules.DistributeOfIncomeAndExpenseDocumentRule#customizeExplicitGeneralLedgerPendingEntry(org.kuali.kfs.sys.document.AccountingDocument,
059         *      org.kuali.kfs.sys.businessobject.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        @Override
082        public Class<? extends AccountingDocument> getDocumentClassForAccountingLineValueAllowedValidation() {
083            return DistributionOfIncomeAndExpenseDocument.class;
084        }
085    }