Search in sources :

Example 1 with AccountReversionService

use of edu.cornell.kfs.coa.service.AccountReversionService in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobalMaintainableImpl method setBusinessObject.

/**
 * Just like AccountReversionMaintainableImpl's setBusinessObject method populates the list of details so there is one
 * detail per active Account Reversion Category, this method populates a list of Account Reversion Change details.
 *
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#setBusinessObject(org.kuali.kfs.kns.bo.PersistableBusinessObject)
 */
@Override
public void setBusinessObject(PersistableBusinessObject businessObject) {
    super.setBusinessObject(businessObject);
    AccountReversionService accountReversionService = SpringContext.getBean(AccountReversionService.class);
    AccountReversionGlobal globalAcctRev = (AccountReversionGlobal) businessObject;
    List<AccountReversionGlobalDetail> details = globalAcctRev.getAccountReversionGlobalDetails();
    LOG.debug("Details size before adding categories = " + details.size());
    if (details == null) {
        details = new ArrayList<AccountReversionGlobalDetail>();
        globalAcctRev.setAccountReversionGlobalDetails(details);
    }
    if (details.size() == 0) {
        Collection<ReversionCategory> categories = getAccountReversionService().getCategoryList();
        for (ReversionCategory category : categories) {
            if (category.isActive()) {
                AccountReversionGlobalDetail detail = new AccountReversionGlobalDetail();
                detail.setAccountReversionCategoryCode(category.getReversionCategoryCode());
                detail.setReversionCategory(category);
                detail.setParentGlobalAccountReversion(globalAcctRev);
                details.add(detail);
            }
        }
        LOG.debug("Details size after adding categories = " + details.size());
        Collections.sort(details, new CategoryComparator());
    }
    super.setBusinessObject(businessObject);
}
Also used : AccountReversionGlobal(edu.cornell.kfs.coa.businessobject.AccountReversionGlobal) AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory) AccountReversionService(edu.cornell.kfs.coa.service.AccountReversionService)

Example 2 with AccountReversionService

use of edu.cornell.kfs.coa.service.AccountReversionService in project cu-kfs by CU-CommunityApps.

the class AccountReversionMaintainableImpl method setBusinessObject.

/**
 * pre-populate the static list of details with each category
 *
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#setBusinessObject(org.kuali.kfs.kns.bo.BusinessObject)
 */
public void setBusinessObject(PersistableBusinessObject businessObject) {
    AccountReversionService accountReversionService = SpringContext.getBean(AccountReversionService.class);
    AccountReversion accountReversion = (AccountReversion) businessObject;
    List<AccountReversionDetail> details = accountReversion.getAccountReversionDetails();
    if (details == null) {
        details = new ArrayList<AccountReversionDetail>();
        accountReversion.setAccountReversionDetails(details);
    }
    if (details.size() == 0) {
        Collection<ReversionCategory> categories = accountReversionService.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());
    }
    super.setBusinessObject(businessObject);
}
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 3 with AccountReversionService

use of edu.cornell.kfs.coa.service.AccountReversionService in project cu-kfs by CU-CommunityApps.

the class AccountReversionGlobal method generateGlobalChangesToPersist.

/**
 * @see org.kuali.kfs.kns.bo.GlobalBusinessObject#generateGlobalChangesToPersist() This creates a list of changes to be made to the
 *      existing and/or new Account Reversion records impacted by this global reversion.
 */
