Search in sources :

Example 1 with IndirectCostRecoveryRateDetail

use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkIcrTypeCodeAndSeriesIdentifierExistWhenSubFundIsCG.

private boolean checkIcrTypeCodeAndSeriesIdentifierExistWhenSubFundIsCG(CuAccountGlobal newAccount) {
    boolean result = true;
    boolean filledIcrTypeCode = checkEmptyValue(newAccount.getAcctIndirectCostRcvyTypeCd());
    boolean filledFinancialIcrSeriesIdentifier = checkEmptyValue(newAccount.getFinancialIcrSeriesIdentifier());
    // Validation for financialIcrSeriesIdentifier
    if (filledFinancialIcrSeriesIdentifier) {
        String fiscalYear = StringUtils.EMPTY + SpringContext.getBean(UniversityDateService.class).getCurrentFiscalYear();
        String icrSeriesId = newAccount.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(Account.class, KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
            putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.ERROR_EXISTENCE, label + " (" + icrSeriesId + ")");
            result &= false;
        } else {
            for (IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
                if (ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())) {
                    putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[] { fiscalYear, icrSeriesId });
                    result &= false;
                    break;
                }
            }
        }
    }
    if (!filledIcrTypeCode || !filledFinancialIcrSeriesIdentifier) {
        if (ObjectUtils.isNotNull(newAccount.getAccountGlobalDetails()) && newAccount.getAccountGlobalDetails().size() > 0) {
            for (AccountGlobalDetail accountGlobalDetail : newAccount.getAccountGlobalDetails()) {
                accountGlobalDetail.refreshReferenceObject(KFSPropertyConstants.ACCOUNT);
                if (!filledIcrTypeCode) {
                    result &= checkEmptyBOField(KFSPropertyConstants.ACCT_INDIRECT_COST_RCVY_TYPE_CD, accountGlobalDetail.getAccount().getAcctIndirectCostRcvyTypeCd(), formatErrorMessage(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_TYPE_CODE_CANNOT_BE_EMPTY));
                }
                if (!filledFinancialIcrSeriesIdentifier) {
                    result &= checkEmptyBOField(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, accountGlobalDetail.getAccount().getFinancialIcrSeriesIdentifier(), formatErrorMessage(KFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_ICR_SERIES_IDENTIFIER_CANNOT_BE_EMPTY));
                }
            }
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) IndirectCostRecoveryRateDetail(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail) AccountGlobalDetail(org.kuali.kfs.coa.businessobject.AccountGlobalDetail) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Example 2 with IndirectCostRecoveryRateDetail

use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail in project cu-kfs by CU-CommunityApps.

the class AccountExtensionRule method checkCgRequiredFields.

/**
 * Overridden to reintroduce some of KualiCo's older ICR Detail validation
 * until KualiCo fixes the ICR validation bug in a new patch.
 *
 * @see org.kuali.kfs.coa.document.validation.impl.AccountRule#checkCgRequiredFields(org.kuali.kfs.coa.businessobject.Account)
 */
@Override
protected boolean checkCgRequiredFields(Account newAccount) {
    boolean result = super.checkCgRequiredFields(newAccount);
    if (shouldCheckIndirectCostRecoveryRateDetails(newAccount)) {
        String fiscalYear = getUniversityDateService().getCurrentFiscalYear().toString();
        String icrSeriesId = newAccount.getFinancialIcrSeriesIdentifier();
        Collection<IndirectCostRecoveryRateDetail> icrRateDetails = findIndirectCostRecoveryRateDetails(fiscalYear, icrSeriesId);
        if (CollectionUtils.isEmpty(icrRateDetails)) {
            String label = getDataDictionaryService().getAttributeLabel(Account.class, KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER);
            putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.ERROR_EXISTENCE, label + " (" + newAccount.getFinancialIcrSeriesIdentifier() + ")");
            result &= false;
        } else {
            for (IndirectCostRecoveryRateDetail icrRateDetail : icrRateDetails) {
                if (ObjectUtils.isNull(icrRateDetail.getIndirectCostRecoveryRate())) {
                    putFieldError(KFSPropertyConstants.FINANCIAL_ICR_SERIES_IDENTIFIER, KFSKeyConstants.IndirectCostRecovery.ERROR_DOCUMENT_ICR_RATE_NOT_FOUND, new String[] { fiscalYear, icrSeriesId });
                    result &= false;
                    break;
                }
            }
        }
    }
    return result;
}
Also used : IndirectCostRecoveryRateDetail(org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail)

Example 3 with IndirectCostRecoveryRateDetail

use of org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail 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)

Aggregations

IndirectCostRecoveryRateDetail (org.kuali.kfs.coa.businessobject.IndirectCostRecoveryRateDetail)3 HashMap (java.util.HashMap)2 DataDictionaryService (org.kuali.kfs.kns.service.DataDictionaryService)2 A21SubAccountChange (edu.cornell.kfs.coa.businessobject.A21SubAccountChange)1 IndirectCostRecoveryAccountChange (edu.cornell.kfs.coa.businessobject.IndirectCostRecoveryAccountChange)1 SubAccountGlobal (edu.cornell.kfs.coa.businessobject.SubAccountGlobal)1 AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)1