001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.purap.service;
017:
018: import java.sql.Date;
019: import java.util.Iterator;
020: import java.util.List;
021: import java.util.Set;
022:
023: import org.kuali.core.bo.user.UniversalUser;
024: import org.kuali.module.purap.bo.PurchaseOrderItem;
025: import org.kuali.module.purap.document.CreditMemoDocument;
026: import org.kuali.module.purap.document.PurchaseOrderDocument;
027: import org.kuali.module.purap.util.VendorGroupingHelper;
028:
029: /**
030: * Defines methods that must be implemented by a CreditMemoService implementation.
031: */
032: public interface CreditMemoService extends
033: AccountsPayableDocumentSpecificService {
034:
035: /**
036: * Gets the Credit memos that can be extracted.
037: *
038: * @param chartCode Chart to select from.
039: * @return Iterator of credit memos.
040: */
041: public Iterator<CreditMemoDocument> getCreditMemosToExtract(
042: String chartCode);
043:
044: /**
045: * Pulls a distinct list of all vendors on CM documents which are ready for extraction.
046: *
047: * @param chartCode
048: * @return
049: */
050: public Set<VendorGroupingHelper> getVendorsOnCreditMemosToExtract(
051: String chartCode);
052:
053: /**
054: * Pulls all extractable credit memo documents for a given vendor.
055: *
056: * @param chartCode
057: * @param vendor
058: * @return
059: */
060: public Iterator<CreditMemoDocument> getCreditMemosToExtractByVendor(
061: String chartCode, VendorGroupingHelper vendor);
062:
063: /**
064: * Get a credit memo by document number.
065: *
066: * @param documentNumber The document number of the credit memo to be retrieved.
067: * @return The credit memo document whose document number matches the input parameter.
068: */
069: public CreditMemoDocument getCreditMemoByDocumentNumber(
070: String documentNumber);
071:
072: /**
073: * Retrieves the Credit Memo document by the purapDocumentIdentifier.
074: *
075: * @param purchasingDocumentIdentifier The purapDocumentIdentifier of the credit memo to be retrieved.
076: * @return The credit memo document whose purapDocumentIdentifier matches the input parameter.
077: */
078: public CreditMemoDocument getCreditMemoDocumentById(
079: Integer purchasingDocumentIdentifier);
080:
081: /**
082: * Makes call to dao to check for duplicate credit memos, and if one is found a message is returned. A duplicate error happens
083: * if there is an existing credit memo with the same vendor number and credit memo number as the one which is being created, or
084: * same vendor number and credit memo date.
085: *
086: * @param cmDocument - CreditMemoDocument to run duplicate check on.
087: * @return String - message indicating a duplicate was found.
088: */
089: public String creditMemoDuplicateMessages(
090: CreditMemoDocument cmDocument);
091:
092: /**
093: * Iterates through the items of the purchase order document and checks for items that have been invoiced.
094: *
095: * @param poDocument - purchase order document containing the lines to check.
096: * @return List<PurchaseOrderItem> - list of invoiced items found.
097: */
098: public List<PurchaseOrderItem> getPOInvoicedItems(
099: PurchaseOrderDocument poDocument);
100:
101: /**
102: * Persists the credit memo without business rule checks.
103: *
104: * @param creditMemoDocument - credit memo document to save.
105: */
106: public void saveDocumentWithoutValidation(
107: CreditMemoDocument creditMemoDocument);
108:
109: /**
110: * Persists the credit memo with business rule checks.
111: *
112: * @param creditMemoDocument - credit memo document to save.
113: */
114: public void populateAndSaveCreditMemo(
115: CreditMemoDocument creditMemoDocument);
116:
117: /**
118: * Performs the credit memo item extended price calculation.
119: *
120: * @param cmDocument - credit memo document to calculate.
121: */
122: public void calculateCreditMemo(CreditMemoDocument cmDocument);
123:
124: /**
125: * Marks a credit memo as on hold.
126: *
127: * @param cmDocument - credit memo document to hold.
128: * @param note - note explaining why the document is being put on hold.
129: * @throws Exception
130: */
131: public void addHoldOnCreditMemo(CreditMemoDocument cmDocument,
132: String note) throws Exception;
133:
134: /**
135: * Determines if the document can be put on hold and if the user has permission to do so.
136: * Must be an Accounts Payable user, credit memo not already on hold, extracted date is null, and credit memo
137: * status approved or complete.
138: *
139: *
140: * @param cmDocument - credit memo document to hold.
141: * @param user - user requesting the hold.
142: * @return boolean - true if hold can occur, false if not allowed.
143: */
144: public boolean canHoldCreditMemo(CreditMemoDocument cmDocument,
145: UniversalUser user);
146:
147: /**
148: * Removes a hold on the credit memo document.
149: *
150: * @param cmDocument - credit memo document to remove hold on.
151: * @param note - note explaining why the credit memo is being taken off hold.
152: */
153: public void removeHoldOnCreditMemo(CreditMemoDocument cmDocument,
154: String note) throws Exception;
155:
156: /**
157: * Determines if the document can be taken off hold and if the given user has permission to do so.
158: * Must be person who put credit memo on hold or accounts payable supervisor and credit memo must be on hold.
159: *
160: * @param cmDocument - credit memo document that is on hold.
161: * @param user - user requesting to remove the hold.
162: * @return boolean - true if user can take document off hold, false if they cannot.
163: */
164: public boolean canRemoveHoldCreditMemo(
165: CreditMemoDocument cmDocument, UniversalUser user);
166:
167: /**
168: * Determines if the document can be canceled and if the given user has permission to do so.
169: * Document can be canceled if not in canceled status already, extracted date is null, hold indicator is false, and user is
170: * member of the accounts payable workgroup.
171: *
172: * @param cmDocument - credit memo document to cancel.
173: * @param user - user requesting the cancel.
174: * @return boolean - true if document can be canceled, false if it cannot be.
175: */
176: public boolean canCancelCreditMemo(CreditMemoDocument cmDocument,
177: UniversalUser user);
178:
179: /**
180: * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
181: * @param cmDocument The credit memo document to be resetted.
182: * @param note The note to be added to the credit memo document.
183: */
184: public void resetExtractedCreditMemo(CreditMemoDocument cmDocument,
185: String note);
186:
187: /**
188: * This is called by PDP to cancel a CreditMemoDocument that has already been extracted
189: *
190: * @param cmDocument The credit memo document to be canceled.
191: * @param note The note to be added to the document to be canceled.
192: */
193: public void cancelExtractedCreditMemo(
194: CreditMemoDocument cmDocument, String note);
195:
196: /**
197: * Reopens the purchase order document related to the given credit memo
198: * document if it is closed.
199: *
200: * @param cmDocument The credit memo document to be used to obtained the
201: * purchase order document to be closed.
202: */
203: public void reopenClosedPO(CreditMemoDocument cmDocument);
204:
205: /**
206: * Mark a credit memo is being used on a payment
207: *
208: * @param cm The credit memo document to be marked as paid.
209: * @param processDate The date to be set as the credit memo's paid timestamp.
210: */
211: public void markPaid(CreditMemoDocument cm, Date processDate);
212: }
|