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_building_type.rb b/app/models/form/sales/pages/property_building_type.rb index 40c8f3738..b9a829a64 100644 --- a/app/models/form/sales/pages/property_building_type.rb +++ b/app/models/form/sales/pages/property_building_type.rb @@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyBuildingType < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_building_type" + @depends_on = [ + { "form.start_year_2025_or_later?" => false }, + { "is_staircase?" => false }, + ] end def questions 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/pages/property_wheelchair_accessible.rb b/app/models/form/sales/pages/property_wheelchair_accessible.rb index a63964059..358f16d50 100644 --- a/app/models/form/sales/pages/property_wheelchair_accessible.rb +++ b/app/models/form/sales/pages/property_wheelchair_accessible.rb @@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_wheelchair_accessible" + @depends_on = [ + { "form.start_year_2025_or_later?" => false }, + { "is_staircase?" => 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/factories/scheme.rb b/spec/factories/scheme.rb index 5f4ad30bc..77d74b70a 100644 --- a/spec/factories/scheme.rb +++ b/spec/factories/scheme.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory :scheme do - service_name { Faker::Name.name } + service_name { "#{Faker::Name.name}'s Housing & Co." } sensitive { Faker::Number.within(range: 0..1) } registered_under_care_act { 1 } support_type { [0, 2, 3, 4, 5].sample } diff --git a/spec/models/form/sales/pages/property_building_type_spec.rb b/spec/models/form/sales/pages/property_building_type_spec.rb index aac8fbf24..b9c6bddca 100644 --- a/spec/models/form/sales/pages/property_building_type_spec.rb +++ b/spec/models/form/sales/pages/property_building_type_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -22,4 +23,46 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do it "has the correct description" do expect(page.description).to be_nil end + + context "with form year 2024" do + let(:form) { Form.new(nil, 2024, [], "sales") } + let(:saledate) { Time.zone.local(2024, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, staircase: nil, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end + + context "with form year 2025" do + let(:form) { Form.new(nil, 2025, [], "sales") } + let(:saledate) { Time.zone.local(2025, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is not routed to" do + expect(page.routed_to?(log, nil)).to be false + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, staircase: nil, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end end diff --git a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb index 01dcb7ce7..bf0493a6d 100644 --- a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb +++ b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb @@ -5,11 +5,8 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } - - before do - allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1))) - end + let(:form) { instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, enabled?: true, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -26,4 +23,46 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do it "has the correct description" do expect(page.description).to be_nil end + + context "with form year 2024" do + let(:form) { Form.new(nil, 2024, [], "sales") } + let(:saledate) { Time.zone.local(2024, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 2, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + end + end + + context "with form year 2025" do + let(:form) { Form.new(nil, 2025, [], "sales") } + let(:saledate) { Time.zone.local(2025, 4, 1) } + + context "with a staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 1, saledate:) } + + it "is not routed to" do + expect(page.routed_to?(log, nil)).to be false + end + end + + context "with a non-staircasing log" do + let(:log) { build(:sales_log, :shared_ownership_setup_complete, staircase: 2, saledate:) } + + it "is routed to" do + expect(page.routed_to?(log, nil)).to be true + end + 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 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 diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index a7d7684f0..6de8e7d33 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -180,7 +180,7 @@ RSpec.describe LocationsController, type: :request do context "when signed in as a data coordinator user" do let(:user) { create(:user, :data_coordinator) } - let(:scheme) { create(:scheme, owning_organisation: user.organisation, service_name: "Some name") } + let(:scheme) { create(:scheme, owning_organisation: user.organisation) } let!(:locations) { create_list(:location, 3, scheme:, startdate: Time.zone.local(2022, 4, 1)) } before do @@ -215,7 +215,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -232,7 +232,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 1 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -254,7 +254,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 2 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -287,7 +287,7 @@ RSpec.describe LocationsController, type: :request do end it "has search in the title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page.title).to eq(expected_title) end end @@ -343,7 +343,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -360,7 +360,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 1 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -382,7 +382,7 @@ RSpec.describe LocationsController, type: :request do end it "has correct page 1 of 2 title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end @@ -415,7 +415,7 @@ RSpec.describe LocationsController, type: :request do end it "has search in the title" do - expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") + expected_title = CGI.unescapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") expect(page).to have_title(expected_title) end end