From 30442fcee27e13d59817dc75b675a89fdac5500e Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:42:05 +0000 Subject: [PATCH] CLDC-3735: Sales - Move Q19 (What type of unit is the property?) (25/26) (#2760) --- .../derived_variables/sales_log_variables.rb | 4 +++ .../pages/property_number_of_bedrooms.rb | 1 + .../sales/subsections/property_information.rb | 3 +- app/models/sales_log.rb | 4 +++ .../2025/sales/property_information.en.yml | 2 +- .../subsections/property_information_spec.rb | 36 +++++++++++++++++++ 6 files changed, 48 insertions(+), 2 deletions(-) diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index e182c2158..a1462454c 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -68,6 +68,10 @@ module DerivedVariables::SalesLogVariables self.la = nil end + if form.start_year_2025_or_later? && is_bedsit? + self.beds = 1 + end + self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say? self.nationality_all_buyer2 = nationality_all_buyer2_group if nationality2_uk_or_prefers_not_to_say? diff --git a/app/models/form/sales/pages/property_number_of_bedrooms.rb b/app/models/form/sales/pages/property_number_of_bedrooms.rb index 796a617d5..a51cbfeca 100644 --- a/app/models/form/sales/pages/property_number_of_bedrooms.rb +++ b/app/models/form/sales/pages/property_number_of_bedrooms.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::PropertyNumberOfBedrooms < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_number_of_bedrooms" + @depends_on = [{ "is_beds_inferred?" => false }] end def questions diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 32df98af5..5d4021681 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -9,9 +9,10 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection def pages @pages ||= [ (uprn_questions if form.start_date.year >= 2024), + (Form::Sales::Pages::PropertyUnitType.new(nil, nil, self) if form.start_year_2025_or_later?), Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_bedrooms_value_check", nil, self), - Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), + (Form::Sales::Pages::PropertyUnitType.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_property_type_value_check", nil, self), Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 23438142f..01741fbc5 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -396,6 +396,10 @@ class SalesLog < Log proptype == 2 end + def is_beds_inferred? + form.start_year_2025_or_later? && is_bedsit? + end + def shared_ownership_scheme? ownershipsch == 1 end diff --git a/config/locales/forms/2025/sales/property_information.en.yml b/config/locales/forms/2025/sales/property_information.en.yml index 240c96f09..d658362ea 100644 --- a/config/locales/forms/2025/sales/property_information.en.yml +++ b/config/locales/forms/2025/sales/property_information.en.yml @@ -69,7 +69,7 @@ en: beds: page_header: "" check_answer_label: "Number of bedrooms" - hint_text: "A bedsit has 1 bedroom." + hint_text: "" question_text: "How many bedrooms does the property have?" proptype: diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index d29ee85fe..ccfeb8e3a 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do before do allow(form).to receive(:start_year_2024_or_later?).and_return(false) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) end context "when 2023" do @@ -48,6 +49,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do before do allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(false) end it "has correct pages" do @@ -75,6 +77,40 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do ) end end + + context "when 2025" do + let(:start_date) { Time.utc(2025, 2, 8) } + + before do + allow(form).to receive(:start_year_2024_or_later?).and_return(true) + allow(form).to receive(:start_year_2025_or_later?).and_return(true) + end + + it "has correct pages" do + expect(property_information.pages.map(&:id)).to eq( + %w[ + uprn + uprn_confirmation + address_matcher + no_address_found + uprn_selection + address + property_local_authority + local_authority_buyer_1_income_max_value_check + local_authority_buyer_2_income_max_value_check + local_authority_combined_income_max_value_check + about_price_la_value_check + property_unit_type + property_number_of_bedrooms + about_price_bedrooms_value_check + monthly_charges_property_type_value_check + percentage_discount_proptype_value_check + property_building_type + property_wheelchair_accessible + ], + ) + end + end end it "has the correct id" do