Search in sources :

Example 1 with FatalErrorException

use of org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException 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)

Example 2 with FatalErrorException

use of org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException in project cu-kfs by CU-CommunityApps.

the class ReversionProcessBase method calculateTotals.

public void calculateTotals() throws FatalErrorException {
    /*
         * How this works: At the start, in the clearCalculationTotals(), both the unit of work's totalAvailable and totalReversion
         * are set to the available amounts from each of the category amounts. Then, as the logic is applied, the totalCarryForward
         * is added to and the totalReversion is subtracted from. Let's look at a simple example: Let's say you've got an amount for
         * C01, which has $2000 available, no encumbrances, that's all you've got. This means that at the end of
         * clearCalculationTotals(), there's $2000 in totalAvailable, $2000 in totalReversion, and $0 in totalCarryForward. Now, C01,
         * let's say, is for code A. So, look below at the if that catches Code A. You'll note that it adds the available amount to
         * totalCarryForward, it's own carryForward, the negated available to totalReversion, and that, done, it sets available to
         * $0. With our example, that means that $2000 is in totalCarryForward (and in the amount's carryForward), the
         * totalReversion has been knocked down to $0, and the available is $0. So, carry forward origin entries get created, and
         * reversions do not. This is also why you don't see a block about calculating R2 totals below...the process has a natural
         * inclination towards creating R2 (ie, ignore encumbrances and revert all available) entries.
         */
    // clear out the unit of work totals we're going to calculate values in, in preperation for applying rules
    clearCalculationTotals();
    // For each category, apply the rules
    for (ReversionCategory category : categoryList) {
        String categoryCode = category.getReversionCategoryCode();
        ReversionCategoryLogic logic = categories.get(categoryCode);
        ReversionUnitOfWorkCategoryAmount amount = unitOfWork.amounts.get(categoryCode);
        ReversionCategoryInfo detail = cfReversionProcessInfo.getReversionDetail(categoryCode);
        if (detail == null) {
            throw new FatalErrorException(" Reversion " + cfReversionProcessInfo.getUniversityFiscalYear() + "-" + cfReversionProcessInfo.getChartOfAccountsCode() + "-" + cfReversionProcessInfo.getSourceAttribute() + " does not have a detail for category " + categoryCode);
        }
        String ruleCode = detail.getReversionCode();
        // if (LOG.isDebugEnabled()) {
        LOG.info("Unit of Work: " + unitOfWork.getChartOfAccountsCode() + unitOfWork.getAccountNumber() + unitOfWork.getSubAccountNumber() + ", category " + category.getReversionCategoryName() + ": budget = " + amount.getBudget() + "; actual = " + amount.getActual() + "; encumbrance = " + amount.getEncumbrance() + "; available = " + amount.getAvailable() + "; apply rule code " + ruleCode);
        // xe
        if (KFSConstants.RULE_CODE_R1.equals(ruleCode) || KFSConstants.RULE_CODE_N1.equals(ruleCode) || KFSConstants.RULE_CODE_C1.equals(ruleCode)) {
            if (amount.getAvailable().compareTo(KualiDecimal.ZERO) > 0) {
                // do we have budget left?
                if (amount.getAvailable().compareTo(amount.getEncumbrance()) > 0) {
                    // is it more than enough to cover our
                    // encumbrances?
                    unitOfWork.addTotalCarryForward(amount.getEncumbrance());
                    amount.addCarryForward(amount.getEncumbrance());
                    unitOfWork.addTotalReversion(amount.getEncumbrance().negated());
                    amount.addAvailable(amount.getEncumbrance().negated());
                } else {
                    // there's not enough available left to cover the encumbrances; cover what we can
                    unitOfWork.addTotalCarryForward(amount.getAvailable());
                    amount.addCarryForward(amount.getAvailable());
                    unitOfWork.addTotalReversion(amount.getAvailable().negated());
                    amount.setAvailable(KualiDecimal.ZERO);
                }
            }
        }
        // Check this in the debugger to see if this is the right amt to get..
        if (CUKFSConstants.RULE_CODE_CA.equals(ruleCode)) {
        // just gonna break this right here...amount.
        // unitOfWork.addTotalCash(amount.getAvailable());
        // amount.addActual(amount.getAvailable());
        // unitOfWork.addTotalReversion(amount.getAvailable().negated());
        // amount.setAvailable(KualiDecimal.ZERO);
        }
        // xa
        if (KFSConstants.RULE_CODE_A.equals(ruleCode)) {
            unitOfWork.addTotalCarryForward(amount.getAvailable());
            amount.addCarryForward(amount.getAvailable());
            unitOfWork.addTotalReversion(amount.getAvailable().negated());
            amount.setAvailable(KualiDecimal.ZERO);
        }
        // xp
        if (KFSConstants.RULE_CODE_C1.equals(ruleCode) || KFSConstants.RULE_CODE_C2.equals(ruleCode)) {
            if (amount.getAvailable().compareTo(KualiDecimal.ZERO) > 0) {
                unitOfWork.addTotalCarryForward(amount.getAvailable());
                amount.addCarryForward(amount.getAvailable());
                unitOfWork.addTotalReversion(amount.getAvailable().negated());
                amount.setAvailable(KualiDecimal.ZERO);
            }
        }
        // xn
        if (KFSConstants.RULE_CODE_N1.equals(ruleCode) || KFSConstants.RULE_CODE_N2.equals(ruleCode)) {
            if (amount.getAvailable().compareTo(KualiDecimal.ZERO) < 0) {
                unitOfWork.addTotalCarryForward(amount.getAvailable());
                amount.addCarryForward(amount.getAvailable());
                unitOfWork.addTotalReversion(amount.getAvailable().negated());
                amount.setAvailable(KualiDecimal.ZERO);
            }
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("Totals Now: " + unitOfWork.getChartOfAccountsCode() + unitOfWork.getAccountNumber() + unitOfWork.getSubAccountNumber() + ", total cash now " + unitOfWork.getTotalCash() + ": total available = " + unitOfWork.getTotalAvailable() + "; total reversion = " + unitOfWork.getTotalReversion() + "; total carry forward = " + unitOfWork.getTotalCarryForward());
        }
    }
}
Also used : ReversionUnitOfWorkCategoryAmount(edu.cornell.kfs.gl.businessobject.ReversionUnitOfWorkCategoryAmount) ReversionCategoryLogic(edu.cornell.kfs.gl.batch.service.ReversionCategoryLogic) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory) FatalErrorException(org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException) ReversionCategoryInfo(edu.cornell.kfs.coa.businessobject.ReversionCategoryInfo)

