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);
}
Aggregations