use of edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute in project cu-kfs by CU-CommunityApps.
the class AccountExtensionRule method checkAppropriationAccount.
protected boolean checkAppropriationAccount(MaintenanceDocument document) {
boolean success = true;
String subFundGroupCode = newAccount.getSubFundGroupCode();
String appropriationAccountNumber = ((AccountExtendedAttribute) newAccount.getExtension()).getAppropriationAccountNumber();
BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
if (!StringUtils.isBlank(appropriationAccountNumber)) {
Map fieldValues = new HashMap();
fieldValues.put("subFundGroupCode", subFundGroupCode);
fieldValues.put("appropriationAccountNumber", appropriationAccountNumber);
Collection<AppropriationAccount> retVals = bos.findMatching(AppropriationAccount.class, fieldValues);
if (retVals.isEmpty()) {
success = false;
putFieldError("extension.appropriationAccountNumber", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_APPROP_ACCT_NOT_GROUP_CODE, new String[] { appropriationAccountNumber, subFundGroupCode });
} else {
for (AppropriationAccount sfp : retVals) {
if (!sfp.isActive()) {
putFieldError("extension.appropriationAccountNumber", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.appropriationAccountNumber"));
success = false;
}
}
}
}
return success;
}
Aggregations