Search in sources :

Example 6 with AccountingLine

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

the class PreEncumbranceDocument method customizeExplicitGeneralLedgerPendingEntry.

@Override
public void customizeExplicitGeneralLedgerPendingEntry(GeneralLedgerPendingEntrySourceDetail postable, GeneralLedgerPendingEntry explicitEntry) {
    explicitEntry.setFinancialBalanceTypeCode(BALANCE_TYPE_PRE_ENCUMBRANCE);
    AccountingLine accountingLine = (AccountingLine) postable;
    // set the reversal date to what was chosen by the user in the interface
    if (ObjectUtils.isNotNull(getReversalDate()) && ObjectUtils.isNull(explicitEntry.getFinancialDocumentReversalDate())) {
        explicitEntry.setFinancialDocumentReversalDate(getReversalDate());
    }
    explicitEntry.setTransactionEntryProcessedTs(null);
    if (accountingLine.isSourceAccountingLine()) {
        explicitEntry.setTransactionEncumbranceUpdateCode(KFSConstants.ENCUMB_UPDT_DOCUMENT_CD);
        explicitEntry.setReferenceFinancialSystemOriginationCode(SpringContext.getBean(HomeOriginationService.class).getHomeOrigination().getFinSystemHomeOriginationCode());
        explicitEntry.setReferenceFinancialDocumentNumber(accountingLine.getReferenceNumber());
        explicitEntry.setReferenceFinancialDocumentTypeCode(explicitEntry.getFinancialDocumentTypeCode());
    // "PE"
    } else if (accountingLine.isTargetAccountingLine()) {
        explicitEntry.setTransactionEncumbranceUpdateCode(KFSConstants.ENCUMB_UPDT_REFERENCE_DOCUMENT_CD);
        explicitEntry.setReferenceFinancialSystemOriginationCode(SpringContext.getBean(HomeOriginationService.class).getHomeOrigination().getFinSystemHomeOriginationCode());
        explicitEntry.setReferenceFinancialDocumentNumber(accountingLine.getReferenceNumber());
        // "PE"
        explicitEntry.setReferenceFinancialDocumentTypeCode(explicitEntry.getFinancialDocumentTypeCode());
    }
}
Also used : PreEncumbranceSourceAccountingLine(edu.cornell.kfs.fp.businessobject.PreEncumbranceSourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) HomeOriginationService(org.kuali.kfs.sys.service.HomeOriginationService)

Example 7 with AccountingLine

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

the class CuDisbursementVoucherDocument method isCAndGReviewRequired.

protected boolean isCAndGReviewRequired() {
    String awardThreshold = getParameterService().getParameterValueAsString("KFS-FP", "DisbursementVoucher", DOLLAR_THRESHOLD_REQUIRING_AWARD_REVIEW);
    KualiDecimal dollarThresholdDecimal = new KualiDecimal(awardThreshold);
    if (this.disbVchrCheckTotalAmount.isGreaterEqual(dollarThresholdDecimal)) {
        return true;
    }
    List<AccountingLine> theList = (List<AccountingLine>) this.sourceAccountingLines;
    for (AccountingLine alb : theList) {
        ParameterEvaluator objectCodes = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", OBJECT_CODES_REQUIRING_AWARD_REVIEW, alb.getFinancialObjectCode());
        if (objectCodes.evaluationSucceeds()) {
            LOG.info("Object Code " + alb.getFinancialObjectCode() + " requires this document to undergo Award review.");
            return true;
        }
    }
    return false;
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) List(java.util.List) ArrayList(java.util.ArrayList) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService)

Example 8 with AccountingLine

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

the class CuDisbursementVoucherDocument method isCampusReviewRequired.

