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/household_situation.rb b/app/models/form/sales/subsections/household_situation.rb index 225b1ae43..2e496908b 100644 --- a/app/models/form/sales/subsections/household_situation.rb +++ b/app/models/form/sales/subsections/household_situation.rb @@ -11,17 +11,9 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection Form::Sales::Pages::Buyer1PreviousTenure.new(nil, nil, self), Form::Sales::Pages::LastAccommodation.new(nil, nil, self), Form::Sales::Pages::LastAccommodationLa.new(nil, nil, self), - Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self), - buyer_2_situation_pages, + (Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self) unless form.start_year_2025_or_later?), + Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self), + Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), ].flatten.compact end - - def buyer_2_situation_pages - if form.start_date.year >= 2023 - [ - Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self), - Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), - ] - end - end end 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/app/services/bulk_upload/lettings/log_creator.rb b/app/services/bulk_upload/lettings/log_creator.rb index 3aaf1d69d..1fd0d45b6 100644 --- a/app/services/bulk_upload/lettings/log_creator.rb +++ b/app/services/bulk_upload/lettings/log_creator.rb @@ -15,7 +15,7 @@ class BulkUpload::Lettings::LogCreator row_parser.log.blank_invalid_non_setup_fields! row_parser.log.bulk_upload = bulk_upload - row_parser.log.creation_method_bulk_upload! + row_parser.log.creation_method = "bulk upload" row_parser.log.skip_update_status = true row_parser.log.status = "pending" row_parser.log.status_cache = row_parser.log.calculate_status diff --git a/app/services/bulk_upload/sales/log_creator.rb b/app/services/bulk_upload/sales/log_creator.rb index 2d0888e4d..ea337d220 100644 --- a/app/services/bulk_upload/sales/log_creator.rb +++ b/app/services/bulk_upload/sales/log_creator.rb @@ -14,7 +14,7 @@ class BulkUpload::Sales::LogCreator row_parser.log.blank_invalid_non_setup_fields! row_parser.log.bulk_upload = bulk_upload - row_parser.log.creation_method_bulk_upload! + row_parser.log.creation_method = "bulk upload" row_parser.log.skip_update_status = true row_parser.log.status = "pending" row_parser.log.status_cache = row_parser.log.calculate_status diff --git a/config/locales/forms/2025/sales/household_situation.en.yml b/config/locales/forms/2025/sales/household_situation.en.yml index 3aa3545d8..6b49a7d37 100644 --- a/config/locales/forms/2025/sales/household_situation.en.yml +++ b/config/locales/forms/2025/sales/household_situation.en.yml @@ -31,12 +31,6 @@ en: hint_text: "" question_text: "Select a local authority" - buyers_organisations: - page_header: "" - check_answer_label: "Organisations buyers were registered with" - hint_text: "Select all that apply. This question is optional. If no options are applicable, leave the options blank, and select save and continue." - question_text: "What organisations were the buyers registered with?" - buy2living: page_header: "" check_answer_label: "Buyer 2 living at the same address" 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/household_situation_spec.rb b/spec/models/form/sales/subsections/household_situation_spec.rb index 10898b27c..903960a8d 100644 --- a/spec/models/form/sales/subsections/household_situation_spec.rb +++ b/spec/models/form/sales/subsections/household_situation_spec.rb @@ -3,16 +3,15 @@ require "rails_helper" RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do subject(:household_characteristics) { described_class.new(nil, nil, section) } - let(:start_date) { Time.utc(2023, 4, 1) } - let(:form) { instance_double(Form, start_date:) } + let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) } let(:section) { instance_double(Form::Sales::Sections::Household, form:) } it "has correct section" do expect(household_characteristics.section).to eq(section) end - context "when the log belongs to the 22/23 collection" do - let(:start_date) { Time.utc(2022, 4, 1) } + context "when the start year is 2024" do + let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: false) } it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( @@ -21,19 +20,22 @@ RSpec.describe Form::Sales::Subsections::HouseholdSituation, type: :model do last_accommodation last_accommodation_la buyers_organisations + buyer_2_living_in + buyer_2_previous_housing_situation ], ) end end - context "when the log belongs to the 23/24 collection" do + context "when the start year is 2025" do + let(:form) { instance_double(Form, start_year_2024_or_later?: true, start_year_2025_or_later?: true) } + it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( %w[ buyer1_previous_tenure last_accommodation last_accommodation_la - buyers_organisations buyer_2_living_in buyer_2_previous_housing_situation ], 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