diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 571968c8f..0277acffb 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -3,7 +3,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection super @id = "household_characteristics" @label = "Household characteristics" - @depends_on = [{ "setup_completed?" => true }] + @depends_on = [{ "setup_completed?" => true, "company_buyer?" => false }] end def pages @@ -92,4 +92,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Buyer2EthnicBackgroundWhite.new(nil, nil, self)] end end + + def displayed_in_tasklist?(log) + !log.company_buyer? + end end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 629215386..90f130c04 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -262,6 +262,10 @@ class SalesLog < Log ownershipsch == 1 end + def company_buyer? + companybuy == 1 + end + def buyers_age_for_old_persons_shared_ownership_invalid? return unless old_persons_shared_ownership? diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb index f1da841a4..b2d6f37a5 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -14,7 +14,6 @@ FactoryBot.define do ownershipsch { 2 } type { 8 } saledate { Time.utc(2023, 2, 2, 10, 36, 49) } - companybuy { 1 } jointpur { 1 } beds { 2 } jointmore { 1 } diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 4645b7231..5a025e8de 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -195,6 +195,22 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model end it "has correct depends on" do - expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true }]) + expect(household_characteristics.depends_on).to eq([{ "setup_completed?" => true, "company_buyer?" => false }]) + end + + context "when the sale is to a company buyer" do + let(:log) { FactoryBot.create(:sales_log, ownershipsch: 3, companybuy: 1) } + + it "is not displayed in tasklist" do + expect(household_characteristics.displayed_in_tasklist?(log)).to eq(false) + end + end + + context "when the sale is not to a company buyer" do + let(:log) { FactoryBot.create(:sales_log, ownershipsch: 3, companybuy: 2) } + + it "is displayed in tasklist" do + expect(household_characteristics.displayed_in_tasklist?(log)).to eq(true) + end end end