1 /*
2 * The Kuali Financial System, a comprehensive financial management system for higher education.
3 *
4 * Copyright 2005-2014 The Kuali Foundation
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package org.kuali.kfs.module.purap.document.service;
20
21 import java.sql.Date;
22 import java.util.Collection;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.Set;
26
27 import org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem;
28 import org.kuali.kfs.module.purap.document.PurchaseOrderDocument;
29 import org.kuali.kfs.module.purap.document.VendorCreditMemoDocument;
30 import org.kuali.kfs.module.purap.util.VendorGroupingHelper;
31
32 /**
33 * Defines methods that must be implemented by a CreditMemoService implementation.
34 */
35 public interface CreditMemoService extends AccountsPayableDocumentSpecificService {
36
37 /**
38 * Populates the document from either the associated payment request document, purchase order document, or vendor detail based
39 * on the credit memo type.
40 *
41 * @param cmDocument - Credit Memo Document to Populate
42 */
43 public void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument);
44
45 /**
46 * Gets the Credit memos that can be extracted.
47 *
48 * @param chartCode Chart to select from.
49 * @return Iterator of credit memos.
50 */
51 public List<VendorCreditMemoDocument> getCreditMemosToExtract(String chartCode);
52
53 /**
54 * Pulls a distinct list of all vendors on CM documents which are ready for extraction.
55 *
56 * @param chartCode
57 * @return
58 */
59 public Set<VendorGroupingHelper> getVendorsOnCreditMemosToExtract( String chartCode);
60
61 /**
62 * Pulls all extractable credit memo documents for a given vendor.
63 *
64 * @param chartCode
65 * @param vendor
66 * @return
67 */
68 public Collection<VendorCreditMemoDocument> getCreditMemosToExtractByVendor( String chartCode, VendorGroupingHelper vendor );
69
70 /**
71 * Get a credit memo by document number.
72 *
73 * @param documentNumber The document number of the credit memo to be retrieved.
74 * @return The credit memo document whose document number matches the input parameter.
75 */
76 public VendorCreditMemoDocument getCreditMemoByDocumentNumber(String documentNumber);
77
78 /**
79 * Retrieves the Credit Memo document by the purapDocumentIdentifier.
80 *
81 * @param purchasingDocumentIdentifier The purapDocumentIdentifier of the credit memo to be retrieved.
82 * @return The credit memo document whose purapDocumentIdentifier matches the input parameter.
83 */
84 public VendorCreditMemoDocument getCreditMemoDocumentById(Integer purchasingDocumentIdentifier);
85
86 /**
87 * Makes call to dao to check for duplicate credit memos, and if one is found a message is returned. A duplicate error happens
88 * if there is an existing credit memo with the same vendor number and credit memo number as the one which is being created, or
89 * same vendor number and credit memo date.
90 *
91 * @param cmDocument - CreditMemoDocument to run duplicate check on.
92 * @return String - message indicating a duplicate was found.
93 */
94 public String creditMemoDuplicateMessages(VendorCreditMemoDocument cmDocument);
95
96 /**
97 * Iterates through the items of the purchase order document and checks for items that have been invoiced.
98 *
99 * @param poDocument - purchase order document containing the lines to check.
100 * @return List<PurchaseOrderItem> - list of invoiced items found.
101 */
102 public List<PurchaseOrderItem> getPOInvoicedItems(PurchaseOrderDocument poDocument);
103
104 /**
105 * Persists the credit memo with business rule checks.
106 *
107 * @param creditMemoDocument - credit memo document to save.
108 */
109 public void populateAndSaveCreditMemo(VendorCreditMemoDocument creditMemoDocument);
110
111 /**
112 * Performs the credit memo item extended price calculation.
113 *
114 * @param cmDocument - credit memo document to calculate.
115 */
116 public void calculateCreditMemo(VendorCreditMemoDocument cmDocument);
117
118 /**
119 * Marks a credit memo as on hold.
120 *
121 * @param cmDocument - credit memo document to hold.
122 * @param note - note explaining why the document is being put on hold.
123 * @return the CreditMemoDocument with updated information.
124 * @throws Exception
125 */
126 public VendorCreditMemoDocument addHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception;
127
128 /**
129 * Removes a hold on the credit memo document.
130 *
131 * @param cmDocument - credit memo document to remove hold on.
132 * @param note - note explaining why the credit memo is being taken off hold.
133 * @return the CreditMemoDocument with updated information.
134 */
135 public VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception;
136
137 /**
138 * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
139 * @param cmDocument The credit memo document to be resetted.
140 * @param note The note to be added to the credit memo document.
141 */
142 public void resetExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note);
143
144 /**
145 * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
146 *
147 * @param cmDocument The credit memo document to be canceled.
148 * @param note The note to be added to the document to be canceled.
149 */
150 public void cancelExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note);
151
152 /**
153 * Reopens the purchase order document related to the given credit memo
154 * document if it is closed.
155 *
156 * @param cmDocument The credit memo document to be used to obtained the
157 * purchase order document to be closed.
158 */
159 public void reopenClosedPO(VendorCreditMemoDocument cmDocument);
160
161 /**
162 * Mark a credit memo is being used on a payment
163 *
164 * @param cm The credit memo document to be marked as paid.
165 * @param processDate The date to be set as the credit memo's paid timestamp.
166 */
167 public void markPaid(VendorCreditMemoDocument cm, Date processDate);
168
169 /**
170 * Determines if there are active credit memos for a purchase order.
171 *
172 * @param purchaseOrderIdentifier
173 * @return
174 */
175 public boolean hasActiveCreditMemosForPurchaseOrder(Integer purchaseOrderIdentifier);
176
177 }
178