Search in sources :

Example 11 with SubAccountGlobal

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

the class SubAccountGlobalRule method checkCgIcrRules.

/**
 * This checks that if the ICR information is entered that it is valid for this fiscal year and that all of its fields are valid
 * as well (such as account)
 *
 * @return true if the ICR information is filled in and it is valid
 */
protected boolean checkCgIcrRules(String subAccountTypeCode, SubAccountGlobalDetail subAccountGlobalDetail) {
    SubAccountGlobal newSubAccountGlobal = (SubAccountGlobal) super.getNewBo();
    A21SubAccountChange a21 = newSubAccountGlobal.getA21SubAccount();
    if (ObjectUtils.isNull(a21)) {
        return true;
    }
    boolean success = true;
    // existence check for Financial Series ID
    if (StringUtils.isNotEmpty(a21.getFinancialIcrSeriesIdentifier())) {
        String fiscalYear = StringUtils.EMPTY + SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
        String icrSeriesId = a21.getFinancialIcrSeriesIdentifier();
        Map<String, String> pkMap = new HashMap<String, String>();
        pkMap.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, fiscalYear);
        pkMap.put(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, icrSeriesId);
        Collection<IndirectCostRecoveryRateDetail> icrRateDetails = getBoService().findMatching(IndirectCostRecoveryRateDetail.class, pkMap);
        if (ObjectUtils.isNull(icrRateDetails) || icrRateDetails.isEmpty()) {
            String label = SpringContext.getBean(DataDictionaryService.class).getAttributeLabel(A21SubAccount.class, KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
            putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.ERROR_EXISTENCE, label + " (" + icrSeriesId + ")");
            success = false;
        } else {
            for (IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
                if (ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())) {
                    putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[] { fiscalYear, icrSeriesId });
                    success = false;
                    break;
                }
            }
        }
    }
    // existence check for ICR Account
    for (IndirectCostRecoveryAccountChange account : newSubAccountGlobal.getActiveIndirectCostRecoveryAccounts()) {
        if (StringUtils.isNotBlank(account.getIndirectCostRecoveryAccountNumber()) && StringUtils.isNotBlank(account.getIndirectCostRecoveryFinCoaCode())) {
            if (ObjectUtils.isNull(account.getIndirectCostRecoveryAccount())) {
                putFieldError(KFSPropertyConstants.INDIRECT_COST_RECOVERY_ACCOUNTS, KFSKeyConstants.ERROR_EXISTENCE, "ICR Account: " + account.getIndirectCostRecoveryFinCoaCode() + "-" + account.getIndirectCostRecoveryAccountNumber());
                success = false;
                break;
            }
        }
    }
    // The cost sharing fields must be empty if the sub-account type code is for ICR
    if (checkCgCostSharingIsEmpty(subAccountGlobalDetail) == false) {
        putFieldError(KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE, KFSKeyConstants.ERROR_DOCUMENT_SUBACCTMAINT_COST_SHARE_SECTION_INVALID, subAccountTypeCode);
        success &= false;
    }
    return success;
}
Also used : SubAccountGlobal(edu.cornell.kfs.coa.businessobject.SubAccountGlobal) HashMap(java.util.HashMap) IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) IndirectCostRecoveryRateDetail(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail) A21SubAccountChange(edu.cornell.kfs.coa.businessobject.A21SubAccountChange) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Example 12 with SubAccountGlobal

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

the class SubAccountGlobalRule method checkSubAccountDetails.

/**
 * Checks that at least one sub account is entered.
 *
 * @return true if at least one sub account entered, false otherwise
 */
public boolean checkSubAccountDetails() {
    boolean success = true;
    SubAccountGlobal newSubAccountGlobal = (SubAccountGlobal) super.getNewBo();
    List<SubAccountGlobalDetail> details = newSubAccountGlobal.getSubAccountGlobalDetails();
    // check if there are any accounts
    if (details.size() == 0) {
        putFieldError(KFSConstants.MAINTENANCE_ADD_PREFIX + CUKFSPropertyConstants.SUB_ACCOUNT_GLBL_CHANGE_DETAILS + "." + KFSPropertyConstants.ACCOUNT_NUMBER, CUKFSKeyConstants.ERROR_DOCUMENT_GLOBAL_SUS_ACCOUNT_NO_SUB_ACCOUNTS);
        success = false;
    }
    return success;
}
Also used : SubAccountGlobal(edu.cornell.kfs.coa.businessobject.SubAccountGlobal) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)

