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.document.PaymentRequestDocument; 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 import org.kuali.ole.vnd.businessobject.PaymentTermType; 23 import org.kuali.rice.core.api.util.type.KualiDecimal; 24 import org.kuali.rice.kew.api.exception.WorkflowException; 25 26 import java.sql.Date; 27 import java.util.Collection; 28 import java.util.HashMap; 29 import java.util.List; 30 31 /** 32 * Defines methods that must be implemented by a PaymentRequestService implementation. 33 */ 34 public interface PaymentRequestService extends AccountsPayableDocumentSpecificService { 35 36 /** 37 * Obtains a list of payment request documents given the purchase order id. 38 * 39 * @param poDocId The purchase order id to be used to obtain a list of payment request documents. 40 * @return The List of payment request documents given the purchase order id. 41 */ 42 public List<PaymentRequestDocument> getPaymentRequestsByPurchaseOrderId(Integer poDocId); 43 44 /** 45 * Obtains a list of payment request documents given the purchase order id, the invoice amount 46 * and the invoice date. 47 * 48 * @param poId The purchase order id used to obtain the payment request documents. 49 * @param invoiceAmount The invoice amount used to obtain the payment request documents. 50 * @param invoiceDate The invoice date used to obtain the payment request documents. 51 * @return The List of payment request documents that match the given criterias (purchase order id, invoice amount and invoice date). 52 */ 53 public List getPaymentRequestsByPOIdInvoiceAmountInvoiceDate(Integer poId, KualiDecimal invoiceAmount, Date invoiceDate); 54 55 /** 56 * Obtains a list of payment request documents given the vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifier and the invoice number. 57 * 58 * @param vendorHeaderGeneratedIdentifier 59 * The vendorHeaderGeneratedIdentifier used to obtain the payment request documents. 60 * @param vendorDetailAssignedIdentifier The vendorDetailAssignedIdentifier used to obtain the payment request documents. 61 * @return The List of payment request documents that match the given criterias. 62 */ 63 public List getPaymentRequestsByVendorNumber(Integer vendorHeaderGeneratedIdentifier, Integer vendorDetailAssignedIdentifier); 64 65 /** 66 * Obtains a list of payment request documents given the vendorHeaderGeneratedIdentifier, vendorDetailAssignedIdentifier and the invoice number. 67 * 68 * @param vendorHeaderGeneratedIdentifier 69 * The vendorHeaderGeneratedIdentifier used to obtain the payment request documents. 70 * @param vendorDetailAssignedIdentifier The vendorDetailAssignedIdentifier used to obtain the payment request documents. 71 * @param invoiceNumber The invoice number used to obtain the payment request documents. 72 * @return The List of payment request documents that match the given criterias. 73 */ 74 public List getPaymentRequestsByVendorNumberInvoiceNumber(Integer vendorHeaderGeneratedIdentifier, Integer vendorDetailAssignedIdentifier, String invoiceNumber); 75 76 77 /** 78 * Determines whether the invoice date is after today. 79 * 80 * @param invoiceDate The invoice date to be determined whether it's after today. 81 * @return boolean true if the given invoice date is after today. 82 */ 83 public boolean isInvoiceDateAfterToday(Date invoiceDate); 84 85 /** 86 * Performs the processing to check whether the payment request is a duplicate and if so, adds 87 * the information about the type of duplication into the resulting HashMap to be returned by this method. 88 * 89 * @param document The payment request document to be processed/checked for duplicates. 90 * @return The HashMap containing "PREQDuplicateInvoice" as the key and the string 91 * describing the types of duplication as the value. 92 */ 93 public HashMap<String, String> paymentRequestDuplicateMessages(PaymentRequestDocument document); 94 95 /** 96 * Calculate based on the terms and calculate a date 10 days from today. Pick the one that is the farthest out. We always 97 * calculate the discount date, if there is one. 98 * 99 * @param invoiceDate The invoice date to be used in the pay date calculation. 100 * @param terms The payment term type to be used in the pay date calculation. 101 * @return The resulting pay date given the invoice date and the terms. 102 */ 103 public java.sql.Date calculatePayDate(Date invoiceDate, PaymentTermType terms); 104 105 /** 106 * Marks a payment request on hold. 107 * 108 * @param document The payment request document to be marked as on hold. 109 * @param note The note to be added to the payment request document while being marked as on hold. 110 * @return The PaymentRequestDocument with updated information. 111 * @throws Exception 112 */ 113 public PaymentRequestDocument addHoldOnPaymentRequest(PaymentRequestDocument document, String note) throws Exception; 114 115 /** 116 * Removes a hold on a payment request. 117 * 118 * @param document The payment request document whose hold is to be removed. 119 * @param note The note to be added to the payment request document while its hold is being removed. 120 * @return The PaymentRequestDocument with updated information. 121 * @throws Exception 122 */ 123 public PaymentRequestDocument removeHoldOnPaymentRequest(PaymentRequestDocument document, String note) throws Exception; 124 125 /** 126 * Obtains the payment request document given the purapDocumentIdentifier. 127 * 128 * @param poDocId The purapDocumentIdentifier of the payment request document to be obtained. 129 * @return The payment request document whose purapDocumentIdentifier matches with the input parameter. 130 */ 131 public PaymentRequestDocument getPaymentRequestById(Integer poDocId); 132 133 /** 134 * Obtains the payment request document given the document number. 135 * 136 * @param documentNumber The document number to be used to obtain the payment request document. 137 * @return The payment request document whose document number matches with the given input parameter. 138 */ 139 public PaymentRequestDocument getPaymentRequestByDocumentNumber(String documentNumber); 140 141 /** 142 * Marks a payment request as requested to be canceled. 143 * 144 * @param document The payment request document to be marked as requested to be canceled. 145 * @param note The note to be added to the payment request document while being marked as requested to be canceled. 146 * @throws Exception 147 */ 148 public void requestCancelOnPaymentRequest(PaymentRequestDocument document, String note) throws Exception; 149 150 /** 151 * Returns true if the payment request has been extracted 152 * 153 * @param document The payment request document to be determined whether it is extracted. 154 * @return boolean true if the payment request document is extracted. 155 */ 156 public boolean isExtracted(PaymentRequestDocument document); 157 158 /** 159 * Removes a request cancel on payment request. 160 * 161 * @param document The payment request document to be used for request cancel. 162 * @param note The note to be added to the payment request document upon the removal of the request cancel. 163 * @throws Exception 164 */ 165 public void removeRequestCancelOnPaymentRequest(PaymentRequestDocument document, String note) throws Exception; 166 167 /** 168 * Resets a Payment Request that had an associated Payment Request or Credit Memo cancelled externally. 169 * 170 * @param paymentRequest The extracted payment request document to be resetted. 171 * @param note The note to be added to the payment request document upon its reset. 172 */ 173 public void resetExtractedPaymentRequest(PaymentRequestDocument paymentRequest, String note); 174 175 /** 176 * Cancels a PREQ that has already been extracted if allowed. 177 * 178 * @param paymentRequest The extracted payment request document to be canceled. 179 * @param note The note to be added to the payment request document. 180 */ 181 public void cancelExtractedPaymentRequest(PaymentRequestDocument paymentRequest, String note); 182 183 /** 184 * Get all the payment requests that are immediate and need to be extracted to PDP. 185 * 186 * @param chartCode The chart code to be used as one of the criterias to retrieve the payment request documents. 187 * @return The iterator of the list of the resulting payment request documents returned by the paymentRequestDao. 188 */ 189 public Collection<PaymentRequestDocument> getImmediatePaymentRequestsToExtract(String chartCode); 190 191 /** 192 * Get all the payment requests that match a credit memo. 193 * 194 * @param cmd The credit memo document to be used to obtain the payment requests. 195 * @return The iterator of the resulting payment request documents returned by the paymentRequestDao. 196 */ 197 public Collection<PaymentRequestDocument> getPaymentRequestsToExtractByCM(String campusCode, VendorCreditMemoDocument cmd); 198 199 /** 200 * Get all the payment requests that match a vendor. 201 * 202 * @param vendor 203 * @param onOrBeforePaymentRequestPayDate 204 * only payment requests with a pay date on or before this date will be extracted 205 * @return Collection of the resulting payment request documents returned by the paymentRequestDao. 206 */ 207 public Collection<PaymentRequestDocument> getPaymentRequestsToExtractByVendor(String campusCode, VendorGroupingHelper vendor, Date onOrBeforePaymentRequestPayDate); 208 209 /** 210 * Get all the payment requests that need to be extracted. 211 * 212 * @return The Collection of the resulting payment request documents returned by the paymentRequestDao. 213 */ 214 public Collection<PaymentRequestDocument> getPaymentRequestsToExtract(Date onOrBeforePaymentRequestPayDate); 215 216 /** 217 * Get all the special payment requests for a single chart that need to be extracted. 218 * 219 * @param chartCode The chart code to be used as one of the criterias to retrieve the payment request documents. 220 * @return The Collection of the resulting payment request documents returned by the paymentRequestDao. 221 */ 222 public Collection<PaymentRequestDocument> getPaymentRequestsToExtractSpecialPayments(String chartCode, Date onOrBeforePaymentRequestPayDate); 223 224 /** 225 * Get all the regular payment requests for a single campus. 226 * 227 * @param chartCode The chart code to be used as one of the criterias to retrieve the payment request documents. 228 * @return The collection of the resulting payment request documents returned by the paymentRequestDao. 229 */ 230 public Collection<PaymentRequestDocument> getPaymentRequestToExtractByChart(String chartCode, Date onOrBeforePaymentRequestPayDate); 231 232 /** 233 * Recalculate the payment request. 234 * 235 * @param pr The payment request document to be calculated. 236 * @param updateDiscount boolean true if we also want to calculate the discount items for the payment request. 237 */ 238 public void calculatePaymentRequest(PaymentRequestDocument pr, boolean updateDiscount); 239 240 /** 241 * Performs calculations on the tax edit area, generates and adds NRA tax charge items as below the line items, with their accounting lines; 242 * the calculation will activate updates on the account summary tab and the general ledger entries as well. 243 * <p/> 244 * The non-resident alien (NRA) tax lines consist of four possible sets of tax lines: 245 * - Federal tax lines 246 * - Federal Gross up tax lines 247 * - State tax lines 248 * - State Gross up tax lines 249 * <p/> 250 * Federal tax lines are generated if the federal tax rate in the payment request is not zero. 251 * State tax lines are generated if the state tax rate in the payment request is not zero. 252 * Gross up tax lines are generated if the tax gross up indicator is set on the payment request and the tax rate is not zero. 253 * 254 * @param preq The payment request the NRA tax lines will be added to. 255 */ 256 public void calculateTaxArea(PaymentRequestDocument preq); 257 258 /** 259 * Populate payment request. 260 * 261 * @param preq The payment request document to be populated. 262 */ 263 public void populatePaymentRequest(PaymentRequestDocument preq); 264 265 /** 266 * Populate and save payment request. 267 * 268 * @param preq The payment request document to be populated and saved. 269 */ 270 public void populateAndSavePaymentRequest(PaymentRequestDocument preq) throws WorkflowException; 271 272 /** 273 * Retrieve a list of PREQs that aren't approved, check to see if they match specific requirements, then auto-approve them if 274 * possible. 275 * 276 * @return boolean true if the auto approval of payment requests has at least one error. 277 */ 278 public boolean autoApprovePaymentRequests(); 279 280 /** 281 * Checks whether the payment request document is eligible for auto approval. If so, then updates 282 * the status of the document to auto approved and calls the documentService to blanket approve 283 * the document, then returns false. 284 * If the document is not eligible for auto approval then returns true. 285 * 286 * @param docNumber The payment request document number (not the payment request ID) to be auto approved. 287 * @param defaultMinimumLimit The default minimum limit amount to be used in determining the eligibility of the document to be auto approved. 288 * @return boolean true if the payment request document is not eligible for auto approval. 289 * @throws RuntimeException To indicate to Spring transactional management that the transaction for this document should be rolled back 290 */ 291 public boolean autoApprovePaymentRequest(String docNumber, KualiDecimal defaultMinimumLimit); 292 293 public boolean autoApprovePaymentRequest(PaymentRequestDocument doc); 294 295 /** 296 * Checks whether the payment request document is eligible for auto approval. If so, then updates 297 * the status of the document to auto approved and calls the documentService to blanket approve 298 * the document, then returns false. 299 * If the document is not eligible for auto approval then returns true. 300 * 301 * @param doc The payment request document to be auto approved. 302 * @param defaultMinimumLimit The default minimum limit amount to be used in determining the eligibility of the document to be auto approved. 303 * @return boolean true if the payment request document is not eligible for auto approval. 304 * @throws RuntimeException To indicate to Spring transactional management that the transaction for this document should be rolled back 305 */ 306 public boolean autoApprovePaymentRequest(PaymentRequestDocument doc, KualiDecimal defaultMinimumLimit); 307 308 /** 309 * Mark a payment request as being paid and set the payment request's paid date as the processDate. 310 * 311 * @param pr The payment request document to be marked as paid and paid date to be set. 312 * @param processDate The date to be set as the payment request's paid date. 313 */ 314 public void markPaid(PaymentRequestDocument pr, Date processDate); 315 316 /** 317 * This method specifies whether the payment request document has a discount item. 318 * 319 * @param preq The payment request document to be verified whether it has a discount item. 320 * @return boolean true if the payment request document has at least one discount item. 321 */ 322 public boolean hasDiscountItem(PaymentRequestDocument preq); 323 324 /** 325 * Changes the current vendor to the vendor passed in. 326 * 327 * @param preq 328 * @param headerId 329 * @param detailId 330 */ 331 public void changeVendor(PaymentRequestDocument preq, Integer headerId, Integer detailId); 332 333 /** 334 * A method to create the description for the payment request document. 335 * 336 * @param purchaseOrderIdentifier The purchase order identifier to be used as part of the description. 337 * @param vendorName The vendor name to be used as part of the description. 338 * @return The resulting description string for the payment request document. 339 */ 340 public String createPreqDocumentDescription(Integer purchaseOrderIdentifier, String vendorName); 341 342 /** 343 * Determines if there are active payment requests for a purchase order. 344 * 345 * @param purchaseOrderIdentifier 346 * @return 347 */ 348 public boolean hasActivePaymentRequestsForPurchaseOrder(Integer purchaseOrderIdentifier); 349 350 public void processPaymentRequestInReceivingStatus(); 351 352 /** 353 * Payment Requests created in the previous fiscal year get backdated if we're at the beginning of the new fiscal year (i.e. 354 * prior to first closing) 355 * 356 * @param paymentRequestDocument 357 * @return 358 */ 359 public boolean allowBackpost(PaymentRequestDocument paymentRequestDocument); 360 361 public boolean isPurchaseOrderValidForPaymentRequestDocumentCreation(PaymentRequestDocument paymentRequestDocument, PurchaseOrderDocument po); 362 363 /** 364 * Removes additional charge items that are not eligible on the payment request document. 365 * 366 * @param document 367 */ 368 public void removeIneligibleAdditionalCharges(PaymentRequestDocument document); 369 370 public boolean encumberedItemExistsForInvoicing(PurchaseOrderDocument document); 371 372 /** 373 * Clears tax info. 374 * 375 * @param document The disbursement voucher document being modified. 376 */ 377 public void clearTax(PaymentRequestDocument document); 378 } 379