Search in sources :

Example 11 with PaymentGroup

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

the class AchBundlerAdviceDaoObj method getDistinctDisbursementNumbersForAchPaymentsNeedingAdviceNotification.

// KFSPTS-1460
/**
 * Returns distinct disbursement numbers for ACH payments needing advice email notifications.
 *
 * NOTE:
 * This method was made transactional per fix described in KULRICE-6914 for the iterator no longer
 * containing the data and iter.hasNext() causing a run time exception.
 *
 * @return an iterator of Disbursement Numbers matching the given criteria
 */
@Transactional
public HashSet<Integer> getDistinctDisbursementNumbersForAchPaymentsNeedingAdviceNotification() {
    LOG.debug("getDistinctDisbursementNumbersForAchPaymentsNeedingAdviceNotification() started");
    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.EXTRACTED);
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    criteria.addIsNull(PdpPropertyConstants.ADVICE_EMAIL_SENT_DATE);
    QueryByCriteria disbursementNumbersQuery = QueryFactory.newQuery(PaymentGroup.class, criteria);
    Iterator iter = getPersistenceBrokerTemplate().getIteratorByQuery(disbursementNumbersQuery);
    // used to pair down to distinct disbursement numbers
    HashSet<Integer> results = new HashSet<Integer>();
    while (iter.hasNext()) {
        PaymentGroup pg = (PaymentGroup) iter.next();
        results.add(new Integer(pg.getDisbursementNbr().toString()));
    }
    return results;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Iterator(java.util.Iterator) QueryByCriteria(org.apache.ojb.broker.query.QueryByCriteria) Criteria(org.apache.ojb.broker.query.Criteria) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with PaymentGroup

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

the class AchBundlerFormatServiceImpl method performFormat.

/**
 ************************************************************************************************
 *     MODS START HERE
 *************************************************************************************************
 */
/**
 * MOD: Overridden to detect if the Bundle ACH Payments system parameter is on and if so, to
 * call the new helper method
 * @see org.kuali.kfs.pdp.service.FormatService#performFormat(java.lang.Integer)
 */
@Override
public void performFormat(Integer processId) throws FormatException {
    LOG.debug("performFormat() started - ACH Bundler Mod");
    // get the PaymentProcess for the given id
    @SuppressWarnings("rawtypes") Map primaryKeys = new HashMap();
    primaryKeys.put(PdpPropertyConstants.PaymentProcess.PAYMENT_PROCESS_ID, processId);
    PaymentProcess paymentProcess = (PaymentProcess) businessObjectService.findByPrimaryKey(PaymentProcess.class, primaryKeys);
    if (paymentProcess == null) {
        LOG.error("performFormat() Invalid proc ID " + processId);
        throw new RuntimeException("Invalid proc ID");
    }
    String processCampus = paymentProcess.getCampusCode();
    FormatProcessSummary postFormatProcessSummary = new FormatProcessSummary();
    // step 1 get ACH or Check, Bank info, ACH info, sorting
    Iterator<PaymentGroup> paymentGroupIterator = SpringContext.getBean(PaymentGroupService.class).getByProcess(paymentProcess);
    while (paymentGroupIterator.hasNext()) {
        PaymentGroup paymentGroup = paymentGroupIterator.next();
        LOG.debug("performFormat() Step 1 Payment Group ID " + paymentGroup.getId());
        // process payment group data
        boolean groupProcessed = processPaymentGroup(paymentGroup, paymentProcess);
        if (!groupProcessed) {
            throw new FormatException("Error encountered during format");
        }
        // save payment group
        businessObjectService.save(paymentGroup);
        // Add to summary information
        postFormatProcessSummary.add(paymentGroup);
    }
    /**
     * MOD: This mod calls a new method that bundles both Checks
     * and ACHs into single disbursements.
     */
    boolean disbursementNumbersAssigned = false;
    if (getAchBundlerHelperService().shouldBundleAchPayments()) {
        LOG.info("ACH BUNDLER MOD: ACTIVE - bundling ACH payments");
        disbursementNumbersAssigned = assignDisbursementNumbersAndBundle(paymentProcess, postFormatProcessSummary);
    } else {
        // KFSPTS-1460: Our method signature for FormatServiceImpl.assignDisbursementNumbersAndCombineChecks did not
        // match this method call: disbursementNumbersAssigned = assignDisbursementNumbersAndCombineChecks(paymentProcess, postFormatProcessSummary);
        // Added parameter "processCampus" so method signatures matched.
        LOG.info("ACH BUNDLER MOD: NOT Active - ACH payments will NOT be bundled");
        disbursementNumbersAssigned = assignDisbursementNumbersAndCombineChecks(paymentProcess, postFormatProcessSummary);
    }
    if (!disbursementNumbersAssigned) {
        throw new FormatException("Error encountered during format");
    }
    // step 3 save the summarizing info
    LOG.debug("performFormat() Save summarizing information");
    postFormatProcessSummary.save();
    // step 4 set formatted indicator to true and save in the db
    paymentProcess.setFormattedIndicator(true);
    businessObjectService.save(paymentProcess);
    // step 5 end the format process for this campus
    LOG.debug("performFormat() End the format process for this campus");
    endFormatProcess(processCampus);
/**
 * MOD: No longer automatically kick off the extractChecks process.  This has to be scheduled in the batch system or run manually there.
 * Otherwise, may conflict with grouping by payee done.
 */
// step 6 tell the extract batch job to start
// LOG.debug("performFormat() Start extract");
// extractChecks();
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) PaymentProcess(org.kuali.kfs.pdp.businessobject.PaymentProcess) FormatProcessSummary(org.kuali.kfs.pdp.businessobject.FormatProcessSummary) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PaymentGroupService(org.kuali.kfs.pdp.service.PaymentGroupService) FormatException(org.kuali.kfs.pdp.service.impl.exception.FormatException)

