Search in sources :

Example 1 with PaymentDetailExtendedAttribute

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;
}
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 2 with PaymentDetailExtendedAttribute

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);
}
Also used : PaymentDetailExtendedAttribute(edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 3 with 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);
}
Also used : CuPurchasingAccountsPayableModuleService(edu.cornell.kfs.integration.purap.CuPurchasingAccountsPayableModuleService) PaymentDetailExtendedAttribute(edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) PaymentSource(org.kuali.kfs.sys.document.PaymentSource) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PaymentDetailExtendedAttribute (edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute)3 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)1 CuPurchasingAccountsPayableModuleService (edu.cornell.kfs.integration.purap.CuPurchasingAccountsPayableModuleService)1 Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 KualiCode (org.kuali.kfs.krad.bo.KualiCode)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)1 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)1 PaymentStatus (org.kuali.kfs.pdp.businessobject.PaymentStatus)1 Bank (org.kuali.kfs.sys.businessobject.Bank)1 PaymentSource (org.kuali.kfs.sys.document.PaymentSource)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1 Transactional (org.springframework.transaction.annotation.Transactional)1