use of org.kuali.kfs.krad.bo.KualiCode in project cu-kfs by CU-CommunityApps.
the class CheckReconciliationImportStep method updateCheckStatus.
/**
* Get Check Status and update pdp
*
* @param cr Check Reconciliation Object
* @return String
*/
private String updateCheckStatus(CheckReconciliation cr, Collection<Bank> banks, List<CheckReconError> records) throws Exception {
String defaultStatus = CRConstants.EXCP;
String oldStatus = CRConstants.EXCP;
List<String> bankCodes = new ArrayList<String>();
// Generate list of valid bank codes
for (Bank bank : banks) {
if (bank.getBankAccountNumber().equals(cr.getBankAccountNumber())) {
bankCodes.add(bank.getBankCode());
}
}
if (bankCodes.size() == 0) {
throw new Exception("Invalid Bank Account Number : " + cr.getBankAccountNumber());
}
Collection<PaymentGroup> paymentGroups = glTransactionService.getAllPaymentGroupForSearchCriteria(cr.getCheckNumber(), bankCodes);
KualiDecimal totalNetAmount = getTotalNetAmount(paymentGroups);
for (PaymentGroup paymentGroup : paymentGroups) {
/*
* At Cornell Check amount may consist of one or more payment group amounts.
*
if( !cr.getAmount().equals(paymentGroup.getNetPaymentAmount()) ) {
records.add(getCheckReconError(cr, "The check amount does not match payment net amount."));
}
*/
if (!(totalNetAmount.doubleValue() == cr.getAmount().doubleValue())) {
records.add(getCheckReconError(cr, "The check amount does not match payment net amount from the payment groups."));
}
if (statusMap.get(cr.getStatus()) != null) {
defaultStatus = statusMap.get(cr.getStatus());
oldStatus = paymentGroup.getPaymentStatusCode();
// Update PDP status and save
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, defaultStatus);
if (paymentGroup.getPaymentStatus() != ((PaymentStatus) code)) {
paymentGroup.setPaymentStatus((PaymentStatus) code);
paymentGroup.setLastUpdatedTimestamp(new Timestamp(cr.getStatusChangeDate().getTime()));
}
if (defaultStatus.equals(CRConstants.CLEARED)) {
if (PaymentStatusCodes.EXTRACTED.equals(oldStatus)) {
businessObjectService.save(paymentGroup);
LOG.info("Check Status in the bank file is cleared. Updated Payment Group : " + paymentGroup.getId() + " Disbursement " + paymentGroup.getDisbursementNbr());
} else {
LOG.warn("Check Status in the bank file is cleared, but Payment Group " + paymentGroup.getId() + " for Disbursement " + paymentGroup.getDisbursementNbr() + " has a current status of " + oldStatus + " and cannot be cleared.");
}
}
} else {
LOG.warn("Update Payment Group Failed ( " + cr.getStatus() + ") ID : " + paymentGroup.getId());
}
}
if (paymentGroups == null) {
LOG.info("No Payments Found : " + cr.getBankAccountNumber() + "-" + cr.getCheckNumber());
} else if (paymentGroups.size() == 0) {
LOG.info("No Payments Found : " + cr.getBankAccountNumber() + "-" + cr.getCheckNumber());
}
return defaultStatus;
}
use of org.kuali.kfs.krad.bo.KualiCode 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 org.kuali.kfs.krad.bo.KualiCode in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherPaymentMaintenanceServiceImpl method changeStatus.
/**
*}
* Copied from PaymentMaintenanceServiceImpl
* @param paymentGroup
* @param newPaymentStatus
* @param changeStatus
* @param note
* @param user
*/
protected void changeStatus(PaymentGroup paymentGroup, String newPaymentStatus, String changeStatus, String note, Person user) {
if (LOG.isDebugEnabled()) {
LOG.debug("changeStatus() enter method with new status of " + newPaymentStatus);
}
PaymentGroupHistory paymentGroupHistory = new PaymentGroupHistory();
KualiCode cd = businessObjectService.findBySinglePrimaryKey(PaymentChangeCode.class, changeStatus);
paymentGroupHistory.setPaymentChange((PaymentChangeCode) cd);
paymentGroupHistory.setOrigPaymentStatus(paymentGroup.getPaymentStatus());
paymentGroupHistory.setChangeUser(user);
paymentGroupHistory.setChangeNoteText(note);
paymentGroupHistory.setPaymentGroup(paymentGroup);
paymentGroupHistory.setChangeTime(new Timestamp(new Date().getTime()));
this.businessObjectService.save(paymentGroupHistory);
KualiCode code = businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, newPaymentStatus);
paymentGroup.setPaymentStatus((PaymentStatus) code);
this.businessObjectService.save(paymentGroup);
LOG.debug("changeStatus() Status has been changed; exit method.");
}
Aggregations