Search in sources :

Example 1 with Bank

use of org.kuali.kfs.sys.businessobject.Bank in project cu-kfs by CU-CommunityApps.

the class AdvanceDepositServiceImpl method createAdvanceDepositDocument.

/**
 * Creates a AdvanceDepositDocument from the List of transactions given.
 *
 * @param transaction List of CashReceiptDocument objects to be used for creating the document.
 * @return A AdvanceDepositDocument populated with the transactions provided.
 */
protected AdvanceDepositDocument createAdvanceDepositDocument(AchIncomeTransaction transaction) {
    AdvanceDepositDocument advanceDepositDocument;
    try {
        String detailReferenceNumber = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DETAIL_REFERENCE_NUMBER);
        String detailDescription = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DETAIL_DESCRIPTION);
        String bankCode = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.BANK_CODE);
        String documentDescription = parameterService.getParameterValueAsString(GenerateAdvanceDepositDocumentsStep.class, CuFPParameterConstants.AdvanceDepositDocument.DOCUMENT_DESCRIPTION);
        advanceDepositDocument = (AdvanceDepositDocument) documentService.getNewDocument(KFSConstants.FinancialDocumentTypeCodes.ADVANCE_DEPOSIT);
        advanceDepositDocument.getDocumentHeader().setDocumentDescription(documentDescription);
        advanceDepositDocument.setCampusLocationCode(CuFPConstants.ADVANCE_DEPOSIT_DEFAULT_CAMPUS_CODE);
        advanceDepositDocument.setDepositDate(dateTimeService.convertToSqlDate(transaction.getBankTimestamp()));
        createSourceAccountingLine(transaction, advanceDepositDocument);
        AdvanceDepositDetail advanceDepositDetail = new AdvanceDepositDetail();
        advanceDepositDetail.setDocumentNumber(advanceDepositDocument.getDocumentNumber());
        advanceDepositDetail.setFinancialDocumentAdvanceDepositDate(dateTimeService.convertToSqlDate(transaction.getLoadTimestamp()));
        advanceDepositDetail.setFinancialDocumentAdvanceDepositAmount(transaction.getTransactionAmount());
        advanceDepositDetail.setFinancialDocumentAdvanceDepositReferenceNumber(detailReferenceNumber);
        advanceDepositDetail.setFinancialDocumentAdvanceDepositDescription(detailDescription);
        advanceDepositDetail.setFinancialDocumentBankCode(bankCode);
        Bank bank = bankService.getByPrimaryId(bankCode);
        advanceDepositDetail.setBank(bank);
        advanceDepositDocument.addAdvanceDeposit(advanceDepositDetail);
    } catch (WorkflowException | ParseException e) {
        LOG.error("Error creating advance deposit documents: " + e.getMessage(), e);
        throw new RuntimeException("Error creating advance deposit documents: " + e.getMessage(), e);
    }
    return advanceDepositDocument;
}
Also used : AdvanceDepositDetail(org.kuali.kfs.fp.businessobject.AdvanceDepositDetail) Bank(org.kuali.kfs.sys.businessobject.Bank) AdvanceDepositDocument(org.kuali.kfs.fp.document.AdvanceDepositDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ParseException(java.text.ParseException)

Example 2 with Bank

use of org.kuali.kfs.sys.businessobject.Bank in project cu-kfs by CU-CommunityApps.

the class CUBankServiceImpl method getDefaultBankByDocType.

public Bank getDefaultBankByDocType(String documentTypeCode) {
    if (StringUtils.isBlank(documentTypeCode)) {
        throw new RuntimeException("Document type not found for document type: " + documentTypeCode);
    }
    if (parameterService.parameterExists(Bank.class, KFSParameterKeyConstants.DEFAULT_BANK_BY_DOCUMENT_TYPE)) {
        List<String> parmValues = new ArrayList<String>(parameterService.getSubParameterValuesAsString(Bank.class, KFSParameterKeyConstants.DEFAULT_BANK_BY_DOCUMENT_TYPE, documentTypeCode));
        if (parmValues != null && !parmValues.isEmpty()) {
            String defaultBankCode = parmValues.get(0);
            Bank defaultBank = this.getByPrimaryId(defaultBankCode);
            // check active status, if not return continuation bank if active
            if (!defaultBank.isActive() && defaultBank.getContinuationBank() != null && defaultBank.getContinuationBank().isActive()) {
                return defaultBank.getContinuationBank();
            }
            return defaultBank;
        }
    }
    return null;
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) ArrayList(java.util.ArrayList)

Example 3 with Bank

use of org.kuali.kfs.sys.businessobject.Bank in project cu-kfs by CU-CommunityApps.

the class IWantDocumentServiceImpl method setUpDVDetailsFromIWantDoc.

/**
 * @see edu.cornell.kfs.module.purap.document.service.IWantDocumentService#setUpDVDetailsFromIWantDoc(edu.cornell.kfs.module.purap.document.IWantDocument, org.kuali.kfs.fp.document.DisbursementVoucherDocument, org.kuali.kfs.fp.document.web.struts.DisbursementVoucherForm)
 */
public CuDisbursementVoucherDocument setUpDVDetailsFromIWantDoc(IWantDocument iWantDocument, CuDisbursementVoucherDocument disbursementVoucherDocument, DisbursementVoucherForm disbursementVoucherForm) throws Exception {
    // DV explanation = I Want Doc business purpose
    disbursementVoucherDocument.getDocumentHeader().setExplanation(iWantDocument.getDocumentHeader().getExplanation());
    // DV desc = IWantDoc desc
    disbursementVoucherDocument.getDocumentHeader().setDocumentDescription(iWantDocument.getDocumentHeader().getDocumentDescription());
    // if org doc number present on I Want doc, copy it to DV
    if (StringUtils.isNotBlank(iWantDocument.getDocumentHeader().getOrganizationDocumentNumber())) {
        disbursementVoucherDocument.getDocumentHeader().setOrganizationDocumentNumber(iWantDocument.getDocumentHeader().getOrganizationDocumentNumber());
    }
    // copy over attachments
    // copyIWantdDocAttachmentsToDV(disbursementVoucherDocument, disbursementVoucherForm, iWantDocument);
    copyIWantDocAttachments(disbursementVoucherDocument, iWantDocument, true, false);
    // DV check amount - IWantDoc total amount
    disbursementVoucherDocument.setDisbVchrCheckTotalAmount(iWantDocument.getTotalDollarAmount());
    // default bank code
    Bank defaultBank = SpringContext.getBean(BankService.class).getDefaultBankByDocType(DisbursementVoucherDocument.class);
    if (defaultBank != null) {
        disbursementVoucherDocument.setDisbVchrBankCode(defaultBank.getBankCode());
        disbursementVoucherDocument.setBank(defaultBank);
    }
    purapService.saveDocumentNoValidation(disbursementVoucherDocument);
    // populate accounting lines
    copyIWantDocAccountingLinesToDVDoc(disbursementVoucherDocument, iWantDocument, disbursementVoucherForm);
    return disbursementVoucherDocument;
}
Also used : BankService(org.kuali.kfs.sys.service.BankService) Bank(org.kuali.kfs.sys.businessobject.Bank)

Example 4 with Bank

use of org.kuali.kfs.sys.businessobject.Bank 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 Bank

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

Aggregations

Bank (org.kuali.kfs.sys.businessobject.Bank)22 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)4 Timestamp (java.sql.Timestamp)4 ArrayList (java.util.ArrayList)4 BankService (org.kuali.kfs.sys.service.BankService)4 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)4 Person (org.kuali.rice.kim.api.identity.Person)3 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 Date (java.sql.Date)2 ParseException (java.text.ParseException)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 KualiCode (org.kuali.kfs.krad.bo.KualiCode)2 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)2 KualiInteger (org.kuali.rice.core.api.util.type.KualiInteger)2 CuPaymentRequestItemExtension (edu.cornell.kfs.module.purap.businessobject.CuPaymentRequestItemExtension)1 PaymentDetailExtendedAttribute (edu.cornell.kfs.pdp.businessobject.PaymentDetailExtendedAttribute)1 CUBankService (edu.cornell.kfs.sys.service.CUBankService)1 VendorDetailExtension (edu.cornell.kfs.vnd.businessobject.VendorDetailExtension)1 BufferedReader (java.io.BufferedReader)1