public List<PersistableBusinessObject> generateGlobalChangesToPersist() {
    List<PersistableBusinessObject> persistingChanges = new ArrayList<PersistableBusinessObject>();
    AccountReversionService accountReversionService = SpringContext.getBean(AccountReversionService.class);
    Map<String, AccountReversionGlobalDetail> detailsMap = this.rearrangeAccountReversionDetailsAsMap();
    for (AccountReversionGlobalAccount acctRevAccount : this.getAccountReversionGlobalAccounts()) {
        // 1. find that account reversion
        AccountReversion currAcctRev = accountReversionService.getByPrimaryId(this.getUniversityFiscalYear(), acctRevAccount.getChartOfAccountsCode(), acctRevAccount.getAccountNumber());
        if (ObjectUtils.isNull(currAcctRev)) {
            // If account reversion does not exist, then create it and its details.
            currAcctRev = new AccountReversion();
            currAcctRev.setUniversityFiscalYear(this.getUniversityFiscalYear());
            currAcctRev.setChartOfAccountsCode(acctRevAccount.getChartOfAccountsCode());
            currAcctRev.setAccountNumber(acctRevAccount.getAccountNumber());
            for (AccountReversionGlobalDetail globalDetail : this.getAccountReversionGlobalDetails()) {
                AccountReversionDetail revDetail = new AccountReversionDetail();
                revDetail.setAccountReversionCategoryCode(globalDetail.getAccountReversionCategoryCode());
                revDetail.setUniversityFiscalYear(currAcctRev.getUniversityFiscalYear());
                revDetail.setChartOfAccountsCode(currAcctRev.getChartOfAccountsCode());
                revDetail.setAccountNumber(currAcctRev.getAccountNumber());
                currAcctRev.addAccountReversionDetail(revDetail);
            }
        }
        // 2. update account reversion
        if (!StringUtils.isBlank(this.getBudgetReversionChartOfAccountsCode())) {
            currAcctRev.setBudgetReversionChartOfAccountsCode(this.getBudgetReversionChartOfAccountsCode());
        }
        if (!StringUtils.isBlank(this.getBudgetReversionAccountNumber())) {
            currAcctRev.setBudgetReversionAccountNumber(this.getBudgetReversionAccountNumber());
        }
        if (!StringUtils.isBlank(this.getCashReversionFinancialChartOfAccountsCode())) {
            currAcctRev.setCashReversionFinancialChartOfAccountsCode(this.getCashReversionFinancialChartOfAccountsCode());
        }
        if (!StringUtils.isBlank(this.getCashReversionAccountNumber())) {
            currAcctRev.setCashReversionAccountNumber(this.getCashReversionAccountNumber());
        }
        if (this.isCarryForwardByObjectCodeIndicator() != null) {
            currAcctRev.setCarryForwardByObjectCodeIndicator(this.isCarryForwardByObjectCodeIndicator().booleanValue());
        }
        if (this.isReversionActiveIndicator() != null) {
            currAcctRev.setActive(this.isReversionActiveIndicator().booleanValue());
        }
        // 3. now, go through each account reversion detail and update each of those
        for (AccountReversionDetail acctRevDetail : currAcctRev.getAccountReversionDetails()) {
            AccountReversionGlobalDetail changeDetail = detailsMap.get(acctRevDetail.getAccountReversionCategoryCode());
            if (changeDetail != null) {
                if (!StringUtils.isBlank(changeDetail.getAccountReversionCode())) {
                    acctRevDetail.setAccountReversionCode(changeDetail.getAccountReversionCode());
                }
                if (!StringUtils.isBlank(changeDetail.getAccountReversionObjectCode())) {
                    acctRevDetail.setAccountReversionObjectCode(changeDetail.getAccountReversionObjectCode());
                }
                if (this.isReversionActiveIndicator() != null) {
                    acctRevDetail.setActive(this.isReversionActiveIndicator().booleanValue());
                }
            }
        }
        currAcctRev.refreshNonUpdateableReferences();
        persistingChanges.add(currAcctRev);
    }
    return persistingChanges;
}
Also used : PersistableBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject) ArrayList(java.util.ArrayList) AccountReversionService(edu.cornell.kfs.coa.service.AccountReversionService)

Example 4 with AccountReversionService

use of edu.cornell.kfs.coa.service.AccountReversionService in project cu-kfs by CU-CommunityApps.

the class AccountReversionInquirable method getSections.

/**
 * Overridden to take out details with inactive categories
 * @see org.kuali.kfs.kns.inquiry.KualiInquirableImpl#getSections(org.kuali.kfs.kns.bo.BusinessObject)
 */
@Override
public List<Section> getSections(BusinessObject bo) {
    List<Section> sections = super.getSections(bo);
    if (accountReversionService == null) {
        accountReversionService = SpringContext.getBean(AccountReversionService.class);
    }
    for (Section section : sections) {
        for (Row row : section.getRows()) {
            List<Field> updatedFields = new ArrayList<Field>();
            for (Field field : row.getFields()) {
                if (shouldIncludeField(field)) {
                    updatedFields.add(field);
                }
            }
            row.setFields(updatedFields);
        }
    }
    return sections;
}
Also used : Field(org.kuali.kfs.kns.web.ui.Field) ArrayList(java.util.ArrayList) Row(org.kuali.kfs.kns.web.ui.Row) Section(org.kuali.kfs.kns.web.ui.Section) AccountReversionService(edu.cornell.kfs.coa.service.AccountReversionService)

Example 5 with AccountReversionService

use of edu.cornell.kfs.coa.service.AccountReversionService in project cu-kfs by CU-CommunityApps.

the class AccountReversionMaintainableImpl method getSections.

/**
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#getSections(org.kuali.kfs.kns.document.MaintenanceDocument, org.kuali.kfs.kns.maintenance.Maintainable)
 */
@Override
public List getSections(MaintenanceDocument document, Maintainable oldMaintainable) {
    List<Section> sections = super.getSections(document, oldMaintainable);
    if (accountReversionService == null) {
        accountReversionService = SpringContext.getBean(AccountReversionService.class);
    }
    for (Section section : sections) {
        for (Row row : section.getRows()) {
            List<Field> updatedFields = new ArrayList<Field>();
            for (Field field : row.getFields()) {
                if (shouldIncludeField(field)) {
                    updatedFields.add(field);
                }
            }
            row.setFields(updatedFields);
        }
    }
    return sections;
}
Also used : Field(org.kuali.kfs.kns.web.ui.Field) ArrayList(java.util.ArrayList) Row(org.kuali.kfs.kns.web.ui.Row) Section(org.kuali.kfs.kns.web.ui.Section) AccountReversionService(edu.cornell.kfs.coa.service.AccountReversionService)

Aggregations

AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)5 ArrayList (java.util.ArrayList)3 ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)2 Field (org.kuali.kfs.kns.web.ui.Field)2 Row (org.kuali.kfs.kns.web.ui.Row)2 Section (org.kuali.kfs.kns.web.ui.Section)2 AccountReversion (edu.cornell.kfs.coa.businessobject.AccountReversion)1 AccountReversionDetail (edu.cornell.kfs.coa.businessobject.AccountReversionDetail)1 AccountReversionGlobal (edu.cornell.kfs.coa.businessobject.AccountReversionGlobal)1 AccountReversionGlobalDetail (edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail)1 PersistableBusinessObject (org.kuali.kfs.krad.bo.PersistableBusinessObject)1