/*
 * Copyright 2008 The Kuali Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kuali.kfs.sys.document;

import java.util.List;

import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry;
import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper;
import org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySourceDetail;
import org.kuali.rice.kns.util.KualiDecimal;

/**
 * A collection of methods needed by anything - document or otherwise - that plans to generate
 * General Ledger pending entries.
 */
public interface GeneralLedgerPendingEntrySource {
    /**
     * Creates any GeneralLedgerPostingEntry's that are based on a document, not those based on GeneralLedgerPendingEntrySourceDetail entries 
     * @param sequenceHelper a sequence helper for the method to create more general ledger pending entries
     */
    public boolean generateDocumentGeneralLedgerPendingEntries(GeneralLedgerPendingEntrySequenceHelper sequenceHelper);

    /**
     * @return the fiscal year when this "helper" was posted
     */
    public Integer getPostingYear();
    
    /**
     * This method determines if the passed in GeneralLedgerPendingEntrySourceDetail is a debit or not.
     * 
     * @param postable
     * @return true if the given GeneralLedgerPendingEntrySourceDetail is a debit, false if it is a credit
     */
    public boolean isDebit(GeneralLedgerPendingEntrySourceDetail postable);
    
    /**
     * Returns a document header associated with this general ledger posting helper
     * @return a document header
     */
    public FinancialSystemDocumentHeader getDocumentHeader();
    
    /**
     * Requests that the posting helper removes any general ledger pending entries it might be holding, so that new ones can be generated
     */
    public void clearAnyGeneralLedgerPendingEntries();
    
    /**
     * Returns a list of any GeneralLedgerPostables this helper has, to create GeneralLedgerPendingEntries
     * @return a list of GeneralLedgerPostables
     */
    public List<GeneralLedgerPendingEntrySourceDetail> getGeneralLedgerPendingEntrySourceDetails();
        
    /**
     * Adds an UNSAVED general ledger pending entry to the GeneralLedgerPendingEntrySource, which the GLPESource can do with as it pleases
     * @param entry the completed entry to give back to the helper to handle
     */
    public void addPendingEntry(GeneralLedgerPendingEntry entry);
    
    /**
     * A method to determine what the actual amount, based off of a GeneralLedgerPendingEntrySourceDetail, should be for the resultant GeneralLedgerPendingEntry
     * 
     * @param accountingLine
     * @return KualiDecimal The amount that will be used to populate the GLPE.
     */
    public KualiDecimal getGeneralLedgerPendingEntryAmountForDetail(GeneralLedgerPendingEntrySourceDetail glpeSourceDetail);
    
    /**
     * 
     * 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.
     * @return
     */
    public String getFinancialDocumentTypeCode();
    
    /**
     * Perform business rules common to all transactional documents when generating general ledger pending entries.
     * 
     * @see org.kuali.rice.kns.rule.GenerateGeneralLedgerPendingEntriesRule#processGenerateGeneralLedgerPendingEntries(org.kuali.rice.kns.document.AccountingDocument,
     *      org.kuali.rice.kns.bo.AccountingLine, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)
     */
    public boolean generateGeneralLedgerPendingEntries(GeneralLedgerPendingEntrySourceDetail glpeSourceDetail, GeneralLedgerPendingEntrySequenceHelper sequenceHelper);

}

@@ -1207,24 +1207,29 @@
 ource %7B%0A
+    %0A
     /**%0A
      * C
@@ -1216,24 +1216,24 @@
    %0A    /**%0A
-
      * Creat
@@ -1467,24 +1467,242 @@
 ing entries%0A
+     * @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%0A
      */%0A    
@@ -2049,24 +2049,16 @@
 or not.%0A
-     * %0A
      * @
@@ -2392,16 +2392,109 @@
 t header
+, having information which should be put into the generated GeneralLedgerPendingEntry records
 %0A     */
@@ -3527,24 +3527,16 @@
 ngEntry%0A
-     * %0A
      * @
@@ -3545,22 +3545,107 @@
 ram 
-accountingLine
+glpeSourceDetail the detail line from the general ledger pending entry source to find an amount for
 %0A   
@@ -3656,29 +3656,16 @@
 @return 
-KualiDecimal 
 The amou
@@ -3705,13 +3705,88 @@
 the 
-GLPE.
+amount on the generated general ledger pending entry for the given source detail
 %0A   
@@ -3928,24 +3928,16 @@
     /**%0A
-     * %0A
      * T
@@ -4146,16 +4146,39 @@
  @return
+ the document type code
 %0A     */
@@ -4252,84 +4252,140 @@
   * 
-Perform business rules common to all transactional documents when generating
+Generates any number of general ledger pending entries from a given general ledger pending entry source detail and adds them to this
  gen
@@ -4412,311 +4412,411 @@
 entr
-ies.%0A     * %0A     * @see org.kuali.rice.kns.rule.G
+y source%0A     * @param glpeSourceDetail the source detail line to g
 enerate
-G
+ g
 eneral
-L
+ l
 edger
-P
+ p
 ending
-E
+ e
 ntries
-Rule#processG
+ for %0A     * @param sequenceHelper the sequence helper which will assign sequence number to g
 enerate
-G
+d g
 eneral
-L
+ l
 edger
-P
+ p
 ending
-E
+ e
 ntries
-(org.kuali.rice.kns.document.AccountingDocument,%0A     *      org.kuali.rice.kns.bo.AccountingLine, org.kuali.kfs.sys.businessobject.GeneralLedgerP
+%0A     * @return true if general ledger pending entry generation was successful; false if an error condition prevented the successful generation of the p
 ending
-EntrySequenceHelper)
+ entries
 %0A   

improve the java docs