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 org.kuali.kfs.fp.document.service.YearEndPendingEntryService;
020    import org.kuali.kfs.sys.businessobject.AccountingLine;
021    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
022    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
023    import org.kuali.kfs.sys.context.SpringContext;
024    import org.kuali.kfs.sys.document.AccountingDocument;
025    import org.kuali.kfs.sys.document.AmountTotaling;
026    
027    
028    /**
029     * Year End version of the <code>TransferOfFundsDocument</code> functionally the only difference is the accounting period code
030     * used on the glpe entries
031     */
032    public class YearEndTransferOfFundsDocument extends TransferOfFundsDocument implements YearEndDocument, AmountTotaling {
033    
034        /**
035         * Constructs a YearEndTransferOfFundsDocument.java.
036         */
037        public YearEndTransferOfFundsDocument() {
038            super();
039        }
040        
041        /**
042         * This method calls the super class's overridden method to perform the general customization actions, then calls the 
043         * YearEndDocumentUtil matching method to perform year end specific customization activities.
044         * 
045         * @param accountingDocument The accounting document containing the general ledger pending entries being customized.
046         * @param accountingLine The accounting line the explicit general ledger pending entry was generated from.
047         * @param explicitEntry The explicit general ledger pending entry to be customized.
048         * 
049         * @see org.kuali.kfs.fp.document.validation.impl.TransferOfFundsDocumentRule#customizeExplicitGeneralLedgerPendingEntry(org.kuali.kfs.sys.document.AccountingDocument,
050         *      org.kuali.kfs.sys.businessobject.AccountingLine, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)
051         * @see YearEndDocumentUtil#customizeExplicitGeneralLedgerPendingEntry(TransactionalDocument, AccountingLine,
052         *      GeneralLedgerPendingEntry)
053         */
054        @Override
055        public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) {
056            super.customizeExplicitGeneralLedgerPendingEntry(postable, explicitEntry);
057            AccountingLine accountingLine = (AccountingLine)postable;
058            SpringContext.getBean(YearEndPendingEntryService.class).customizeExplicitGeneralLedgerPendingEntry(this, accountingLine, explicitEntry);
059        }
060    
061        /**
062         * Overridden to populate object code from last year's offset definition
063         * @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)
064         */
065        @Override
066        public boolean customizeOffsetGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail accountingLine, GeneralLedgerPendingEntry explicitEntry, GeneralLedgerPendingEntry offsetEntry) {
067            boolean success = super.customizeOffsetGeneralLedgerPendingEntry(accountingLine, explicitEntry, offsetEntry);
068            success &= SpringContext.getBean(YearEndPendingEntryService.class).customizeOffsetGeneralLedgerPendingEntry(this, accountingLine, explicitEntry, offsetEntry);
069            return success;
070        }
071        
072        @Override
073        public Class<? extends AccountingDocument> getDocumentClassForAccountingLineValueAllowedValidation() {
074            return TransferOfFundsDocument.class;
075        }
076    }