Browse Source

Pluralise buyer in sales information sections

pull/2272/head
Kat 2 years ago
parent
commit
0b64f4140f
  1. 20
      app/models/form/sales/pages/deposit_value_check.rb
  2. 13
      app/models/form/sales/pages/living_before_purchase.rb
  3. 6
      app/models/form/sales/questions/living_before_purchase.rb
  4. 6
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  5. 3
      app/models/form/sales/subsections/outright_sale.rb
  6. 6
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  7. 3
      spec/models/form/sales/pages/deposit_value_check_spec.rb
  8. 12
      spec/models/form/sales/pages/living_before_purchase_spec.rb
  9. 2
      spec/models/form/sales/questions/living_before_purchase_spec.rb
  10. 2
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
  11. 3
      spec/models/form/sales/subsections/outright_sale_spec.rb
  12. 2
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

20
app/models/form/sales/pages/deposit_value_check.rb

@ -1,17 +1,12 @@
class Form::Sales::Pages::DepositValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [
{
"deposit_over_soft_max?" => true,
},
]
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@informative_text = {
"translation" => "soft_validations.deposit.hint_text",
"arguments" => [],
}
@title_text = {
"translation" => "soft_validations.deposit.title_text",
"translation" => "soft_validations.deposit.title_text.#{joint_purchase ? 'two' : 'one'}",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@ -25,6 +20,7 @@ class Form::Sales::Pages::DepositValueCheck < ::Form::Page
},
],
}
@joint_purchase = joint_purchase
end
def questions
@ -36,4 +32,12 @@ class Form::Sales::Pages::DepositValueCheck < ::Form::Page
def interruption_screen_question_ids
%w[savings deposit]
end
def depends_on
if @joint_purchase
[{ "joint_purchase?" => true, "deposit_over_soft_max?" => true }]
else
[{ "not_joint_purchase?" => true, "deposit_over_soft_max?" => true }]
end
end
end

13
app/models/form/sales/pages/living_before_purchase.rb

@ -1,7 +1,8 @@
class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page
def initialize(id, hsh, subsection, ownershipsch:)
def initialize(id, hsh, subsection, ownershipsch:, joint_purchase:)
super(id, hsh, subsection)
@ownershipsch = ownershipsch
@joint_purchase = joint_purchase
end
def questions
@ -13,7 +14,15 @@ class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page
def living_before_purchase
if form.start_date.year >= 2023
Form::Sales::Questions::LivingBeforePurchase.new(nil, nil, self, ownershipsch: @ownershipsch)
Form::Sales::Questions::LivingBeforePurchase.new(nil, nil, self, ownershipsch: @ownershipsch, joint_purchase: @joint_purchase)
end
end
def depends_on
if @joint_purchase
[{ "joint_purchase?" => true }]
else
[{ "not_joint_purchase?" => true }]
end
end
end

6
app/models/form/sales/questions/living_before_purchase.rb

@ -1,9 +1,9 @@
class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question
def initialize(id, hsh, page, ownershipsch:)
def initialize(id, hsh, page, ownershipsch:, joint_purchase:)
super(id, hsh, page)
@id = "proplen_asked"
@check_answer_label = "Buyer lived in the property before purchasing"
@header = "Did the buyer live in the property before purchasing it?"
@check_answer_label = "#{joint_purchase ? 'Buyers' : 'Buyer'} lived in the property before purchasing"
@header = "Did the #{joint_purchase ? 'buyers' : 'buyer'} live in the property before purchasing it?"
@hint_text = nil
@type = "radio"
@answer_options = ANSWER_OPTIONS

6
app/models/form/sales/subsections/discounted_ownership_scheme.rb

@ -8,7 +8,8 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
def pages
@pages ||= [
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self, ownershipsch: 2),
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership_joint_purchase", nil, self, ownershipsch: 2, joint_purchase: true),
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self, ownershipsch: 2, joint_purchase: false),
Form::Sales::Pages::AboutPriceRtb.new(nil, nil, self),
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_price_value_check", nil, self),
Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_value_check", nil, self),
@ -33,7 +34,8 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self, ownershipsch: 2, optional: false),
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_deposit_value_check", nil, self),
Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self),
Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_joint_purchase_value_check", nil, self, joint_purchase: true),
Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self, joint_purchase: false),
Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_deposit", nil, self),
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),

