Search in sources :

Example 6 with DictionaryValidationService

use of org.kuali.kfs.kns.service.DictionaryValidationService in project cu-kfs by CU-CommunityApps.

the class AccountGlobalRule method checkCgIncomeStreamRequired.

/**
 * This method checks to see if the contracts and grants income stream account is required
 *
 * @param accountGlobals
 * @return false if it is required (and not entered) or invalid/inactive
 */
protected boolean checkCgIncomeStreamRequired(AccountGlobal accountGlobals) {
    boolean result = true;
    boolean required = false;
    // if the subFundGroup object is null, we cant test, so exit
    if (ObjectUtils.isNull(accountGlobals.getSubFundGroup())) {
        return result;
    }
    // retrieve the subfundcode and fundgroupcode
    String subFundGroupCode = accountGlobals.getSubFundGroupCode().trim();
    String fundGroupCode = accountGlobals.getSubFundGroup().getFundGroupCode().trim();
    // changed foundation code.  Now, it is using similar 'income stream account' validation rule for 'Account'
    if (isIncomeStreamAccountRequired(fundGroupCode, subFundGroupCode)) {
        required = true;
    }
    // if the income stream account is not required, then we're done
    if (!required) {
        return result;
    }
    if (newAccountGlobal.isRemoveIncomeStreamChartAndAccount()) {
        putFieldError(CUKFSPropertyConstants.REMOVE_INCOME_STREAM_CHART_AND_ACCOUNT, CUKFSKeyConstants.ERROR_DOCUMENT_ACCT_GLB_MAINT_REMOVE_INC_STR_CHART_AND_ACCT_CHECKED_WHEN_INC_STR_REQ);
    }
    // make sure both coaCode and accountNumber are filled out
    String error_message_prefix = WHEN_FUND_PREFIX + fundGroupCode + AND_SUB_FUND + subFundGroupCode;
    result &= checkEmptyBOField(KFSPropertyConstants.INCOME_STREAM_ACCOUNT_NUMBER, accountGlobals.getIncomeStreamAccountNumber(), error_message_prefix + ", Income Stream Account Number");
    result &= checkEmptyBOField(KFSPropertyConstants.INCOME_STREAM_CHART_OF_ACCOUNTS_CODE, accountGlobals.getIncomeStreamFinancialCoaCode(), error_message_prefix + ", Income Stream Chart Of Accounts Code");
    // if both fields arent present, then we're done
    if (!result) {
        return result;
    }
    // do an existence/active test
    DictionaryValidationService dvService = super.getDictionaryValidationService();
    boolean referenceExists = dvService.validateReferenceExists(accountGlobals, KFSPropertyConstants.INCOME_STREAM_ACCOUNT);
    if (!referenceExists) {
        putFieldError(KFSPropertyConstants.INCOME_STREAM_ACCOUNT_NUMBER, KFSKeyConstants.ERROR_EXISTENCE, "Income Stream Account: " + accountGlobals.getIncomeStreamFinancialCoaCode() + "-" + accountGlobals.getIncomeStreamAccountNumber());
        result &= false;
    }
    return result;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService)

Aggregations

DictionaryValidationService (org.kuali.kfs.kns.service.DictionaryValidationService)6 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AccountGlobalDetail (org.kuali.kfs.coa.businessobject.AccountGlobalDetail)1 SalesTax (org.kuali.kfs.fp.businessobject.SalesTax)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1 RemotableAttributeError (org.kuali.rice.core.api.uif.RemotableAttributeError)1 DocumentAttributeString (org.kuali.rice.kew.api.document.attribute.DocumentAttributeString)1