Search in sources :

Example 1 with CheckReconciliation

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationMaintainableImpl method doRouteStatusChange.

/**
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#doRouteStatusChange(org.kuali.kfs.kns.bo.DocumentHeader)
 */
public void doRouteStatusChange(DocumentHeader documentHeader) {
    WorkflowDocument workflowDocument = documentHeader.getWorkflowDocument();
    if (workflowDocument.isProcessed() && !KFSConstants.MAINTENANCE_NEW_ACTION.equalsIgnoreCase(getMaintenanceAction())) {
        DocumentService documentService = SpringContext.getBean(DocumentService.class);
        MaintenanceDocument document;
        try {
            document = (MaintenanceDocument) documentService.getByDocumentHeaderId(documentHeader.getDocumentNumber());
            CheckReconciliation oldCr = (CheckReconciliation) document.getOldMaintainableObject().getBusinessObject();
            CheckReconciliation newCr = (CheckReconciliation) document.getNewMaintainableObject().getBusinessObject();
            if (ObjectUtils.isNotNull(oldCr) && !oldCr.getStatus().equalsIgnoreCase(newCr.getStatus())) {
                Date currentDate = SpringContext.getBean(DateTimeService.class).getCurrentSqlDate();
                newCr.setStatusChangeDate(currentDate);
                // KFSUPGRADE-377
                if (CRConstants.CANCELLED.equalsIgnoreCase(newCr.getStatus())) {
                    newCr.setCancelDocHdrId(documentHeader.getDocumentNumber());
                }
            }
        } catch (WorkflowException e) {
            throw new RuntimeCacheException(e);
        }
    }
}
Also used : RuntimeCacheException(org.apache.ojb.broker.cache.RuntimeCacheException) WorkflowDocument(org.kuali.rice.kew.api.WorkflowDocument) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) DateTimeService(org.kuali.rice.core.api.datetime.DateTimeService) DocumentService(org.kuali.kfs.krad.service.DocumentService) Date(java.sql.Date)

Example 2 with CheckReconciliation

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationRule method processCustomRouteDocumentBusinessRules.

/**
 * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
 */
protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
    LOG.info("processCustomRouteDocumentBusinessRules called");
    setupConvenienceObjects();
    boolean valid = true;
    if (newCheckReconciliation.getAmount() == null) {
        putFieldError("amount", CRKeyConstants.ERROR_CR_INVALID_AMOUNT);
        valid = false;
    } else if (newCheckReconciliation.getAmount().isZero()) {
        if (oldCheckReconciliation != null && CRConstants.EXCP.equalsIgnoreCase(oldCheckReconciliation.getStatus()) && CRConstants.VOIDED.equalsIgnoreCase(newCheckReconciliation.getStatus())) {
            valid = true;
        } else {
            putFieldError("amount", CRKeyConstants.ERROR_CR_INVALID_AMOUNT);
            valid = false;
        }
    } else if (newCheckReconciliation.getAmount().isNegative()) {
        putFieldError("amount", CRKeyConstants.ERROR_CR_INVALID_AMOUNT);
        valid = false;
    }
    BusinessObjectService businessObjectService = SpringContext.getBean(BusinessObjectService.class);
    Map<String, Object> fieldValues = new HashMap<String, Object>();
    fieldValues.put("checkNumber", newCheckReconciliation.getCheckNumber());
    fieldValues.put("bankAccountNumber", newCheckReconciliation.getBankAccountNumber());
    Collection<CheckReconciliation> checks = businessObjectService.findMatching(CheckReconciliation.class, fieldValues);
    boolean isEdit = document.isEdit();
    if (checks.size() > 0 && !isEdit) {
        valid = false;
        putFieldError("checkNumber", "error.checkexists");
    }
    return valid;
}
Also used : HashMap(java.util.HashMap) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Example 3 with CheckReconciliation

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationImportStep method setCheckReconciliationAttributes.

/**
 * Set CheckReconciliation Attributes
 *
 * @param hash
 * @return
 * @throws ParseException
 */
