Search in sources :

Example 11 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class PaymentSourceExtractionServiceImpl method extractPaymentsForCampus.

/**
 * This method extracts all outstanding payments from all the disbursement vouchers in approved status for a given
 * campus and adds these payments to a batch file that is uploaded for processing.
 *
 * @param campusCode     The id code of the campus the payments will be retrieved for.
 * @param principalId    The user object used when creating the batch file to upload with outstanding payments.
 * @param processRunDate This is the date that the batch file is created, often this value will be today's date.
 */
protected void extractPaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("extractPaymentsForCampus() started for campus: " + campusCode);
    }
    Batch batch = createBatch(campusCode, principalId, processRunDate);
    int count = 0;
    KualiDecimal totalAmount = KualiDecimal.ZERO;
    for (PaymentSource document : documents) {
        if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
            addPayment(document, batch, processRunDate, false);
            count++;
            totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
        }
    }
    batch.setPaymentCount(new KualiInteger(count));
    batch.setPaymentTotalAmount(totalAmount);
    businessObjectService.save(batch);
    paymentFileEmailService.sendLoadEmail(batch);
}
Also used : Batch(org.kuali.kfs.pdp.businessobject.Batch) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) PaymentSource(org.kuali.kfs.sys.document.PaymentSource)

Example 12 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class PaymentSourceExtractionServiceImpl method extractImmediatePaymentsForCampus.

/**
 * Builds payment batch for Disbursement Vouchers marked as immediate
 *
 * @param campusCode     the campus code the disbursement vouchers should be associated with
 * @param principalId    the user responsible building the payment batch (typically the System User, kfs)
 * @param processRunDate the time that the job to build immediate payments is run
 */
protected void extractImmediatePaymentsForCampus(String campusCode, String principalId, Date processRunDate, List<? extends PaymentSource> documents) {
    LOG.debug("extractImmediatePaymentsForCampus() started for campus: " + campusCode);
    if (!documents.isEmpty()) {
        Batch batch = createBatch(campusCode, principalId, processRunDate);
        int count = 0;
        KualiDecimal totalAmount = KualiDecimal.ZERO;
        for (PaymentSource document : documents) {
            if (getPaymentSourceToExtractService().shouldExtractPayment(document)) {
                addPayment(document, batch, processRunDate, false);
                count++;
                totalAmount = totalAmount.add(getPaymentSourceToExtractService().getPaymentAmount(document));
            }
        }
        batch.setPaymentCount(new KualiInteger(count));
        batch.setPaymentTotalAmount(totalAmount);
        businessObjectService.save(batch);
        paymentFileEmailService.sendLoadEmail(batch);
    }
}
Also used : Batch(org.kuali.kfs.pdp.businessobject.Batch) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) PaymentSource(org.kuali.kfs.sys.document.PaymentSource)

Example 13 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class CheckReconciliationDaoOjb method getNewCheckReconciliations.

/**
 * @see com.rsmart.kuali.kfs.cr.dataaccess.CheckReconciliationDao#getNewCheckReconciliations(java.util.Collection)
 */
