diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index c6dde13ab..646d1e5bf 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -49,6 +49,10 @@ class FormHandler today < window_end_date ? today.year - 1 : today.year end + def current_collection_start_date + Time.utc(current_collection_start_year, 4, 5) + end + def form_name_from_start_year(year, type) form_mappings = { 0 => "current_#{type}", 1 => "previous_#{type}", -1 => "next_#{type}" } form_mappings[current_collection_start_year - year] diff --git a/app/views/locations/toggle_active.html.erb b/app/views/locations/toggle_active.html.erb index a74527bae..2757c5804 100644 --- a/app/views/locations/toggle_active.html.erb +++ b/app/views/locations/toggle_active.html.erb @@ -12,15 +12,16 @@ <%= form_with model: @location, url: scheme_location_deactivate_path(scheme_id: @location.scheme.id, location_id: @location.id), method: "patch", local: true do |f| %>
+ <% collection_start_date = FormHandler.instance.current_collection_start_date %> <%= f.govuk_error_summary %> <%= f.govuk_radio_buttons_fieldset :deactivation_date, legend: { text: I18n.t("questions.location.deactivation.apply_from")}, caption: { text: "Deactivate #{@location.postcode}"}, - hint: { text: I18n.t("hints.location.deactivation")} do %> + hint: { text: I18n.t("hints.location.deactivation", date: collection_start_date.to_formatted_s(:govuk_date))} do %> <%= govuk_warning_text text: I18n.t("warnings.location.deactivation.existing_logs") %> <%= f.govuk_radio_button :deactivation_date, - Time.now(), - label: { text: "From the start of the current collection period (5 April 2022)" } %> + collection_start_date, + label: { text: "From the start of the current collection period (#{collection_start_date.to_formatted_s(:govuk_date)})" } %> <%= f.govuk_radio_button :deactivation_date, "other", diff --git a/config/locales/en.yml b/config/locales/en.yml index 2902f85b0..d0aa9371a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -382,7 +382,7 @@ en: postcode: "For example, SW1P 4DF." name: "This is how you refer to this location within your organisation" units: "A unit can be a bedroom in a shared house or flat, or a house with 4 bedrooms. Do not include bedrooms used for wardens, managers, volunteers or sleep-in staff." - deactivation: "If the date is before 5 April 2022, select ‘From the start of the current collection period’ because the previous period has now closed." + deactivation: "If the date is before %{date}, select ‘From the start of the current collection period’ because the previous period has now closed." warnings: location: diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 81a9b1c45..5b7ba0a2b 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -118,6 +118,10 @@ RSpec.describe FormHandler do it "returns the correct next sales form name" do expect(form_handler.form_name_from_start_year(2023, "sales")).to eq("next_sales") end + + it "returns the correct current start date" do + expect(form_handler.current_collection_start_date).to eq(Time.utc(2022, 4, 5)) + end end context "with the date before 1st of April" do