protected boolean isCampusReviewRequired() {
    List<ActionTakenValue> actions = RouteContext.getCurrentRouteContext().getDocument().getActionsTaken();
    List<String> people = new ArrayList<String>();
    for (ActionTakenValue atv : actions) {
        if (!people.contains(atv.getPrincipalId())) {
            people.add(atv.getPrincipalId());
        }
    }
    if (people.size() < 2) {
        return true;
    }
    List<AccountingLine> theList = (List<AccountingLine>) this.sourceAccountingLines;
    for (AccountingLine alb : theList) {
        ParameterEvaluator objectCodes = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", OBJECT_CODES_REQUIRING_CAMPUS_REVIEW, alb.getFinancialObjectCode());
        if (objectCodes.evaluationSucceeds()) {
            LOG.info("Object Code " + alb.getFinancialObjectCode() + " requires this document to undergo Campus review.");
            return true;
        }
    }
    ParameterEvaluator paymentReasons = SpringContext.getBean(ParameterEvaluatorService.class).getParameterEvaluator("KFS-FP", "DisbursementVoucher", PAYMENT_REASONS_REQUIRING_CAMPUS_REVIEW, this.dvPayeeDetail.getDisbVchrPaymentReasonCode());
    if (paymentReasons.evaluationSucceeds()) {
        return true;
    }
    String dollarThreshold = getParameterService().getParameterValueAsString("KFS-FP", "DisbursementVoucher", DOLLAR_THRESHOLD_REQUIRING_CAMPUS_REVIEW);
    KualiDecimal dollarThresholdDecimal = new KualiDecimal(dollarThreshold);
    if (this.disbVchrCheckTotalAmount.isGreaterEqual(dollarThresholdDecimal)) {
        return true;
    }
    return false;
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) ActionTakenValue(org.kuali.rice.kew.actiontaken.ActionTakenValue) ArrayList(java.util.ArrayList) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) List(java.util.List) ArrayList(java.util.ArrayList) ParameterEvaluator(org.kuali.rice.core.api.parameter.ParameterEvaluator) ParameterEvaluatorService(org.kuali.rice.core.api.parameter.ParameterEvaluatorService)

Example 9 with AccountingLine

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

the class CuPurapGeneralLedgerServiceImpl method generateEntriesPaymentRequest.

