/** * @see * org.kuali.ext.mm.service.ProfileService#isValidNewCustomerProfile(org.kuali.ext.mm.businessobject.Profile) */ public boolean isValidNewCustomerProfile(Profile profile) { boolean isValid = true; FinancialDataService finDataService = SpringContext.getBean(FinancialDataService.class); if (!getAddressService().isPhoneNumberFormatValid(profile.getProfilePhoneNumber())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.PROFILE_PHONE_NUMBER, ShopCartKeyConstants.ERROR_PROFILE_PHONE_NUMBER); isValid = false; } if (!profile.isPersonalUseIndicator()) { if (StringUtils.isBlank(profile.getFinacialChartOfAccountsCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.FIN_COA_CODE, ShopCartKeyConstants.ERROR_PROFILE_COA_CODE); isValid = false; } else { if (!finDataService.validateChart(profile.getFinacialChartOfAccountsCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.FIN_COA_CODE, ShopCartKeyConstants.ERROR_PROFILE_COA_CODE); isValid = false; } } if (StringUtils.isBlank(profile.getOrganizationCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.ORGANIZATION_CODE, ShopCartKeyConstants.ERROR_PROFILE_ORG_CODE_BLANK, profile.getOrganizationCode()); isValid = false; } else { if (!finDataService.validateOrg( profile.getFinacialChartOfAccountsCode(), profile.getOrganizationCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.ORGANIZATION_CODE, ShopCartKeyConstants.ERROR_PROFILE_ORG_CODE, profile.getOrganizationCode(), profile.getFinacialChartOfAccountsCode()); isValid = false; } } if (StringUtils.isBlank(profile.getAccountNumber())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.ACCOUNT_NBR, ShopCartKeyConstants.ERROR_PROFILE_ACCOUNT_NUMBER); isValid = false; } else { if (!finDataService.validateAccount( profile.getFinacialChartOfAccountsCode(), profile.getAccountNumber())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.ACCOUNT_NBR, ShopCartKeyConstants.ERROR_PROFILE_ACCOUNT_NUMBER); isValid = false; } else { if (StringUtils.isNotBlank(profile.getSubAccountNumber())) { if (!finDataService.validateSubAccount( profile.getFinacialChartOfAccountsCode(), profile.getAccountNumber(), profile.getSubAccountNumber())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.SUB_ACCOUNT_NUMBER, ShopCartKeyConstants.ERROR_PROFILE_SUB_ACCOUNT, profile.getSubAccountNumber()); isValid = false; } } } } if (StringUtils.isNotBlank(profile.getProjectCode()) && !finDataService.validateProject(profile.getProjectCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.PROJECT_CODE, ShopCartKeyConstants.ERROR_PROFILE_PROJECT_CODE, profile.getProjectCode()); isValid = false; } if (StringUtils.isBlank(profile.getCampusCode()) || !isValidCampus(profile.getCampusCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.CAMPUS_CODE, ShopCartKeyConstants.ERROR_PROFILE_CAMPUS_CODE); isValid = false; } if (StringUtils.isBlank(profile.getDeliveryBuildingCode()) || !finDataService.validateBuilding( profile.getCampusCode(), profile.getDeliveryBuildingCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.DELIVERY_BUILDING_CODE, ShopCartKeyConstants.ERROR_PROFILE_DELIVERY_BUILDING); isValid = false; } if (StringUtils.isBlank(profile.getDeliveryBuildingRoomNumber()) || !finDataService.validateBuildingRoom( profile.getCampusCode(), profile.getDeliveryBuildingCode(), profile.getDeliveryBuildingRoomNumber())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.DELIVERY_BUILDING_ROOM, ShopCartKeyConstants.ERROR_PROFILE_DELIVERY_BUILDING_ROOM); isValid = false; } if (StringUtils.isBlank(profile.getBillingBuildingCode()) || !finDataService.validateBuilding( profile.getCampusCode(), profile.getBillingBuildingCode())) { GlobalVariables.getMessageMap() .putError( ShopCartConstants.ProfileForm.PROFILE_TO_EDIT + "." + MMConstants.Profile.BILLING_BUILDING_CODE, ShopCartKeyConstants.ERROR_PROFILE_BILLING_BUILDING); isValid = false; } } return isValid; }