Search in sources :

Example 6 with OriginEntryFull

use of org.kuali.kfs.gl.businessobject.OriginEntryFull in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method buildOriginEntry.

protected OriginEntryFull buildOriginEntry(ConcurStandardAccountingExtractDetailLine detailLine, KualiDecimal amount) {
    BiConsumer<OriginEntryFull, ConcurStandardAccountingExtractDetailLine> originEntryConfigurer;
    if (collectorHelper.isCashAdvanceLine(detailLine)) {
        originEntryConfigurer = getConfigurerForCashAdvanceOriginEntry(detailLine);
    } else if (collectorHelper.isAtmFeeDebitLine(detailLine)) {
        originEntryConfigurer = this::configureAtmFeeDebitOriginEntry;
    } else {
        originEntryConfigurer = this::configureRegularOriginEntry;
    }
    OriginEntryFull originEntry = buildOriginEntryWithoutAccountingIdentifiers(detailLine, amount);
    originEntryConfigurer.accept(originEntry, detailLine);
    return originEntry;
}
Also used : OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull) ConcurStandardAccountingExtractDetailLine(edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)

Example 7 with OriginEntryFull

use of org.kuali.kfs.gl.businessobject.OriginEntryFull in project cu-kfs by CU-CommunityApps.

the class ConcurDetailLineGroupForCollector method buildOffsetOriginEntry.

protected OriginEntryFull buildOffsetOriginEntry(OriginEntryFull baseEntry, KualiDecimal amountToOffset) {
    OriginEntryFull offsetEntry = new OriginEntryFull(baseEntry);
    KualiDecimal offsetAmount = amountToOffset.negated();
    setTransactionSequenceNumberToNextAvailableValue(offsetEntry);
    configureAmountAndDebitCreditCodeOnOriginEntry(offsetEntry, offsetAmount);
    return offsetEntry;
}
Also used : KualiDecimal(org.kuali.rice.core.api.util.type.KualiDecimal) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 8 with OriginEntryFull

use of org.kuali.kfs.gl.businessobject.OriginEntryFull in project cu-kfs by CU-CommunityApps.

the class AccountReversionProcessImpl method processBalances.

/**
 * Given a list of balances, this method generates the origin entries for the organization reversion/carry forward process, and saves those
 * to an initialized origin entry group
 *
 * @param balances an iterator of balances to process; each balance returned by the iterator will be processed by this method
 */
public void processBalances(Iterator<Balance> balances) {
    boolean skipToNextUnitOfWork = false;
    unitOfWork = new ReversionUnitOfWork();
    unitOfWork.setCategories(categoryList);
    int brokenCodeCount = 0;
    Balance bal;
    while (balances.hasNext()) {
        bal = balances.next();
        // we only want AC balance types so we will limit them here rather than in the query used for both Account Reversion and Organization Reversion.
        if (!bal.getBalanceTypeCode().equals(KFSConstants.BALANCE_TYPE_ACTUAL)) {
            continue;
        }
        String acctNumber = bal.getAccountNumber();
        if (LOG.isDebugEnabled()) {
            LOG.debug("BALANCE SELECTED: " + bal.getUniversityFiscalYear() + bal.getChartOfAccountsCode() + bal.getAccountNumber() + bal.getSubAccountNumber() + bal.getObjectCode() + bal.getSubObjectCode() + bal.getBalanceTypeCode() + bal.getObjectTypeCode() + " " + bal.getAccountLineAnnualBalanceAmount().add(bal.getBeginningBalanceLineAmount()));
        }
        try {
            if (!unitOfWork.isInitialized()) {
                unitOfWork.setFields(bal.getChartOfAccountsCode(), bal.getAccountNumber(), bal.getSubAccountNumber());
                retrieveCurrentReversionAndAccount(bal);
            } else // just gonna leave this broken code here....
            if (!unitOfWork.wouldHold(bal)) {
                if (!skipToNextUnitOfWork) {
                    calculateTotals();
                    List<OriginEntryFull> originEntriesToWrite = generateOutputOriginEntries();
                    summarizeOriginEntries(originEntriesToWrite);
                    if (holdGeneratedOriginEntries) {
                        generatedOriginEntries.addAll(originEntriesToWrite);
                    }
                    int recordsWritten = writeOriginEntries(originEntriesToWrite);
                    incrementCount("recordsWritten", recordsWritten);
                    getReversionUnitOfWorkService().save(unitOfWork);
                }
                unitOfWork.setFields(bal.getChartOfAccountsCode(), bal.getAccountNumber(), bal.getSubAccountNumber());
                retrieveCurrentReversionAndAccount(bal);
                brokenCodeCount++;
                skipToNextUnitOfWork = false;
            }
            if (skipToNextUnitOfWork) {
                // if there is no org reversion or an org reversion detail is missing or the balances are off for
                continue;
            // this unit of work,
            // just skip all the balances until we change unit of work
            }
            calculateBucketAmounts(bal);
        } catch (FatalErrorException fee) {
            LOG.info(fee.getMessage());
            skipToNextUnitOfWork = true;
        }
    }
    System.out.println("Total broken code balances processed: " + brokenCodeCount);
    // save the final unit of work
    if (!skipToNextUnitOfWork && getBalancesSelected() > 0) {
        try {
            calculateTotals();
            List<OriginEntryFull> originEntriesToWrite = generateOutputOriginEntries();
            summarizeOriginEntries(originEntriesToWrite);
            if (holdGeneratedOriginEntries) {
                generatedOriginEntries.addAll(originEntriesToWrite);
            }
            int recordsWritten = writeOriginEntries(originEntriesToWrite);
            incrementCount("recordsWritten", recordsWritten);
            getReversionUnitOfWorkService().save(unitOfWork);
        } catch (FatalErrorException fee) {
            LOG.info(fee.getMessage());
        }
    }
}
Also used : ReversionUnitOfWork(edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork) List(java.util.List) FatalErrorException(org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException) Balance(org.kuali.kfs.gl.businessobject.Balance) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 9 with OriginEntryFull

