Browse Source

Extract lettings setup validation from shared validations

pull/2744/head
Manny Dinssa 8 months ago
parent
commit
35bd9c2b03
  1. 14
      app/models/validations/shared_validations.rb
  2. 20
      config/locales/en.yml
  3. 25
      config/locales/validations/lettings/setup.en.yml

14
app/models/validations/shared_validations.rb

@ -79,9 +79,9 @@ module Validations::SharedValidations
if location_inactive_status.present?
date, scope, deactivation_date = location_inactive_status.values_at(:date, :scope, :deactivation_date)
record.errors.add :startdate, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.startdate", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :location_id, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :scheme_id, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :startdate, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.startdate", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :location_id, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
record.errors.add :scheme_id, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:)
end
end
@ -90,8 +90,8 @@ module Validations::SharedValidations
if scheme_inactive_status.present?
date, scope, deactivation_date = scheme_inactive_status.values_at(:date, :scope, :deactivation_date)
record.errors.add :startdate, I18n.t("validations.setup.startdate.scheme.#{scope}.startdate", name: record.scheme.service_name, date:, deactivation_date:)
record.errors.add :scheme_id, I18n.t("validations.setup.startdate.scheme.#{scope}.scheme_id", name: record.scheme.service_name, date:, deactivation_date:)
record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.scheme.#{scope}.startdate", name: record.scheme.service_name, date:, deactivation_date:)
record.errors.add :scheme_id, I18n.t("validations.lettings.setup.startdate.scheme.#{scope}.scheme_id", name: record.scheme.service_name, date:, deactivation_date:)
end
end
@ -121,8 +121,8 @@ module Validations::SharedValidations
return if record.scheme.blank? || record.startdate.blank?
return if record.scheme.has_active_locations_on_date?(record.startdate)
record.errors.add :startdate, I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: record.scheme.service_name)
record.errors.add :scheme_id, I18n.t("validations.setup.startdate.scheme.locations_inactive.scheme_id", name: record.scheme.service_name)
record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.scheme.locations_inactive.startdate", name: record.scheme.service_name)
record.errors.add :scheme_id, I18n.t("validations.lettings.setup.startdate.scheme.locations_inactive.scheme_id", name: record.scheme.service_name)
end
def shared_validate_partner_count(record, max_people)

20
config/locales/en.yml

@ -312,26 +312,6 @@ en:
managing_organisation: "Enter a date when the managing organisation was active. %{managing_organisation} became active on %{managing_organisation_available_from}."
different_organisations: "Enter a date when the owning and managing organisations were active. %{owning_organisation} became active on %{owning_organisation_active_from}, and %{managing_organisation} became active on %{managing_organisation_active_from}."
location:
deactivated:
startdate: "The location %{postcode} is inactive on this date. Enter another date or choose another location."
location_id: "This location is not active on the tenancy start date. Choose another location or edit the tenancy start date."
activating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
reactivating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
scheme:
deactivated:
startdate: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
scheme_id: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
reactivating_soon:
startdate: "The scheme %{name} is not available until %{date}. Enter a tenancy start date after %{date}."
scheme_id: "The scheme %{name} is not available until %{date}. Select another scheme or edit the tenancy start date."
locations_inactive:
startdate: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
scheme_id: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
owning_organisation:
invalid: "Please select the owning organisation or managing organisation that you belong to."
data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation."

25
config/locales/validations/lettings/setup.en.yml

@ -0,0 +1,25 @@
en:
validations:
lettings:
setup:
startdate:
location:
deactivated:
startdate: "The location %{postcode} is inactive on this date. Enter another date or choose another location."
location_id: "This location is not active on the tenancy start date. Choose another location or edit the tenancy start date."
activating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
reactivating_soon:
startdate: "The location %{postcode} is not available until %{date}. Enter a tenancy start date after %{date}."
location_id: "The location %{postcode} is not available until %{date}. Select another location or edit the tenancy start date."
scheme:
deactivated:
startdate: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
scheme_id: "The scheme %{name} was deactivated on %{date} and was not available on the day you entered. Select another scheme or edit the tenancy start date."
reactivating_soon:
startdate: "The scheme %{name} is not available until %{date}. Enter a tenancy start date after %{date}."
scheme_id: "The scheme %{name} is not available until %{date}. Select another scheme or edit the tenancy start date."
locations_inactive:
startdate: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
scheme_id: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme."
Loading…
Cancel
Save