Search in sources :

Example 1 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 2 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 (!(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)
        purapAccountRevisionService.cancelCreditMemoAccountRevisions(cm.getItems(), cm.getPostingYearFromPendingGLEntries(), cm.getPostingPeriodCodeFromPendingGLEntries());
    }
    getBusinessObjectService().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) 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)

Example 3 with AccountingLine

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

the class KualiAccountingDocumentActionBase method processAccountingLines.

/**
 * @param transDoc
 * @param transForm
 * @param lineSet
 */
protected void processAccountingLines(AccountingDocument transDoc, KualiAccountingDocumentFormBase transForm, String lineSet) {
    // figure out which set of lines we're looking at
    List formLines;
    boolean source;
    if (lineSet.equals(KFSConstants.SOURCE)) {
        formLines = transDoc.getSourceAccountingLines();
        source = true;
    } else {
        formLines = transDoc.getTargetAccountingLines();
        source = false;
    }
    // find and process corresponding form and baselines
    int index = 0;
    for (Iterator i = formLines.iterator(); i.hasNext(); index++) {
        AccountingLine formLine = (AccountingLine) i.next();
        // update sales tax required attribute for view
        checkSalesTax(transDoc, formLine, source, false, index);
    }
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with AccountingLine

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

the class KualiAccountingDocumentActionBase method refreshSalesTaxInfo.

/**
 * This method refreshes the sales tax fields on a refresh or tab toggle so that all the information that was
 * there before is still there after a state change
 *
 * @param form
 */
protected void refreshSalesTaxInfo(ActionForm form) {
    KualiAccountingDocumentFormBase accountingForm = (KualiAccountingDocumentFormBase) form;
    AccountingDocument document = (AccountingDocument) accountingForm.getDocument();
    List sourceLines = document.getSourceAccountingLines();
    List targetLines = document.getTargetAccountingLines();
    handleSalesTaxRequiredAllLines(accountingForm, sourceLines);
    handleSalesTaxRequiredAllLines(accountingForm, targetLines);
    AccountingLine newTargetLine = accountingForm.getNewTargetLine();
    AccountingLine newSourceLine = accountingForm.getNewSourceLine();
    if (newTargetLine != null) {
        handleSalesTaxRequired(document, newTargetLine, false, true, 0);
    }
    if (newSourceLine != null) {
        handleSalesTaxRequired(document, newSourceLine, true, true, 0);
    }
}
Also used : SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) List(java.util.List) ArrayList(java.util.ArrayList) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument)

Example 5 with AccountingLine

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

the class KualiAccountingDocumentActionBase method uploadAccountingLines.

/**
 * This method determines whether we are uploading source or target lines, and then calls uploadAccountingLines
 * directly on the document object. This method handles retrieving the actual upload file as an input stream into
 * the document.
 *
 * @param isSource
 * @param form
 * @throws FileNotFoundException
 * @throws IOException
 */
protected void uploadAccountingLines(boolean isSource, ActionForm form) throws FileNotFoundException, IOException {
    KualiAccountingDocumentFormBase tmpForm = (KualiAccountingDocumentFormBase) form;
    List importedLines = null;
    AccountingDocument financialDocument = tmpForm.getFinancialDocument();
    AccountingLineParser accountingLineParser = financialDocument.getAccountingLineParser();
    // import the lines
    String errorPathPrefix = null;
    try {
        if (isSource) {
            errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.SOURCE_ACCOUNTING_LINE_ERRORS;
            FormFile sourceFile = tmpForm.getSourceFile();
            checkUploadFile(sourceFile);
            importedLines = accountingLineParser.importSourceAccountingLines(sourceFile.getFileName(), sourceFile.getInputStream(), financialDocument);
        } else {
            errorPathPrefix = KFSConstants.DOCUMENT_PROPERTY_NAME + "." + KFSConstants.TARGET_ACCOUNTING_LINE_ERRORS;
            FormFile targetFile = tmpForm.getTargetFile();
            checkUploadFile(targetFile);
            importedLines = accountingLineParser.importTargetAccountingLines(targetFile.getFileName(), targetFile.getInputStream(), financialDocument);
        }
    } catch (AccountingLineParserException e) {
        GlobalVariables.getMessageMap().putError(errorPathPrefix, e.getErrorKey(), e.getErrorParameters());
    }
    // add line to list for those lines which were successfully imported
    if (importedLines != null) {
        for (Object importedLineObject : importedLines) {
            AccountingLine importedLine = (AccountingLine) importedLineObject;
            insertAccountingLine(isSource, tmpForm, importedLine);
        }
    }
}
Also used : AccountingLineParser(org.kuali.kfs.sys.businessobject.AccountingLineParser) SourceAccountingLine(org.kuali.kfs.sys.businessobject.SourceAccountingLine) AccountingLine(org.kuali.kfs.sys.businessobject.AccountingLine) TargetAccountingLine(org.kuali.kfs.sys.businessobject.TargetAccountingLine) AccountingLineParserException(org.kuali.kfs.sys.exception.AccountingLineParserException) List(java.util.List) ArrayList(java.util.ArrayList) AccountingDocument(org.kuali.kfs.sys.document.AccountingDocument) FormFile(org.apache.struts.upload.FormFile)

Aggregations

AccountingLine (org.kuali.kfs.sys.businessobject.AccountingLine)22 ArrayList (java.util.ArrayList)12 SourceAccountingLine (org.kuali.kfs.sys.businessobject.SourceAccountingLine)12 List (java.util.List)10 Iterator (java.util.Iterator)7 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)6 TargetAccountingLine (org.kuali.kfs.sys.businessobject.TargetAccountingLine)6 AccountingDocument (org.kuali.kfs.sys.document.AccountingDocument)5 HashMap (java.util.HashMap)4 GeneralLedgerPendingEntrySequenceHelper (org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper)4 Map (java.util.Map)3 ParameterEvaluator (org.kuali.kfs.core.api.parameter.ParameterEvaluator)3 ParameterEvaluatorService (org.kuali.kfs.core.api.parameter.ParameterEvaluatorService)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 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)2 PurApAccountingLine (org.kuali.kfs.module.purap.businessobject.PurApAccountingLine)2