use of org.kuali.kfs.sys.document.PaymentSource in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method extractImmediatePaymentsForCampus.
/**
* Builds payment batch for Disbursement Vouchers marked as immediate
*
* @param campusCode the campus code the disbursement vouchers should be associated with
* @param user the user responsible building the payment batch (typically the System User, kfs)
* @param processRunDate the time that the job to build immediate payments is run
*/
protected void extractImmediatePaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
LOG.debug("extractImmediatesPaymentsForCampus() started for campus: " + campusCode);
if (!documents.isEmpty()) {
final PaymentSource firstPaymentSource = documents.get(0);
Batch batch = createBatch(campusCode, principalId, processRunDate);
Integer count = 0;
KualiDecimal totalAmount = KualiDecimal.ZERO;
for (PaymentSource document : documents) {
if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
addPayment(document, batch, processRunDate, false);
count++;
totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
}
}
batch.setPaymentCount(new KualiInteger(count));
batch.setPaymentTotalAmount(totalAmount);
businessObjectService.save(batch);
paymentFileEmailService.sendLoadEmail(batch);
}
}
use of org.kuali.kfs.sys.document.PaymentSource in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method extractPaymentsForCampus.
/**
* This method extracts all outstanding payments from all the disbursement vouchers in approved status for a given campus and
* adds these payments to a batch file that is uploaded for processing.
*
* @param campusCode The id code of the campus the payments will be retrieved for.
* @param user The user object used when creating the batch file to upload with outstanding payments.
* @param processRunDate This is the date that the batch file is created, often this value will be today's date.
*/
protected void extractPaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
if (LOG.isDebugEnabled()) {
LOG.debug("extractPaymentsForCampus() started for campus: " + campusCode);
}
Batch batch = createBatch(campusCode, principalId, processRunDate);
Integer count = 0;
KualiDecimal totalAmount = KualiDecimal.ZERO;
for (PaymentSource document : documents) {
if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
addPayment(document, batch, processRunDate, false);
count++;
totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
}
}
batch.setPaymentCount(new KualiInteger(count));
batch.setPaymentTotalAmount(totalAmount);
businessObjectService.save(batch);
paymentFileEmailService.sendLoadEmail(batch);
}
use of org.kuali.kfs.sys.document.PaymentSource in project cu-kfs by CU-CommunityApps.
the class CuProcessPdpCancelPaidServiceImpl method processPdpPaid.
/**
* Default implementation uses most of the "while" loop contents from the ProcessPdpCancelPaidServiceImpl.processPdpPaids method,
* with additional CU-related changes as needed. This implementation also runs within its own transaction.
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public void processPdpPaid(PaymentDetail paymentDetail, Date processDate) {
String documentTypeCode = paymentDetail.getFinancialDocumentTypeCode();
String documentNumber = paymentDetail.getCustPaymentDocNbr();
if (purchasingAccountsPayableModuleService.isPurchasingBatchDocument(documentTypeCode)) {
purchasingAccountsPayableModuleService.handlePurchasingBatchPaids(documentNumber, documentTypeCode, processDate);
} else {
PaymentSourceToExtractService<PaymentSource> extractService = getPaymentSourceToExtractService(paymentDetail);
if (extractService != null) {
try {
PaymentSource dv = (PaymentSource) documentService.getByDocumentHeaderId(documentNumber);
extractService.markAsPaid(dv, processDate);
} catch (WorkflowException we) {
throw new RuntimeException("Could not retrieve document #" + documentNumber, we);
}
} else {
LOG.warn("processPdpPaids() Unknown document type (" + documentTypeCode + ") for document ID: " + documentNumber);
return;
}
}
paymentGroupService.processPaidGroup(paymentDetail.getPaymentGroup(), processDate);
}
use of org.kuali.kfs.sys.document.PaymentSource 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