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;
}
Aggregations