Search in sources :

Example 1 with AccountReversionGlobalDetail

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

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

the class AccountReversionGlobalMaintainableImpl method processAfterNew.

/**
 * Just like OrganizationReversionMaintainableImpl's setBusinessObject method populates the list of details so there is one
 * detail per active Organization Reversion Category, this method populates a list of Organization Reversion Change details.
 *
 * @see org.kuali.kfs.kns.maintenance.KualiMaintainableImpl#setBusinessObject(org.kuali.kfs.krad.bo.PersistableBusinessObject)
 */
@Override
public void processAfterNew(MaintenanceDocument document, Map<String, String[]> requestParameters) {
    super.processAfterNew(document, requestParameters);
    AccountReversionGlobal globalOrgRev = (AccountReversionGlobal) getBusinessObject();
    List<AccountReversionGlobalDetail> details = globalOrgRev.getAccountReversionGlobalDetails();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Details size before adding categories = " + details.size());
    }
    if (details == null) {
        details = new ArrayList<AccountReversionGlobalDetail>();
        globalOrgRev.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(globalOrgRev);
                details.add(detail);
            }
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug("Details size after adding categories = " + details.size());
        }
        Collections.sort(details, new CategoryComparator());
    }
}
Also used : AccountReversionGlobal(edu.cornell.kfs.coa.businessobject.AccountReversionGlobal) AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail) ReversionCategory(edu.cornell.kfs.coa.businessobject.ReversionCategory)

Example 3 with AccountReversionGlobalDetail

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

the class AccountReversionGlobalRule method areAllDetailsValid.

/**
 * Tests if all of the {@link AccountReversionGlobalDetail} objects associated with the given global account reversion are
 * valid.
 *
 * @param globalAcctRev the global account reversion to check
 * @return true if valid, false otherwise
 */
public boolean areAllDetailsValid(AccountReversionGlobal globalAcctRev) {
    boolean success = true;
    for (int i = 0; i < globalAcctRev.getAccountReversionGlobalDetails().size(); i++) {
        AccountReversionGlobalDetail detail = globalAcctRev.getAccountReversionGlobalDetails().get(i);
        String errorPath = MAINTAINABLE_ERROR_PREFIX + "accountReversionGlobalDetails[" + i + "]";
        GlobalVariables.getMessageMap().addToErrorPath(errorPath);
        if (!StringUtils.isBlank(detail.getAccountReversionObjectCode()) && !StringUtils.isBlank(detail.getAccountReversionCode())) {
            success &= this.checkDetailAcctReversionCategoryValidity(detail);
            success &= this.checkDetailObjectCodeValidity(globalAcctRev, detail);
            success &= this.checkDetailObjectReversionCodeValidity(detail);
        }
        GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
    }
    return success;
}
Also used : AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail)

Example 4 with AccountReversionGlobalDetail

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

the class AccountReversionGlobalRule method checkAllAccountReversionsExistOrAllFieldsAreDefined.

/**
 * Checks that either every account reversion on the document references an existing account reversion object,
 * or that all fields have been filled in so that new account reversions can be saved properly.
 * Will skip validation if a fiscal year has not been specified on the document.
 *
 * @param globalAcctRev global Account Reversion to check
 * @return true if all referenced account reversions already exist or all reversion and detail fields are filled in, false otherwise.
 */
public boolean checkAllAccountReversionsExistOrAllFieldsAreDefined(AccountReversionGlobal globalAcctRev) {
    boolean success = true;
    if (globalAcctRev.getUniversityFiscalYear() != null) {
        boolean allAccountReversionsExist = true;
        List<AccountReversionGlobalAccount> globalAccounts = globalAcctRev.getAccountReversionGlobalAccounts();
        for (int i = 0; allAccountReversionsExist && i < globalAccounts.size(); i++) {
            allAccountReversionsExist &= ObjectUtils.isNotNull(accountReversionService.getByPrimaryId(globalAcctRev.getUniversityFiscalYear(), globalAccounts.get(i).getChartOfAccountsCode(), globalAccounts.get(i).getAccountNumber()));
        }
        if (!allAccountReversionsExist) {
            // If new account reversions were specified, make sure all reversion fields are filled. (We know fiscal year is defined at this point.)
            boolean allFieldsFilled = StringUtils.isNotBlank(globalAcctRev.getBudgetReversionChartOfAccountsCode()) && StringUtils.isNotBlank(globalAcctRev.getBudgetReversionAccountNumber()) && globalAcctRev.getCarryForwardByObjectCodeIndicator() != null && StringUtils.isNotBlank(globalAcctRev.getCashReversionFinancialChartOfAccountsCode()) && StringUtils.isNotBlank(globalAcctRev.getCashReversionAccountNumber()) && globalAcctRev.getReversionActiveIndicator() != null;
            if (!allFieldsFilled) {
                GlobalVariables.getMessageMap().putError(GLOBAL_ACCOUNT_FIELDS_SECTION, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCT_REVERSION_MISSING_FIELDS_FOR_NEW_REVERSION);
                success = false;
            }
            // Also check that reversion details are all filled. (Reversion category code should already be set up by the document initialization.)
            for (AccountReversionGlobalDetail globalDetail : globalAcctRev.getAccountReversionGlobalDetails()) {
                allFieldsFilled &= StringUtils.isNotBlank(globalDetail.getAccountReversionCategoryCode()) && StringUtils.isNotBlank(globalDetail.getAccountReversionCode());
            }
            if (!allFieldsFilled) {
                GlobalVariables.getMessageMap().putError(GLOBAL_DETAIL_FIELDS_SECTION, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_ACCT_REVERSION_MISSING_FIELDS_FOR_NEW_REVERSION_DETAIL);
                success = false;
            }
        }
    }
    return success;
}
Also used : AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail) AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Example 5 with AccountReversionGlobalDetail

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