Example 3 with FatalErrorException

use of org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException 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 4 with FatalErrorException

use of org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException in project cu-kfs by CU-CommunityApps.

the class ReversionProcessBase method generateCarryForwards.

public void generateCarryForwards(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException {
    int originEntriesWritten = 0;
    OriginEntryFull entry = getEntry();
    entry.setUniversityFiscalYear((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR) + 1);
    entry.setChartOfAccountsCode(unitOfWork.chartOfAccountsCode);
    entry.setAccountNumber(unitOfWork.accountNumber);
    entry.setSubAccountNumber(unitOfWork.subAccountNumber);
    entry.setFinancialObjectCode((String) jobParameters.get(KFSConstants.BEG_BUD_CASH_OBJECT_CD));
    entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_CURRENT_BUDGET);
    getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
    if (ObjectUtils.isNull(entry.getFinancialObject())) {
        throw new FatalErrorException("Object Code for Entry not found: " + entry);
    }
    ObjectCode objectCode = entry.getFinancialObject();
    entry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
    entry.setUniversityFiscalPeriodCode(KFSConstants.MONTH1);
    entry.setFinancialDocumentTypeCode(DEFAULT_FINANCIAL_DOCUMENT_TYPE_CODE);
    entry.setFinancialSystemOriginationCode(DEFAULT_FINANCIAL_SYSTEM_ORIGINATION_CODE);
    entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
    entry.setTransactionLedgerEntrySequenceNumber(1);
    entry.setTransactionLedgerEntryDescription(FUND_CARRIED_MESSAGE + (Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
    entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCarryForward());
    entry.setTransactionDate((Date) jobParameters.get(KFSConstants.TRANSACTION_DT));
    entry.setProjectCode(KFSConstants.getDashProjectCode());
    // 2995 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
    // 2996 WS-AMT-N.
    // 2997 MOVE WS-AMT-X TO TRN-AMT-RED-X.
    originEntriesToWrite.add(entry);
    entry = getEntry();
    entry.setUniversityFiscalYear((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR) + 1);
    entry.setChartOfAccountsCode(unitOfWork.chartOfAccountsCode);
    entry.setAccountNumber(unitOfWork.accountNumber);
    entry.setSubAccountNumber(unitOfWork.subAccountNumber);
    entry.setFinancialObjectCode((String) jobParameters.get(KFSConstants.UNALLOC_OBJECT_CD));
    getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
    if (ObjectUtils.isNull(entry.getFinancialObject())) {
        throw new FatalErrorException("Object Code for Entry not found: " + entry);
    }
    objectCode = entry.getFinancialObject();
    entry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
    entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
    entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_CURRENT_BUDGET);
    entry.setUniversityFiscalPeriodCode(KFSConstants.MONTH1);
    entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
    entry.setTransactionLedgerEntryDescription(FUND_CARRIED_MESSAGE + (Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
    entry.setTransactionLedgerEntryAmount(unitOfWork.getTotalCarryForward());
    // 3079 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
    // 3080 WS-AMT-N.
    // 3081 MOVE WS-AMT-X TO TRN-AMT-RED-X.
    originEntriesToWrite.add(entry);
}
Also used : FatalErrorException(org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Example 5 with FatalErrorException

use of org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException in project cu-kfs by CU-CommunityApps.

the class ReversionProcessBase method generateMany.

public void generateMany(List<OriginEntryFull> originEntriesToWrite) throws FatalErrorException {
    int originEntriesCreated = 0;
    for (Iterator<ReversionCategory> iter = categoryList.iterator(); iter.hasNext(); ) {
        ReversionCategory cat = iter.next();
        ReversionCategoryInfo detail = cfReversionProcessInfo.getReversionDetail(cat.getReversionCategoryCode());
        ReversionUnitOfWorkCategoryAmount amount = unitOfWork.amounts.get(cat.getReversionCategoryCode());
        if (!amount.getCarryForward().isZero()) {
            KualiDecimal commonAmount = amount.getCarryForward();
            String commonObject = detail.getReversionObjectCode();
            OriginEntryFull entry = getEntry();
            entry.setUniversityFiscalYear((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR) + 1);
            entry.setChartOfAccountsCode(unitOfWork.chartOfAccountsCode);
            entry.setAccountNumber(unitOfWork.accountNumber);
            entry.setSubAccountNumber(unitOfWork.subAccountNumber);
            entry.setFinancialObjectCode((String) jobParameters.get(KFSConstants.BEG_BUD_CASH_OBJECT_CD));
            entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
            entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_CURRENT_BUDGET);
            getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
            if (ObjectUtils.isNull(entry.getFinancialObject())) {
                throw new FatalErrorException("Object Code for Entry not found: " + entry);
            }
            ObjectCode objectCode = entry.getFinancialObject();
            entry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
            entry.setUniversityFiscalPeriodCode(KFSConstants.MONTH1);
            entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
            entry.setTransactionLedgerEntryDescription(FUND_CARRIED_MESSAGE + (Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
            entry.setTransactionLedgerEntryAmount(commonAmount);
            // 3259 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
            // 3260 WS-AMT-N.
            // 3261 MOVE WS-AMT-X TO TRN-AMT-RED-X.
            originEntriesToWrite.add(entry);
            entry = getEntry();
            entry.setUniversityFiscalYear((Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR) + 1);
            entry.setChartOfAccountsCode(unitOfWork.chartOfAccountsCode);
            entry.setAccountNumber(unitOfWork.accountNumber);
            entry.setSubAccountNumber(unitOfWork.subAccountNumber);
            entry.setFinancialObjectCode(commonObject);
            entry.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
            entry.setFinancialBalanceTypeCode(KFSConstants.BALANCE_TYPE_CURRENT_BUDGET);
            getPersistenceService().retrieveReferenceObject(entry, KFSPropertyConstants.FINANCIAL_OBJECT);
            if (ObjectUtils.isNull(entry.getFinancialObject())) {
                throw new FatalErrorException("Object Code for Entry not found: " + entry);
            }
            objectCode = entry.getFinancialObject();
            entry.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode());
            entry.setUniversityFiscalPeriodCode(KFSConstants.MONTH1);
            entry.setDocumentNumber(DEFAULT_DOCUMENT_NUMBER_PREFIX + unitOfWork.accountNumber);
            entry.setTransactionLedgerEntryDescription(FUND_CARRIED_MESSAGE + (Integer) jobParameters.get(KFSConstants.UNIV_FISCAL_YR));
            entry.setTransactionLedgerEntryAmount(commonAmount);
            // 3343 MOVE TRN-LDGR-ENTR-AMT TO WS-AMT-W-PERIOD
            // 3344 WS-AMT-N.
            // 3345 MOVE WS-AMT-X TO TRN-AMT-RED-X.
            originEntriesToWrite.add(entry);
        }
    }
}
Also used : ReversionUnitOfWorkCategoryAmount(edu.cornell.kfs.gl.businessobject.ReversionUnitOfWorkCategoryAmount) KualiDecimal(org.kuali.kfs.core.api.util.type.KualiDecimal) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory) FatalErrorException(org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException) ObjectCode(org.kuali.kfs.coa.businessobject.ObjectCode) ReversionCategoryInfo(edu.cornell.kfs.coa.businessobject.ReversionCategoryInfo) OriginEntryFull(org.kuali.kfs.gl.businessobject.OriginEntryFull)

Aggregations

FatalErrorException (org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException)6 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)5 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)3 ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)2 ReversionCategoryInfo (edu.cornell.kfs.coa.businessobject.ReversionCategoryInfo)2 ReversionUnitOfWorkCategoryAmount (edu.cornell.kfs.gl.businessobject.ReversionUnitOfWorkCategoryAmount)2 ReversionCategoryLogic (edu.cornell.kfs.gl.batch.service.ReversionCategoryLogic)1 ReversionUnitOfWork (edu.cornell.kfs.gl.businessobject.ReversionUnitOfWork)1 List (java.util.List)1 KualiDecimal (org.kuali.kfs.core.api.util.type.KualiDecimal)1 Balance (org.kuali.kfs.gl.businessobject.Balance)1