Example 13 with SubAccountGlobal

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

the class SubAccountGlobalRule method checkCgRules.

/**
 * Checks CG rules.
 *
 * @param document
 * @return true if valid, false otherwise
 */
protected boolean checkCgRules(MaintenanceDocument document) {
    boolean success = true;
    SubAccountGlobal newSubAccountGlobal = (SubAccountGlobal) super.getNewBo();
    List<SubAccountGlobalDetail> subAccountGlobalDetails = newSubAccountGlobal.getSubAccountGlobalDetails();
    for (SubAccountGlobalDetail subAccountGlobalDetail : subAccountGlobalDetails) {
        success &= checkCgRules(newSubAccountGlobal, subAccountGlobalDetail);
    }
    return success;
}
Also used : SubAccountGlobal(edu.cornell.kfs.coa.businessobject.SubAccountGlobal) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)

Example 14 with SubAccountGlobal

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

the class GlobalIndirectCostRecoveryAccountsRuleTest method testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail.

@Test
public void testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail() {
    LOG.debug("enter testSubAccountGlobalCheckICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate_Fail");
    SubAccountGlobal subAccountGlobal = (SubAccountGlobal) SubAccountGlobalFixture.SUB_ACCT_GLOBAL_1111111_2222222_98_2.getSubAccountGlobal();
    SubAccountGlobalDetail subAccountGlobalDetail = SubAccountGlobalDetailFixture.SUB_ACCOUNT_GLOBAL_DETAIL_3333333_100_INACTIVATE.getSubAccountGlobalDetail();
    List<IndirectCostRecoveryAccount> existingIcrAccountsOnDetail = new ArrayList<IndirectCostRecoveryAccount>();
    existingIcrAccountsOnDetail.addAll(subAccountGlobalDetail.getSubAccount().getA21SubAccount().getA21IndirectCostRecoveryAccounts());
    LOG.debug("updates");
    List<IndirectCostRecoveryAccountChange> updates = subAccountGlobal.getIndirectCostRecoveryAccounts();
    logDetailsForIcrAccountChanges(updates);
    LOG.debug("existing");
    logDetailsForIcrAccounts(existingIcrAccountsOnDetail);
    boolean result = globalIndirectCostRecoveryAccountsRule.checkICRAccountTotalDistributionOnDetailWillBe100PercentAfterUpdate(updates, existingIcrAccountsOnDetail, subAccountGlobalDetail, subAccountGlobal);
    assertFalse("Updated Sub Account Global ICR account distribution should NOT have been 100%", result);
}
Also used : SubAccountGlobal(edu.cornell.kfs.coa.businessobject.SubAccountGlobal) SubAccountGlobalDetail(edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail) IndirectCostRecoveryAccount(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount) IndirectCostRecoveryAccountChange(edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

SubAccountGlobal (edu.cornell.kfs.coa.businessobject.SubAccountGlobal)14 SubAccountGlobalDetail (edu.cornell.kfs.coa.businessobject.SubAccountGlobalDetail)7 A21SubAccountChange (edu.cornell.kfs.coa.businessobject.A21SubAccountChange)5 IndirectCostRecoveryAccountChange (edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)3 IndirectCostRecoveryAccount (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryAccount)3 HashMap (java.util.HashMap)1 IndirectCostRecoveryRateDetail (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail)1 SubAccount (org.kuali.kfs.coa.businessobject.SubAccount)1 DataDictionaryService (org.kuali.kfs.kns.service.DataDictionaryService)1 MaintenanceLock (org.kuali.kfs.krad.maintenance.MaintenanceLock)1 ConfigurationService (org.kuali.rice.core.api.config.property.ConfigurationService)1