protected boolean generateEntriesPaymentRequest(PaymentRequestDocument preq, List encumbrances, List summaryAccounts, String processType) {
    LOG.debug("generateEntriesPaymentRequest() started");
    boolean success = true;
    preq.setGeneralLedgerPendingEntries(new ArrayList());
    /*
         * Can't let generalLedgerPendingEntryService just create all the entries because we need the sequenceHelper to carry over
         * from the encumbrances to the actuals and also because we need to tell the PaymentRequestDocumentRule customize entry
         * method how to customize differently based on if creating an encumbrance or actual.
         */
    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(preq.getDocumentNumber()));
    // when cancelling a PREQ, do not book encumbrances if PO is CLOSED
    if (encumbrances != null && !(CANCEL_PAYMENT_REQUEST.equals(processType) && PurapConstants.PurchaseOrderStatuses.APPDOC_CLOSED.equals(preq.getPurchaseOrderDocument().getApplicationDocumentStatus()))) {
        LOG.debug("generateEntriesPaymentRequest() generate encumbrance entries");
        if (CREATE_PAYMENT_REQUEST.equals(processType)) {
            // on create, use CREDIT code for encumbrances
            preq.setDebitCreditCodeForGLEntries(GL_CREDIT_CODE);
        } else if (CANCEL_PAYMENT_REQUEST.equals(processType)) {
            // on cancel, use DEBIT code
            preq.setDebitCreditCodeForGLEntries(GL_DEBIT_CODE);
        } else if (MODIFY_PAYMENT_REQUEST.equals(processType)) {
        // no encumbrances for modify
        }
        preq.setGenerateEncumbranceEntries(true);
        for (Iterator iter = encumbrances.iterator(); iter.hasNext(); ) {
            AccountingLine accountingLine = (AccountingLine) iter.next();
            preq.generateGeneralLedgerPendingEntries(accountingLine, sequenceHelper);
            // increment for the next line
            sequenceHelper.increment();
        }
    }
    if (ObjectUtils.isNotNull(summaryAccounts) && !summaryAccounts.isEmpty()) {
        LOG.debug("generateEntriesPaymentRequest() now book the actuals");
        preq.setGenerateEncumbranceEntries(false);
        if (CREATE_PAYMENT_REQUEST.equals(processType) || MODIFY_PAYMENT_REQUEST.equals(processType)) {
            // on create and modify, use DEBIT code
            preq.setDebitCreditCodeForGLEntries(GL_DEBIT_CODE);
        } else if (CANCEL_PAYMENT_REQUEST.equals(processType)) {
            // on cancel, use CREDIT code
            preq.setDebitCreditCodeForGLEntries(GL_CREDIT_CODE);
        }
        for (Iterator iter = summaryAccounts.iterator(); iter.hasNext(); ) {
            SummaryAccount summaryAccount = (SummaryAccount) iter.next();
            preq.generateGeneralLedgerPendingEntries(summaryAccount.getAccount(), sequenceHelper);
            // increment for the next line
            sequenceHelper.increment();
        }
        // generate offset accounts for use tax if it exists (useTaxContainers will be empty if not a use tax document)
        List<UseTaxContainer> useTaxContainers = SpringContext.getBean(PurapAccountingService.class).generateUseTaxAccount(preq);
        for (UseTaxContainer useTaxContainer : useTaxContainers) {
            PurApItemUseTax offset = useTaxContainer.getUseTax();
            List<SourceAccountingLine> accounts = useTaxContainer.getAccounts();
            for (SourceAccountingLine sourceAccountingLine : accounts) {
                preq.generateGeneralLedgerPendingEntries(sourceAccountingLine, sequenceHelper, useTaxContainer.getUseTax());
                // increment for the next line
                sequenceHelper.increment();
            }
        }
        // Manually save preq summary accounts
        if (MODIFY_PAYMENT_REQUEST.equals(processType)) {
            // for modify, regenerate the summary from the doc
            List<SummaryAccount> summaryAccountsForModify = SpringContext.getBean(PurapAccountingService.class).generateSummaryAccountsWithNoZeroTotalsNoUseTax(preq);
            saveAccountsPayableSummaryAccounts(summaryAccountsForModify, preq.getPurapDocumentIdentifier(), PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
        } else {
            // for create and cancel, use the summary accounts
            saveAccountsPayableSummaryAccounts(summaryAccounts, preq.getPurapDocumentIdentifier(), PurapDocTypeCodes.PAYMENT_REQUEST_DOCUMENT);
        }
        // manually save cm account change tables (CAMS needs this)
        if (CREATE_PAYMENT_REQUEST.equals(processType) || MODIFY_PAYMENT_REQUEST.equals(processType)) {
            SpringContext.getBean(PurapAccountRevisionService.class).savePaymentRequestAccountRevisions(preq.getItems(), preq.getPostingYearFromPendingGLEntries(), preq.getPostingPeriodCodeFromPendingGLEntries());
        } else if (CANCEL_PAYMENT_REQUEST.equals(processType)) {
            SpringContext.getBean(PurapAccountRevisionService.class).cancelPaymentRequestAccountRevisions(preq.getItems(), preq.getPostingYearFromPendingGLEntries(), preq.getPostingPeriodCodeFromPendingGLEntries());
        }
        // we would only want to do this when booking the actuals (not the encumbrances)
        if (preq.getGeneralLedgerPendingEntries() == null || preq.getGeneralLedgerPendingEntries().size() < 2) {
            LOG.warn("No gl entries for accounting lines.");
        } else {
            // upon create, build the entries normally
            if (CREATE_PAYMENT_REQUEST.equals(processType)) {
                getPaymentMethodGeneralLedgerPendingEntryService().generatePaymentMethodSpecificDocumentGeneralLedgerPendingEntries(preq, ((CuPaymentRequestDocument) preq).getPaymentMethodCode(), preq.getBankCode(), KRADConstants.DOCUMENT_PROPERTY_NAME + "." + "bankCode", preq.getGeneralLedgerPendingEntry(0), false, false, sequenceHelper);
            } else if (MODIFY_PAYMENT_REQUEST.equals(processType)) {
                // upon modify, we need to calculate the deltas here and pass them in so the appropriate adjustments are created
                KualiDecimal bankOffsetAmount = KualiDecimal.ZERO;
                Map<String, KualiDecimal> changesByChart = new HashMap<String, KualiDecimal>();
                if (ObjectUtils.isNotNull(summaryAccounts) && !summaryAccounts.isEmpty()) {
                    for (SummaryAccount a : (List<SummaryAccount>) summaryAccounts) {
                        bankOffsetAmount = bankOffsetAmount.add(a.getAccount().getAmount());
                        if (changesByChart.get(a.getAccount().getChartOfAccountsCode()) == null) {
                            changesByChart.put(a.getAccount().getChartOfAccountsCode(), a.getAccount().getAmount());
                        } else {
                            changesByChart.put(a.getAccount().getChartOfAccountsCode(), changesByChart.get(a.getAccount().getChartOfAccountsCode()).add(a.getAccount().getAmount()));
                        }
                    }
                }
                getPaymentMethodGeneralLedgerPendingEntryService().generatePaymentMethodSpecificDocumentGeneralLedgerPendingEntries(preq, ((CuPaymentRequestDocument) preq).getPaymentMethodCode(), preq.getBankCode(), KRADConstants.DOCUMENT_PROPERTY_NAME + "." + "bankCode", preq.getGeneralLedgerPendingEntry(0), true, false, sequenceHelper, bankOffsetAmount, changesByChart);
            }
        }
        preq.generateDocumentGeneralLedgerPendingEntries(sequenceHelper);
    // END MOD
    }
    // Manually save GL entries for Payment Request and encumbrances
    saveGLEntries(preq.getGeneralLedgerPendingEntries());
    return success;
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) UseTaxContainer(org.kuali.kfs.module.purap.util.UseTaxContainer) PurApItemUseTax(org.kuali.kfs.module.purap.businessobject.PurApItemUseTax) ArrayList(java.util.ArrayList) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) PurapAccountingService(org.kuali.kfs.module.purap.service.PurapAccountingService) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) PurapAccountRevisionService(org.kuali.kfs.module.purap.service.PurapAccountRevisionService) SummaryAccount(org.kuali.kfs.module.purap.util.SummaryAccount) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) Iterator(java.util.Iterator) KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) HashMap(java.util.HashMap) Map(java.util.Map)

