diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 9dc8828e8..2f2a9eb89 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -103,13 +103,16 @@ module Validations::SoftValidations TWO_YEARS_IN_DAYS = 730 TEN_YEARS_IN_DAYS = 3650 + TWENTY_YEARS_IN_DAYS = 7300 def major_repairs_date_in_soft_range? - mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS) + upper_limit = form.start_year_2025_or_later? ? TWENTY_YEARS_IN_DAYS : TEN_YEARS_IN_DAYS + mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - upper_limit, startdate.to_date - TWO_YEARS_IN_DAYS) end def voiddate_in_soft_range? - voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS) + upper_limit = form.start_year_2025_or_later? ? TWENTY_YEARS_IN_DAYS : TEN_YEARS_IN_DAYS + voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - upper_limit, startdate.to_date - TWO_YEARS_IN_DAYS) end def net_income_higher_or_lower_text diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index b4188ba8c..0027c2d71 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -265,6 +265,24 @@ RSpec.describe Validations::SoftValidations do expect(record.major_repairs_date_in_soft_range?).to be false end end + + context "with 2025 logs" do + context "when the void date is within 20 years of the tenancy start date" do + it "shows the interruption screen" do + record.startdate = Time.zone.local(2026, 2, 1) + record.mrcdate = Time.zone.local(2007, 2, 1) + expect(record.major_repairs_date_in_soft_range?).to be true + end + end + + context "when the void date is less than 2 years before the tenancy start date" do + it "does not show the interruption screen" do + record.startdate = Time.zone.local(2026, 2, 1) + record.mrcdate = Time.zone.local(2025, 2, 1) + expect(record.major_repairs_date_in_soft_range?).to be false + end + end + end end describe "void date soft validations" do @@ -283,6 +301,24 @@ RSpec.describe Validations::SoftValidations do expect(record.voiddate_in_soft_range?).to be false end end + + context "with 2025 logs" do + context "when the void date is within 20 years of the tenancy start date" do + it "shows the interruption screen" do + record.startdate = Time.zone.local(2026, 2, 1) + record.voiddate = Time.zone.local(2007, 2, 1) + expect(record.voiddate_in_soft_range?).to be true + end + end + + context "when the void date is less than 2 years before the tenancy start date" do + it "does not show the interruption screen" do + record.startdate = Time.zone.local(2026, 2, 1) + record.voiddate = Time.zone.local(2025, 2, 1) + expect(record.voiddate_in_soft_range?).to be false + end + end + end end describe "old persons shared ownership soft validations" do