Search in sources :

Example 1 with CuPurchasingAccountsPayableModuleService

use of edu.cornell.kfs.integration.purap.CuPurchasingAccountsPayableModuleService in project cu-kfs by CU-CommunityApps.

the class CuProcessPdpCancelPaidServiceImpl method processPdpCancel.

/**
 * Default implementation uses most of the "while" loop contents from the ProcessPdpCancelPaidServiceImpl.processPdpCancels method,
 * with additional CU-related changes as needed. This implementation also runs within its own transaction.
 */
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void processPdpCancel(PaymentDetail paymentDetail, Date processDate) {
    String documentTypeCode = paymentDetail.getFinancialDocumentTypeCode();
    String documentNumber = paymentDetail.getCustPaymentDocNbr();
    boolean primaryCancel = paymentDetail.getPrimaryCancelledPayment();
    boolean disbursedPayment = PdpConstants.PaymentStatusCodes.CANCEL_PAYMENT.equals(paymentDetail.getPaymentGroup().getPaymentStatusCode());
    // KFSPTS-2719
    boolean crCancel = false;
    PaymentDetailExtendedAttribute paymentDetailExtendedAttribute = (PaymentDetailExtendedAttribute) paymentDetail.getExtension();
    if (ObjectUtils.isNotNull(paymentDetailExtendedAttribute)) {
        crCancel = paymentDetailExtendedAttribute.getCrCancelledPayment();
    }
    if (purchasingAccountsPayableModuleService.isPurchasingBatchDocument(documentTypeCode)) {
        ((CuPurchasingAccountsPayableModuleService) purchasingAccountsPayableModuleService).handlePurchasingBatchCancels(documentNumber, documentTypeCode, primaryCancel, disbursedPayment, crCancel);
    } else {
        PaymentSourceToExtractService<PaymentSource> extractService = getPaymentSourceToExtractService(paymentDetail);
        if (extractService != null) {
            try {
                PaymentSource dv = (PaymentSource) documentService.getByDocumentHeaderId(documentNumber);
                if (dv != null) {
                    if (disbursedPayment || primaryCancel || crCancel) {
                        if (!crCancel) {
                            extractService.cancelPayment(dv, processDate);
                        }
                    } else {
                        extractService.resetFromExtraction(dv);
                    }
                }
            } catch (WorkflowException we) {
                throw new RuntimeException("Could not retrieve document #" + documentNumber, we);
            }
        } else {
            LOG.warn("processPdpCancel() Unknown document type (" + documentTypeCode + ") for document ID: " + documentNumber);
            return;
        }
    }
    paymentGroupService.processCancelledGroup(paymentDetail.getPaymentGroup(), processDate);
}
Also used : CuPurchasingAccountsPayableModuleService(edu.cornell.kfs.integration.purap.CuPurchasingAccountsPayableModuleService) PaymentDetailExtendedAttribute(edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) PaymentSource(org.kuali.kfs.sys.document.PaymentSource) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

CuPurchasingAccountsPayableModuleService (edu.cornell.kfs.integration.purap.CuPurchasingAccountsPayableModuleService)1 PaymentDetailExtendedAttribute (edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute)1 PaymentSource (org.kuali.kfs.sys.document.PaymentSource)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1 Transactional (org.springframework.transaction.annotation.Transactional)1