use of edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class GlTransactionStep method execute.
/**
* Execute
*
* @param jobName Job Name
* @param jobRunDate Job Date
* @see org.kuali.kfs.kns.bo.Step#execute(java.lang.String, java.util.Date)
*/
public boolean execute(String jobName, Date jobRunDate) throws InterruptedException {
LOG.info("Started GlTransactionStep @ " + (new Date()).toString());
LOG.info("Get Bank List");
Collection<Bank> banks = businessObjectService.findAll(Bank.class);
List<String> bankCodes = null;
Collection<PaymentGroup> paymentGroups = null;
Map<String, Object> fieldValues = null;
Collection<CheckReconciliation> records = null;
// Stop payments
fieldValues = new HashMap<String, Object>();
fieldValues.put("glTransIndicator", "N");
fieldValues.put("status", CRConstants.STOP);
fieldValues.put("sourceCode", CRConstants.PDP_SRC);
records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
for (CheckReconciliation cr : records) {
bankCodes = new ArrayList<String>();
// Generate list of valid bank codes
setBankCodes(banks, cr, bankCodes);
if (bankCodes.size() > 0) {
paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
if (paymentGroups.isEmpty()) {
LOG.warn("No payment group found id : " + cr.getId());
} else {
for (PaymentGroup paymentGroup : paymentGroups) {
// KFSUPGRADE-636
// Create cancellation offsets for STOPed checks. KFSPTS-1741
glPendingTransactionService.generateStopGeneralLedgerPendingEntry(paymentGroup);
// glTransactionService.generateGlPendingTransactionStop(paymentGroup);
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
paymentGroup.setPaymentStatus((PaymentStatus) code);
}
Date lastUpdate = cr.getStatusChangeDate();
if (ObjectUtils.isNull(lastUpdate)) {
lastUpdate = new Date();
}
paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
businessObjectService.save(paymentGroup);
// Update status
cr.setGlTransIndicator(Boolean.TRUE);
businessObjectService.save(cr);
LOG.info("Generated Stop GL Pending Transacation");
}
}
}
}
// Canceled payments
fieldValues = new HashMap<String, Object>();
fieldValues.put("glTransIndicator", "N");
fieldValues.put("status", CRConstants.CANCELLED);
fieldValues.put("sourceCode", CRConstants.PDP_SRC);
records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
for (CheckReconciliation cr : records) {
bankCodes = new ArrayList<String>();
// Generate list of valid bank codes
setBankCodes(banks, cr, bankCodes);
if (bankCodes.size() > 0) {
paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
if (paymentGroups.isEmpty()) {
LOG.warn("No payment group found id : " + cr.getId());
} else {
for (PaymentGroup paymentGroup : paymentGroups) {
// KFSPTS-2260
glPendingTransactionService.generateCRCancellationGeneralLedgerPendingEntry(paymentGroup);
// glTransactionService.generateGlPendingTransactionCancel(paymentGroup);
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
paymentGroup.setPaymentStatus((PaymentStatus) code);
}
Date lastUpdate = cr.getStatusChangeDate();
if (ObjectUtils.isNull(lastUpdate)) {
lastUpdate = new Date();
}
paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
businessObjectService.save(paymentGroup);
// update cancel flag on payment details
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
// paymentDetail.refreshReferenceObject("extension");
PaymentDetailExtendedAttribute extendedAttribute = (PaymentDetailExtendedAttribute) paymentDetail.getExtension();
extendedAttribute.setCrCancelledPayment(Boolean.TRUE);
businessObjectService.save(paymentDetail);
}
// Update status
cr.setGlTransIndicator(Boolean.TRUE);
businessObjectService.save(cr);
LOG.info("Generated Cancelled GL Pending Transacation");
}
}
}
}
// VOID payments
fieldValues = new HashMap<String, Object>();
fieldValues.put("glTransIndicator", "N");
fieldValues.put("status", CRConstants.VOIDED);
fieldValues.put("sourceCode", CRConstants.PDP_SRC);
records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
for (CheckReconciliation cr : records) {
bankCodes = new ArrayList<String>();
// Generate list of valid bank codes
setBankCodes(banks, cr, bankCodes);
if (bankCodes.size() > 0) {
paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
if (paymentGroups.isEmpty()) {
LOG.warn("No payment group found id : " + cr.getId());
} else {
for (PaymentGroup paymentGroup : paymentGroups) {
// Do not generate GL tarsactions for VIODED trasactions
// glTransactionService.generateGlPendingTransactionStop(paymentGroup);
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
paymentGroup.setPaymentStatus((PaymentStatus) code);
}
Date lastUpdate = cr.getStatusChangeDate();
if (ObjectUtils.isNull(lastUpdate)) {
lastUpdate = new Date();
}
paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
businessObjectService.save(paymentGroup);
// Update status
cr.setGlTransIndicator(Boolean.TRUE);
businessObjectService.save(cr);
LOG.info("Generated VOID GL Pending Transacation");
}
}
}
}
// Stale payments
fieldValues = new HashMap<String, Object>();
fieldValues.put("glTransIndicator", "N");
fieldValues.put("status", CRConstants.STALE);
fieldValues.put("sourceCode", CRConstants.PDP_SRC);
records = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
for (CheckReconciliation cr : records) {
bankCodes = new ArrayList<String>();
// Generate list of valid bank codes
setBankCodes(banks, cr, bankCodes);
if (bankCodes.size() > 0) {
paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
if (paymentGroups.isEmpty()) {
LOG.warn("No payment group found id : " + cr.getId());
} else {
for (PaymentGroup paymentGroup : paymentGroups) {
// KFSPTS-2246
glPendingTransactionService.generateStaleGeneralLedgerPendingEntry(paymentGroup);
// glPendingTransactionService.g .generateStaleGeneralLedgerPendingEntry(paymentGroup);
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, cr.getStatus());
if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
paymentGroup.setPaymentStatus((PaymentStatus) code);
}
Date lastUpdate = cr.getStatusChangeDate();
if (ObjectUtils.isNull(lastUpdate)) {
lastUpdate = new Date();
}
paymentGroup.setLastUpdatedTimestamp(new Timestamp(lastUpdate.getTime()));
businessObjectService.save(paymentGroup);
// Update status
cr.setGlTransIndicator(Boolean.TRUE);
businessObjectService.save(cr);
LOG.info("Generated Stale GL Pending Transacation");
}
}
}
}
LOG.info("Completed GlTransactionStep @ " + (new Date()).toString());
return true;
}
use of edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class PaymentDetail method postPersist.
@Override
public void postPersist() {
super.postPersist();
// add extended attribute
PaymentDetailExtendedAttribute paymentDetailExtendedAttribute = new PaymentDetailExtendedAttribute();
paymentDetailExtendedAttribute.setId(this.getId());
paymentDetailExtendedAttribute.setCrCancelledPayment(false);
this.setExtension(paymentDetailExtendedAttribute);
SpringContext.getBean(BusinessObjectService.class).save(paymentDetailExtendedAttribute);
}
use of edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute 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