diff --git a/app/models/form/lettings/pages/no_address_found.rb b/app/models/form/lettings/pages/no_address_found.rb
index b1a78caf6..631d6f58e 100644
--- a/app/models/form/lettings/pages/no_address_found.rb
+++ b/app/models/form/lettings/pages/no_address_found.rb
@@ -3,12 +3,13 @@ class Form::Lettings::Pages::NoAddressFound < ::Form::Page
super
@id = "no_address_found"
@type = "interruption_screen"
+ @copy_key = "lettings.soft_validations.no_address_found"
@title_text = {
- "translation" => "soft_validations.no_address_found.title_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
- "translation" => "soft_validations.no_address_found.informative_text",
+ "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@depends_on = [
diff --git a/app/models/form/sales/pages/handover_date_check.rb b/app/models/form/sales/pages/handover_date_check.rb
index 690c3dde7..8ae41316c 100644
--- a/app/models/form/sales/pages/handover_date_check.rb
+++ b/app/models/form/sales/pages/handover_date_check.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::HandoverDateCheck < ::Form::Page
super
@id = "handover_date_check"
@copy_key = "sales.soft_validations.hodate_check"
- @depends_on = [{ "saledate_check" => nil, "hodate_3_years_or_more_saledate?" => true },
- { "saledate_check" => 1, "hodate_3_years_or_more_saledate?" => true }]
@informative_text = {}
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
@@ -12,6 +10,16 @@ class Form::Sales::Pages::HandoverDateCheck < ::Form::Page
}
end
+ def depends_on
+ if form.start_year_2025_or_later?
+ [{ "saledate_check" => nil, "hodate_5_years_or_more_saledate?" => true },
+ { "saledate_check" => 1, "hodate_5_years_or_more_saledate?" => true }]
+ else
+ [{ "saledate_check" => nil, "hodate_3_years_or_more_saledate?" => true },
+ { "saledate_check" => 1, "hodate_3_years_or_more_saledate?" => true }]
+ end
+ end
+
def questions
@questions ||= [
Form::Sales::Questions::HandoverDateCheck.new(nil, nil, self),
diff --git a/app/models/form/sales/subsections/household_situation.rb b/app/models/form/sales/subsections/household_situation.rb
index 2e496908b..d5b8ab7e2 100644
--- a/app/models/form/sales/subsections/household_situation.rb
+++ b/app/models/form/sales/subsections/household_situation.rb
@@ -3,7 +3,14 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection
super
@id = "household_situation"
@label = "Household situation"
- @depends_on = [{ "setup_completed?" => true }]
+ end
+
+ def depends_on
+ if form.start_year_2025_or_later?
+ [{ "setup_completed?" => true, "is_staircase?" => false }]
+ else
+ [{ "setup_completed?" => true }]
+ end
end
def pages
@@ -16,4 +23,10 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection
Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self),
].flatten.compact
end
+
+ def displayed_in_tasklist?(log)
+ return true unless form.start_year_2025_or_later?
+
+ log.staircase != 1
+ end
end
diff --git a/app/models/form/sales/subsections/income_benefits_and_savings.rb b/app/models/form/sales/subsections/income_benefits_and_savings.rb
index 19b6e7e03..9244267b9 100644
--- a/app/models/form/sales/subsections/income_benefits_and_savings.rb
+++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb
@@ -3,7 +3,14 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
super
@id = "income_benefits_and_savings"
@label = "Income, benefits and savings"
- @depends_on = [{ "setup_completed?" => true }]
+ end
+
+ def depends_on
+ if form.start_year_2025_or_later?
+ [{ "setup_completed?" => true, "is_staircase?" => false }]
+ else
+ [{ "setup_completed?" => true }]
+ end
end
def pages
@@ -36,6 +43,12 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
].compact
end
+ def displayed_in_tasklist?(log)
+ return true unless form.start_year_2025_or_later?
+
+ log.staircase != 1
+ end
+
private
def previous_shared_page
diff --git a/app/models/form/sales/subsections/other_household_information.rb b/app/models/form/sales/subsections/other_household_information.rb
index 3acc9ffd5..e30afddc1 100644
--- a/app/models/form/sales/subsections/other_household_information.rb
+++ b/app/models/form/sales/subsections/other_household_information.rb
@@ -3,7 +3,14 @@ class Form::Sales::Subsections::OtherHouseholdInformation < ::Form::Subsection
super
@id = "other_household_information"
@label = "Other household information"
- @depends_on = [{ "setup_completed?" => true }]
+ end
+
+ def depends_on
+ if form.start_year_2025_or_later?
+ [{ "setup_completed?" => true, "is_staircase?" => false }]
+ else
+ [{ "setup_completed?" => true }]
+ end
end
def pages
@@ -17,4 +24,10 @@ class Form::Sales::Subsections::OtherHouseholdInformation < ::Form::Subsection
Form::Sales::Pages::HouseholdWheelchairCheck.new("wheelchair_check", nil, self),
]
end
+
+ def displayed_in_tasklist?(log)
+ return true unless form.start_year_2025_or_later?
+
+ log.staircase != 1
+ end
end
diff --git a/app/models/form/section.rb b/app/models/form/section.rb
index 97a128f74..a836bd45a 100644
--- a/app/models/form/section.rb
+++ b/app/models/form/section.rb
@@ -10,4 +10,8 @@ class Form::Section
@subsections = hsh["subsections"].map { |s_id, s| Form::Subsection.new(s_id, s, self) }
end
end
+
+ def displayed_in_tasklist?(log)
+ subsections.any? { |subsection| subsection.displayed_in_tasklist?(log) }
+ end
end
diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb
index 09e6d1436..e9eba8184 100644
--- a/app/models/validations/property_validations.rb
+++ b/app/models/validations/property_validations.rb
@@ -46,4 +46,31 @@ module Validations::PropertyValidations
record.errors.add :postcode_full, :wrong_format, message: error_message
end
end
+
+ def validate_la_in_england(record)
+ return unless record.form.start_year_2025_or_later?
+
+ if record.is_general_needs?
+ return unless record.la
+ return if record.la.in?(LocalAuthority.england.pluck(:code))
+
+ record.errors.add :la, I18n.t("validations.lettings.property.la.not_in_england")
+ record.errors.add :postcode_full, I18n.t("validations.lettings.property.postcode_full.not_in_england")
+ record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.not_in_england")
+ record.errors.add :uprn_confirmation, I18n.t("validations.lettings.property.uprn_confirmation.not_in_england")
+ record.errors.add :uprn_selection, I18n.t("validations.lettings.property.uprn_selection.not_in_england")
+ if record.uprn.present?
+ record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.address_not_in_england")
+ else
+ record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.postcode_not_in_england")
+ end
+ elsif record.is_supported_housing?
+ return unless record.location
+ return if record.location.location_code.in?(LocalAuthority.england.pluck(:code))
+
+ record.errors.add :location_id, I18n.t("validations.lettings.property.location_id.not_in_england")
+ record.errors.add :scheme_id, I18n.t("validations.lettings.property.scheme_id.not_in_england")
+ record.errors.add :startdate, I18n.t("validations.lettings.property.startdate.location_not_in_england")
+ end
+ end
end
diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb
index 5cf70ed8d..2238a634a 100644
--- a/app/models/validations/sales/property_validations.rb
+++ b/app/models/validations/sales/property_validations.rb
@@ -36,4 +36,20 @@ module Validations::Sales::PropertyValidations
record.errors.add :postcode_full, :wrong_format, message: error_message
end
end
+
+ def validate_la_in_england(record)
+ return unless record.form.start_year_2025_or_later? && record.la.present?
+ return if record.la.in?(LocalAuthority.england.pluck(:code))
+
+ record.errors.add :la, I18n.t("validations.sales.property_information.la.not_in_england")
+ record.errors.add :postcode_full, I18n.t("validations.sales.property_information.postcode_full.not_in_england")
+ record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.not_in_england")
+ record.errors.add :uprn_confirmation, I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england")
+ record.errors.add :uprn_selection, I18n.t("validations.sales.property_information.uprn_selection.not_in_england")
+ if record.uprn.present?
+ record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.address_not_in_england")
+ else
+ record.errors.add :saledate, I18n.t("validations.sales.property_information.saledate.postcode_not_in_england")
+ end
+ end
end
diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb
index 1ce9bf0ca..3825271c5 100644
--- a/app/models/validations/sales/sale_information_validations.rb
+++ b/app/models/validations/sales/sale_information_validations.rb
@@ -12,7 +12,10 @@ module Validations::Sales::SaleInformationValidations
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_hodate")
end
- if record.saledate - record.hodate >= 3.years && record.form.start_year_2024_or_later?
+ if (record.saledate - 5.years) >= record.hodate && record.form.start_year_2025_or_later?
+ record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_less_than_5_years_from_saledate")
+ record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_5_years_from_hodate")
+ elsif (record.saledate - 3.years) >= record.hodate && record.startdate.year <= 2024
record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_less_than_3_years_from_saledate")
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_3_years_from_hodate")
end
diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb
index 5095e5ff9..d53391dd1 100644
--- a/app/models/validations/sales/soft_validations.rb
+++ b/app/models/validations/sales/soft_validations.rb
@@ -110,6 +110,12 @@ module Validations::Sales::SoftValidations
saledate - hodate >= 3.years
end
+ def hodate_5_years_or_more_saledate?
+ return unless hodate && saledate
+
+ saledate - hodate >= 5.years
+ end
+
def purchase_price_higher_or_lower_text
value < sale_range.soft_min ? "lower" : "higher"
end
diff --git a/app/views/logs/_tasklist.html.erb b/app/views/logs/_tasklist.html.erb
index df8a3afad..e2f977a70 100644
--- a/app/views/logs/_tasklist.html.erb
+++ b/app/views/logs/_tasklist.html.erb
@@ -1,5 +1,6 @@
- <% @log.form.sections.map do |section| %>
+ <% @log.form.sections.each do |section| %>
+ <% next unless section.displayed_in_tasklist?(@log) %>
-
<%= section.label %>
@@ -8,7 +9,7 @@
<%= section.description.html_safe %>
<% end %>
- <% section.subsections.map do |subsection| %>
+ <% section.subsections.each do |subsection| %>
<% if subsection.displayed_in_tasklist?(@log) && (subsection.applicable_questions(@log).count > 0 || !subsection.enabled?(@log)) %>
<% subsection_status = subsection.status(@log) %>
-
diff --git a/config/locales/forms/2024/lettings/soft_validations.en.yml b/config/locales/forms/2024/lettings/soft_validations.en.yml
index ada093d39..b4a76af04 100644
--- a/config/locales/forms/2024/lettings/soft_validations.en.yml
+++ b/config/locales/forms/2024/lettings/soft_validations.en.yml
@@ -130,3 +130,11 @@ en:
question_text: "Are you sure the property has been vacant for this long?"
title_text: "You told us the property has been vacant for 2 years."
informative_text: "This is longer than we would expect."
+
+ no_address_found:
+ page_header: ""
+ check_answer_label: "No address found"
+ hint_text: ""
+ question_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
+ title_text: "No address found"
+ informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
diff --git a/config/locales/validations/lettings/property_information.en.yml b/config/locales/validations/lettings/property_information.en.yml
index 6530c9488..091e89664 100644
--- a/config/locales/validations/lettings/property_information.en.yml
+++ b/config/locales/validations/lettings/property_information.en.yml
@@ -4,6 +4,7 @@ en:
property:
postcode_full:
invalid: "Enter a postcode in the correct format, for example AA1 1AA."
+ not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
rsnvac:
non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary."
referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting."
@@ -18,4 +19,18 @@ en:
one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms."
uprn:
invalid: "UPRN must be 12 digits or less."
-
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ uprn_confirmation:
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ uprn_selection:
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ la:
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ scheme_id:
+ not_in_england: "This scheme’s only location is outside of England. Only create logs for lettings in England."
+ location_id:
+ not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England."
+ startdate:
+ postcode_not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
+ address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ location_not_in_england: "It looks like you have selected a location outside of England. Only create logs for lettings in England."
diff --git a/config/locales/validations/sales/property_information.en.yml b/config/locales/validations/sales/property_information.en.yml
index a91e47849..9014f1d78 100644
--- a/config/locales/validations/sales/property_information.en.yml
+++ b/config/locales/validations/sales/property_information.en.yml
@@ -7,6 +7,7 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "Enter a postcode in the correct format, for example AA1 1AA."
+ not_in_england: "It looks like you have entered a postcode outside of England - only submit Lettings forms for Lettings that occur in England"
ppostcode_full:
postcode_must_match_previous:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
@@ -20,9 +21,19 @@ en:
joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match."
not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match."
invalid: "UPRN must be 12 digits or less."
+ not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
beds:
bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit."
proptype:
bedsits_have_max_one_bedroom: "Answer cannot be 'Bedsit' if the property has 2 or more bedrooms."
uprn_known:
invalid: "You must answer UPRN known?"
+ la:
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ uprn_confirmation:
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ uprn_selection:
+ not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
+ saledate:
+ postcode_not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
+ address_not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
diff --git a/config/locales/validations/sales/sale_information.en.yml b/config/locales/validations/sales/sale_information.en.yml
index 55b9cfede..ea17953fb 100644
--- a/config/locales/validations/sales/sale_information.en.yml
+++ b/config/locales/validations/sales/sale_information.en.yml
@@ -8,9 +8,11 @@ en:
hodate:
must_be_before_saledate: "Practical completion or handover date must be before sale completion date."
must_be_less_than_3_years_from_saledate: "Practical completion or handover date must be less than 3 years before sale completion date."
+ must_be_less_than_5_years_from_saledate: "Practical completion or handover date must be less than 5 years before sale completion date."
saledate:
must_be_after_hodate: "Sale completion date must be after practical completion or handover date."
must_be_less_than_3_years_from_hodate: "Sale completion date must be less than 3 years after practical completion or handover date."
+ must_be_less_than_5_years_from_hodate: "Sale completion date must be less than 5 years after practical completion or handover date."
must_be_after_exdate: "Sale completion date must be after contract exchange date."
must_be_less_than_1_year_from_exdate: "Sale completion date must be less than 1 year after contract exchange date."
mortgage_used_year: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for the selected year."
diff --git a/spec/models/form/lettings/pages/no_address_found_spec.rb b/spec/models/form/lettings/pages/no_address_found_spec.rb
index ad8c04e04..1825d4d30 100644
--- a/spec/models/form/lettings/pages/no_address_found_spec.rb
+++ b/spec/models/form/lettings/pages/no_address_found_spec.rb
@@ -5,7 +5,8 @@ RSpec.describe Form::Lettings::Pages::NoAddressFound, type: :model do
let(:page_id) { nil }
let(:page_definition) { nil }
- let(:subsection) { instance_double(Form::Subsection) }
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
let(:log) { create(:lettings_log) }
it "has correct subsection" do
@@ -37,11 +38,11 @@ RSpec.describe Form::Lettings::Pages::NoAddressFound, type: :model do
end
it "has the correct title_text" do
- expect(page.title_text).to eq({ "arguments" => [], "translation" => "soft_validations.no_address_found.title_text" })
+ expect(page.title_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.no_address_found.title_text" })
end
it "has the correct informative_text" do
- expect(page.informative_text).to eq({ "arguments" => [], "translation" => "soft_validations.no_address_found.informative_text" })
+ expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.lettings.soft_validations.no_address_found.informative_text" })
end
it "has the correct interruption_screen_question_ids" do
diff --git a/spec/models/form/sales/pages/handover_date_check_spec.rb b/spec/models/form/sales/pages/handover_date_check_spec.rb
index ae465da16..e6cc3acf5 100644
--- a/spec/models/form/sales/pages/handover_date_check_spec.rb
+++ b/spec/models/form/sales/pages/handover_date_check_spec.rb
@@ -5,44 +5,66 @@ RSpec.describe Form::Sales::Pages::HandoverDateCheck, type: :model do
let(:page_id) { "" }
let(:page_definition) { nil }
- let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
- let(:subsection) { instance_double(Form::Subsection, form:) }
- it "has correct subsection" do
- expect(page.subsection).to eq(subsection)
- end
+ context "when form start year is <= 2024" do
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
- it "has correct questions" do
- expect(page.questions.map(&:id)).to eq(%w[hodate_check])
- end
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
- it "has the correct id" do
- expect(page.id).to eq("handover_date_check")
- end
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[hodate_check])
+ end
- it "has the correct title_text" do
- expect(page.title_text).to eq({
- "translation" => "forms.2024.sales.soft_validations.hodate_check.title_text",
- "arguments" => [],
- })
- end
+ it "has the correct id" do
+ expect(page.id).to eq("handover_date_check")
+ end
- it "has the correct informative_text" do
- expect(page.informative_text).to eq({})
- end
+ it "has the correct title_text" do
+ expect(page.title_text).to eq({
+ "translation" => "forms.2024.sales.soft_validations.hodate_check.title_text",
+ "arguments" => [],
+ })
+ end
- it "has correct depends_on" do
- expect(page.depends_on).to eq([
- { "hodate_3_years_or_more_saledate?" => true, "saledate_check" => nil },
- { "hodate_3_years_or_more_saledate?" => true, "saledate_check" => 1 },
- ])
- end
+ it "has the correct informative_text" do
+ expect(page.informative_text).to eq({})
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([
+ { "hodate_3_years_or_more_saledate?" => true, "saledate_check" => nil },
+ { "hodate_3_years_or_more_saledate?" => true, "saledate_check" => 1 },
+ ])
+ end
+
+ it "is interruption screen page" do
+ expect(page.interruption_screen?).to eq(true)
+ end
- it "is interruption screen page" do
- expect(page.interruption_screen?).to eq(true)
+ it "is has correct interruption_screen_question_ids" do
+ expect(page.interruption_screen_question_ids).to eq(%w[hodate saledate])
+ end
end
- it "is has correct interruption_screen_question_ids" do
- expect(page.interruption_screen_question_ids).to eq(%w[hodate saledate])
+ context "when form start year is 2025" do
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1), start_year_2025_or_later?: true) }
+ let(:subsection) { instance_double(Form::Subsection, form:) }
+
+ it "has the correct title_text" do
+ expect(page.title_text).to eq({
+ "translation" => "forms.2025.sales.soft_validations.hodate_check.title_text",
+ "arguments" => [],
+ })
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([
+ { "hodate_5_years_or_more_saledate?" => true, "saledate_check" => nil },
+ { "hodate_5_years_or_more_saledate?" => true, "saledate_check" => 1 },
+ ])
+ end
end
end
diff --git a/spec/models/form/sales/subsections/household_situation_spec.rb b/spec/models/form/sales/subsections/household_situation_spec.rb
index 903960a8d..821847d9e 100644
--- a/spec/models/form/sales/subsections/household_situation_spec.rb
+++ b/spec/models/form/sales/subsections/household_situation_spec.rb
@@ -25,6 +25,14 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
],
)
end
+
+ it "has the correct id" do
+ expect(household_characteristics.id).to eq("household_situation")
+ end
+
+ it "has the correct label" do
+ expect(household_characteristics.label).to eq("Household situation")
+ end
end
context "when the start year is 2025" do
@@ -41,17 +49,9 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do
],
)
end
- end
- it "has the correct id" do
- expect(household_characteristics.id).to eq("household_situation")
- end
-
- it "has the correct label" do
- expect(household_characteristics.label).to eq("Household situation")
- end
-
- it "has correct depends on" do
- expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
+ it "has correct depends on" do
+ expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "is_staircase?" => false }])
+ end
end
end
diff --git a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
index 22a84f2a9..557155758 100644
--- a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
+++ b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb
@@ -11,8 +11,16 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
expect(subsection.section).to eq(section)
end
+ it "has the correct id" do
+ expect(subsection.id).to eq("income_benefits_and_savings")
+ end
+
+ it "has the correct label" do
+ expect(subsection.label).to eq("Income, benefits and savings")
+ end
+
describe "pages" do
- let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:)) }
+ let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:, start_year_2025_or_later?: false)) }
context "when 2022" do
let(:start_date) { Time.utc(2022, 2, 8) }
@@ -83,18 +91,19 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
],
)
end
- end
- end
- it "has the correct id" do
- expect(subsection.id).to eq("income_benefits_and_savings")
+ it "has correct depends on" do
+ expect(subsection.depends_on).to eq([{ "setup_completed?" => true }])
+ end
+ end
end
- it "has the correct label" do
- expect(subsection.label).to eq("Income, benefits and savings")
- end
+ context "when 2025" do
+ let(:start_date) { Time.utc(2025, 2, 8) }
+ let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:, start_year_2025_or_later?: true)) }
- it "has correct depends on" do
- expect(subsection.depends_on).to eq([{ "setup_completed?" => true }])
+ it "has correct depends on" do
+ expect(subsection.depends_on).to eq([{ "setup_completed?" => true, "is_staircase?" => false }])
+ end
end
end
diff --git a/spec/models/form/sales/subsections/other_household_information_spec.rb b/spec/models/form/sales/subsections/other_household_information_spec.rb
index 461ad2cc9..836540b5b 100644
--- a/spec/models/form/sales/subsections/other_household_information_spec.rb
+++ b/spec/models/form/sales/subsections/other_household_information_spec.rb
@@ -5,36 +5,48 @@ RSpec.describe Form::Sales::Subsections::OtherHouseholdInformation, type: :model
let(:subsection_id) { nil }
let(:subsection_definition) { nil }
- let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
- let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
- it "has correct section" do
- expect(household_characteristics.section).to eq(section)
- end
+ context "when 2024" do
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_2025_or_later?: false) }
+ let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
- it "has correct pages" do
- expect(household_characteristics.pages.map(&:id)).to eq(
- %w[
- armed_forces
- buyer_still_serving
- armed_forces_spouse
- household_disability
- disability_wheelchair_check
- household_wheelchair
- wheelchair_check
- ],
- )
- end
+ it "has correct section" do
+ expect(household_characteristics.section).to eq(section)
+ end
- it "has the correct id" do
- expect(household_characteristics.id).to eq("other_household_information")
- end
+ it "has correct pages" do
+ expect(household_characteristics.pages.map(&:id)).to eq(
+ %w[
+ armed_forces
+ buyer_still_serving
+ armed_forces_spouse
+ household_disability
+ disability_wheelchair_check
+ household_wheelchair
+ wheelchair_check
+ ],
+ )
+ end
- it "has the correct label" do
- expect(household_characteristics.label).to eq("Other household information")
+ it "has the correct id" do
+ expect(household_characteristics.id).to eq("other_household_information")
+ end
+
+ it "has the correct label" do
+ expect(household_characteristics.label).to eq("Other household information")
+ end
+
+ it "has correct depends on" do
+ expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
+ end
end
- it "has correct depends on" do
- expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }])
+ context "when 2025" do
+ let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1), start_year_2025_or_later?: true) }
+ let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
+
+ it "has correct depends on" do
+ expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "is_staircase?" => false }])
+ end
end
end
diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb
index f478ae466..142cb2491 100644
--- a/spec/models/validations/property_validations_spec.rb
+++ b/spec/models/validations/property_validations_spec.rb
@@ -204,4 +204,78 @@ RSpec.describe Validations::PropertyValidations do
end
end
end
+
+ describe "#validate_la_in_england" do
+ context "with a log on or after 2025" do
+ before do
+ allow(log.form).to receive(:start_year_2025_or_later?).and_return true
+ end
+
+ context "and the local authority is not in England for general needs log" do
+ let(:log) { build(:lettings_log, la: "S12000019", needstype: 1) }
+
+ it "adds an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["la"]).to include(I18n.t("validations.lettings.property.la.not_in_england"))
+ expect(log.errors["postcode_full"]).to include(I18n.t("validations.lettings.property.postcode_full.not_in_england"))
+ expect(log.errors["uprn"]).to include(I18n.t("validations.lettings.property.uprn.not_in_england"))
+ expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.lettings.property.uprn_confirmation.not_in_england"))
+ expect(log.errors["uprn_selection"]).to include(I18n.t("validations.lettings.property.uprn_selection.not_in_england"))
+ expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.postcode_not_in_england"))
+ expect(log.errors["scheme_id"]).to be_empty
+ expect(log.errors["location_id"]).to be_empty
+ end
+ end
+
+ context "and the local authority is not in England for supported housing log" do
+ let(:location) { create(:location, location_code: "S12000019") }
+ let(:log) { build(:lettings_log, la: "S12000019", needstype: 2, location:) }
+
+ it "adds an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["scheme_id"]).to include(I18n.t("validations.lettings.property.scheme_id.not_in_england"))
+ expect(log.errors["location_id"]).to include(I18n.t("validations.lettings.property.location_id.not_in_england"))
+ expect(log.errors["startdate"]).to include(I18n.t("validations.lettings.property.startdate.location_not_in_england"))
+ expect(log.errors["la"]).to be_empty
+ expect(log.errors["postcode_full"]).to be_empty
+ expect(log.errors["uprn"]).to be_empty
+ expect(log.errors["uprn_confirmation"]).to be_empty
+ expect(log.errors["uprn_selection"]).to be_empty
+ end
+ end
+
+ context "and the local authority is in England" do
+ let(:log) { build(:lettings_log, la: "E06000002") }
+
+ it "does not add an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["la"]).to be_empty
+ expect(log.errors["postcode_full"]).to be_empty
+ expect(log.errors["uprn"]).to be_empty
+ expect(log.errors["uprn_confirmation"]).to be_empty
+ expect(log.errors["uprn_selection"]).to be_empty
+ expect(log.errors["startdate"]).to be_empty
+ end
+ end
+ end
+
+ context "with a log before 2025" do
+ before do
+ allow(log.form).to receive(:start_year_2025_or_later?).and_return false
+ end
+
+ context "and the local authority is not in England" do
+ let(:log) { build(:lettings_log, la: "S12000019") }
+
+ it "does not add an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["la"]).to be_empty
+ expect(log.errors["postcode_full"]).to be_empty
+ expect(log.errors["uprn"]).to be_empty
+ expect(log.errors["uprn_confirmation"]).to be_empty
+ expect(log.errors["uprn_selection"]).to be_empty
+ end
+ end
+ end
+ end
end
diff --git a/spec/models/validations/sales/property_validations_spec.rb b/spec/models/validations/sales/property_validations_spec.rb
index df0396845..c5af3ae78 100644
--- a/spec/models/validations/sales/property_validations_spec.rb
+++ b/spec/models/validations/sales/property_validations_spec.rb
@@ -142,4 +142,60 @@ RSpec.describe Validations::Sales::PropertyValidations do
end
end
end
+
+ describe "#validate_la_in_england" do
+ context "with a log on or after 2025" do
+ before do
+ allow(log.form).to receive(:start_year_2025_or_later?).and_return true
+ end
+
+ context "and the local authority is not in England" do
+ let(:log) { build(:sales_log, la: "S12000019") }
+
+ it "adds an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["la"]).to include(I18n.t("validations.sales.property_information.la.not_in_england"))
+ expect(log.errors["postcode_full"]).to include(I18n.t("validations.sales.property_information.postcode_full.not_in_england"))
+ expect(log.errors["uprn"]).to include(I18n.t("validations.sales.property_information.uprn.not_in_england"))
+ expect(log.errors["uprn_confirmation"]).to include(I18n.t("validations.sales.property_information.uprn_confirmation.not_in_england"))
+ expect(log.errors["uprn_selection"]).to include(I18n.t("validations.sales.property_information.uprn_selection.not_in_england"))
+ expect(log.errors["saledate"]).to include(I18n.t("validations.sales.property_information.saledate.postcode_not_in_england"))
+ end
+ end
+
+ context "and the local authority is in England" do
+ let(:log) { build(:sales_log, la: "E06000002") }
+
+ it "does not add an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["la"]).to be_empty
+ expect(log.errors["postcode_full"]).to be_empty
+ expect(log.errors["uprn"]).to be_empty
+ expect(log.errors["uprn_confirmation"]).to be_empty
+ expect(log.errors["uprn_selection"]).to be_empty
+ expect(log.errors["saledate"]).to be_empty
+ end
+ end
+ end
+
+ context "with a log before 2025" do
+ before do
+ allow(log.form).to receive(:start_year_2025_or_later?).and_return false
+ end
+
+ context "and the local authority is not in England" do
+ let(:log) { build(:sales_log, la: "S12000019") }
+
+ it "does not add an error" do
+ property_validator.validate_la_in_england(log)
+ expect(log.errors["la"]).to be_empty
+ expect(log.errors["postcode_full"]).to be_empty
+ expect(log.errors["uprn"]).to be_empty
+ expect(log.errors["uprn_confirmation"]).to be_empty
+ expect(log.errors["uprn_selection"]).to be_empty
+ expect(log.errors["saledate"]).to be_empty
+ end
+ end
+ end
+ end
end
diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb
index e7b1d53d5..fabe3c8c5 100644
--- a/spec/models/validations/sales/sale_information_validations_spec.rb
+++ b/spec/models/validations/sales/sale_information_validations_spec.rb
@@ -60,10 +60,11 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
context "and form year is 2023 or earlier" do
let(:record) { build(:sales_log, hodate: Date.new(2020, 12, 1), saledate: Date.new(2023, 12, 1)) }
- it "does not add an error" do
+ it "does add an error" do
sale_information_validator.validate_practical_completion_date(record)
- expect(record.errors).not_to be_present
+ expect(record.errors[:hodate]).to be_present
+ expect(record.errors[:saledate]).to be_present
end
end