Search in sources :

Example 21 with AccountingLine

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

the class CuPendingTransactionServiceImpl method generateEntriesPaymentRequest.

/**
 * Creates the general ledger entries for Payment Request actions.
 *
 * @param preq Payment Request document to create entries
 * @param encumbrances List of encumbrance accounts if applies
 * @param accountingLines List of preq accounts to create entries
 * @param processType Type of process (create, modify, cancel)
 * @return Boolean returned indicating whether entry creation succeeded
 */
protected boolean generateEntriesPaymentRequest(PaymentRequestDocument preq, List encumbrances, List summaryAccounts) {
    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) {
        // on cancel, use DEBIT code
        preq.setDebitCreditCodeForGLEntries(GL_DEBIT_CODE);
        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);
        // 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 GL entries for Payment Request and encumbrances
    LOG.debug("saveGLEntries() started");
    businessObjectService.save(preq.getGeneralLedgerPendingEntries());
    return success;
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) SummaryAccount(org.kuali.kfs.module.purap.util.SummaryAccount) UseTaxContainer(org.kuali.kfs.module.purap.util.UseTaxContainer) PurApItemUseTax(org.kuali.kfs.module.purap.businessobject.PurApItemUseTax) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) PurapAccountingService(org.kuali.kfs.module.purap.service.PurapAccountingService) GeneralLedgerPendingEntrySequenceHelper(org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)

Example 22 with AccountingLine

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

the class CUFinancialSystemDocumentServiceImpl method buildAccountingLineMap.

/**
 * @param accountingLines
 * @return Map containing accountingLines from the given List, indexed by their sequenceNumber
 */
protected Map buildAccountingLineMap(List<AccountingLine> accountingLines) {
    Map lineMap = new HashMap();
    for (Iterator i = accountingLines.iterator(); i.hasNext(); ) {
        AccountingLine accountingLine = (AccountingLine) i.next();
        Integer sequenceNumber = accountingLine.getSequenceNumber();
        if (sequenceNumber != null) {
            lineMap.put(sequenceNumber, accountingLine);
        }
    }
    return lineMap;
}
Also used : AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) HashMap(java.util.HashMap) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

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