From 35bd9c2b03d6cc4f8b4a27a3cd51c3eff78e0feb Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:59:06 +0000 Subject: [PATCH] Extract lettings setup validation from shared validations --- app/models/validations/shared_validations.rb | 14 +++++------ config/locales/en.yml | 20 --------------- .../locales/validations/lettings/setup.en.yml | 25 +++++++++++++++++++ 3 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 config/locales/validations/lettings/setup.en.yml diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index 22e215fa7..74b5c42c4 100644 --- a/app/models/validations/shared_validations.rb +++ b/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) diff --git a/config/locales/en.yml b/config/locales/en.yml index f359bb14b..08706530a 100644 --- a/config/locales/en.yml +++ b/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." diff --git a/config/locales/validations/lettings/setup.en.yml b/config/locales/validations/lettings/setup.en.yml new file mode 100644 index 000000000..27abcad1e --- /dev/null +++ b/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."