diff --git a/app/models/form/sales/pages/about_staircase.rb b/app/models/form/sales/pages/about_staircase.rb index 2d1a17db4..4d5882916 100644 --- a/app/models/form/sales/pages/about_staircase.rb +++ b/app/models/form/sales/pages/about_staircase.rb @@ -1,17 +1,18 @@ class Form::Sales::Pages::AboutStaircase < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "about_staircasing" + def initialize(id, hsh, subsection, joint_purchase:) + super(id, hsh, subsection) + @joint_purchase = joint_purchase @header = "About the staircasing transaction" @depends_on = [{ "staircase" => 1, + "joint_purchase?" => joint_purchase, }] end def questions @questions ||= [ Form::Sales::Questions::StaircaseBought.new(nil, nil, self), - Form::Sales::Questions::StaircaseOwned.new(nil, nil, self), + Form::Sales::Questions::StaircaseOwned.new(nil, nil, self, joint_purchase: @joint_purchase), staircase_sale_question, ].compact end diff --git a/app/models/form/sales/pages/buyer_previous.rb b/app/models/form/sales/pages/buyer_previous.rb index 361b3ba47..f37c6a847 100644 --- a/app/models/form/sales/pages/buyer_previous.rb +++ b/app/models/form/sales/pages/buyer_previous.rb @@ -1,12 +1,13 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "buyer_previous" + def initialize(id, hsh, subsection, joint_purchase:) + super(id, hsh, subsection) + @joint_purchase = joint_purchase + @depends_on = [{ "joint_purchase?" => joint_purchase }] end def questions @questions ||= [ - Form::Sales::Questions::BuyerPrevious.new(nil, nil, self), + Form::Sales::Questions::BuyerPrevious.new(nil, nil, self, joint_purchase: @joint_purchase), ] end end diff --git a/app/models/form/sales/pages/previous_ownership.rb b/app/models/form/sales/pages/previous_ownership.rb index 88b438e07..50711baf7 100644 --- a/app/models/form/sales/pages/previous_ownership.rb +++ b/app/models/form/sales/pages/previous_ownership.rb @@ -1,12 +1,13 @@ class Form::Sales::Pages::PreviousOwnership < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "previous_ownership" + def initialize(id, hsh, subsection, joint_purchase:) + super(id, hsh, subsection) + @joint_purchase = joint_purchase + @depends_on = [{ "joint_purchase?" => @joint_purchase }] end def questions @questions ||= [ - Form::Sales::Questions::Prevown.new(nil, nil, self), + Form::Sales::Questions::Prevown.new(nil, nil, self, joint_purchase: @joint_purchase), ] end end diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb index 18ac019cb..15fe330f0 100644 --- a/app/models/form/sales/questions/buyer_previous.rb +++ b/app/models/form/sales/questions/buyer_previous.rb @@ -1,9 +1,9 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, joint_purchase:) + super(id, hsh, page) @id = "soctenant" - @check_answer_label = "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?" - @header = "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?" + @check_answer_label = I18n.t("check_answer_labels.soctenant", count: joint_purchase ? 2 : 1) + @header = I18n.t("questions.soctenant", count: joint_purchase ? 2 : 1) @type = "radio" @answer_options = ANSWER_OPTIONS end diff --git a/app/models/form/sales/questions/prevown.rb b/app/models/form/sales/questions/prevown.rb index a9a3b086b..571e1af8f 100644 --- a/app/models/form/sales/questions/prevown.rb +++ b/app/models/form/sales/questions/prevown.rb @@ -1,9 +1,9 @@ class Form::Sales::Questions::Prevown < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, joint_purchase:) + super(id, hsh, page) @id = "prevown" - @check_answer_label = "Buyers previously owned a property" - @header = "Has the buyer previously owned a property?" + @check_answer_label = I18n.t("check_answer_labels.prevown", count: joint_purchase ? 2 : 1) + @header = I18n.t("questions.prevown", count: joint_purchase ? 2 : 1) @type = "radio" @answer_options = ANSWER_OPTIONS end diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb index 7e6dab5d6..a3596554e 100644 --- a/app/models/form/sales/questions/staircase_owned.rb +++ b/app/models/form/sales/questions/staircase_owned.rb @@ -1,9 +1,9 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, joint_purchase:) + super(id, hsh, page) @id = "stairowned" - @check_answer_label = "Percentage the buyer now owns in total" - @header = "What percentage of the property does the buyer now own in total?" + @check_answer_label = I18n.t("check_answer_labels.stairowned", count: joint_purchase ? 2 : 1) + @header = I18n.t("questions.stairowned", count: joint_purchase ? 2 : 1) @type = "numeric" @width = 5 @min = 0 diff --git a/app/models/form/sales/subsections/income_benefits_and_savings.rb b/app/models/form/sales/subsections/income_benefits_and_savings.rb index 9ff584d47..502b87fc9 100644 --- a/app/models/form/sales/subsections/income_benefits_and_savings.rb +++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb @@ -23,7 +23,8 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection Form::Sales::Pages::Savings.new(nil, nil, self), Form::Sales::Pages::SavingsValueCheck.new("savings_value_check", nil, self), Form::Sales::Pages::DepositValueCheck.new("savings_deposit_value_check", nil, self), - Form::Sales::Pages::PreviousOwnership.new(nil, nil, self), + Form::Sales::Pages::PreviousOwnership.new("previous_ownership_joint_purchase", nil, self, joint_purchase: true), + Form::Sales::Pages::PreviousOwnership.new("previous_ownership_not_joint_purchase", nil, self, joint_purchase: false), previous_shared_page, ].compact end diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 1f0cd6450..1c30f3b6f 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -10,14 +10,16 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection @pages ||= [ Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self), Form::Sales::Pages::Staircase.new(nil, nil, self), - Form::Sales::Pages::AboutStaircase.new(nil, nil, self), + Form::Sales::Pages::AboutStaircase.new("about_staircasing_joint_purchase", nil, self, joint_purchase: true), + Form::Sales::Pages::AboutStaircase.new("about_staircasing_not_joint_purchase", nil, self, joint_purchase: false), Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), Form::Sales::Pages::Resale.new(nil, nil, self), Form::Sales::Pages::ExchangeDate.new(nil, nil, self), Form::Sales::Pages::HandoverDate.new(nil, nil, self), Form::Sales::Pages::HandoverDateCheck.new(nil, nil, self), Form::Sales::Pages::LaNominations.new(nil, nil, self), - Form::Sales::Pages::BuyerPrevious.new(nil, nil, self), + Form::Sales::Pages::BuyerPrevious.new("buyer_previous_joint_purchase", nil, self, joint_purchase: true), + Form::Sales::Pages::BuyerPrevious.new("buyer_previous_not_joint_purchase", nil, self, joint_purchase: false), Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self), Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self), Form::Sales::Pages::PreviousTenure.new(nil, nil, self), diff --git a/config/locales/en.yml b/config/locales/en.yml index 8665c022a..c3762e259 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -538,6 +538,15 @@ en: W: "Suitable for someone who uses a wheelchair and offers the full use of all rooms and facilities." A: "Fitted with stairlifts, ramps, level access showers or grab rails." N: "Not designed to wheelchair-user standards or fitted with any equipment or adaptations." + soctenant: + one: "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?" + other: "Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?" + prevown: + one: "Has the buyer previously owned a property?" + other: "Have any of the buyers previously owned a property?" + stairowned: + one: "What percentage of the property does the buyer now own in total?" + other: "What percentage of the property do the buyers now own in total?" hints: location: @@ -551,6 +560,17 @@ en: bulk_upload: needstype: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." + check_answer_labels: + soctenant: + one: "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?" + other: "Any buyers were registered providers, housing association or local authority tenants immediately before this sale?" + prevown: + one: "Buyer previously owned a property" + other: "Buyers previously owned a property" + stairowned: + one: "Percentage the buyer now owns in total" + other: "Percentage the buyers now own in total" + warnings: location: deactivate: diff --git a/spec/models/form/sales/pages/about_staircase_spec.rb b/spec/models/form/sales/pages/about_staircase_spec.rb index 3828f52e4..48aa82acf 100644 --- a/spec/models/form/sales/pages/about_staircase_spec.rb +++ b/spec/models/form/sales/pages/about_staircase_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase:) } - let(:page_id) { nil } + let(:page_id) { "an_id" } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + let(:joint_purchase) { false } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -32,7 +33,7 @@ RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do end it "has the correct id" do - expect(page.id).to eq("about_staircasing") + expect(page.id).to eq("an_id") end it "has the correct header" do @@ -43,9 +44,23 @@ RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do expect(page.description).to be_nil end - it "has correct depends_on" do - expect(page.depends_on).to eq([{ - "staircase" => 1, - }]) + context "when not a joint purchase" do + it "has correct depends_on" do + expect(page.depends_on).to eq([{ + "staircase" => 1, + "joint_purchase?" => false, + }]) + end + end + + context "when a joint purchase" do + let(:joint_purchase) { true } + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ + "staircase" => 1, + "joint_purchase?" => true, + }]) + end end end diff --git a/spec/models/form/sales/pages/buyer_previous_spec.rb b/spec/models/form/sales/pages/buyer_previous_spec.rb index a3355c137..e6dda073e 100644 --- a/spec/models/form/sales/pages/buyer_previous_spec.rb +++ b/spec/models/form/sales/pages/buyer_previous_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase:) } - let(:page_id) { nil } + let(:page_id) { "example" } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + let(:joint_purchase) { false } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -16,7 +17,7 @@ RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do end it "has the correct id" do - expect(page.id).to eq("buyer_previous") + expect(page.id).to eq("example") end it "has the correct header" do @@ -26,4 +27,18 @@ RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do it "has the correct description" do expect(page.description).to be_nil end + + context "when sales is a joint purchase" do + let(:joint_purchase) { true } + + it "has the correct depends on" do + expect(page.depends_on).to eq([{ "joint_purchase?" => true }]) + end + end + + context "when sales is not a joint purchase" do + it "has the correct depends on" do + expect(page.depends_on).to eq([{ "joint_purchase?" => false }]) + end + end end diff --git a/spec/models/form/sales/pages/previous_ownership_spec.rb b/spec/models/form/sales/pages/previous_ownership_spec.rb index 7fe0d2795..69c93fefa 100644 --- a/spec/models/form/sales/pages/previous_ownership_spec.rb +++ b/spec/models/form/sales/pages/previous_ownership_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase:) } - let(:page_id) { nil } + let(:page_id) { "example_id" } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } + let(:joint_purchase) { true } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -16,7 +17,7 @@ RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do end it "has the correct id" do - expect(page.id).to eq("previous_ownership") + expect(page.id).to eq("example_id") end it "has the correct header" do @@ -26,4 +27,16 @@ RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do it "has the correct description" do expect(page.description).to be_nil end + + it "when sale is a joint purchase has the correct depends on" do + expect(page.depends_on).to eq([{ "joint_purchase?" => true }]) + end + + context "when sale is not a joint purchase" do + let(:joint_purchase) { false } + + it "has the correct depends on" do + expect(page.depends_on).to eq([{ "joint_purchase?" => false }]) + end + end end diff --git a/spec/models/form/sales/questions/buyer_previous_spec.rb b/spec/models/form/sales/questions/buyer_previous_spec.rb index 07d3685f8..a1348f17b 100644 --- a/spec/models/form/sales/questions/buyer_previous_spec.rb +++ b/spec/models/form/sales/questions/buyer_previous_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do - subject(:question) { described_class.new(question_id, question_definition, page) } + subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase:) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } + let(:joint_purchase) { true } it "has correct page" do expect(question.page).to eq(page) @@ -15,12 +16,26 @@ RSpec.describe Form::Sales::Questions::BuyerPrevious, type: :model do expect(question.id).to eq("soctenant") end - it "has the correct header" do - expect(question.header).to eq("Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?") + context "when a joint purchase" do + it "has the correct header" do + expect(question.header).to eq("Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Any buyers were registered providers, housing association or local authority tenants immediately before this sale?") + end end - it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Buyer was a registered provider, housing association or local authority tenant immediately before this sale?") + context "when not a joint purchase" do + let(:joint_purchase) { false } + + it "has the correct header" do + expect(question.header).to eq("Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer was a registered provider, housing association or local authority tenant immediately before this sale?") + end end it "has the correct type" do diff --git a/spec/models/form/sales/questions/prevown_spec.rb b/spec/models/form/sales/questions/prevown_spec.rb index dda2b7c70..d7b101c99 100644 --- a/spec/models/form/sales/questions/prevown_spec.rb +++ b/spec/models/form/sales/questions/prevown_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::Prevown, type: :model do - subject(:question) { described_class.new(question_id, question_definition, page) } + subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase:) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } + let(:joint_purchase) { false } it "has correct page" do expect(question.page).to eq(page) @@ -15,12 +16,26 @@ RSpec.describe Form::Sales::Questions::Prevown, type: :model do expect(question.id).to eq("prevown") end - it "has the correct header" do - expect(question.header).to eq("Has the buyer previously owned a property?") + context "when sale is not a joint purchase" do + it "has the correct header" do + expect(question.header).to eq("Has the buyer previously owned a property?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer previously owned a property") + end end - it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Buyers previously owned a property") + context "when sale is a joint purchase" do + let(:joint_purchase) { true } + + it "has the correct header" do + expect(question.header).to eq("Have any of the buyers previously owned a property?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyers previously owned a property") + end end it "has the correct type" do diff --git a/spec/models/form/sales/questions/staircase_owned_spec.rb b/spec/models/form/sales/questions/staircase_owned_spec.rb index cbd577784..8e78d540a 100644 --- a/spec/models/form/sales/questions/staircase_owned_spec.rb +++ b/spec/models/form/sales/questions/staircase_owned_spec.rb @@ -1,11 +1,12 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do - subject(:question) { described_class.new(question_id, question_definition, page) } + subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase:) } let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } + let(:joint_purchase) { false } it "has correct page" do expect(question.page).to eq(page) @@ -15,12 +16,26 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do expect(question.id).to eq("stairowned") end - it "has the correct header" do - expect(question.header).to eq("What percentage of the property does the buyer now own in total?") + context "when a joint purchase" do + let(:joint_purchase) { true } + + it "has the correct header" do + expect(question.header).to eq("What percentage of the property do the buyers now own in total?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Percentage the buyers now own in total") + end end - it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Percentage the buyer now owns in total") + context "when not a joint purchase" do + it "has the correct header" do + expect(question.header).to eq("What percentage of the property does the buyer now own in total?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Percentage the buyer now owns in total") + end end it "has the correct type" do diff --git a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb index 6c0997fd2..aef451878 100644 --- a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb +++ b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb @@ -35,7 +35,8 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model savings savings_value_check savings_deposit_value_check - previous_ownership + previous_ownership_joint_purchase + previous_ownership_not_joint_purchase ], ) end @@ -62,7 +63,8 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model savings savings_value_check savings_deposit_value_check - previous_ownership + previous_ownership_joint_purchase + previous_ownership_not_joint_purchase previous_shared ], ) diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb index ee9f624aa..3c189f93f 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -16,14 +16,16 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do %w[ living_before_purchase_shared_ownership staircasing - about_staircasing + about_staircasing_joint_purchase + about_staircasing_not_joint_purchase staircase_bought_value_check resale exchange_contracts handover_date handover_date_check la_nominations - buyer_previous + buyer_previous_joint_purchase + buyer_previous_not_joint_purchase previous_bedrooms previous_property_type shared_ownership_previous_tenure