diff --git a/app/models/form.rb b/app/models/form.rb index bef73eb6e..cee9694d4 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -30,6 +30,7 @@ class Form "sections" => sections, } @unresolved_log_redirect_page_id = "tenancy_start_date" if type == "lettings" + @edit_end_date = Time.zone.local(start_year + 1, 12, 31) # this is to be manually updated each year when we want to stop users from editing logs else raise "No form definition file exists for given year".freeze unless File.exist?(form_path) @@ -43,10 +44,10 @@ class Form @questions = pages.flat_map(&:questions) @start_date = Time.iso8601(form_definition["start_date"]) @new_logs_end_date = Time.iso8601(form_definition["end_date"]) - @submission_deadline = Time.zone.local(2023, 6, 9) + @submission_deadline = Time.zone.local(@start_date.year + 1, 6, 9) + @edit_end_date = Time.zone.local(@start_date.year + 1, 12, 31) @unresolved_log_redirect_page_id = form_definition["unresolved_log_redirect_page_id"] end - @edit_end_date = @new_logs_end_date + 2.months # it depends on the year and QA activities, but it would always be later than new logs end date @name = "#{start_date.year}_#{new_logs_end_date.year}_#{type}" end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 3f5b38b91..498c2c460 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -372,7 +372,7 @@ RSpec.describe Form, type: :model do expect(form.questions.first.id).to eq("owning_organisation_id") expect(form.start_date).to eq(Time.zone.parse("2022-04-01")) expect(form.new_logs_end_date).to eq(Time.zone.parse("2023-08-07")) - expect(form.edit_end_date).to eq(Time.zone.parse("2023-10-07")) + expect(form.edit_end_date).to eq(Time.zone.parse("2023-12-31")) expect(form.submission_deadline).to eq(Time.zone.parse("2023-06-09")) expect(form.unresolved_log_redirect_page_id).to eq(nil) end diff --git a/spec/models/validations/sales/setup_validations_spec.rb b/spec/models/validations/sales/setup_validations_spec.rb index e0bad66ae..fdaa78752 100644 --- a/spec/models/validations/sales/setup_validations_spec.rb +++ b/spec/models/validations/sales/setup_validations_spec.rb @@ -133,7 +133,7 @@ RSpec.describe Validations::Sales::SetupValidations do let(:record) { build(:sales_log, saledate: Time.zone.local(2025, 4, 1)) } before do - allow(Time).to receive(:now).and_return(Time.zone.local(2024, 12, 8)) + allow(Time).to receive(:now).and_return(Time.zone.local(2025, 1, 8)) end it "cannot create new logs for the previous collection year" do diff --git a/spec/models/validations/setup_validations_spec.rb b/spec/models/validations/setup_validations_spec.rb index f85af32ff..e329be9b7 100644 --- a/spec/models/validations/setup_validations_spec.rb +++ b/spec/models/validations/setup_validations_spec.rb @@ -109,7 +109,7 @@ RSpec.describe Validations::SetupValidations do context "when after the new logs end date and after the edit end date for the previous period" do before do - allow(Time).to receive(:now).and_return(Time.zone.local(2023, 12, 8)) + allow(Time).to receive(:now).and_return(Time.zone.local(2024, 1, 8)) end it "cannot create new logs for the previous collection year" do