Example 13 with PaymentGroup

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

the class AchBundlerHelperServiceImpl method getDistinctDisbursementNumbersForPendingAchPaymentsByBankCode.

/**
 * Finds all of the distinct disbursement numbers for pending ACH payments by a specific bankd code.
 * @see com.rsmart.kuali.kfs.pdp.service.AchBundlerHelperService#getDistinctDisbursementNumbersForPendingAchPaymentsByBankCode(java.lang.String)
 */
public HashSet<Integer> getDistinctDisbursementNumbersForPendingAchPaymentsByBankCode(String bankCode) {
    Map fieldValues = new HashMap();
    fieldValues.put(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    fieldValues.put(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.PENDING_ACH);
    fieldValues.put(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);
    List<PaymentGroup> paymentGroupList = (List<PaymentGroup>) getBusinessObjectService().findMatching(PaymentGroup.class, fieldValues);
    // used to pair down to distinct bank codes
    HashSet<Integer> results = new HashSet<Integer>();
    for (PaymentGroup pg : paymentGroupList) {
        results.add(new Integer(pg.getDisbursementNbr().toString()));
    }
    return results;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 14 with PaymentGroup

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

the class AchBundlerHelperServiceImpl method getDistinctBankCodesForPendingAchPayments.

/**
 * Finds all of the distinct bank codes for pending ACH payments.
 * @return a unique sorted List of bank codes
 */
public HashSet<String> getDistinctBankCodesForPendingAchPayments() {
    Map fieldValues = new HashMap();
    fieldValues.put(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, PdpConstants.DisbursementTypeCodes.ACH);
    fieldValues.put(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PAYMENT_STATUS_CODE, PdpConstants.PaymentStatusCodes.PENDING_ACH);
    List<PaymentGroup> paymentGroupList = (List<PaymentGroup>) getBusinessObjectService().findMatching(PaymentGroup.class, fieldValues);
    // used to pair down to distinct bank codes
    HashSet<String> results = new HashSet<String>();
    for (PaymentGroup pg : paymentGroupList) {
        results.add(pg.getBankCode());
    }
    return results;
}
Also used : PaymentGroup(org.kuali.kfs.pdp.businessobject.PaymentGroup) HashMap(java.util.HashMap) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 15 with PaymentGroup

use of org.kuali.kfs.pdp.businessobject.PaymentGroup 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)

Aggregations

PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)25 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)11 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)9 HashMap (java.util.HashMap)7 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)7 Date (java.util.Date)6 BufferedWriter (java.io.BufferedWriter)5 IOException (java.io.IOException)5 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)5 FileWriter (java.io.FileWriter)4 Timestamp (java.sql.Timestamp)4 Iterator (java.util.Iterator)4 List (java.util.List)4 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 PaymentStatus (org.kuali.kfs.pdp.businessobject.PaymentStatus)3 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)3 CuDisbursementVoucherDocument (edu.cornell.kfs.fp.document.CuDisbursementVoucherDocument)2