View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.module.purap.service;
17  
18  import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
19  import org.kuali.ole.module.purap.businessobject.PurApItem;
20  import org.kuali.ole.module.purap.document.InvoiceDocument;
21  import org.kuali.ole.module.purap.document.OlePurchasingAccountsPayableDocument;
22  import org.kuali.ole.module.purap.document.PaymentRequestDocument;
23  import org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocument;
24  import org.kuali.ole.module.purap.util.SummaryAccount;
25  import org.kuali.ole.module.purap.util.UseTaxContainer;
26  import org.kuali.ole.sys.businessobject.SourceAccountingLine;
27  import org.kuali.rice.core.api.util.type.KualiDecimal;
28  
29  import java.util.List;
30  import java.util.Set;
31  
32  /**
33   * This class is used to generate Account Summaries for the Purchasing Accounts Payable Module account lists as well as to generate account lists that can be
34   * used for distribution to below the line items or any other items that may require distribution
35   */
36  public interface PurapAccountingService {
37  
38      /**
39       * unused see other generateAccountDistribution methods
40       *
41       * @param accounts
42       * @param totalAmount
43       * @param percentScale
44       * @return
45       * @deprecated
46       */
47      @Deprecated
48      public List<PurApAccountingLine> generateAccountDistributionForProration(List<SourceAccountingLine> accounts, KualiDecimal totalAmount, Integer percentScale);
49  
50      /**
51       * Determines an appropriate account distribution for a particular Purchasing Accounts Payable list of Accounts.  It does this by looking at the accounts that were provided
52       * which should be generated from a generateSummary method.  It then builds up a list of PurApAccountingLines (specified by the Class variable) and tries to determine the
53       * appropriate percents to use on the new accounts, this may require some moving of percents to the last account as a slush.
54       *
55       * @param accounts     the incoming source accounts from generateSummary
56       * @param totalAmount  the total amount of the document
57       * @param percentScale the scale to round to
58       * @param clazz        the class of the Purchasing Accounts Payable Account
59       * @return a list of new Purchasing Accounts Payable Accounts
60       */
61      public List<PurApAccountingLine> generateAccountDistributionForProration(List<SourceAccountingLine> accounts, KualiDecimal totalAmount, Integer percentScale, Class clazz);
62  
63      /**
64       * Determines an appropriate account distribution for a particular Purchasing Accounts Payable list of Accounts.  It does this by looking at the accounts that were provided
65       * which should be generated from a generateSummary method.  It then builds up a list of PurApAccountingLines (specified by the Class variable) and tries to determine the
66       * appropriate percents to use on the new accounts, this may require some moving of percents to the last account as a slush.  This is called when a document has a zero dollar
67       * total
68       *
69       * @param accounts     the incoming source accounts from generateSummary
70       * @param percentScale the scale to round to
71       * @param clazz        the class of the Purchasing Accounts Payable Account
72       * @return a list of new Purchasing Accounts Payable Accounts
73       */
74      public List<PurApAccountingLine> generateAccountDistributionForProrationWithZeroTotal(PurchasingAccountsPayableDocument purapdoc);
75  
76      /**
77       * This creates summary accounts based on a list of items.
78       *
79       * @param document the document to generate the summary accounts from
80       * @return a list of summary accounts.
81       */
82      public List<SummaryAccount> generateSummaryAccounts(PurchasingAccountsPayableDocument document);
83      public List<SummaryAccount> generateSummaryAccounts(OlePurchasingAccountsPayableDocument document);
84  
85      /**
86       * This creates summary accounts based on a list of items excluding zero totals.
87       *
88       * @param document the document to generate the summary accounts from
89       * @return a list of summary accounts.
90       */
91      public List<SummaryAccount> generateSummaryAccountsWithNoZeroTotals(PurchasingAccountsPayableDocument document);
92  
93  
94      /**
95       * This creates summary accounts based on a list of items excluding zero totals and use tax.
96       *
97       * @param document the document to generate the summary accounts from
98       * @return a list of summary accounts.
99       */
100     public List<SummaryAccount> generateSummaryAccountsWithNoZeroTotalsNoUseTax(PurchasingAccountsPayableDocument document);
101 
102     public List<SummaryAccount> generateSummaryAccountsWithNoZeroTotalsNoUseTax(OlePurchasingAccountsPayableDocument document);
103 
104 
105     /**
106      * Generates an account summary, that is it creates a list of source accounts
107      * by rounding up the Purchasing Accounts Payable accounts off of the Purchasing Accounts Payable items.
108      *
109      * @param document the document to generate the summary from
110      * @return a list of source accounts
111      */
112     public List<SourceAccountingLine> generateSummary(List<PurApItem> items);
113 
114     /**
115      * Generates an account summary with only taxable accounts.
116      *
117      * @param items
118      * @return
119      */
120     public List<SourceAccountingLine> generateSummaryTaxableAccounts(List<PurApItem> items);
121 
122     /**
123      * convenience method that generates a list of source accounts while excluding items with
124      * $0 amounts
125      *
126      * @param items the items to generate source accounts from
127      * @return a list of source accounts "rolled up" from the purap accounts
128      */
129     public List<SourceAccountingLine> generateSummaryWithNoZeroTotals(List<PurApItem> items);
130 
131     /**
132      * convenience method that generates a list of source accounts while excluding items with
133      * $0 amounts and use tax
134      *
135      * @param items the items to generate source accounts from
136      * @return a list of source accounts "rolled up" from the purap accounts
137      */
138     public List<SourceAccountingLine> generateSummaryWithNoZeroTotalsNoUseTax(List<PurApItem> items);
139 
140     /**
141      * convenience method that generates a list of source accounts while excluding items with
142      * $0 amounts and using the alternate amount
143      *
144      * @param items the items to generate source accounts from
145      * @return a list of source accounts "rolled up" from the purap accounts
146      */
147     public List<SourceAccountingLine> generateSummaryWithNoZeroTotalsUsingAlternateAmount(List<PurApItem> items);
148 
149     /**
150      * convenience method that generates a list of source accounts while excluding items with
151      * the specified item types
152      *
153      * @param items                 the items to generate source accounts from
154      * @param excludedItemTypeCodes the item types to exclude
155      * @return a list of source accounts "rolled up" from the purap accounts
156      */
157     public List<SourceAccountingLine> generateSummaryExcludeItemTypes(List<PurApItem> items, Set excludedItemTypeCodes);
158 
159     /**
160      * convenience method that generates a list of source accounts while excluding items with
161      * the specified item types and not including items with zero totals
162      *
163      * @param items                 the items to generate source accounts from
164      * @param excludedItemTypeCodes the item types to exclude
165      * @return a list of source accounts "rolled up" from the purap accounts
166      */
167     public List<SourceAccountingLine> generateSummaryExcludeItemTypesAndNoZeroTotals(List<PurApItem> items, Set excludedItemTypeCodes);
168 
169     /**
170      * convenience method that generates a list of source accounts while only including items with
171      * the specified item types
172      *
173      * @param items                 the items to generate source accounts from
174      * @param excludedItemTypeCodes the item types to include
175      * @return a list of source accounts "rolled up" from the purap accounts
176      */
177     public List<SourceAccountingLine> generateSummaryIncludeItemTypes(List<PurApItem> items, Set includedItemTypeCodes);
178 
179     /**
180      * convenience method that generates a list of source accounts while only including items with
181      * the specified item types and not including items with zero totals
182      *
183      * @param items                 the items to generate source accounts from
184      * @param excludedItemTypeCodes the item types to include
185      * @return a list of source accounts "rolled up" from the purap accounts
186      */
187     public List<SourceAccountingLine> generateSummaryIncludeItemTypesAndNoZeroTotals(List<PurApItem> items, Set includedItemTypeCodes);
188 
189     /**
190      * Updates account amounts based on the percents.  If this is a preq past full entry it updates the
191      * percents based on the amounts instead
192      *
193      * @param document the document
194      */
195     public void updateAccountAmounts(PurchasingAccountsPayableDocument document);
196 
197     public void updateAccountAmounts(OlePurchasingAccountsPayableDocument document);
198 
199     /**
200      * Updates a single items account amounts
201      *
202      * @param item
203      */
204     public void updateItemAccountAmounts(PurApItem item);
205 
206     /**
207      * Updates a single preq item accounts amounts
208      *
209      * @param item
210      */
211     public void updatePreqItemAccountAmounts(PurApItem item);
212 
213     /**
214      * Updates a single preq item accounts amounts
215      *
216      * @param item
217      */
218     public void updatePreqProportionalItemAccountAmounts(PurApItem item);
219 
220     public List<PurApAccountingLine> getAccountsFromItem(PurApItem item);
221 
222     /**
223      * Deletes the ap summary accounts by the id of the doc type (Payment Request - PREQ or Credit Memo - CM)
224      *
225      * @param purapDocumentIdentifier The purapDocumentIdentifier of the document whose summary accounts are to be deleted.
226      */
227     public void deleteSummaryAccounts(Integer purapDocumentIdentifier, String docType);
228 
229     /**
230      * Retrieves the ap summary accounts by the id of the doc type (Payment Request - PREQ or Credit Memo - CM)
231      *
232      * @param purapDocumentIdentifier The purapDocumentIdentifier of the document.
233      */
234     public List getAccountsPayableSummaryAccounts(Integer purapDocumentIdentifier, String docType);
235 
236     /**
237      * This method generates summary accounts for a vendor payment.
238      *
239      * @param document
240      * @return This will get the proper amount on the items that is sent to the vendor
241      */
242     public List<SourceAccountingLine> generateSourceAccountsForVendorRemit(PurchasingAccountsPayableDocument document);
243     public List<SourceAccountingLine> generateSourceAccountsForVendorRemit(OlePurchasingAccountsPayableDocument document);
244 
245     /**
246      * Converts the amount to percent and updates the percent field on the CreditMemoAccount
247      *
248      * @param pr The payment request document containing the accounts whose percentage would be set.
249      */
250     public void convertMoneyToPercent(PaymentRequestDocument pr);
251 
252     /**
253      * Converts the amount to percent and updates the percent field on the CreditMemoAccount
254      *
255      * @param pr The payment request document containing the accounts whose percentage would be set.
256      */
257     public void convertMoneyToPercent(InvoiceDocument inv);
258 
259     /**
260      * Generates use tax helper class for a purap document
261      *
262      * @param document
263      * @return useTaxContainer
264      */
265     public List<UseTaxContainer> generateUseTaxAccount(PurchasingAccountsPayableDocument document);
266 
267     public List<UseTaxContainer> generateUseTaxAccount(OlePurchasingAccountsPayableDocument document);
268 
269     /**
270      * Checks whether the specified accounting line in the specified PurAP document is used for tax withholding.
271      * This applies only to PaymentRequestDocument; otherwise it always returns false.
272      *
273      * @param document the specified PurAP document
274      * @param account  the specified accounting line
275      * @return true if the accounting line is a tax account
276      */
277     public boolean isTaxAccount(PurchasingAccountsPayableDocument document, SourceAccountingLine account);
278     public boolean isTaxAccount(OlePurchasingAccountsPayableDocument document, SourceAccountingLine account);
279 
280     /**
281      * calculates values for a list of accounting lines based on an amount
282      *
283      * @param <T>
284      * @param sourceAccountingLines
285      * @param totalAmount
286      */
287     public <T extends PurApAccountingLine> void updateAccountAmountsWithTotal(List<T> sourceAccountingLines, KualiDecimal totalAmount);
288 
289     /**
290      * calculates values for a list of accounting lines based on an amount taking discount into account
291      *
292      * @param <T>
293      * @param sourceAccountingLines
294      * @param totalAmount
295      * @param discountAmount
296      */
297     public <T extends PurApAccountingLine> void updateAccountAmountsWithTotal(List<T> sourceAccountingLines,
298                                                                               KualiDecimal totalAmount, KualiDecimal discountAmount);
299 
300     /**
301      * calculates values for a list of accounting lines based on an amount on preq for sequential method.
302      *
303      * @param <T>
304      * @param sourceAccountingLines
305      * @param totalAmount
306      */
307     public <T extends PurApAccountingLine> void updatePreqAccountAmountsWithTotal(List<T> sourceAccountingLines, KualiDecimal totalAmount);
308 
309     /**
310      * calculates values for a list of accounting lines based on an amount on preq for proportional method.
311      *
312      * @param <T>
313      * @param sourceAccountingLines
314      * @param totalAmount
315      */
316     public <T extends PurApAccountingLine> void updatePreqProporationalAccountAmountsWithTotal(List<T> sourceAccountingLines, KualiDecimal totalAmount);
317 
318     /**
319      * Merges list 2 into list 1
320      *
321      * @param list1
322      * @param list2
323      * @return
324      */
325     public List<SourceAccountingLine> mergeAccountingLineLists(List<SourceAccountingLine> accountingLines1, List<SourceAccountingLine> accountingLines2);
326 
327     /**
328      * Retrieves the summary accounts by payment request document id.
329      *
330      * @param paymentRequestIdentifier - payment request document id
331      * @return List of SummaryAccounts
332      */
333     public List getSummaryAccountsbyPaymentRequestIdentifier(Integer paymentRequestIdentifier);
334 
335     /**
336      * Retrieves the summary accounts by Invoice document id.
337      *
338      * @param invoicetIdentifier - payment request document id
339      * @return List of SummaryAccounts
340      */
341     public List getSummaryAccountsbyInvoiceIdentifier(Integer invoicetIdentifier);
342 
343 
344     /**
345      * Retrieves the summary accounts by credit memo document id.
346      *
347      * @param creditMemoIdentifier - credit memo document id
348      * @return List of SummaryAccounts
349      */
350     public List getSummaryAccountsbyCreditMemoIdentifier(Integer creditMemoIdentifier);
351 
352 }