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.Collection;
019    import java.util.List;
020    
021    import org.kuali.kfs.module.ar.businessobject.Customer;
022    import org.kuali.kfs.module.ar.businessobject.CustomerInvoiceDetail;
023    import org.kuali.kfs.module.ar.businessobject.NonInvoicedDistribution;
024    import org.kuali.kfs.module.ar.document.CustomerInvoiceDocument;
025    import org.kuali.rice.kns.util.KualiDecimal;
026    
027    public interface CustomerInvoiceDocumentService {
028    
029        /**
030         * Converts discount lines on the customer invoice document to paidapplieds. This method is only intended to be used once the
031         * document is at least in the Processed state, and will throw an error if used on a document in an earlier state. This method
032         * is intended to be called from the CustomerInvoiceDocument.handleRouteStatusChange
033         * 
034         * @param invoice A populated Invoice document that is at least PROCESSED.
035         */
036        public void convertDiscountsToPaidApplieds(CustomerInvoiceDocument invoice);
037    
038        /**
039         * Retrieves all invoice documents that are Open with outstanding balances, including workflow headers.
040         * 
041         * @return A collection of CustomerInvoiceDocument documents, or an empty list of no matches.
042         */
043        public Collection<CustomerInvoiceDocument> getAllOpenCustomerInvoiceDocuments();
044    
045        /**
046         * Retrieves all invoice documents that are Open with outstanding balances. Will NOT retrieve workflow headers, so results of
047         * this are not suitable for using to route, save, or otherwise perform workflow operations upon.
048         * 
049         * @return
050         */
051        public Collection<CustomerInvoiceDocument> getAllOpenCustomerInvoiceDocumentsWithoutWorkflow();
052    
053        /**
054         * Gets invoices without workflow headers, retrieves the workflow headers and returns invoices with workflow headers.
055         * 
056         * @return
057         */
058        public Collection<CustomerInvoiceDocument> attachWorkflowHeadersToTheInvoices(Collection<CustomerInvoiceDocument> invoices);
059    
060        /**
061         * Retrieves all Open Invoices for this given Customer Number. IMPORTANT - Workflow headers and status are not retrieved by this
062         * method, only the raw Customer Invoice Document from the Database. If you need a full workflow document, you can do use
063         * DocumentService to retrieve each by document number.
064         * 
065         * @param customerNumber
066         * @return
067         */
068        public Collection<CustomerInvoiceDocument> getOpenInvoiceDocumentsByCustomerNumber(String customerNumber);
069    
070        /**
071         * Retrieves all Open Invoices for the given Customer Name and Customer Type Code Note that the customerName field is turned
072         * into a 'LIKE customerName*' query. IMPORTANT - Workflow headers and status are not retrieved by this method, only the raw
073         * Customer Invoice Document from the Database. If you need a full workflow document, you can do use DocumentService to retrieve
074         * each by document number.
075         * 
076         * @param customerName
077         * @param customerTypeCode
078         * @return
079         */
080        public Collection getOpenInvoiceDocumentsByCustomerNameByCustomerType(String customerName, String customerTypeCode);
081    
082        /**
083         * Retrieves all Open Invoices for the given Customer Name. Note that this is a leading substring search, so whatever is entered
084         * into the customerName field is turned into a 'LIKE customerName*' query. IMPORTANT - Workflow headers and status are not
085         * retrieved by this method, only the raw Customer Invoice Document from the Database. If you need a full workflow document, you
086         * can do use DocumentService to retrieve each by document number.
087         * 
088         * @param customerName
089         * @return
090         */
091        public Collection<CustomerInvoiceDocument> getOpenInvoiceDocumentsByCustomerName(String customerName);
092    
093        /**
094         * Retrieves all Open Invoices for the given Customer Type Code. IMPORTANT - Workflow headers and status are not retrieved by
095         * this method, only the raw Customer Invoice Document from the Database. If you need a full workflow document, you can do use
096         * DocumentService to retrieve each by document number.
097         * 
098         * @param customerTypeCode
099         * @return
100         */
101        public Collection<CustomerInvoiceDocument> getOpenInvoiceDocumentsByCustomerType(String customerTypeCode);
102    
103        /**
104         * This method sets up default values for customer invoice document on initiation.
105         * 
106         * @param document
107         */
108        public void setupDefaultValuesForNewCustomerInvoiceDocument(CustomerInvoiceDocument document);
109    
110        /**
111         * This method sets up default values for customer invoice document when copied.
112         * 
113         * @param customerInvoiceDocument
114         */
115        public void setupDefaultValuesForCopiedCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument);
116    
117        /**
118         * If the customer number and address identifiers are present, display customer information
119         */
120        public void loadCustomerAddressesForCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument);
121    
122        /**
123         * @param customerNumber
124         * @return
125         */
126        public Collection<CustomerInvoiceDocument> getCustomerInvoiceDocumentsByCustomerNumber(String customerNumber);
127    
128        /**
129         * @param customerInvoiceDocumentNumber
130         * @return
131         */
132        public Collection<CustomerInvoiceDetail> getCustomerInvoiceDetailsForCustomerInvoiceDocument(String customerInvoiceDocumentNumber);
133    
134        /**
135         * @param customerInvoiceDocument
136         * @return
137         */
138        public Collection<CustomerInvoiceDetail> getCustomerInvoiceDetailsForCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument);
139    
140    
141        /**
142         * Cached for better performance
143         * 
144         * @param customerInvoiceDocument
145         * @return
146         */
147        public Collection<CustomerInvoiceDetail> getCustomerInvoiceDetailsForCustomerInvoiceDocumentWithCaching(CustomerInvoiceDocument customerInvoiceDocument);
148    
149        /**
150         * @param invoiceNumber
151         * @return
152         */
153        public Customer getCustomerByOrganizationInvoiceNumber(String invoiceNumber);
154    
155        /**
156         * @param organizationInvoiceNumber
157         * @return
158         */
159        public CustomerInvoiceDocument getInvoiceByOrganizationInvoiceNumber(String organizationInvoiceNumber);
160    
161        /**
162         * @param documentNumber
163         * @return
164         */
165        public Customer getCustomerByInvoiceDocumentNumber(String documentNumber);
166    
167        /**
168         * @param invoiceDocumentNumber
169         * @return
170         */
171        public CustomerInvoiceDocument getInvoiceByInvoiceDocumentNumber(String invoiceDocumentNumber);
172    
173        public List<CustomerInvoiceDocument> getPrintableCustomerInvoiceDocumentsByInitiatorPrincipalName(String initiatorPrincipalName);
174    
175        public List<CustomerInvoiceDocument> getPrintableCustomerInvoiceDocumentsByBillingChartAndOrg(String chartOfAccountsCode, String organizationCode);
176    
177        public List<CustomerInvoiceDocument> getPrintableCustomerInvoiceDocumentsForBillingStatementByBillingChartAndOrg(String chartOfAccountsCode, String organizationCode);
178        
179        public List<CustomerInvoiceDocument> getPrintableCustomerInvoiceDocumentsByProcessingChartAndOrg(String chartOfAccountsCode, String organizationCode);
180    
181        public List<CustomerInvoiceDocument> getCustomerInvoiceDocumentsByBillingChartAndOrg(String chartOfAccountsCode, String organizationCode);
182    
183        public List<CustomerInvoiceDocument> getCustomerInvoiceDocumentsByProcessingChartAndOrg(String chartOfAccountsCode, String organizationCode);
184    
185        public Collection<CustomerInvoiceDocument> getCustomerInvoiceDocumentsByAccountNumber(String accountNumber);
186    
187        /**
188         * @param documentNumber
189         * @return
190         */
191        // public Collection<InvoicePaidApplied> getInvoicePaidAppliedsForInvoice(String documentNumber);
192        /**
193         * @param documentNumber
194         * @return
195         */
196        public Collection<NonInvoicedDistribution> getNonInvoicedDistributionsForInvoice(String documentNumber);
197    
198        /**
199         * @param documentNumber
200         * @return
201         */
202        public KualiDecimal getNonInvoicedTotalForInvoice(String documentNumber);
203    
204        /**
205         * @param invoice
206         * @return
207         */
208        public KualiDecimal getNonInvoicedTotalForInvoice(CustomerInvoiceDocument invoice);
209    
210        /**
211         * @param documentNumber
212         * @return
213         */
214        public KualiDecimal getPaidAppliedTotalForInvoice(String documentNumber);
215    
216        /**
217         * @param invoice
218         * @return
219         */
220        public KualiDecimal getPaidAppliedTotalForInvoice(CustomerInvoiceDocument invoice);
221    
222        /**
223         * This method updates the open invoice indicator if amounts have been completely paid off
224         * 
225         * @param invoice
226         */
227        public void closeCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument);
228    
229        /**
230         * This method...
231         * 
232         * @param customerInvoiceDocumentNumber
233         * @return
234         */
235        public KualiDecimal getOpenAmountForCustomerInvoiceDocument(String customerInvoiceDocumentNumber);
236    
237    
238        /**
239         * This method...
240         * 
241         * @param customerInvoiceDocumentNumber
242         * @return
243         */
244        public KualiDecimal getOpenAmountForCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument);
245    
246        public KualiDecimal getOriginalTotalAmountForCustomerInvoiceDocument(CustomerInvoiceDocument customerInvoiceDocument);
247    
248        public boolean checkIfInvoiceNumberIsFinal(String invDocumentNumber);
249    }