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    package org.kuali.kfs.sys.document;
017    
018    import java.util.List;
019    
020    import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
021    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
022    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper;
023    import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
024    import org.kuali.rice.kns.util.KualiDecimal;
025    
026    /**
027     * A collection of methods needed by anything - document or otherwise - that plans to generate
028     * General Ledger pending entries.
029     */
030    public interface GeneralLedgerPendingEntrySource {
031        
032        /**
033         * Creates any GeneralLedgerPostingEntry's that are based on a document, not those based on GeneralLedgerPendingEntrySourceDetail entries 
034         * @param sequenceHelper a sequence helper for the method to create more general ledger pending entries
035         * @return true if the pending entries were able to be successfully created and added to this GeneralLedgerPendingEntrySource; false if an error condition occurred with mean that GLPEs were not correctly generated
036         */
037        public boolean generateDocumentGeneralLedgerPendingEntries(GeneralLedgerPendingEntrySequenceHelper sequenceHelper);
038    
039        /**
040         * @return the fiscal year when this "helper" was posted
041         */
042        public Integer getPostingYear();
043        
044        /**
045         * This method determines if the passed in GeneralLedgerPendingEntrySourceDetail is a debit or not.
046         * @param postable
047         * @return true if the given GeneralLedgerPendingEntrySourceDetail is a debit, false if it is a credit
048         */
049        public boolean isDebit(GeneralLedgerPendingEntrySourceDetail postable);
050        
051        /**
052         * Returns a document header associated with this general ledger posting helper
053         * @return a document header, having information which should be put into the generated GeneralLedgerPendingEntry records
054         */
055        public FinancialSystemDocumentHeader getDocumentHeader();
056        
057        /**
058         * Requests that the posting helper removes any general ledger pending entries it might be holding, so that new ones can be generated
059         */
060        public void clearAnyGeneralLedgerPendingEntries();
061        
062        /**
063         * Returns a list of any GeneralLedgerPostables this helper has, to create GeneralLedgerPendingEntries
064         * @return a list of GeneralLedgerPostables
065         */
066        public List<GeneralLedgerPendingEntrySourceDetail> getGeneralLedgerPendingEntrySourceDetails();
067            
068        /**
069         * Adds an UNSAVED general ledger pending entry to the GeneralLedgerPendingEntrySource, which the GLPESource can do with as it pleases
070         * @param entry the completed entry to give back to the helper to handle
071         */
072        public void addPendingEntry(GeneralLedgerPendingEntry entry);
073        
074        /**
075         * A method to determine what the actual amount, based off of a GeneralLedgerPendingEntrySourceDetail, should be for the resultant GeneralLedgerPendingEntry
076         * @param glpeSourceDetail the detail line from the general ledger pending entry source to find an amount for
077         * @return The amount that will be used to populate the amount on the generated general ledger pending entry for the given source detail
078         */
079        public KualiDecimal getGeneralLedgerPendingEntryAmountForDetail(GeneralLedgerPendingEntrySourceDetail glpeSourceDetail);
080        
081        /**
082         * This method returns the financial document type code. It's required to return the appropriate financial document type code only if poster class is not assignable from  org.kuali.rice.kns.document.
083         * @return the document type code
084         */
085        public String getFinancialDocumentTypeCode();
086        
087        /**
088         * Generates any number of general ledger pending entries from a given general ledger pending entry source detail and adds them to this general ledger pending entry source
089         * @param glpeSourceDetail the source detail line to generate general ledger pending entries for 
090         * @param sequenceHelper the sequence helper which will assign sequence number to generated general ledger pending entries
091         * @return true if general ledger pending entry generation was successful; false if an error condition prevented the successful generation of the pending entries
092         */
093        public boolean generateGeneralLedgerPendingEntries(GeneralLedgerPendingEntrySourceDetail glpeSourceDetail, GeneralLedgerPendingEntrySequenceHelper sequenceHelper);
094    
095    }