Example 10 with AccountingLine

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

the class CuPendingTransactionServiceImpl method generateCreditMemoReversalEntries.

/**
 * Generates the reversal entries for the given input VendorCreditMemoDocument.
 *
 * @param doc
 *            the VendorCreditMemoDocument for which we generate the reversal entries
 * @param sequenceHelper
 */
protected void generateCreditMemoReversalEntries(VendorCreditMemoDocument cm) {
    cm.setGeneralLedgerPendingEntries(new ArrayList());
    boolean success = true;
    GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(cm.getDocumentNumber()));
    if (!cm.isSourceVendor()) {
        LOG.debug("generateEntriesCreditMemo() create encumbrance entries for CM against a PO or PREQ (not vendor)");
        PurchaseOrderDocument po = null;
        if (cm.isSourceDocumentPurchaseOrder()) {
            LOG.debug("generateEntriesCreditMemo() PO type");
            po = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(cm.getPurchaseOrderIdentifier());
        } else if (cm.isSourceDocumentPaymentRequest()) {
            LOG.debug("generateEntriesCreditMemo() PREQ type");
            po = SpringContext.getBean(PurchaseOrderService.class).getCurrentPurchaseOrder(cm.getPaymentRequestDocument().getPurchaseOrderIdentifier());
        }
        // for CM cancel or create, do not book encumbrances if PO is CLOSED, but do update the amounts on the PO
        List encumbrances = getCreditMemoEncumbrance(cm, po);
        if (!(PurapConstants.PurchaseOrderStatuses.APPDOC_CLOSED.equals(po.getApplicationDocumentStatus()))) {
            if (encumbrances != null) {
                cm.setGenerateEncumbranceEntries(true);
                // even if generating encumbrance entries on cancel, call is the same because the method gets negative amounts
                // from
                // the map so Debits on negatives = a credit
                cm.setDebitCreditCodeForGLEntries(GL_DEBIT_CODE);
                for (Iterator iter = encumbrances.iterator(); iter.hasNext(); ) {
                    AccountingLine accountingLine = (AccountingLine) iter.next();
                    if (accountingLine.getAmount().compareTo(ZERO) != 0) {
                        cm.generateGeneralLedgerPendingEntries(accountingLine, sequenceHelper);
                        // increment for the next line
                        sequenceHelper.increment();
                    }
                }
            }
        }
    }
    List<SummaryAccount> summaryAccounts = SpringContext.getBean(PurapAccountingService.class).generateSummaryAccountsWithNoZeroTotalsNoUseTax(cm);
    if (summaryAccounts != null) {
        LOG.debug("generateEntriesCreditMemo() now book the actuals");
        cm.setGenerateEncumbranceEntries(false);
        for (Iterator iter = summaryAccounts.iterator(); iter.hasNext(); ) {
            SummaryAccount summaryAccount = (SummaryAccount) iter.next();
            cm.generateGeneralLedgerPendingEntries(summaryAccount.getAccount(), sequenceHelper);
            // increment for the next line
            sequenceHelper.increment();
        }
        // generate offset accounts for use tax if it exists (useTaxContainers will be empty if not a use tax document)
        List<UseTaxContainer> useTaxContainers = SpringContext.getBean(PurapAccountingService.class).generateUseTaxAccount(cm);
        for (UseTaxContainer useTaxContainer : useTaxContainers) {
            PurApItemUseTax offset = useTaxContainer.getUseTax();
            List<SourceAccountingLine> accounts = useTaxContainer.getAccounts();
            for (SourceAccountingLine sourceAccountingLine : accounts) {
                cm.generateGeneralLedgerPendingEntries(sourceAccountingLine, sequenceHelper, useTaxContainer.getUseTax());
                // increment for the next line
                sequenceHelper.increment();
            }
        }
        // manually save cm account change tables (CAMS needs this)
        SpringContext.getBean(PurapAccountRevisionService.class).cancelCreditMemoAccountRevisions(cm.getItems(), cm.getPostingYearFromPendingGLEntries(), cm.getPostingPeriodCodeFromPendingGLEntries());
    }
    businessObjectService.save(cm.getGeneralLedgerPendingEntries());
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) UseTaxContainer(org.kuali.kfs.module.purap.util.UseTaxContainer) PurApItemUseTax(org.kuali.kfs.module.purap.businessobject.PurApItemUseTax) PurchaseOrderService(org.kuali.kfs.module.purap.document.service.PurchaseOrderService) ArrayList(java.util.ArrayList) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) PurapAccountingService(org.kuali.kfs.module.purap.service.PurapAccountingService) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper) PurapAccountRevisionService(org.kuali.kfs.module.purap.service.PurapAccountRevisionService) SummaryAccount(org.kuali.kfs.module.purap.util.SummaryAccount) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)22 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)13 ArrayList (java.util.ArrayList)12 List (java.util.List)10 Iterator (java.util.Iterator)9 TargetAccountingLine (org.kuali.kfs.sys.businessobject.TargetAccountingLine)7 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)6 HashMap (java.util.HashMap)5 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)5 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)4 Map (java.util.Map)3 PurApItemUseTax (org.kuali.kfs.module.purap.businessobject.PurApItemUseTax)3 PurapAccountingService (org.kuali.kfs.module.purap.service.PurapAccountingService)3 SummaryAccount (org.kuali.kfs.module.purap.util.SummaryAccount)3 UseTaxContainer (org.kuali.kfs.module.purap.util.UseTaxContainer)3 GeneralLedgerPendingEntry (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntry)3 ParameterEvaluator (org.kuali.rice.core.api.parameter.ParameterEvaluator)3 ParameterEvaluatorService (org.kuali.rice.core.api.parameter.ParameterEvaluatorService)3 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2