Browse Source

Add collection start date

pull/981/head
Kat 4 years ago
parent
commit
b48f9251cd
  1. 4
      app/models/form_handler.rb
  2. 7
      app/views/locations/toggle_active.html.erb
  3. 2
      config/locales/en.yml
  4. 4
      spec/models/form_handler_spec.rb

4
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]

7
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| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% 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",

2
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:

4
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

Loading…
Cancel
Save