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.purap.document.service;
017
018 import java.sql.Date;
019 import java.util.Collection;
020 import java.util.Iterator;
021 import java.util.List;
022 import java.util.Set;
023
024 import org.kuali.kfs.module.purap.businessobject.PurchaseOrderItem;
025 import org.kuali.kfs.module.purap.document.VendorCreditMemoDocument;
026 import org.kuali.kfs.module.purap.document.PurchaseOrderDocument;
027 import org.kuali.kfs.module.purap.util.VendorGroupingHelper;
028 import org.kuali.rice.kim.bo.Person;
029
030 /**
031 * Defines methods that must be implemented by a CreditMemoService implementation.
032 */
033 public interface CreditMemoService extends AccountsPayableDocumentSpecificService {
034
035 /**
036 * Populates the document from either the associated payment request document, purchase order document, or vendor detail based
037 * on the credit memo type.
038 *
039 * @param cmDocument - Credit Memo Document to Populate
040 */
041 public void populateDocumentAfterInit(VendorCreditMemoDocument cmDocument);
042
043 /**
044 * Gets the Credit memos that can be extracted.
045 *
046 * @param chartCode Chart to select from.
047 * @return Iterator of credit memos.
048 */
049 public Iterator<VendorCreditMemoDocument> getCreditMemosToExtract(String chartCode);
050
051 /**
052 * Pulls a distinct list of all vendors on CM documents which are ready for extraction.
053 *
054 * @param chartCode
055 * @return
056 */
057 public Set<VendorGroupingHelper> getVendorsOnCreditMemosToExtract( String chartCode);
058
059 /**
060 * Pulls all extractable credit memo documents for a given vendor.
061 *
062 * @param chartCode
063 * @param vendor
064 * @return
065 */
066 public Collection<VendorCreditMemoDocument> getCreditMemosToExtractByVendor( String chartCode, VendorGroupingHelper vendor );
067
068 /**
069 * Get a credit memo by document number.
070 *
071 * @param documentNumber The document number of the credit memo to be retrieved.
072 * @return The credit memo document whose document number matches the input parameter.
073 */
074 public VendorCreditMemoDocument getCreditMemoByDocumentNumber(String documentNumber);
075
076 /**
077 * Retrieves the Credit Memo document by the purapDocumentIdentifier.
078 *
079 * @param purchasingDocumentIdentifier The purapDocumentIdentifier of the credit memo to be retrieved.
080 * @return The credit memo document whose purapDocumentIdentifier matches the input parameter.
081 */
082 public VendorCreditMemoDocument getCreditMemoDocumentById(Integer purchasingDocumentIdentifier);
083
084 /**
085 * Makes call to dao to check for duplicate credit memos, and if one is found a message is returned. A duplicate error happens
086 * if there is an existing credit memo with the same vendor number and credit memo number as the one which is being created, or
087 * same vendor number and credit memo date.
088 *
089 * @param cmDocument - CreditMemoDocument to run duplicate check on.
090 * @return String - message indicating a duplicate was found.
091 */
092 public String creditMemoDuplicateMessages(VendorCreditMemoDocument cmDocument);
093
094 /**
095 * Iterates through the items of the purchase order document and checks for items that have been invoiced.
096 *
097 * @param poDocument - purchase order document containing the lines to check.
098 * @return List<PurchaseOrderItem> - list of invoiced items found.
099 */
100 public List<PurchaseOrderItem> getPOInvoicedItems(PurchaseOrderDocument poDocument);
101
102 /**
103 * Persists the credit memo with business rule checks.
104 *
105 * @param creditMemoDocument - credit memo document to save.
106 */
107 public void populateAndSaveCreditMemo(VendorCreditMemoDocument creditMemoDocument);
108
109 /**
110 * Performs the credit memo item extended price calculation.
111 *
112 * @param cmDocument - credit memo document to calculate.
113 */
114 public void calculateCreditMemo(VendorCreditMemoDocument cmDocument);
115
116 /**
117 * Marks a credit memo as on hold.
118 *
119 * @param cmDocument - credit memo document to hold.
120 * @param note - note explaining why the document is being put on hold.
121 * @return the CreditMemoDocument with updated information.
122 * @throws Exception
123 */
124 public VendorCreditMemoDocument addHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception;
125
126 /**
127 * Removes a hold on the credit memo document.
128 *
129 * @param cmDocument - credit memo document to remove hold on.
130 * @param note - note explaining why the credit memo is being taken off hold.
131 * @return the CreditMemoDocument with updated information.
132 */
133 public VendorCreditMemoDocument removeHoldOnCreditMemo(VendorCreditMemoDocument cmDocument, String note) throws Exception;
134
135 /**
136 * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
137 * @param cmDocument The credit memo document to be resetted.
138 * @param note The note to be added to the credit memo document.
139 */
140 public void resetExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note);
141
142 /**
143 * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
144 *
145 * @param cmDocument The credit memo document to be canceled.
146 * @param note The note to be added to the document to be canceled.
147 */
148 public void cancelExtractedCreditMemo(VendorCreditMemoDocument cmDocument, String note);
149
150 /**
151 * Reopens the purchase order document related to the given credit memo
152 * document if it is closed.
153 *
154 * @param cmDocument The credit memo document to be used to obtained the
155 * purchase order document to be closed.
156 */
157 public void reopenClosedPO(VendorCreditMemoDocument cmDocument);
158
159 /**
160 * Mark a credit memo is being used on a payment
161 *
162 * @param cm The credit memo document to be marked as paid.
163 * @param processDate The date to be set as the credit memo's paid timestamp.
164 */
165 public void markPaid(VendorCreditMemoDocument cm, Date processDate);
166
167 /**
168 * Determines if there are active credit memos for a purchase order.
169 *
170 * @param purchaseOrderIdentifier
171 * @return
172 */
173 public boolean hasActiveCreditMemosForPurchaseOrder(Integer purchaseOrderIdentifier);
174
175 }
176