Search in sources :

Example 6 with ReversionCategory

use of edu.cornell.kfs.coa.businessobject.ReversionCategory in project cu-kfs by CU-CommunityApps.

the class AccountReversionServiceImpl method isCategoryActive.

/**
 * @see org.kuali.kfs.coa.service.OrganizationReversionService#isCategoryActive(java.lang.String)
 */
public boolean isCategoryActive(String categoryCode) {
    Map<String, Object> pkMap = new HashMap<String, Object>();
    pkMap.put("reversionCategoryCode", categoryCode);
    final ReversionCategory category = (ReversionCategory) businessObjectService.findByPrimaryKey(ReversionCategory.class, pkMap);
    if (category == null)
        return false;
    return category.isActive();
}
Also used : HashMap(java.util.HashMap) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory) GenericReversionCategory(edu.cornell.kfs.gl.batch.service.impl.GenericReversionCategory)

Example 7 with ReversionCategory

use of edu.cornell.kfs.coa.businessobject.ReversionCategory 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 8 with ReversionCategory

use of edu.cornell.kfs.coa.businessobject.ReversionCategory in project cu-kfs by CU-CommunityApps.

the class ReversionUnitOfWork method setCategories.

public void setCategories(List<ReversionCategory> cats) {
    for (ReversionCategory element : cats) {
        ReversionUnitOfWorkCategoryAmount ca = new ReversionUnitOfWorkCategoryAmount(element.getReversionCategoryCode());
        amounts.put(element.getReversionCategoryCode(), ca);
    }
}
Also used : ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory)

Example 9 with ReversionCategory

use of edu.cornell.kfs.coa.businessobject.ReversionCategory in project cu-kfs by CU-CommunityApps.

the class AccountReversionMaintainableImpl method processAfterNew.

@Override
public void processAfterNew(MaintenanceDocument document, Map<String, String[]> requestParameters) {
    super.processAfterNew(document, requestParameters);
    AccountReversion accountReversion = (AccountReversion) getBusinessObject();
    List<AccountReversionDetail> details = accountReversion.getAccountReversionDetails();
    if (details == null) {
        details = new ArrayList<AccountReversionDetail>();
        accountReversion.setAccountReversionDetails(details);
    }
    if (details.size() == 0) {
        Collection<ReversionCategory> categories = SpringContext.getBean(AccountReversionService.class).getCategoryList();
        for (ReversionCategory category : categories) {
            if (category.isActive()) {
                AccountReversionDetail detail = new AccountReversionDetail();
                detail.setAccountReversionCategoryCode(category.getReversionCategoryCode());
                detail.setReversionCategory(category);
                details.add(detail);
            }
        }
        Collections.sort(details, new categoryComparator());
    }
}
Also used : AccountReversion(edu.cornell.kfs.coa.businessobject.AccountReversion) AccountReversionDetail(edu.cornell.kfs.coa.businessobject.AccountReversionDetail) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory) AccountReversionService(edu.cornell.kfs.coa.service.AccountReversionService)

Example 10 with ReversionCategory

use of edu.cornell.kfs.coa.businessobject.ReversionCategory in project cu-kfs by CU-CommunityApps.

the class ReversionCategoryMaintainableImpl method retrieveExistingReversionCategory.

/**
 * Grabs the old version of this reversion category from the database
 * @return the old version of this reversion category
 */
protected ReversionCategory retrieveExistingReversionCategory() {
    final ReversionCategory orgRevCategory = (ReversionCategory) getBusinessObject();
    Map<String, Object> pkMap = new HashMap<String, Object>();
    pkMap.put("reversionCategoryCode", ((ReversionCategory) getBusinessObject()).getReversionCategoryCode());
    final ReversionCategory oldRevCategory = (ReversionCategory) SpringContext.getBean(BusinessObjectService.class).findByPrimaryKey(ReversionCategory.class, pkMap);
    return oldRevCategory;
}
Also used : HashMap(java.util.HashMap) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory)

Aggregations

ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)15 ReversionCategoryLogic (edu.cornell.kfs.gl.batch.service.ReversionCategoryLogic)4 HashMap (java.util.HashMap)4 AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)3 GenericReversionCategory (edu.cornell.kfs.gl.batch.service.impl.GenericReversionCategory)3 ReversionUnitOfWorkCategoryAmount (edu.cornell.kfs.gl.businessobject.ReversionUnitOfWorkCategoryAmount)3 AccountReversion (edu.cornell.kfs.coa.businessobject.AccountReversion)2 AccountReversionDetail (edu.cornell.kfs.coa.businessobject.AccountReversionDetail)2 AccountReversionGlobal (edu.cornell.kfs.coa.businessobject.AccountReversionGlobal)2 AccountReversionGlobalDetail (edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail)2 ReversionCategoryInfo (edu.cornell.kfs.coa.businessobject.ReversionCategoryInfo)2 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 FatalErrorException (org.kuali.kfs.gl.batch.service.impl.exception.FatalErrorException)2 KualiDecimal (org.kuali.rice.core.api.util.type.KualiDecimal)2 ArrayList (java.util.ArrayList)1 ObjectCode (org.kuali.kfs.coa.businessobject.ObjectCode)1 OriginEntryFull (org.kuali.kfs.gl.businessobject.OriginEntryFull)1 KeyValuesService (org.kuali.kfs.krad.service.KeyValuesService)1 ConcreteKeyValue (org.kuali.rice.core.api.util.ConcreteKeyValue)1