private CheckReconciliation setCheckReconciliationAttributes(Map<Integer, String> hash) throws ParseException {
    String checkNumber = null;
    Date checkDate = null;
    KualiDecimal amount = null;
    String accountNumber = null;
    String status = null;
    Date issueDate = null;
    String payeeName = "";
    String payeeID = "";
    // Cornell Columns
    Integer payeeNameCol = Integer.parseInt("12");
    Integer issueDateCol = Integer.parseInt("7");
    Integer payeeIDCol = Integer.parseInt("6");
    checkNumber = hash.get(checkNumCol);
    String rawCheckDate = hash.get(checkDateCol);
    if (rawCheckDate == null || rawCheckDate.equals("") || rawCheckDate.equals("000000"))
        rawCheckDate = "991231";
    checkDate = getGregorianCalendar(rawCheckDate).getTime();
    // checkDate     = dateformat.parse(rawCheckDate);  //Date Paid
    amount = isAmountDecimalValue ? new KualiDecimal(addDecimalPoint(hash.get(amountCol))) : new KualiDecimal(hash.get(amountCol));
    if (accountNumCol > 0)
        accountNumber = isAccountNumHeaderValue ? getHeaderValue(accountNumCol) : hash.get(accountNumCol);
    else
        accountNumber = getParameterService().getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.ACCOUNT_NUM);
    status = hash.get(statusCol);
    String issueDateRawValue = hash.get(issueDateCol);
    payeeName = hash.get(payeeNameCol);
    payeeID = hash.get(payeeIDCol);
    if (issueDateRawValue == null || issueDateRawValue.equals("") || issueDateRawValue.equals("000000"))
        issueDateRawValue = "991231";
    // issueDate = dateformat.parse(issueDateRawValue);
    issueDate = getGregorianCalendar(issueDateRawValue).getTime();
    CheckReconciliation cr = new CheckReconciliation();
    cr.setAmount(amount);
    cr.setCheckDate(new java.sql.Date(issueDate.getTime()));
    cr.setCheckNumber(new KualiInteger(checkNumber));
    cr.setBankAccountNumber(accountNumber);
    cr.setStatus(status);
    cr.setStatusChangeDate(new java.sql.Date(checkDate.getTime()));
    cr.setGlTransIndicator(false);
    cr.setPayeeName(payeeName);
    cr.setPayeeId(payeeID);
    return cr;
}
Also used : KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KualiInteger(org.kuali.rice.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) Date(java.util.Date)

Example 4 with CheckReconciliation

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationImportStep method parseTextFile.

/**
 * Parse File
 *
 * @param checkFile Check File Path
 * @throws Exception
 */