use of org.kuali.kfs.gl.businessobject.OriginEntryFull in project cu-kfs by CU-CommunityApps.

the class CuScrubberProcessImpl method generateCostShareEntries.

/**
 * Overridden to update cost share source account entries so that they will post to the
 * continuation account if the cost share account is closed.
 *
 * @see org.kuali.kfs.gl.batch.service.impl.ScrubberProcessImpl#generateCostShareEntries(
 *         org.kuali.kfs.gl.businessobject.OriginEntryInformation, org.kuali.kfs.gl.service.ScrubberReportData)
 */
@Override
protected ScrubberProcessTransactionError generateCostShareEntries(OriginEntryInformation scrubbedEntry, ScrubberReportData scrubberReport) {
    // 3000-COST-SHARE to 3100-READ-OFSD in the cobol Generate Cost Share Entries
    LOG.debug("generateCostShareEntries() started");
    try {
        OriginEntryFull costShareEntry = OriginEntryFull.copyFromOriginEntryable(scrubbedEntry);
        SystemOptions scrubbedEntryOption = accountingCycleCachingService.getSystemOptions(scrubbedEntry.getUniversityFiscalYear());
        A21SubAccount scrubbedEntryA21SubAccount = accountingCycleCachingService.getA21SubAccount(scrubbedEntry.getChartOfAccountsCode(), scrubbedEntry.getAccountNumber(), scrubbedEntry.getSubAccountNumber());
        costShareEntry.setFinancialObjectCode(parameterService.getParameterValueAsString(ScrubberStep.class, GeneralLedgerConstants.GlScrubberGroupParameters.COST_SHARE_OBJECT_CODE_PARM_NM));
        costShareEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        costShareEntry.setFinancialObjectTypeCode(scrubbedEntryOption.getFinancialObjectTypeTransferExpenseCd());
        costShareEntry.setTransactionLedgerEntrySequenceNumber(new Integer(0));
        StringBuffer description = new StringBuffer();
        description.append(costShareDescription);
        description.append(" ").append(scrubbedEntry.getAccountNumber());
        description.append(offsetString);
        costShareEntry.setTransactionLedgerEntryDescription(description.toString());
        costShareEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount);
        if (scrubCostShareAmount.isPositive()) {
            costShareEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        } else {
            costShareEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
            costShareEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount.negated());
        }
        costShareEntry.setTransactionDate(runDate);
        costShareEntry.setOrganizationDocumentNumber(null);
        costShareEntry.setProjectCode(KFSConstants.getDashProjectCode());
        costShareEntry.setOrganizationReferenceId(null);
        costShareEntry.setReferenceFinancialDocumentTypeCode(null);
        costShareEntry.setReferenceFinancialSystemOriginationCode(null);
        costShareEntry.setReferenceFinancialDocumentNumber(null);
        costShareEntry.setFinancialDocumentReversalDate(null);
        costShareEntry.setTransactionEncumbranceUpdateCode(null);
        createOutputEntry(costShareEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        OriginEntryFull costShareOffsetEntry = new OriginEntryFull(costShareEntry);
        costShareOffsetEntry.setTransactionLedgerEntryDescription(getOffsetMessage());
        OffsetDefinition offsetDefinition = accountingCycleCachingService.getOffsetDefinition(scrubbedEntry.getUniversityFiscalYear(), scrubbedEntry.getChartOfAccountsCode(), KFSConstants.TRANSFER_FUNDS, scrubbedEntry.getFinancialBalanceTypeCode());
        if (offsetDefinition != null) {
            if (offsetDefinition.getFinancialObject() == null) {
                StringBuffer objectCodeKey = new StringBuffer();
                objectCodeKey.append(offsetDefinition.getUniversityFiscalYear());
                objectCodeKey.append("-").append(offsetDefinition.getChartOfAccountsCode());
                objectCodeKey.append("-").append(offsetDefinition.getFinancialObjectCode());
                Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_OBJECT_CODE_NOT_FOUND) + " (" + objectCodeKey.toString() + ")", Message.TYPE_FATAL);
                LOG.debug("generateCostShareEntries() Error 1 object not found");
                return new ScrubberProcessTransactionError(costShareEntry, m);
            }
            costShareOffsetEntry.setFinancialObjectCode(offsetDefinition.getFinancialObjectCode());
            costShareOffsetEntry.setFinancialObject(offsetDefinition.getFinancialObject());
            costShareOffsetEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
            StringBuffer offsetKey = new StringBuffer("cost share transfer ");
            offsetKey.append(scrubbedEntry.getUniversityFiscalYear());
            offsetKey.append("-");
            offsetKey.append(scrubbedEntry.getChartOfAccountsCode());
            offsetKey.append("-TF-");
            offsetKey.append(scrubbedEntry.getFinancialBalanceTypeCode());
            Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_NOT_FOUND) + " (" + offsetKey.toString() + ")", Message.TYPE_FATAL);
            LOG.debug("generateCostShareEntries() Error 2 offset not found");
            return new ScrubberProcessTransactionError(costShareEntry, m);
        }
        costShareOffsetEntry.setFinancialObjectTypeCode(offsetDefinition.getFinancialObject().getFinancialObjectTypeCode());
        if (costShareEntry.isCredit()) {
            costShareOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        } else {
            costShareOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        }
        try {
            flexibleOffsetAccountService.updateOffset(costShareOffsetEntry);
        } catch (InvalidFlexibleOffsetException e) {
            Message m = new Message(e.getMessage(), Message.TYPE_FATAL);
            if (LOG.isDebugEnabled()) {
                LOG.debug("generateCostShareEntries() Cost Share Transfer Flexible Offset Error: " + e.getMessage());
            }
            return new ScrubberProcessTransactionError(costShareEntry, m);
        }
        createOutputEntry(costShareOffsetEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        OriginEntryFull costShareSourceAccountEntry = new OriginEntryFull(costShareEntry);
        description = new StringBuffer();
        description.append(costShareDescription);
        description.append(" ").append(scrubbedEntry.getAccountNumber());
        description.append(offsetString);
        costShareSourceAccountEntry.setTransactionLedgerEntryDescription(description.toString());
        // CU Customization: If Cost Share account is closed, use its continuation account instead.
        ScrubberProcessTransactionError continuationError = setupEntryWithPotentialContinuation(costShareSourceAccountEntry, scrubbedEntryA21SubAccount);
        if (continuationError != null) {
            return continuationError;
        }
        setCostShareObjectCode(costShareSourceAccountEntry, scrubbedEntry);
        if (StringHelper.isNullOrEmpty(costShareSourceAccountEntry.getSubAccountNumber())) {
            costShareSourceAccountEntry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
        }
        costShareSourceAccountEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        costShareSourceAccountEntry.setFinancialObjectTypeCode(scrubbedEntryOption.getFinancialObjectTypeTransferExpenseCd());
        costShareSourceAccountEntry.setTransactionLedgerEntrySequenceNumber(new Integer(0));
        costShareSourceAccountEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount);
        if (scrubCostShareAmount.isPositive()) {
            costShareSourceAccountEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        } else {
            costShareSourceAccountEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
            costShareSourceAccountEntry.setTransactionLedgerEntryAmount(scrubCostShareAmount.negated());
        }
        costShareSourceAccountEntry.setTransactionDate(runDate);
        costShareSourceAccountEntry.setOrganizationDocumentNumber(null);
        costShareSourceAccountEntry.setProjectCode(KFSConstants.getDashProjectCode());
        costShareSourceAccountEntry.setOrganizationReferenceId(null);
        costShareSourceAccountEntry.setReferenceFinancialDocumentTypeCode(null);
        costShareSourceAccountEntry.setReferenceFinancialSystemOriginationCode(null);
        costShareSourceAccountEntry.setReferenceFinancialDocumentNumber(null);
        costShareSourceAccountEntry.setFinancialDocumentReversalDate(null);
        costShareSourceAccountEntry.setTransactionEncumbranceUpdateCode(null);
        createOutputEntry(costShareSourceAccountEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        OriginEntryFull costShareSourceAccountOffsetEntry = new OriginEntryFull(costShareSourceAccountEntry);
        costShareSourceAccountOffsetEntry.setTransactionLedgerEntryDescription(getOffsetMessage());
        // Lookup the new offset definition.
        offsetDefinition = accountingCycleCachingService.getOffsetDefinition(scrubbedEntry.getUniversityFiscalYear(), scrubbedEntry.getChartOfAccountsCode(), KFSConstants.TRANSFER_FUNDS, scrubbedEntry.getFinancialBalanceTypeCode());
        if (offsetDefinition != null) {
            if (offsetDefinition.getFinancialObject() == null) {
                Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
                StringBuffer objectCodeKey = new StringBuffer();
                objectCodeKey.append(costShareEntry.getUniversityFiscalYear());
                objectCodeKey.append("-").append(scrubbedEntry.getChartOfAccountsCode());
                objectCodeKey.append("-").append(scrubbedEntry.getFinancialObjectCode());
                Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_OBJECT_CODE_NOT_FOUND) + " (" + objectCodeKey.toString() + ")", Message.TYPE_FATAL);
                LOG.debug("generateCostShareEntries() Error 3 object not found");
                return new ScrubberProcessTransactionError(costShareSourceAccountEntry, m);
            }
            costShareSourceAccountOffsetEntry.setFinancialObjectCode(offsetDefinition.getFinancialObjectCode());
            costShareSourceAccountOffsetEntry.setFinancialObject(offsetDefinition.getFinancialObject());
            costShareSourceAccountOffsetEntry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
        } else {
            Map<Transaction, List<Message>> errors = new HashMap<Transaction, List<Message>>();
            StringBuffer offsetKey = new StringBuffer("cost share transfer source ");
            offsetKey.append(scrubbedEntry.getUniversityFiscalYear());
            offsetKey.append("-");
            offsetKey.append(scrubbedEntry.getChartOfAccountsCode());
            offsetKey.append("-TF-");
            offsetKey.append(scrubbedEntry.getFinancialBalanceTypeCode());
            Message m = new Message(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_OFFSET_DEFINITION_NOT_FOUND) + " (" + offsetKey.toString() + ")", Message.TYPE_FATAL);
            LOG.debug("generateCostShareEntries() Error 4 offset not found");
            return new ScrubberProcessTransactionError(costShareSourceAccountEntry, m);
        }
        costShareSourceAccountOffsetEntry.setFinancialObjectTypeCode(offsetDefinition.getFinancialObject().getFinancialObjectTypeCode());
        if (scrubbedEntry.isCredit()) {
            costShareSourceAccountOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        } else {
            costShareSourceAccountOffsetEntry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        }
        try {
            flexibleOffsetAccountService.updateOffset(costShareSourceAccountOffsetEntry);
        } catch (InvalidFlexibleOffsetException e) {
            Message m = new Message(e.getMessage(), Message.TYPE_FATAL);
            if (LOG.isDebugEnabled()) {
                LOG.debug("generateCostShareEntries() Cost Share Transfer Account Flexible Offset Error: " + e.getMessage());
            }
            return new ScrubberProcessTransactionError(costShareEntry, m);
        }
        createOutputEntry(costShareSourceAccountOffsetEntry, OUTPUT_GLE_FILE_ps);
        scrubberReport.incrementCostShareEntryGenerated();
        scrubCostShareAmount = KualiDecimal.ZERO;
    } catch (IOException ioe) {
        LOG.error("generateCostShareEntries() Stopped: " + ioe.getMessage());
        throw new RuntimeException("generateCostShareEntries() Stopped: " + ioe.getMessage(), ioe);
    }
    LOG.debug("generateCostShareEntries() successful");
    return null;
}
Also used : Message(org.kuali.kfs.sys.Message) HashMap(java.util.HashMap) IOException(java.io.IOException) InvalidFlexibleOffsetException(org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException) ScrubberStep(org.kuali.kfs.gl.batch.ScrubberStep) Transaction(org.kuali.kfs.gl.businessobject.Transaction) OffsetDefinition(org.kuali.kfs.coa.businessobject.OffsetDefinition) List(java.util.List) SystemOptions(org.kuali.kfs.sys.businessobject.SystemOptions) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull) ScrubberProcessTransactionError(org.kuali.kfs.gl.businessobject.ScrubberProcessTransactionError) A21SubAccount(org.kuali.kfs.coa.businessobject.A21SubAccount)

