diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index 8131df4a7..63ce4af47 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -28,8 +28,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::DiscountedSaleValueCheck.new("discounted_sale_mortgage_value_check", nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_mortgage_value_check", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_mortgage", nil, self), - Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self, ownershipsch: 2), - Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self, ownershipsch: 2), + mortgage_lender_questions, Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check", nil, self), @@ -41,10 +40,19 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::DiscountedSaleValueCheck.new("discounted_sale_deposit_value_check", nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_discounted_ownership_value_check", nil, self), - ] + ].flatten.compact end def displayed_in_tasklist?(log) log.ownershipsch.nil? || log.ownershipsch == 2 end + + def mortgage_lender_questions + unless form.start_year_2025_or_later? + [ + Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self, ownershipsch: 2), + Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self, ownershipsch: 2), + ] + end + end end diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb index bfd5313fb..a573103a3 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model let(:subsection_id) { nil } let(:subsection_definition) { nil } - let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + 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::SaleInformation, form:) } it "has correct section" do @@ -83,4 +83,46 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model expect(discounted_ownership_scheme.displayed_in_tasklist?(log)).to eq(false) end end + + context "with form on or after 2025" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2025, 4, 1), start_year_2025_or_later?: true) } + + it "has correct pages" do + expect(discounted_ownership_scheme.pages.map(&:id)).to eq( + %w[ + living_before_purchase_discounted_ownership_joint_purchase + living_before_purchase_discounted_ownership + purchase_price + discount + extra_borrowing_price_value_check + percentage_discount_value_check + grant + grant_value_check + purchase_price_discounted_ownership + discounted_sale_grant_value_check + about_price_discounted_ownership_value_check + discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount + mortgage_used_discounted_ownership + discounted_ownership_mortgage_used_mortgage_value_check + discounted_sale_mortgage_used_value_check + mortgage_amount_discounted_ownership + discounted_ownership_mortgage_amount_mortgage_value_check + discounted_sale_mortgage_value_check + extra_borrowing_mortgage_value_check + discounted_ownership_deposit_and_mortgage_value_check_after_mortgage + mortgage_length_discounted_ownership + extra_borrowing_discounted_ownership + extra_borrowing_value_check + deposit_discounted_ownership + extra_borrowing_deposit_value_check + discounted_ownership_deposit_joint_purchase_value_check + discounted_ownership_deposit_value_check + discounted_ownership_deposit_and_mortgage_value_check_after_deposit + discounted_sale_deposit_value_check + leasehold_charges_discounted_ownership + monthly_charges_discounted_ownership_value_check + ], + ) + end + end end