Search in sources :

Example 1 with CreditMemoService

use of org.kuali.kfs.module.purap.document.service.CreditMemoService in project cu-kfs by CU-CommunityApps.

the class CuPurchasingAccountsPayableModuleServiceImpl method handlePurchasingBatchCancels.

/**
 * @see org.kuali.kfs.integration.pdp.service.PurchasingAccountsPayableModuleService#handlePurchasingBatchCancels(java.lang.String)
 */
public void handlePurchasingBatchCancels(String documentNumber, String documentTypeCode, boolean primaryCancel, boolean disbursedPayment, boolean crCancel) {
    ParameterService parameterService = SpringContext.getBean(ParameterService.class);
    PaymentRequestService paymentRequestService = SpringContext.getBean(PaymentRequestService.class);
    CreditMemoService creditMemoService = SpringContext.getBean(CreditMemoService.class);
    String preqCancelNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, PurapParameterConstants.PURAP_PDP_PREQ_CANCEL_NOTE);
    String preqResetNote = parameterService.getParameterValueAsString(PaymentRequestDocument.class, PurapParameterConstants.PURAP_PDP_PREQ_RESET_NOTE);
    String cmCancelNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, PurapParameterConstants.PURAP_PDP_CM_CANCEL_NOTE);
    String cmResetNote = parameterService.getParameterValueAsString(VendorCreditMemoDocument.class, PurapParameterConstants.PURAP_PDP_CM_RESET_NOTE);
    if (PurapConstants.PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT.equals(documentTypeCode)) {
        PaymentRequestDocument pr = paymentRequestService.getPaymentRequestByDocumentNumber(documentNumber);
        if (pr != null) {
            if (disbursedPayment || primaryCancel || crCancel) {
                if (!crCancel) {
                    paymentRequestService.cancelExtractedPaymentRequest(pr, preqCancelNote);
                }
            } else {
                paymentRequestService.resetExtractedPaymentRequest(pr, preqResetNote);
            }
        } else {
            LOG.error("processPdpCancels() DOES NOT EXIST, CANNOT PROCESS - Payment Request with doc type of " + documentTypeCode + " with id " + documentNumber);
        }
    } else if (PurapConstants.PurapDocTypeCodes.CREDIT_MEMO_DOCUMENT.equals(documentTypeCode)) {
        VendorCreditMemoDocument cm = creditMemoService.getCreditMemoByDocumentNumber(documentNumber);
        if (cm != null) {
            if (disbursedPayment || primaryCancel || crCancel) {
                if (!crCancel) {
                    creditMemoService.cancelExtractedCreditMemo(cm, cmCancelNote);
                }
            } else {
                creditMemoService.resetExtractedCreditMemo(cm, cmResetNote);
            }
        } else {
            LOG.error("processPdpCancels() DOES NOT EXIST, CANNOT PROCESS - Credit Memo with doc type of " + documentTypeCode + " with id " + documentNumber);
        }
    }
}
Also used : VendorCreditMemoDocument(org.kuali.kfs.module.purap.document.VendorCreditMemoDocument) ParameterService(org.kuali.kfs.coreservice.framework.parameter.ParameterService) PaymentRequestService(org.kuali.kfs.module.purap.document.service.PaymentRequestService) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) CreditMemoService(org.kuali.kfs.module.purap.document.service.CreditMemoService)

Aggregations

ParameterService (org.kuali.kfs.coreservice.framework.parameter.ParameterService)1 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)1 VendorCreditMemoDocument (org.kuali.kfs.module.purap.document.VendorCreditMemoDocument)1 CreditMemoService (org.kuali.kfs.module.purap.document.service.CreditMemoService)1 PaymentRequestService (org.kuali.kfs.module.purap.document.service.PaymentRequestService)1