public Collection<CheckReconciliation> getNewCheckReconciliations(Collection<Bank> banks) {
    Collection<CheckReconciliation> data = new ArrayList<CheckReconciliation>();
    CheckReconciliation cr = null;
    // String sql = "SELECT p.disb_nbr, p.disb_ts, SUM(d.net_pmt_amt), b.bnk_cd,p.pmt_payee_nm, p.payee_id_typ_cd,p.payee_id FROM pdp_pmt_grp_t p, pdp_pmt_dtl_t d, fp_bank_t b WHERE p.bnk_cd = b.bnk_cd AND p.pmt_grp_id = d.pmt_grp_id AND p.disb_typ_cd = 'CHCK' AND NOT EXISTS ( SELECT 'x' from cu_cr_check_recon_t cr WHERE cr.check_nbr = p.disb_nbr AND cr.bank_account_nbr = b.bnk_acct_nbr) GROUP BY p.disb_nbr, p.disb_ts, b.bnk_cd";
    String sql = "SELECT p.disb_nbr, p.disb_ts, SUM(d.net_pmt_amt), b.bnk_cd,p.pmt_payee_nm, p.payee_id_typ_cd,p.payee_id  FROM pdp_pmt_grp_t p, pdp_pmt_dtl_t d, fp_bank_t b WHERE p.bnk_cd = b.bnk_cd AND p.pmt_grp_id = d.pmt_grp_id AND p.disb_ts is not null AND p.disb_typ_cd = 'CHCK' AND NOT EXISTS ( SELECT 'x' from cu_cr_check_recon_t cr WHERE cr.check_nbr = p.disb_nbr AND cr.bank_account_nbr = b.bnk_acct_nbr) group by p.disb_nbr, p.disb_ts, b.bnk_cd, p.pmt_payee_nm, p.payee_id_typ_cd, p.payee_id";
    try {
        Connection c = getPersistenceBroker(true).serviceConnectionManager().getConnection();
        Statement s = c.createStatement();
        ResultSet rs = s.executeQuery(sql);
        String bnkCd = null;
        while (rs.next()) {
            cr = new CheckReconciliation();
            cr.setCheckNumber(new KualiInteger(rs.getInt(1)));
            // This is last status change date.
            cr.setCheckDate(new java.sql.Date(rs.getDate(2).getTime()));
            cr.setAmount(new KualiDecimal(rs.getDouble(3)));
            bnkCd = rs.getString(4);
            cr.setPayeeName(rs.getString(5));
            cr.setPayeeType(rs.getString(6));
            cr.setPayeeId(rs.getString(7));
            for (Bank bank : banks) {
                if (bank.getBankCode().equals(bnkCd)) {
                    cr.setBankAccountNumber(bank.getBankAccountNumber());
                }
            }
            cr.setGlTransIndicator(Boolean.FALSE);
            if (cr.getAmount().isZero()) {
                cr.setStatus(CRConstants.EXCP);
            } else {
                cr.setStatus(CRConstants.ISSUED);
            }
            cr.setSourceCode(CRConstants.PDP_SRC);
            cr.setBankCode(bnkCd);
            data.add(cr);
        }
        s.close();
    } catch (Exception e) {
        LOG.error("getNewCheckReconciliations", e);
    }
    return data;
}
Also used : Bank(org.kuali.kfs.sys.businessobject.Bank) Statement(java.sql.Statement) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) Date(java.sql.Date) ResultSet(java.sql.ResultSet) CheckReconciliation(com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal)

Example 14 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class GlTransactionServiceImpl method generateGlPendingTransaction.

/**
 * Generate GlPendingTransaction
 *
 * @param paymentGroup
 * @param financialDocumentTypeCode
 * @param stale
 */
private void generateGlPendingTransaction(PaymentGroup paymentGroup, String financialDocumentTypeCode, boolean stale) {
    List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
    for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
        accountListings.addAll(paymentDetail.getAccountDetail());
    }
    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
    for (PaymentAccountDetail paymentAccountDetail : accountListings) {
        GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
        glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
        glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
        glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
        glPendingTransaction.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime());
        glPendingTransaction.setTransactionDt(transactionTimestamp);
        AccountingPeriod fiscalPeriod = accountingPeriodService.getByDate(new java.sql.Date(transactionTimestamp.getTime()));
        glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
        glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode());
        glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
        glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
        glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
        // Set doc type and origin code
        glPendingTransaction.setFinancialDocumentTypeCode(financialDocumentTypeCode);
        glPendingTransaction.setFsOriginCd(CRConstants.CR_FDOC_ORIGIN_CODE);
        String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_ACCOUNT);
        String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_OBJECT_CODE);
        String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_COA);
        // Use clearing parameters if stale
        String accountNbr = stale ? clAcct : paymentAccountDetail.getAccountNbr();
        String finObjectCode = stale ? obCode : paymentAccountDetail.getFinObjectCode();
        String finCoaCd = stale ? coaCode : paymentAccountDetail.getFinChartCode();
        Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities();
        if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue()) && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) {
            OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(), glPendingTransaction.getChartOfAccountsCode(), paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(), glPendingTransaction.getFinancialBalanceTypeCode());
            glPendingTransaction.setAccountNumber(accountNbr);
            glPendingTransaction.setChartOfAccountsCode(finCoaCd);
            glPendingTransaction.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : finObjectCode);
            glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            glPendingTransaction.setAccountNumber(accountNbr);
            glPendingTransaction.setChartOfAccountsCode(finCoaCd);
            glPendingTransaction.setFinancialObjectCode(finObjectCode);
            glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
        }
        glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
        if (paymentAccountDetail.getAccountNetAmount().bigDecimalValue().signum() >= 0) {
            glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_CREDIT_CODE);
        } else {
            glPendingTransaction.setDebitCrdtCd(KFSConstants.GL_DEBIT_CODE);
        }
        glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
        String trnDesc;
        String payeeName = paymentGroup.getPayeeName();
        trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
        String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr();
        if (StringUtils.isNotBlank(poNbr)) {
            trnDesc += " " + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9));
        }
        String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr();
        if (StringUtils.isNotBlank(invoiceNbr)) {
            trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14) : StringUtils.rightPad(invoiceNbr, 14));
        }
        if (trnDesc.length() > 40) {
            trnDesc = trnDesc.substring(0, 40);
        }
        glPendingTransaction.setDescription(trnDesc);
        glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr());
        glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId());
        glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr());
        // update the offset account if necessary
        SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction);
        this.businessObjectService.save(glPendingTransaction);
        sequenceHelper.increment();
    }
}
Also used : GlPendingTransaction(org.kuali.kfs.pdp.businessobject.GlPendingTransaction) KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) AccountingPeriod(org.kuali.kfs.coa.businessobject.AccountingPeriod) ArrayList(java.util.ArrayList) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) Date(java.sql.Date) Date(java.sql.Date) PaymentDetail(org.kuali.kfs.pdp.businessobject.PaymentDetail) FlexibleOffsetAccountService(org.kuali.kfs.sys.service.FlexibleOffsetAccountService) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) OffsetDefinitionService(org.kuali.kfs.coa.service.OffsetDefinitionService) PaymentAccountDetail(org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)

