Search in sources :

Example 1 with PaymentMethodChart

use of edu.cornell.kfs.fp.businessobject.PaymentMethodChart in project cu-kfs by CU-CommunityApps.

the class PaymentMethodRule method processCustomRouteDocumentBusinessRules.

@Override
protected boolean processCustomRouteDocumentBusinessRules(MaintenanceDocument document) {
    boolean continueRouting = super.processCustomRouteDocumentBusinessRules(document);
    PaymentMethod paymentMethod = (PaymentMethod) document.getNewMaintainableObject().getBusinessObject();
    // checks on the main record
    GlobalVariables.getMessageMap().clearErrorPath();
    GlobalVariables.getMessageMap().addToErrorPath("document.newMaintainableObject");
    // TODO : This is a hack now, foreign draft does not need this check
    if (!StringUtils.equals(PaymentMethod.PM_CODE_FOREIGN_DRAFT, paymentMethod.getPaymentMethodCode()) && !StringUtils.equals(PaymentMethod.PM_CODE_WIRE, paymentMethod.getPaymentMethodCode())) {
        continueRouting &= sanityCheckFlags(paymentMethod);
    }
    continueRouting &= checkNeedForBankCode(paymentMethod);
    // checks on the chart records
    for (int i = 0; i < paymentMethod.getPaymentMethodCharts().size(); i++) {
        GlobalVariables.getMessageMap().addToErrorPath("paymentMethodCharts[" + i + "]");
        PaymentMethodChart paymentMethodChart = paymentMethod.getPaymentMethodCharts().get(i);
        if (paymentMethodChart.isNewCollectionRecord()) {
            continueRouting &= isNewEffectiveDateInFuture(paymentMethod.getPaymentMethodCharts().get(i));
            continueRouting &= checkFeeInformation(paymentMethod, paymentMethod.getPaymentMethodCharts().get(i));
            continueRouting &= checkClearingAccountInformation(paymentMethod, paymentMethod.getPaymentMethodCharts().get(i));
        }
        GlobalVariables.getMessageMap().removeFromErrorPath("paymentMethodCharts[" + i + "]");
    }
    GlobalVariables.getMessageMap().removeFromErrorPath("document.newMaintainableObject");
    return continueRouting;
}
Also used : PaymentMethodChart(edu.cornell.kfs.fp.businessobject.PaymentMethodChart) PaymentMethod(edu.cornell.kfs.fp.businessobject.PaymentMethod)

Example 2 with PaymentMethodChart

use of edu.cornell.kfs.fp.businessobject.PaymentMethodChart in project cu-kfs by CU-CommunityApps.

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateClearingAccountOffsetEntries.

/**
 * When the "A" payment method is used for AP Credit Cards - generate the needed entries in the clearing account.
 *
 * @param document Document into which to add the generated GL Entries.
 * @param sequenceHelper helper class to keep track of GLPE sequence
 */
public boolean generateClearingAccountOffsetEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, Map<String, KualiDecimal> actualTotalsByChart) {
    if (actualTotalsByChart == null) {
        actualTotalsByChart = getNonOffsetActualTotalsByChart(document);
    }
    for (String chart : actualTotalsByChart.keySet()) {
        KualiDecimal offsetAmount = actualTotalsByChart.get(chart);
        if (!KualiDecimal.ZERO.equals(offsetAmount)) {
            PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(chart, new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
            if (pmc == null) {
                LOG.warn("No Applicable PaymentMethodChart found for chart: " + chart + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
                // skip this line - still attempt for other charts
                continue;
            }
            String clearingChartCode = pmc.getClearingChartOfAccountsCode();
            String clearingAccountNumber = pmc.getClearingAccountNumber();
            // liability object code
            String clearingObjectCode = pmc.getClearingFinancialObjectCode();
            GeneralLedgerPendingEntry apOffsetEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
            apOffsetEntry.setTransactionLedgerEntrySequenceNumber(new Integer(sequenceHelper.getSequenceCounter()));
            apOffsetEntry.setChartOfAccountsCode(clearingChartCode);
            apOffsetEntry.setAccountNumber(clearingAccountNumber);
            apOffsetEntry.setFinancialObjectCode(clearingObjectCode);
            // if internal billing
            if (StringUtils.equals(PaymentMethod.PM_CODE_INTERNAL_BILLING, pm.getPaymentMethodCode())) {
                apOffsetEntry.setFinancialSubObjectCode(pmc.getClearingFinancialSubObjectCode());
                apOffsetEntry.setSubAccountNumber(pmc.getClearingSubAccountNumber());
            } else {
                apOffsetEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
                apOffsetEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
            }
            apOffsetEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
            // retrieve object type
            ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(clearingChartCode, clearingObjectCode);
            if (objectCode == null) {
                LOG.fatal("Specified offset object code: " + clearingChartCode + "-" + clearingObjectCode + " does not exist - failed to generate CC offset entries", new RuntimeException());
                return false;
            }
            apOffsetEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
            apOffsetEntry.setTransactionLedgerEntryAmount(offsetAmount.abs());
            apOffsetEntry.setTransactionDebitCreditCode(offsetAmount.isNegative() ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
            apOffsetEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
            document.addPendingEntry(apOffsetEntry);
            sequenceHelper.increment();
            // handle the offset entry
            GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(apOffsetEntry);
            getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), apOffsetEntry, sequenceHelper, offsetEntry);
            document.addPendingEntry(offsetEntry);
            sequenceHelper.increment();
        }
    }
    return true;
}
Also used : PaymentMethodChart(edu.cornell.kfs.fp.businessobject.PaymentMethodChart) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Example 3 with PaymentMethodChart

use of edu.cornell.kfs.fp.businessobject.PaymentMethodChart in project cu-kfs by CU-CommunityApps.

the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFeeAssessmentEntries.

/**
 * Generates the GL entries to charge the department for the foreign draft and credit the Wire Charge
 * Fee Account as specified by system parameters.
 *
 * @param document Document into which to add the generated GL Entries.
 */
protected boolean generateFeeAssessmentEntries(PaymentMethod pm, AccountingDocument document, GeneralLedgerPendingEntry templatePendingEntry, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, boolean reverseEntries) {
    LOG.debug("generateForeignDraftChargeEntries started");
    PaymentMethodChart pmc = pm.getPaymentMethodChartInfo(templatePendingEntry.getChartOfAccountsCode(), new java.sql.Date(document.getDocumentHeader().getWorkflowDocument().getDateCreated().getMillis()));
    if (pmc == null) {
        LOG.warn("No Applicable PaymentMethodChart found for chart: " + templatePendingEntry.getChartOfAccountsCode() + " and date: " + document.getDocumentHeader().getWorkflowDocument().getDateCreated());
        return false;
    }
    // Get all the parameters which control these entries
    String feeIncomeChartCode = pmc.getFeeIncomeChartOfAccountsCode();
    String feeIncomeAccountNumber = pmc.getFeeIncomeAccountNumber();
    String feeExpenseObjectCode = pmc.getFeeExpenseFinancialObjectCode();
    String feeIncomeObjectCode = pmc.getFeeIncomeFinancialObjectCode();
    KualiDecimal feeAmount = pmc.getFeeAmount();
    // skip creation if the fee has been set to zero
    if (!KualiDecimal.ZERO.equals(feeAmount)) {
        // grab the explicit entry for the first accounting line and adjust for the foreign draft fee
        GeneralLedgerPendingEntry chargeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
        chargeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
        // change the object code (expense to the department)
        chargeEntry.setFinancialObjectCode(feeExpenseObjectCode);
        chargeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
        chargeEntry.setTransactionLedgerEntryDescription(StringUtils.left("Automatic debit for " + pm.getPaymentMethodName() + " fee", 40));
        chargeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        // retrieve object type
        ObjectCode objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(chargeEntry.getChartOfAccountsCode(), chargeEntry.getFinancialObjectCode());
        if (objectCode == null) {
            LOG.fatal("Specified offset object code: " + chargeEntry.getChartOfAccountsCode() + "-" + chargeEntry.getFinancialObjectCode() + " does not exist - failed to generate foreign draft fee entries", new RuntimeException());
            return false;
        }
        chargeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
        // Set the amount from the parameter
        chargeEntry.setTransactionLedgerEntryAmount(feeAmount);
        chargeEntry.setTransactionDebitCreditCode(reverseEntries ? GL_CREDIT_CODE : GL_DEBIT_CODE);
        document.addPendingEntry(chargeEntry);
        sequenceHelper.increment();
        // handle the offset entry
        GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(chargeEntry);
        getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), chargeEntry, sequenceHelper, offsetEntry);
        document.addPendingEntry(offsetEntry);
        sequenceHelper.increment();
        // Now, create the income entry in the AP Foreign draft fee account
        GeneralLedgerPendingEntry feeIncomeEntry = new GeneralLedgerPendingEntry(document.getGeneralLedgerPendingEntry(0));
        feeIncomeEntry.setTransactionLedgerEntrySequenceNumber(sequenceHelper.getSequenceCounter());
        feeIncomeEntry.setChartOfAccountsCode(feeIncomeChartCode);
        feeIncomeEntry.setAccountNumber(feeIncomeAccountNumber);
        feeIncomeEntry.setFinancialObjectCode(feeIncomeObjectCode);
        feeIncomeEntry.setFinancialSubObjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankFinancialSubObjectCode());
        feeIncomeEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
        feeIncomeEntry.setProjectCode(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankProjectCode());
        // retrieve object type
        objectCode = getObjectCodeService().getByPrimaryIdForCurrentYear(feeIncomeChartCode, feeIncomeObjectCode);
        if (objectCode == null) {
            LOG.fatal("Specified income object code: " + feeIncomeChartCode + "-" + feeIncomeObjectCode + " does not exist - failed to generate foreign draft income entries", new RuntimeException());
            return false;
        }
        feeIncomeEntry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
        feeIncomeEntry.setTransactionLedgerEntryAmount(feeAmount);
        feeIncomeEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        feeIncomeEntry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_ACTUAL);
        document.addPendingEntry(feeIncomeEntry);
        sequenceHelper.increment();
        // create the offset entry
        offsetEntry = new GeneralLedgerPendingEntry(feeIncomeEntry);
        getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), feeIncomeEntry, sequenceHelper, offsetEntry);
        document.addPendingEntry(offsetEntry);
        sequenceHelper.increment();
    }
    return true;
}
Also used : PaymentMethodChart(edu.cornell.kfs.fp.businessobject.PaymentMethodChart) GeneralLedgerPendingEntry(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode)

Aggregations

PaymentMethodChart (edu.cornell.kfs.fp.businessobject.PaymentMethodChart)3 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)2 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 PaymentMethod (edu.cornell.kfs.fp.businessobject.PaymentMethod)1