Example 10 with OriginEntryFull

use of org.kuali.kfs.gl.businessobject.OriginEntryFull in project cu-kfs by CU-CommunityApps.

the class ReversionProcessBase method generateCashReversions.

public void generateCashReversions(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException {
    int entriesWritten = 0;
    // Reversion of cash from the actual account in the fiscal year ending (balance type of NB)
    OriginEntryFull entry = getEntry();
    entry.refreshReferenceObject("option");
    entry.setChartOfAccountsCode(unitOfWork.chartOfAccountsCode);
    entry.setAccountNumber(unitOfWork.accountNumber);
    entry.setSubAccountNumber(unitOfWork.subAccountNumber);
    entry.setFinancialObjectCode(cfReversionProcessInfo.getCashReversionChartCashObjectCode());
    entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(DEFAULT_FINANCIAL_BALANCE_TYPE_CODE);
    getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
    if (ObjectUtils.isNull(entry.getFinancialObject())) {
        throw new FatalErrorException("Object Code for Entry not found: " + entry);
    }
    entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + entry.getAccountNumber());
    entry.setTransactionLedgerEntryDescription(CASH_REVERTED_TO_MESSAGE + " " + cfReversionProcessInfo.getCashReversionAccountNumber());
    entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash());
    if (unitOfWork.getTotalCash().compareTo(KualiDecimal.ZERO) > 0) {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    } else {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash().negated());
    }
    entry.setFinancialObjectTypeCode(entry.getFinancialObject().getFinancialObjectTypeCode());
    // 3468 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
    // 3469 WS-AMT-N.
    // 3470 MOVE WS-AMT-X TO TRN-AMT-RED-X.
    originEntriesToWrite.add(entry);
    // Reversion of fund balance, starting with the actual account, to match the cash that was reverted (balance type of NB)
    entry = getEntry();
    entry.setChartOfAccountsCode(unitOfWork.chartOfAccountsCode);
    entry.setAccountNumber(unitOfWork.accountNumber);
    entry.setSubAccountNumber(unitOfWork.subAccountNumber);
    entry.setFinancialObjectCode((String) jobParameters.get(CUKFSConstants.CASH_REVERSION_OBJECT_CD));
    entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(DEFAULT_FINANCIAL_BALANCE_TYPE_CODE);
    getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
    if (ObjectUtils.isNull(entry.getFinancialObject())) {
        throw new FatalErrorException("Object Code for Entry not found: " + entry);
    }
    entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
    entry.setTransactionLedgerEntryDescription(FUND_BALANCE_REVERTED_TO_MESSAGE + cfReversionProcessInfo.getCashReversionAccountNumber());
    entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash().abs());
    if (unitOfWork.getTotalCash().compareTo(KualiDecimal.ZERO) > 0) {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
    } else {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    }
    entry.setFinancialObjectTypeCode(entry.getFinancialObject().getFinancialObjectTypeCode());
    // 3570 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
    // 3571 WS-AMT-N.
    // 3572 MOVE WS-AMT-X TO TRN-AMT-RED-X.
    getFlexibleOffsetAccountService().updateOffset(entry);
    originEntriesToWrite.add(entry);
    // Reversion of cash to the cash reversion account in the fiscal year ending (balance type of NB)
    entry = getEntry();
    entry.setChartOfAccountsCode(cfReversionProcessInfo.getCashReversionFinancialChartOfAccountsCode());
    entry.setAccountNumber(cfReversionProcessInfo.getCashReversionAccountNumber());
    entry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
    entry.setFinancialObjectCode(cfReversionProcessInfo.getCashReversionChartCashObjectCode());
    entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(DEFAULT_FINANCIAL_BALANCE_TYPE_CODE);
    getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
    if (ObjectUtils.isNull(entry.getFinancialObject())) {
        throw new FatalErrorException("Object Code for Entry not found: " + entry);
    }
    entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
    entry.setTransactionLedgerEntryDescription(CASH_REVERTED_FROM_MESSAGE + unitOfWork.accountNumber + " " + unitOfWork.subAccountNumber);
    entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash());
    if (unitOfWork.getTotalCash().compareTo(KualiDecimal.ZERO) > 0) {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
    } else {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
        entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash().negated());
    }
    entry.setFinancialObjectTypeCode(entry.getFinancialObject().getFinancialObjectTypeCode());
    // 3668 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
    // 3669 WS-AMT-N.
    // 3670 MOVE WS-AMT-X TO TRN-AMT-RED-X.
    originEntriesToWrite.add(entry);
    // Reversion of fund balance, starting with the cash reversion account, to match the cash that was reverted (balance type of NB)
    entry = getEntry();
    entry.setChartOfAccountsCode(cfReversionProcessInfo.getCashReversionFinancialChartOfAccountsCode());
    entry.setAccountNumber(cfReversionProcessInfo.getCashReversionAccountNumber());
    entry.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
    entry.setFinancialObjectCode((String) jobParameters.get(CUKFSConstants.CASH_REVERSION_OBJECT_CD));
    entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(DEFAULT_FINANCIAL_BALANCE_TYPE_CODE);
    getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
    if (ObjectUtils.isNull(entry.getFinancialObject())) {
        throw new FatalErrorException("Object Code for Entry not found: " + entry);
    }
    entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
    entry.setTransactionLedgerEntryDescription(FUND_BALANCE_REVERTED_FROM_MESSAGE + unitOfWork.accountNumber + " " + unitOfWork.subAccountNumber);
    entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash());
    if (unitOfWork.getTotalCash().compareTo(KualiDecimal.ZERO) > 0) {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_CREDIT_CODE);
    } else {
        entry.setTransactionDebitCreditCode(KFSConstants.GL_DEBIT_CODE);
        entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCash().negated());
    }
    entry.setFinancialObjectTypeCode(entry.getFinancialObject().getFinancialObjectTypeCode());
    // 3768 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
    // 3769 WS-AMT-N.
    // 3770 MOVE WS-AMT-X TO TRN-AMT-RED-X.
    getFlexibleOffsetAccountService().updateOffset(entry);
    originEntriesToWrite.add(entry);
}
Also used : FatalErrorException(org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Aggregations

OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)20 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)6 FatalErrorException (org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException)5 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)4 ConcurStandardAccountingExtractDetailLine (edu.cornell.kfs.concur.batch.businessobject.ConcurStandardAccountingExtractDetailLine)3 List (java.util.List)3 InvalidFlexibleOffsetException (org.kuali.kfs.sys.exception.InvalidFlexibleOffsetException)3 IOException (java.io.IOException)2 Message (org.kuali.kfs.sys.Message)2 ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)1 ReversionCategoryInfo (edu.cornell.kfs.coa.businessobject.ReversionCategoryInfo)1 ReversionUnitOfWork (edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork)1 ReversionUnitOfWorkCategoryAmount (edu.cornell.kfs.gl.businessobject.ReversionUnitOfWorkCategoryAmount)1 BigDecimal (java.math.BigDecimal)1 Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 A21SubAccount (org.kuali.kfs.coa.businessobject.A21SubAccount)1