Search in sources :

Example 1 with MajorReportingCategory

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

the class AccountExtensionRule method checkMajorReportingCategoryCode.

protected boolean checkMajorReportingCategoryCode(MaintenanceDocument document) {
    boolean success = true;
    String majorReportingCategoryCode = ((AccountExtendedAttribute) newAccount.getExtension()).getMajorReportingCategoryCode();
    BusinessObjectService bos = SpringContext.getBean(BusinessObjectService.class);
    // MajorReportingCategory code is not a required field, if no value is entered no validation is performed
    if (!StringUtils.isBlank(majorReportingCategoryCode)) {
        Map fieldValues = new HashMap();
        fieldValues.put("majorReportingCategoryCode", majorReportingCategoryCode);
        Collection<MajorReportingCategory> retVals = bos.findMatching(MajorReportingCategory.class, fieldValues);
        if (retVals.isEmpty()) {
            putFieldError("extension.majorReportingCategoryCode", CUKFSKeyConstants.ERROR_DOCUMENT_ACCMAINT_MJR_RPT_CAT_CODE_NOT_EXIST, new String[] { majorReportingCategoryCode });
            success = false;
        } else {
            for (MajorReportingCategory sfp : retVals) {
                if (!sfp.isActive()) {
                    putFieldError("extension.majorReportingCategoryCode", KFSKeyConstants.ERROR_INACTIVE, getFieldLabel(Account.class, "extension.majorReportingCategoryCode"));
                    success = false;
                }
            }
        }
    }
    return success;
}
Also used : Account(org.kuali.kfs.coa.businessobject.Account) AppropriationAccount(edu.cornell.kfs.coa.businessobject.AppropriationAccount) MajorReportingCategory(edu.cornell.kfs.coa.businessobject.MajorReportingCategory) HashMap(java.util.HashMap) AccountExtendedAttribute(edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute) HashMap(java.util.HashMap) Map(java.util.Map) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService)

Aggregations

AccountExtendedAttribute (edu.cornell.kfs.coa.businessobject.AccountExtendedAttribute)1 AppropriationAccount (edu.cornell.kfs.coa.businessobject.AppropriationAccount)1 MajorReportingCategory (edu.cornell.kfs.coa.businessobject.MajorReportingCategory)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Account (org.kuali.kfs.coa.businessobject.Account)1 BusinessObjectService (org.kuali.kfs.krad.service.BusinessObjectService)1