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.module.ar.document.service;
017    
018    import java.util.List;
019    
020    import org.kuali.kfs.module.ar.businessobject.CashControlDetail;
021    import org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail;
022    import org.kuali.kfs.module.ar.businessobject.InvoicePaidApplied;
023    import org.kuali.kfs.module.ar.document.CashControlDocument;
024    import org.kuali.kfs.module.ar.document.CustomerInvoiceDocument;
025    import org.kuali.kfs.module.ar.document.PaymentApplicationDocument;
026    import org.kuali.rice.kew.exception.WorkflowException;
027    
028    public interface PaymentApplicationDocumentService {
029        
030        /**
031         * 
032         * Retrieves the CashControlDetail line associated with the passed-in PaymentApplication Document.
033         * 
034         * @param document A valid PaymentApplication Document
035         * @return The associated CashControlDetail, if exists, or null if not.
036         */
037        public CashControlDetail getCashControlDetailForPaymentApplicationDocument(PaymentApplicationDocument document);
038        
039        /**
040         * 
041         * Retrieves the CashControlDetail line associated with the passed-in PaymentApplication Document number.
042         * 
043         * @param payAppDocNumber A valid PaymentApplication Document Number
044         * @return The associated CashControlDetail, if exists, or null if not.
045         */
046        public CashControlDetail getCashControlDetailForPayAppDocNumber(String payAppDocNumber);
047        
048        /**
049         * 
050         * Retrieves the CashControlDocument associated with the passed-in PaymentApplication Document.
051         * 
052         * @param document A valid PaymentApplication Document
053         * @return The associated CashControlDocument, if exists, or null if not.
054         */
055        public CashControlDocument getCashControlDocumentForPaymentApplicationDocument(PaymentApplicationDocument document);
056        
057        /**
058         * 
059         * Retrieves the CashControlDocument associated with the passed-in PaymentApplication Document number.
060         * @param payAppDocNumber A valid PaymentApplication Document number
061         * @return The associated CashControlDocument, if exists, or null if not.
062         */
063        public CashControlDocument getCashControlDocumentForPayAppDocNumber(String payAppDocNumber);
064        
065        /**
066         * 
067         * Creates PaidApplieds for all the invoice lines on the passed in InvoiceDocument, on the passed in 
068         * PaymentApplicationDocument.
069         * 
070         * This method will overwrite any existing PaidApplieds on the document, it assumes an empty 
071         * PayApp doc with no paidapplieds.
072         * 
073         * This method does no checking to prevent over or under applying, it assumes that the documents have 
074         * been setup such that it will work correctly.  So if this method is used to over or under apply, then 
075         * the resulting PaymentApplicationDocument will fail business rules validation.
076         * 
077         * @param customerInvoiceDocument
078         * @param paymentApplicationDocument
079         * @return
080         */
081        public PaymentApplicationDocument createInvoicePaidAppliedsForEntireInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument, PaymentApplicationDocument paymentApplicationDocument);
082        
083        /**
084         * This method creates an invoice paid applied for the given customer invoice detail. 
085         * 
086         * This method assumes that no existing paidApplieds are already on the document.
087         * 
088         * @param customerInvoiceDetail the customer invoice detail for which we want to create the invoice paid applied
089         * @param applicationDocNbr the payment application document number
090         * @param universityFiscalYear the university fiscal year
091         * @param universityFiscalPeriodCode the university fiscal period code
092         * @param amount the amount to be applied
093         * @return the created invoice paid applied if it did not exist, null otherwise
094         */
095        public InvoicePaidApplied createInvoicePaidAppliedForInvoiceDetail(CustomerInvoiceDetail customerInvoiceDetail, PaymentApplicationDocument paymentApplicationDocument, Integer paidAppliedItemNumber);
096        
097        /**
098         * This method is used in the lockbox process to create a PA document which is then auto-approved when the amount on the invoice matches 
099         * the amount on the lockbox.
100         * 
101         * @param customerInvoiceDocument
102         * @return
103         */
104        public PaymentApplicationDocument createPaymentApplicationToMatchInvoice(CustomerInvoiceDocument customerInvoiceDocument) throws WorkflowException;
105    
106        public PaymentApplicationDocument createSaveAndApprovePaymentApplicationToMatchInvoice(CustomerInvoiceDocument customerInvoiceDocument, String approvalAnnotation, List workflowNotificationRecipients) throws WorkflowException;
107        public PaymentApplicationDocument createAndSavePaymentApplicationToMatchInvoice(CustomerInvoiceDocument customerInvoiceDocument) throws WorkflowException;
108        
109        /**
110         * This method returns true if invoicePaidApplied is the applied payment for 
111         * the customer invoice detail based on document number and item/sequence number.
112         * 
113         * @param customerInvoiceDetail
114         * @param invoicePaidApplied
115         * @return
116         */
117        public boolean customerInvoiceDetailPairsWithInvoicePaidApplied(CustomerInvoiceDetail customerInvoiceDetail, InvoicePaidApplied invoicePaidApplied);
118        
119    }