Example 15 with KualiInteger

use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.

the class DisbursementVoucherDocumentBatchServiceImpl method getNewDisbursementVoucherBatch.

/**
 * Creates and populates a new DisbursementVoucherBatch instance
 *
 * @return DisbursementVoucherBatch
 */
protected DisbursementVoucherBatch getNewDisbursementVoucherBatch() {
    DisbursementVoucherBatch disbursementVoucherBatch = new DisbursementVoucherBatch();
    // get next available batch id
    KualiInteger batchId = new KualiInteger(sequenceAccessorService.getNextAvailableSequenceNumber(FPConstants.DV_BATCH_ID_SEQUENCE_NAME));
    disbursementVoucherBatch.setBatchId(batchId);
    disbursementVoucherBatch.setProcessPrincipalId(GlobalVariables.getUserSession().getPerson().getPrincipalId());
    disbursementVoucherBatch.setProcessTimestamp(dateTimeService.getCurrentTimestamp());
    return disbursementVoucherBatch;
}
Also used : KualiInteger(org.kuali.kfs.core.api.util.type.KualiInteger) DisbursementVoucherBatch(com.rsmart.kuali.kfs.fp.businessobject.DisbursementVoucherBatch)

Aggregations

KualiInteger (org.kuali.kfs.core.api.util.type.KualiInteger)26 ArrayList (java.util.ArrayList)8 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)7 PaymentDetail (org.kuali.kfs.pdp.businessobject.PaymentDetail)7 Date (java.sql.Date)5 HashMap (java.util.HashMap)5 CustomerProfile (org.kuali.kfs.pdp.businessobject.CustomerProfile)5 PaymentNoteText (org.kuali.kfs.pdp.businessobject.PaymentNoteText)5 Date (java.util.Date)4 GlPendingTransaction (org.kuali.kfs.pdp.businessobject.GlPendingTransaction)4 PaymentAccountDetail (org.kuali.kfs.pdp.businessobject.PaymentAccountDetail)4 CheckReconciliation (com.rsmart.kuali.kfs.cr.businessobject.CheckReconciliation)3 AccountingPeriod (org.kuali.kfs.coa.businessobject.AccountingPeriod)3 OffsetDefinition (org.kuali.kfs.coa.businessobject.OffsetDefinition)3 Batch (org.kuali.kfs.pdp.businessobject.Batch)3 PaymentGroup (org.kuali.kfs.pdp.businessobject.PaymentGroup)3 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)3 Timestamp (java.sql.Timestamp)2 Calendar (java.util.Calendar)2 List (java.util.List)2