the class AccountReversionGlobalRule method processCustomAddCollectionLineBusinessRules.

/**
 * This performs rules checks whenever a new {@link AccountReversionGlobalDetail} or {@link AccountReversionGlobalAccount} is added
 * <p>
 * This includes:
 * <ul>
 * <li>{@link AccountReversionGlobalRule#checkDetailObjectCodeValidity(AccountReversionGlobal, AccountReversionGlobalDetail)}</li>
 * <li>{@link AccountReversionGlobalRule#checkDetailObjectReversionCodeValidity(AccountReversionGlobalDetail)}</li>
 * <li>ensure that the chart of accounts code and account number for {@link AccountReversionGlobalAccount} are not empty values</li>
 * <li>{@link AccountReversionGlobalRule#checkAllObjectCodesForValidity(AccountReversionGlobal, AccountReversionGlobalAccount)}</li>
 * <li>{@link AccountReversionGlobalRule#checkAccountChartValidity(AccountReversionGlobalAccount)</li>
 * <li>{@link AccountReversionGlobalRule#checkAccountValidity(AccountReversionGlobalAccount)</li>
 * <li>{@link AccountReversionGlobalRule#checkAccountIsNotAmongAcctRevAccounts(AccountReversionGlobal, AccountReversionGlobalAccount)</li>
 * </ul>
 * @see org.kuali.kfs.kns.maintenance.rules.MaintenanceDocumentRuleBase#processCustomAddCollectionLineBusinessRules(org.kuali.kfs.kns.document.MaintenanceDocument,
 *      java.lang.String, org.kuali.kfs.kns.bo.PersistableBusinessObject)
 */
@Override
public boolean processCustomAddCollectionLineBusinessRules(MaintenanceDocument document, String collectionName, PersistableBusinessObject line) {
    boolean success = true;
    AccountReversionGlobal globalAcctRev = (AccountReversionGlobal) ((AccountReversionGlobalMaintainableImpl) document.getNewMaintainableObject()).getBusinessObject();
    if (line instanceof AccountReversionGlobalDetail) {
        AccountReversionGlobalDetail detail = (AccountReversionGlobalDetail) line;
        success &= checkDetailObjectCodeValidity(globalAcctRev, detail);
        success &= checkDetailObjectReversionCodeValidity(detail);
    } else if (line instanceof AccountReversionGlobalAccount) {
        AccountReversionGlobalAccount acct = (AccountReversionGlobalAccount) line;
        if (!checkEmptyValue(acct.getChartOfAccountsCode()) || !checkEmptyValue(acct.getAccountNumber())) {
            // Skip Most validation if chart or account are empty. The default required-field checking will populate the error map accordingly.
            success = false;
        }
        if (success) {
            success &= checkAllObjectCodesForValidity(globalAcctRev, acct);
            success &= checkAccountChartValidity(acct);
            success &= checkAccountValidity(acct);
            success &= checkAccountIsNotAmongAcctRevAccounts(globalAcctRev, acct);
        }
    }
    return success;
}
Also used : AccountReversionGlobal(edu.cornell.kfs.coa.businessobject.AccountReversionGlobal) AccountReversionGlobalDetail(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail) AccountReversionGlobalAccount(edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)

Aggregations

AccountReversionGlobalDetail (edu.cornell.kfs.coa.businessobject.AccountReversionGlobalDetail)6 AccountReversionGlobal (edu.cornell.kfs.coa.businessobject.AccountReversionGlobal)3 AccountReversionGlobalAccount (edu.cornell.kfs.coa.businessobject.AccountReversionGlobalAccount)2 ReversionCategory (edu.cornell.kfs.coa.businessobject.ReversionCategory)2 AccountReversionService (edu.cornell.kfs.coa.service.AccountReversionService)1