3
app/models/form/sales/subsections/outright_sale.rb

@ -19,7 +19,8 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self, ownershipsch: 3),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self, ownershipsch: 3),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self, ownershipsch: 3, optional: false),
Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self),
Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_joint_purchase_value_check", nil, self, joint_purchase: true),
Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self, joint_purchase: false),
leasehold_charge_pages,
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_outright_sale_value_check", nil, self),
].flatten.compact

6
app/models/form/sales/subsections/shared_ownership_scheme.rb

@ -8,7 +8,8 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
def pages
@pages ||= [
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership_joint_purchase", nil, self, ownershipsch: 1, joint_purchase: true),
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self, ownershipsch: 1, joint_purchase: false),
Form::Sales::Pages::Staircase.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),
@ -41,7 +42,8 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
(Form::Sales::Pages::AboutDepositWithDiscount.new("about_deposit_with_discount_optional", nil, self, optional: true) if form.start_year_after_2024?),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self, ownershipsch: 1, optional: false),
(Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_after_2024?),
Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self),
Form::Sales::Pages::DepositValueCheck.new("deposit_joint_purchase_value_check", nil, self, joint_purchase: true),
Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self),
Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1),

3
spec/models/form/sales/pages/deposit_value_check_spec.rb

@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::DepositValueCheck, 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: false) }
let(:page_id) { "deposit_value_check" }
let(:page_definition) { nil }
@ -27,6 +27,7 @@ RSpec.describe Form::Sales::Pages::DepositValueCheck, type: :model do
expect(page.depends_on).to eq([
{
"deposit_over_soft_max?" => true,
"not_joint_purchase?" => true,
},
])
end

12
spec/models/form/sales/pages/living_before_purchase_spec.rb

@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::LivingBeforePurchase, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1) }
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, joint_purchase: false) }
let(:page_id) { nil }
let(:page_definition) { nil }
@ -44,6 +44,14 @@ RSpec.describe Form::Sales::Pages::LivingBeforePurchase, type: :model do
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
expect(page.depends_on).to eq([{ "not_joint_purchase?" => true }])
end
context "with joint purchase" do
subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, joint_purchase: true) }
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end
end

2
spec/models/form/sales/questions/living_before_purchase_spec.rb

@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::LivingBeforePurchase, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1) }
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1, joint_purchase: false) }
let(:question_id) { nil }
let(:question_definition) { nil }

2
spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb

@ -14,6 +14,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
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
about_price_rtb
extra_borrowing_price_value_check
@ -39,6 +40,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
extra_borrowing_value_check
about_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

3
spec/models/form/sales/subsections/outright_sale_spec.rb

@ -39,6 +39,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
mortgage_length_outright_sale
extra_borrowing_outright_sale
about_deposit_outright_sale
outright_sale_deposit_joint_purchase_value_check
outright_sale_deposit_value_check
monthly_charges_outright_sale_value_check
],
@ -67,6 +68,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
mortgage_length_outright_sale
extra_borrowing_outright_sale
about_deposit_outright_sale
outright_sale_deposit_joint_purchase_value_check
outright_sale_deposit_value_check
leasehold_charges_outright_sale
monthly_charges_outright_sale_value_check
@ -93,6 +95,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
mortgage_length_outright_sale
extra_borrowing_outright_sale
about_deposit_outright_sale
outright_sale_deposit_joint_purchase_value_check
outright_sale_deposit_value_check
leasehold_charges_outright_sale
monthly_charges_outright_sale_value_check

2
spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
it "has correct pages" do
expect(shared_ownership_scheme.pages.map(&:id)).to eq(
%w[
living_before_purchase_shared_ownership_joint_purchase
living_before_purchase_shared_ownership
staircasing
about_staircasing_joint_purchase
@ -49,6 +50,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
extra_borrowing_shared_ownership
about_deposit_with_discount
about_deposit_shared_ownership
deposit_joint_purchase_value_check
deposit_value_check
shared_ownership_deposit_value_check
monthly_rent

Loading…
Cancel
Save