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