From 926a7526f56f9b18ee1440f92dcd61d375bb8e4d Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Fri, 17 Mar 2023 10:43:12 +0000 Subject: [PATCH] feat: respond to PR comments pt. 1 --- app/models/validations/sales/setup_validations.rb | 12 ++++++------ app/models/validations/setup_validations.rb | 12 ++++++------ config/locales/en.yml | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb index e7090aabf..e76993907 100644 --- a/app/models/validations/sales/setup_validations.rb +++ b/app/models/validations/sales/setup_validations.rb @@ -3,10 +3,10 @@ module Validations::Sales::SetupValidations include CollectionTimeHelper def validate_saledate(record) - return unless record.saledate && date_valid?("saledate", record) + return unless record.saledate && date_valid?("saledate", record) && FeatureToggle.saledate_collection_window_validation_enabled? - unless record.saledate.between?(active_collection_start_date, current_collection_end_date) || !FeatureToggle.saledate_collection_window_validation_enabled? - record.errors.add :saledate, validation_error_message + unless record.saledate.between?(active_collection_start_date, current_collection_end_date) + record.errors.add :saledate, saledate_validation_error_message end end @@ -20,12 +20,12 @@ private end end - def validation_error_message + def saledate_validation_error_message current_end_year_long = current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y") if FormHandler.instance.sales_in_crossover_period? I18n.t( - "validations.setup.saledate.previous_and_current_financial_year", + "validations.setup.saledate.previous_and_current_collection_year", previous_start_year_short: previous_collection_start_date.strftime("%y"), previous_end_year_short: previous_collection_end_date.strftime("%y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), @@ -34,7 +34,7 @@ private ) else I18n.t( - "validations.setup.saledate.current_financial_year", + "validations.setup.saledate.current_collection_year", current_start_year_short: current_collection_start_date.strftime("%y"), current_end_year_short: current_collection_end_date.strftime("%y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb index 5123fa29c..0865ebae6 100644 --- a/app/models/validations/setup_validations.rb +++ b/app/models/validations/setup_validations.rb @@ -3,10 +3,10 @@ module Validations::SetupValidations include CollectionTimeHelper def validate_startdate_setup(record) - return unless record.startdate && date_valid?("startdate", record) + return unless record.startdate && date_valid?("startdate", record) && FeatureToggle.startdate_collection_window_validation_enabled? - unless record.startdate.between?(active_collection_start_date, current_collection_end_date) || !FeatureToggle.startdate_collection_window_validation_enabled? - record.errors.add :startdate, validation_error_message + unless record.startdate.between?(active_collection_start_date, current_collection_end_date) + record.errors.add :startdate, startdate_validation_error_message end end @@ -44,12 +44,12 @@ private end end - def validation_error_message + def startdate_validation_error_message current_end_year_long = current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y") if FormHandler.instance.lettings_in_crossover_period? I18n.t( - "validations.setup.startdate.previous_and_current_financial_year", + "validations.setup.startdate.previous_and_current_collection_year", previous_start_year_short: previous_collection_start_date.strftime("%y"), previous_end_year_short: previous_collection_end_date.strftime("%y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), @@ -58,7 +58,7 @@ private ) else I18n.t( - "validations.setup.startdate.current_financial_year", + "validations.setup.startdate.current_collection_year", current_start_year_short: current_collection_start_date.strftime("%y"), current_end_year_short: current_collection_end_date.strftime("%y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), diff --git a/config/locales/en.yml b/config/locales/en.yml index 50574115e..1bb09ec12 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -155,17 +155,17 @@ en: intermediate_rent_product_name: blank: "Enter name of other intermediate rent product" saledate: - current_financial_year: + current_collection_year: Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long} - previous_and_current_financial_year: + previous_and_current_collection_year: "Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}" type: percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type" startdate: - current_financial_year: + current_collection_year: Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long} - previous_and_current_financial_year: + previous_and_current_collection_year: "Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}" later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date" before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme"