use of org.kuali.kfs.pdp.businessobject.Batch in project cu-kfs by CU-CommunityApps.
the class PaymentFileServiceImpl method createNewBatch.
/**
* Create a new <code>Batch</code> record for the payment file.
*
* @param paymentFile parsed payment file object
* @param fileName payment file name (without path)
* @return <code>Batch<code> object
*/
protected Batch createNewBatch(PaymentFileLoad paymentFile, String fileName) {
Timestamp now = dateTimeService.getCurrentTimestamp();
Calendar nowPlus30 = Calendar.getInstance();
nowPlus30.setTime(now);
nowPlus30.add(Calendar.DATE, 30);
Calendar nowMinus30 = Calendar.getInstance();
nowMinus30.setTime(now);
nowMinus30.add(Calendar.DATE, -30);
Batch batch = new Batch();
CustomerProfile customer = customerProfileService.get(paymentFile.getChart(), paymentFile.getUnit(), paymentFile.getSubUnit());
batch.setCustomerProfile(customer);
batch.setCustomerFileCreateTimestamp(new Timestamp(paymentFile.getCreationDate().getTime()));
batch.setFileProcessTimestamp(now);
batch.setPaymentCount(new KualiInteger(paymentFile.getPaymentCount()));
if (fileName.length() > 30) {
batch.setPaymentFileName(fileName.substring(0, 30));
} else {
batch.setPaymentFileName(fileName);
}
batch.setPaymentTotalAmount(paymentFile.getPaymentTotalAmount());
batch.setSubmiterUserId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
return batch;
}
use of org.kuali.kfs.pdp.businessobject.Batch 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.pdp.businessobject.Batch in project cu-kfs by CU-CommunityApps.
the class PaymentSourceExtractionServiceImpl method createBatch.
/**
* This method creates a Batch instance and populates it with the information provided.
*
* @param campusCode The campus code used to retrieve a customer profile to be set on the batch.
* @param orgCode the organization code used to retrieve a customer profile to be set on the batch.
* @param subUnitCode the sub-unit code used to retrieve a customer profile to be set on the batch.
* @param user The user who submitted the batch.
* @param processRunDate The date the batch was submitted and the date the customer profile was generated.
* @return A fully populated batch instance.
*/
protected Batch createBatch(String campusCode, String principalId, Date processRunDate) {
final String orgCode = getPaymentSourceToExtractService().getPreDisbursementCustomerProfileUnit();
final String subUnitCode = getPaymentSourceToExtractService().getPreDisbursementCustomerProfileSubUnit();
CustomerProfile customer = customerProfileService.get(campusCode, orgCode, subUnitCode);
if (customer == null) {
throw new IllegalArgumentException("Unable to find customer profile for " + campusCode + "/" + orgCode + "/" + subUnitCode);
}
// Create the group for this campus
Batch batch = new Batch();
batch.setCustomerProfile(customer);
batch.setCustomerFileCreateTimestamp(new Timestamp(processRunDate.getTime()));
batch.setFileProcessTimestamp(new Timestamp(processRunDate.getTime()));
batch.setPaymentFileName(KFSConstants.DISBURSEMENT_VOUCHER_PDP_EXTRACT_FILE_NAME);
batch.setSubmiterUserId(principalId);
// Set these for now, we will update them later
batch.setPaymentCount(KualiInteger.ZERO);
batch.setPaymentTotalAmount(KualiDecimal.ZERO);
businessObjectService.save(batch);
return batch;
}
use of org.kuali.kfs.pdp.businessobject.Batch 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.pdp.businessobject.Batch in project cu-kfs by CU-CommunityApps.
the class PaymentFileServiceImpl method loadPayments.
/**
* @see org.kuali.kfs.pdp.service.PaymentFileService#loadPayments(java.lang.String)
*/
@Override
public void loadPayments(PaymentFileLoad paymentFile, LoadPaymentStatus status, String incomingFileName) {
status.setChart(paymentFile.getChart());
status.setUnit(paymentFile.getUnit());
status.setSubUnit(paymentFile.getSubUnit());
status.setCreationDate(paymentFile.getCreationDate());
status.setDetailCount(paymentFile.getActualPaymentCount());
status.setDetailTotal(paymentFile.getCalculatedPaymentTotalAmount());
// create batch record for payment load
Batch batch = createNewBatch(paymentFile, getBaseFileName(incomingFileName));
businessObjectService.save(batch);
paymentFile.setBatchId(batch.getId());
status.setBatchId(batch.getId());
// do warnings and set defaults
List<String> warnings = paymentFileValidationService.doSoftEdits(paymentFile);
status.setWarnings(warnings);
// store groups
for (PaymentGroup paymentGroup : paymentFile.getPaymentGroups()) {
businessObjectService.save(paymentGroup);
}
// send list of warnings
paymentFileEmailService.sendLoadEmail(paymentFile, warnings);
if (paymentFile.isTaxEmailRequired()) {
paymentFileEmailService.sendTaxEmail(paymentFile);
}
removeDoneFile(incomingFileName);
LOG.debug("loadPayments() was successful");
status.setLoadStatus(LoadPaymentStatus.LoadStatus.SUCCESS);
}
Aggregations