private void parseTextFile(String checkFile, List<CheckReconError> records) throws Exception {
    LOG.info("Parsing File : " + checkFile);
    File file = new File(checkFile);
    BufferedReader br = new BufferedReader(new FileReader(file));
    String line = null;
    int totalLinesProcessed = 0;
    Timestamp ts = new Timestamp(new java.util.Date().getTime());
    Collection<Bank> banks = businessObjectService.findAll(Bank.class);
    while ((line = br.readLine()) != null) {
        if (header && totalLinesProcessed == 0) {
            headerLine = line;
            headerMap = parseHeaderLine();
            totalLinesProcessed++;
        } else if (footer && !br.ready()) {
            footerLine = line;
            footerMap = parseFooterLine();
            totalLinesProcessed++;
        } else {
            CheckReconciliation cr = null;
            if (CRConstants.DELIMITED.equals(fileType)) {
                cr = parseDelimitedLine(line);
            } else if (CRConstants.FIXED.equals(fileType)) {
                cr = parseFixedLine(line);
            }
            // Find existing check record
            CheckReconciliation existingRecord = getCheckReconciliation(cr.getCheckNumber(), cr.getBankAccountNumber());
            if (existingRecord == null) {
                // Update update ts
                cr.setLastUpdate(ts);
                // Set Status to Exception
                cr.setStatus(CRConstants.EXCP);
                // Set GL Trans False
                cr.setGlTransIndicator(Boolean.FALSE);
                String notFoundSrc = getParameterService().getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.SRC_NOT_FOUND);
                String notFoundBankCd = getParameterService().getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.BNK_CD_NOT_FOUND);
                cr.setSourceCode(notFoundSrc);
                cr.setBankCode(notFoundBankCd);
                businessObjectService.save(cr);
                records.add(getCheckReconError(cr, "The bank record does not exist in reconciliation table. " + cr.getCheckNumber()));
                LOG.error("Check Record Not Found");
            } else {
                if (CRConstants.PDP_SRC.equals(existingRecord.getSourceCode())) {
                    // update pdp records if checkstatus id cleared
                    String checkStatus = updateCheckStatus(cr, banks, records);
                    // update CheckRecon record if checkstatus is cleared
                    if (checkStatus.equals(CRConstants.CLEARED)) {
                        // ==== CU Customization: Only update when previous check status is Issued. ====
                        if (CRConstants.ISSUED.equals(existingRecord.getStatus())) {
                            cr.setStatus(checkStatus);
                            existingRecord.setStatus(checkStatus);
                            existingRecord.setStatusChangeDate(cr.getStatusChangeDate());
                            existingRecord.setLastUpdate(ts);
                            businessObjectService.save(existingRecord);
                            LOG.info("Updated Check Recon Record : " + existingRecord.getId());
                        } else {
                            LOG.warn("Could not update PDP-sourced Check Recon Record status to " + CRConstants.CLEARED + " because the existing status is " + existingRecord.getStatus() + " for this PDP-sourced record : " + existingRecord.getId());
                        }
                    } else if (checkStatus.equals(CRConstants.STOP)) {
                        if (!existingRecord.getStatus().equalsIgnoreCase(CRConstants.STOP)) {
                            records.add(getCheckReconError(cr, "Bank file status shows STOP and Check Recon table status is not STOP"));
                            LOG.error("Bank file status is STOP and Check Recon table status is not STOP for check " + cr.getCheckNumber());
                        }
                    } else if (checkStatus.equals(CRConstants.VOIDED)) {
                        if (!existingRecord.getStatus().equalsIgnoreCase(CRConstants.VOIDED)) {
                            records.add(getCheckReconError(cr, "Bank file status is VOIDED and Check Recon table status is not VOIDED"));
                            LOG.error("Bank file status is VOIDED and Check Recon table status is not VOID for check " + cr.getCheckNumber());
                        }
                    }
                } else {
                    String checkStatus = getCheckStatus(cr);
                    if (checkStatus.equals(CRConstants.CLEARED)) {
                        // ==== CU Customization: Only update when previous check status is Issued. ====
                        if (CRConstants.ISSUED.equals(existingRecord.getStatus())) {
                            cr.setStatus(checkStatus);
                            existingRecord.setStatus(checkStatus);
                            existingRecord.setStatusChangeDate(cr.getStatusChangeDate());
                            existingRecord.setLastUpdate(ts);
                            businessObjectService.save(existingRecord);
                            LOG.info("Updated Check Recon Record : " + existingRecord.getId());
                        } else {
                            LOG.warn("Could not update Check Recon Record status to " + CRConstants.CLEARED + " because the current status is " + existingRecord.getStatus() + " for this record : " + existingRecord.getId());
                        }
                    } else if (checkStatus.equals(CRConstants.STOP)) {
                        if (!existingRecord.getStatus().equalsIgnoreCase(CRConstants.STOP)) {
                            records.add(getCheckReconError(cr, "Bank file status is STOP and Check Recon table status is not STOP"));
                            LOG.error("Bank file status is STOP and Check Recon table status is not STOP for check " + cr.getCheckNumber());
                        }
                    } else if (checkStatus.equals(CRConstants.VOIDED)) {
                        if (!existingRecord.getStatus().equalsIgnoreCase(CRConstants.VOIDED)) {
                            records.add(getCheckReconError(cr, "Bank file status is VOID and Check Recon table status is not VOID"));
                            LOG.error("Bank file status is VOIDED and Check Recon table status is not VOID for check " + cr.getCheckNumber());
                        }
                    }
                }
            }
            totalLinesProcessed++;
        }
    }
    LOG.info("Processed Records : " + totalLinesProcessed);
    br.close();
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) BufferedReader(java.io.BufferedReader) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) FileReader(java.io.FileReader) File(java.io.File) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 5 with CheckReconciliation

use of com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationImportStep method importPdpPayments.

/**
 * Import PDP Payments
 */
private void importPdpPayments() {
    Collection<Bank> banks = businessObjectService.findAll(Bank.class);
    Collection<CheckReconciliation> payments = glTransactionService.getNewCheckReconciliations(banks);
    for (CheckReconciliation temp : payments) {
        businessObjectService.save(temp);
    }
    LOG.info("Found (" + payments.size() + ") New PDP payments.");
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)

Aggregations

CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)10 Timestamp (java.sql.Timestamp)4 Date (java.util.Date)4 Bank (org.kuali.kfs.sys.businessobject.Bank)4 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)4 Date (java.sql.Date)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 CheckReconciliationReport (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliationReport)1 PaymentDetailExtendedAttribute (edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 List (java.util.List)1 RuntimeCacheException (org.apache.ojb.broker.cache.RuntimeCacheException)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1