Search in sources :

Example 1 with PaymentStatus

use of org.kuali.kfs.pdp.businessobject.PaymentStatus 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;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Bank(org.kuali.kfs.sys.businessobject.Bank) KualiCode(org.kuali.kfs.krad.bo.KualiCode) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) Timestamp(java.sql.Timestamp) ParseException(java.text.ParseException) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Example 2 with PaymentStatus

use of org.kuali.kfs.pdp.businessobject.PaymentStatus 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;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Bank(org.kuali.kfs.sys.businessobject.Bank) KualiCode(org.kuali.kfs.krad.bo.KualiCode) PaymentDetailExtendedAttribute(edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute) Timestamp(java.sql.Timestamp) Date(java.util.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Example 3 with PaymentStatus

use of org.kuali.kfs.pdp.businessobject.PaymentStatus in project cu-kfs by CU-CommunityApps.

the class CuExtractPaymentServiceImpl method extractAchPayments.

/**
 * MOD: Overridden to detect if the Bundle ACH Payments system parameter is on and if so, to
 * call the new extraction bundler method
 * @see org.kuali.kfs.pdp.batch.service.ExtractPaymentService#extractAchPayments()
 */
@Override
public void extractAchPayments() {
    LOG.debug("MOD - extractAchPayments() started");
    Date processDate = dateTimeService.getCurrentDate();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    PaymentStatus extractedStatus = (PaymentStatus) businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.EXTRACTED);
    String achFilePrefix = kualiConfigurationService.getPropertyValueAsString(PdpKeyConstants.ExtractPayment.ACH_FILENAME);
    achFilePrefix = MessageFormat.format(achFilePrefix, new Object[] { null });
    String filename = getOutputFile(achFilePrefix, processDate);
    LOG.debug("MOD: extractAchPayments() filename = " + filename);
    /**
     * MOD: This is the only section in the method that is changed.  This mod calls a new method that bundles
     * ACHs into single disbursements if the flag to do so is turned on.
     */
    if (getAchBundlerHelperService().shouldBundleAchPayments()) {
        writeExtractBundledAchFile(extractedStatus, filename, processDate, sdf);
    } else {
        writeExtractAchFile(extractedStatus, filename, processDate, sdf);
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Example 4 with PaymentStatus

use of org.kuali.kfs.pdp.businessobject.PaymentStatus in project cu-kfs by CU-CommunityApps.

the class CuFormatServiceImpl method startFormatProcess.

@Override
public FormatProcessSummary startFormatProcess(Person user, String campus, List<CustomerProfile> customers, Date paydate, String paymentTypes, String paymentDistribution) {
    LOG.debug("startFormatProcess() started");
    for (CustomerProfile element : customers) {
        LOG.debug("startFormatProcess() Customer: " + element);
    }
    // Create the process
    Date d = new Date();
    PaymentProcess paymentProcess = new PaymentProcess();
    paymentProcess.setCampusCode(campus);
    paymentProcess.setProcessUser(user);
    paymentProcess.setProcessTimestamp(new Timestamp(d.getTime()));
    this.businessObjectService.save(paymentProcess);
    // add an entry in the format process table (to lock the format process)
    FormatProcess formatProcess = new FormatProcess();
    formatProcess.setPhysicalCampusProcessCode(campus);
    formatProcess.setBeginFormat(dateTimeService.getCurrentTimestamp());
    formatProcess.setPaymentProcIdentifier(paymentProcess.getId().intValue());
    this.businessObjectService.save(formatProcess);
    Timestamp now = new Timestamp((new Date()).getTime());
    java.sql.Date sqlDate = new java.sql.Date(paydate.getTime());
    Calendar c = Calendar.getInstance();
    c.setTime(sqlDate);
    c.set(Calendar.HOUR, 11);
    c.set(Calendar.MINUTE, 59);
    c.set(Calendar.SECOND, 59);
    c.set(Calendar.MILLISECOND, 59);
    c.set(Calendar.AM_PM, Calendar.PM);
    Timestamp paydateTs = new Timestamp(c.getTime().getTime());
    LOG.debug("startFormatProcess() last update = " + now);
    LOG.debug("startFormatProcess() entered paydate = " + paydate);
    LOG.debug("startFormatProcess() actual paydate = " + paydateTs);
    PaymentStatus format = this.businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.FORMAT);
    List customerIds = new ArrayList();
    for (Iterator iter = customers.iterator(); iter.hasNext(); ) {
        CustomerProfile element = (CustomerProfile) iter.next();
        customerIds.add(element.getId());
    }
    // Mark all of them ready for format
    Iterator groupIterator = ((CuFormatPaymentDao) formatPaymentDao).markPaymentsForFormat(customerIds, paydateTs, paymentTypes, paymentDistribution);
    while (groupIterator.hasNext()) {
        PaymentGroup paymentGroup = (PaymentGroup) groupIterator.next();
        paymentGroup.setLastUpdatedTimestamp(paydateTs);
        paymentGroup.setPaymentStatus(format);
        paymentGroup.setProcess(paymentProcess);
        businessObjectService.save(paymentGroup);
    }
    // summarize them
    FormatProcessSummary preFormatProcessSummary = new FormatProcessSummary();
    Iterator<PaymentGroup> iterator = this.paymentGroupService.getByProcess(paymentProcess);
    while (iterator.hasNext()) {
        PaymentGroup paymentGroup = iterator.next();
        preFormatProcessSummary.add(paymentGroup);
    }
    // if no payments found for format clear the format process
    if (preFormatProcessSummary.getProcessSummaryList().size() == 0) {
        LOG.debug("startFormatProcess() No payments to process.  Format process ending");
        // ?? maybe call end format process
        clearUnfinishedFormat(paymentProcess.getId().intValue());
    }
    return preFormatProcessSummary;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) CustomerProfile(org.kuali.kfs.pdp.businessobject.CustomerProfile) FormatProcess(org.kuali.kfs.pdp.businessobject.FormatProcess) Timestamp(java.sql.Timestamp) Date(java.util.Date) PaymentProcess(org.kuali.kfs.pdp.businessobject.PaymentProcess) FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CuFormatPaymentDao(edu.cornell.kfs.pdp.dataaccess.CuFormatPaymentDao) PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Example 5 with PaymentStatus

use of org.kuali.kfs.pdp.businessobject.PaymentStatus in project cu-kfs by CU-CommunityApps.

the class CuFormatServiceImpl method processPaymentGroup.

protected boolean processPaymentGroup(PaymentGroup paymentGroup, PaymentProcess paymentProcess) {
    boolean successful = true;
    paymentGroup.setSortValue(paymentGroupService.getSortGroupId(paymentGroup));
    paymentGroup.setPhysCampusProcessCd(paymentProcess.getCampusCode());
    paymentGroup.setProcess(paymentProcess);
    populateDisbursementType(paymentGroup);
    if (StringUtils.equalsIgnoreCase(paymentGroup.getDisbursementTypeCode(), PdpConstants.DisbursementTypeCodes.CHECK)) {
        PaymentStatus paymentStatus = (PaymentStatus) businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.PENDING_CHECK);
        paymentGroup.setPaymentStatus(paymentStatus);
    } else {
        PaymentStatus paymentStatus = (PaymentStatus) businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.PENDING_ACH);
        paymentGroup.setPaymentStatus(paymentStatus);
    }
    // set payment group bank
    successful &= validateAndUpdatePaymentGroupBankCode(paymentGroup, paymentGroup.getDisbursementType(), paymentGroup.getBatch().getCustomerProfile());
    return successful;
}
Also used : PaymentStatus(org.kuali.kfs.pdp.businessobject.PaymentStatus)

Aggregations

PaymentStatus (org.kuali.kfs.pdp.businessobject.PaymentStatus)6 Date (java.util.Date)4 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)3 KualiCode (org.kuali.kfs.krad.bo.KualiCode)2 Bank (org.kuali.kfs.sys.businessobject.Bank)2 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 PaymentDetailExtendedAttribute (edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute)1 CuFormatPaymentDao (edu.cornell.kfs.pdp.dataaccess.CuFormatPaymentDao)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Test (org.junit.Test)1 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)1 FormatProcess (org.kuali.kfs.pdp.businessobject.FormatProcess)1 FormatProcessSummary (org.kuali.kfs.pdp.businessobject.FormatProcessSummary)1 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)1