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.HashMap;
020: import java.util.Iterator;
021: import java.util.List;
022:
023: import org.kuali.core.bo.user.UniversalUser;
024: import org.kuali.core.util.KualiDecimal;
025: import org.kuali.module.purap.document.CreditMemoDocument;
026: import org.kuali.module.purap.document.PaymentRequestDocument;
027: import org.kuali.module.purap.util.VendorGroupingHelper;
028: import org.kuali.module.vendor.bo.PaymentTermType;
029:
030: import edu.iu.uis.eden.exception.WorkflowException;
031:
032: /**
033: * Defines methods that must be implemented by a PaymentRequestService implementation.
034: */
035: public interface PaymentRequestService extends
036: AccountsPayableDocumentSpecificService {
037:
038: /**
039: * Persists the payment request without business rule checks.
040: *
041: * @param paymentRequestDocument - payment request document to save.
042: */
043: public void saveDocumentWithoutValidation(
044: PaymentRequestDocument paymentRequestDocument);
045:
046: /**
047: * Obtains a list of payment request documents given the purchase order id.
048: *
049: * @param poDocId The purchase order id to be used to obtain a list of payment request documents.
050: * @return The List of payment request documents given the purchase order id.
051: */
052: public List<PaymentRequestDocument> getPaymentRequestsByPurchaseOrderId(
053: Integer poDocId);
054:
055: /**
056: * Obtains a list of payment request documents given the purchase order id, the invoice amount
057: * and the invoice date.
058: *
059: * @param poId The purchase order id used to obtain the payment request documents.
060: * @param invoiceAmount The invoice amount used to obtain the payment request documents.
061: * @param invoiceDate The invoice date used to obtain the payment request documents.
062: * @return The List of payment request documents that match the given criterias (purchase order id, invoice amount and invoice date).
063: */
064: public List getPaymentRequestsByPOIdInvoiceAmountInvoiceDate(
065: Integer poId, KualiDecimal invoiceAmount, Date invoiceDate);
066:
067: /**
068: * Obtains a list of payment request documents given the vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifier and the invoice number.
069: *
070: * @param vendorHeaderGeneratedIdentifier The vendorHeaderGeneratedIdentifier used to obtain the payment request documents.
071: * @param vendorDetailAssignedIdentifier The vendorDetailAssignedIdentifier used to obtain the payment request documents.
072: * @param invoiceNumber The invoice number used to obtain the payment request documents.
073: * @return The List of payment request documents that match the given criterias.
074: */
075: public List getPaymentRequestsByVendorNumberInvoiceNumber(
076: Integer vendorHeaderGeneratedIdentifier,
077: Integer vendorDetailAssignedIdentifier, String invoiceNumber);
078:
079: /**
080: * Determines whether the invoice date is after today.
081: *
082: * @param invoiceDate The invoice date to be determined whether it's after today.
083: * @return boolean true if the given invoice date is after today.
084: */
085: public boolean isInvoiceDateAfterToday(Date invoiceDate);
086:
087: /**
088: * Performs the processing to check whether the payment request is a duplicate and if so, adds
089: * the information about the type of duplication into the resulting HashMap to be returned by this method.
090: *
091: * @param document The payment request document to be processed/checked for duplicates.
092: * @return The HashMap containing "PREQDuplicateInvoice" as the key and the string
093: * describing the types of duplication as the value.
094: */
095: public HashMap<String, String> paymentRequestDuplicateMessages(
096: PaymentRequestDocument document);
097:
098: /**
099: * Calculate based on the terms and calculate a date 10 days from today. Pick the one that is the farthest out. We always
100: * calculate the discount date, if there is one.
101: *
102: * @param invoiceDate The invoice date to be used in the pay date calculation.
103: * @param terms The payment term type to be used in the pay date calculation.
104: * @return The resulting pay date given the invoice date and the terms.
105: */
106: public Date calculatePayDate(Date invoiceDate, PaymentTermType terms);
107:
108: /**
109: * Marks a payment request on hold.
110: *
111: * @param document The payment request document to be marked as on hold.
112: * @param note The note to be added to the payment request document while being marked as on hold.
113: * @throws Exception
114: */
115: public void addHoldOnPaymentRequest(
116: PaymentRequestDocument document, String note)
117: throws Exception;
118:
119: /**
120: * Determines if a user has permission to put the payment request on hold.
121: *
122: * @param document The payment request document to be determined whether the user has permission to put it on hold.
123: * @param user The user whose permission to put the payment request on hold is to be determined.
124: * @return boolean true if the user has permission to put the payment request on hold.
125: */
126: public boolean canHoldPaymentRequest(
127: PaymentRequestDocument document, UniversalUser user);
128:
129: /**
130: * Determines if a user has permission to remove a hold on the payment request.
131: *
132: * @param document The payment request document to be determined whether the user has permission to remove hold on it.
133: * @param user The user whose permission to remove hold on the payment request is to be determined.
134: * @return boolean true if the user has permission to remove hold on the payment request.
135: */
136: public boolean canRemoveHoldPaymentRequest(
137: PaymentRequestDocument document, UniversalUser user);
138:
139: /**
140: * Removes a hold on a payment request.
141: *
142: * @param document The payment request document whose hold is to be removed.
143: * @param note The note to be added to the payment request document while its hold is being removed.
144: * @throws Exception
145: */
146: public void removeHoldOnPaymentRequest(
147: PaymentRequestDocument document, String note)
148: throws Exception;
149:
150: /**
151: * Obtains the payment request document given the purapDocumentIdentifier.
152: *
153: * @param poDocId The purapDocumentIdentifier of the payment request document to be obtained.
154: * @return The payment request document whose purapDocumentIdentifier matches with the input parameter.
155: */
156: public PaymentRequestDocument getPaymentRequestById(Integer poDocId);
157:
158: /**
159: * Obtains the payment request document given the document number.
160: *
161: * @param documentNumber The document number to be used to obtain the payment request document.
162: * @return The payment request document whose document number matches with the given input parameter.
163: */
164: public PaymentRequestDocument getPaymentRequestByDocumentNumber(
165: String documentNumber);
166:
167: /**
168: * Marks a payment request as requested to be canceled.
169: *
170: * @param document The payment request document to be marked as requested to be canceled.
171: * @param note The note to be added to the payment request document while being marked as requested to be canceled.
172: * @throws Exception
173: */
174: public void requestCancelOnPaymentRequest(
175: PaymentRequestDocument document, String note)
176: throws Exception;
177:
178: /**
179: * Returns true if the payment request has been extracted
180: *
181: * @param document The payment request document to be determined whether it is extracted.
182: * @return boolean true if the payment request document is extracted.
183: */
184: public boolean isExtracted(PaymentRequestDocument document);
185:
186: /**
187: * Determines if a user has permission to request cancel on the payment request.
188: *
189: * @param document The payment request document to be determined whether the user has permission to request cancel on it.
190: * @param user The user whose permission to request cancel on the payment request is to be determined.
191: * @return boolean true if the user has permission to request cancel on the payment request.
192: */
193: public boolean canUserRequestCancelOnPaymentRequest(
194: PaymentRequestDocument document, UniversalUser user);
195:
196: /**
197: * Determines if a user has permission to remove a request for cancel on the payment request.
198: *
199: * @param document The payment request document to be determined whether the user has permission to remove a request for cancel on it.
200: * @param user The user whose permission to remove a request for cancel on the payment request is to be determined.
201: * @return boolean true if the user has permission to remove a request for cancel on the payment request.
202: */
203: public boolean canUserRemoveRequestCancelOnPaymentRequest(
204: PaymentRequestDocument document, UniversalUser user);
205:
206: /**
207: * Removes a request cancel on payment request.
208: *
209: * @param document The payment request document to be used for request cancel.
210: * @param note The note to be added to the payment request document upon the removal of the request cancel.
211: * @throws Exception
212: */
213: public void removeRequestCancelOnPaymentRequest(
214: PaymentRequestDocument document, String note)
215: throws Exception;
216:
217: /**
218: * Resets a Payment Request that had an associated Payment Request or Credit Memo cancelled externally.
219: *
220: * @param paymentRequest The extracted payment request document to be resetted.
221: * @param note The note to be added to the payment request document upon its reset.
222: */
223: public void resetExtractedPaymentRequest(
224: PaymentRequestDocument paymentRequest, String note);
225:
226: /**
227: * Cancels a PREQ that has already been extracted if allowed.
228: *
229: * @param paymentRequest The extracted payment request document to be canceled.
230: * @param note The note to be added to the payment request document.
231: */
232: public void cancelExtractedPaymentRequest(
233: PaymentRequestDocument paymentRequest, String note);
234:
235: /**
236: * Get all the payment requests that are immediate and need to be extracted to PDP.
237: *
238: * @param chartCode The chart code to be used as one of the criterias to retrieve the payment request documents.
239: * @return The iterator of the list of the resulting payment request documents returned by the paymentRequestDao.
240: */
241: public Iterator<PaymentRequestDocument> getImmediatePaymentRequestsToExtract(
242: String chartCode);
243:
244: /**
245: * Get all the payment requests that match a credit memo.
246: *
247: * @param cmd The credit memo document to be used to obtain the payment requests.
248: * @return The iterator of the resulting payment request documents returned by the paymentRequestDao.
249: */
250: public Iterator<PaymentRequestDocument> getPaymentRequestsToExtractByCM(
251: String campusCode, CreditMemoDocument cmd);
252:
253: /**
254: * Get all the payment requests that match a vendor.
255: *
256: * @param vendor
257: * @return The iterator of the resulting payment request documents returned by the paymentRequestDao.
258: */
259: public Iterator<PaymentRequestDocument> getPaymentRequestsToExtractByVendor(
260: String campusCode, VendorGroupingHelper vendor);
261:
262: /**
263: * Get all the payment requests that need to be extracted.
264: *
265: * @return The iterator of the resulting payment request documents returned by the paymentRequestDao.
266: */
267: public Iterator<PaymentRequestDocument> getPaymentRequestsToExtract();
268:
269: /**
270: * Get all the special payment requests for a single chart that need to be extracted.
271: *
272: * @param chartCode The chart code to be used as one of the criterias to retrieve the payment request documents.
273: * @return The iterator of the resulting payment request documents returned by the paymentRequestDao.
274: */
275: public Iterator<PaymentRequestDocument> getPaymentRequestsToExtractSpecialPayments(
276: String chartCode);
277:
278: /**
279: * Get all the regular payment requests for a single campus.
280: *
281: * @param chartCode The chart code to be used as one of the criterias to retrieve the payment request documents.
282: * @return The iterator of the resulting payment request documents returned by the paymentRequestDao.
283: */
284: public Iterator<PaymentRequestDocument> getPaymentRequestToExtractByChart(
285: String chartCode);
286:
287: /**
288: * Recalculate the payment request.
289: *
290: * @param pr The payment request document to be calculated.
291: * @param updateDiscount boolean true if we also want to calculate the discount items for the payment request.
292: */
293: public void calculatePaymentRequest(PaymentRequestDocument pr,
294: boolean updateDiscount);
295:
296: /**
297: * Populate payment request.
298: *
299: * @param preq The payment request document to be populated.
300: */
301: public void populatePaymentRequest(PaymentRequestDocument preq);
302:
303: /**
304: * Populate and save payment request.
305: *
306: * @param preq The payment request document to be populated and saved.
307: */
308: public void populateAndSavePaymentRequest(
309: PaymentRequestDocument preq) throws WorkflowException;
310:
311: /**
312: * Retrieve a list of PREQs that aren't approved, check to see if they match specific requirements, then auto-approve them if
313: * possible.
314: *
315: * @return boolean true if the auto approval of payment requests has at least one error.
316: */
317: public boolean autoApprovePaymentRequests();
318:
319: /**
320: * Checks whether the payment request document is eligible for auto approval. If so, then updates
321: * the status of the document to auto approved and calls the documentService to blanket approve
322: * the document, then returns false.
323: * If the document is not eligible for auto approval then returns true.
324: *
325: * @param doc The payment request document to be auto approved.
326: * @param defaultMinimumLimit The default minimum limit amount to be used in determining the eligibility of the document to be auto approved.
327: * @return boolean true if the payment request document is not eligible for auto approval.
328: */
329: public boolean autoApprovePaymentRequest(
330: PaymentRequestDocument doc, KualiDecimal defaultMinimumLimit);
331:
332: /**
333: * Deletes the payment request summary accounts by purapDocumentIdentifier
334: *
335: * @param purapDocumentIdentifier The purapDocumentIdentifier of the payment request document whose summary accounts are to be deleted.
336: */
337: public void deleteSummaryAccounts(Integer purapDocumentIdentifier);
338:
339: /**
340: * Mark a payment request as being paid and set the payment request's paid date as the processDate.
341: *
342: * @param pr The payment request document to be marked as paid and paid date to be set.
343: * @param processDate The date to be set as the payment request's paid date.
344: */
345: public void markPaid(PaymentRequestDocument pr, Date processDate);
346:
347: /**
348: * This method specifies whether the payment request document has a discount item.
349: *
350: * @param preq The payment request document to be verified whether it has a discount item.
351: * @return boolean true if the payment request document has at least one discount item.
352: */
353: public boolean hasDiscountItem(PaymentRequestDocument preq);
354: }
|