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.document.service;
17  
18  import org.kuali.ole.module.purap.businessobject.PurchaseOrderItem;
19  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
20  import org.kuali.ole.module.purap.document.VendorCreditMemoDocument;
21  import org.kuali.ole.module.purap.util.VendorGroupingHelper;
22  
23  import java.sql.Date;
24  import java.util.Collection;
25  import java.util.List;
26  import java.util.Set;
27  
28  /**
29   * Defines methods that must be implemented by a CreditMemoService implementation.
30   */
31  public interface CreditMemoService extends AccountsPayableDocumentSpecificService {
32  
33      /**
34       * Populates the document from either the associated payment request document, purchase order document, or vendor detail based
35       * on the credit memo type.
36       *
37       * @param cmDocument - Credit Memo Document to Populate
38       */
39      public void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument);
40  
41      /**
42       * Gets the Credit memos that can be extracted.
43       *
44       * @param chartCode Chart to select from.
45       * @return Iterator of credit memos.
46       */
47      public List<VendorCreditMemoDocument> getCreditMemosToExtract(String chartCode);
48  
49      /**
50       * Pulls a distinct list of all vendors on CM documents which are ready for extraction.
51       *
52       * @param chartCode
53       * @return
54       */
55      public Set<VendorGroupingHelper> getVendorsOnCreditMemosToExtract(String chartCode);
56  
57      /**
58       * Pulls all extractable credit memo documents for a given vendor.
59       *
60       * @param chartCode
61       * @param vendor
62       * @return
63       */
64      public Collection<VendorCreditMemoDocument> getCreditMemosToExtractByVendor(String chartCode, VendorGroupingHelper vendor);
65  
66      /**
67       * Get a credit memo by document number.
68       *
69       * @param documentNumber The document number of the credit memo to be retrieved.
70       * @return The credit memo document whose document number matches the input parameter.
71       */
72      public VendorCreditMemoDocument getCreditMemoByDocumentNumber(String documentNumber);
73  
74      /**
75       * Retrieves the Credit Memo document by the purapDocumentIdentifier.
76       *
77       * @param purchasingDocumentIdentifier The purapDocumentIdentifier of the credit memo to be retrieved.
78       * @return The credit memo document whose purapDocumentIdentifier matches the input parameter.
79       */
80      public VendorCreditMemoDocument getCreditMemoDocumentById(Integer purchasingDocumentIdentifier);
81  
82      /**
83       * Makes call to dao to check for duplicate credit memos, and if one is found a message is returned. A duplicate error happens
84       * if there is an existing credit memo with the same vendor number and credit memo number as the one which is being created, or
85       * same vendor number and credit memo date.
86       *
87       * @param cmDocument - CreditMemoDocument to run duplicate check on.
88       * @return String - message indicating a duplicate was found.
89       */
90      public String creditMemoDuplicateMessages(VendorCreditMemoDocument cmDocument);
91  
92      /**
93       * Iterates through the items of the purchase order document and checks for items that have been invoiced.
94       *
95       * @param poDocument - purchase order document containing the lines to check.
96       * @return List<PurchaseOrderItem> - list of invoiced items found.
97       */
98      public List<PurchaseOrderItem> getPOInvoicedItems(PurchaseOrderDocument poDocument);
99  
100     /**
101      * Persists the credit memo with business rule checks.
102      *
103      * @param creditMemoDocument - credit memo document to save.
104      */
105     public void populateAndSaveCreditMemo(VendorCreditMemoDocument creditMemoDocument);
106 
107     /**
108      * Performs the credit memo item extended price calculation.
109      *
110      * @param cmDocument - credit memo document to calculate.
111      */
112     public void calculateCreditMemo(VendorCreditMemoDocument cmDocument);
113 
114     /**
115      * Marks a credit memo as on hold.
116      *
117      * @param cmDocument - credit memo document to hold.
118      * @param note       - note explaining why the document is being put on hold.
119      * @return the CreditMemoDocument with updated information.
120      * @throws Exception
121      */
122     public VendorCreditMemoDocument addHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception;
123 
124     /**
125      * Removes a hold on the credit memo document.
126      *
127      * @param cmDocument - credit memo document to remove hold on.
128      * @param note       - note explaining why the credit memo is being taken off hold.
129      * @return the CreditMemoDocument with updated information.
130      */
131     public VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception;
132 
133     /**
134      * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
135      *
136      * @param cmDocument The credit memo document to be resetted.
137      * @param note       The note to be added to the credit memo document.
138      */
139     public void resetExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note);
140 
141     /**
142      * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
143      *
144      * @param cmDocument The credit memo document to be canceled.
145      * @param note       The note to be added to the document to be canceled.
146      */
147     public void cancelExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note);
148 
149     /**
150      * Reopens the purchase order document related to the given credit memo
151      * document if it is closed.
152      *
153      * @param cmDocument The credit memo document to be used to obtained the
154      *                   purchase order document to be closed.
155      */
156     public void reopenClosedPO(VendorCreditMemoDocument cmDocument);
157 
158     /**
159      * Mark a credit memo is being used on a payment
160      *
161      * @param cm          The credit memo document to be marked as paid.
162      * @param processDate The date to be set as the credit memo's paid timestamp.
163      */
164     public void markPaid(VendorCreditMemoDocument cm, Date processDate);
165 
166     /**
167      * Determines if there are active credit memos for a purchase order.
168      *
169      * @param purchaseOrderIdentifier
170      * @return
171      */
172     public boolean hasActiveCreditMemosForPurchaseOrder(Integer purchaseOrderIdentifier);
173 
174 }
175