Browse Source

Pluralise buyer in savings

pull/2272/head
Kat 2 years ago
parent
commit
f1d03799d5
  1. 18
      app/models/form/sales/pages/savings.rb
  2. 20
      app/models/form/sales/pages/savings_value_check.rb
  3. 6
      app/models/form/sales/questions/savings.rb
  4. 8
      app/models/form/sales/questions/savings_nk.rb
  5. 9
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  6. 14
      spec/models/form/sales/pages/savings_spec.rb
  7. 18
      spec/models/form/sales/pages/savings_value_check_spec.rb
  8. 2
      spec/models/form/sales/questions/savings_nk_spec.rb
  9. 2
      spec/models/form/sales/questions/savings_spec.rb
  10. 6
      spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

18
app/models/form/sales/pages/savings.rb

@ -1,13 +1,21 @@
class Form::Sales::Pages::Savings < ::Form::Page class Form::Sales::Pages::Savings < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection, joint_purchase:)
super super(id, hsh, subsection)
@id = "savings" @joint_purchase = joint_purchase
end end
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::SavingsNk.new(nil, nil, self), Form::Sales::Questions::SavingsNk.new(nil, nil, self, joint_purchase: @joint_purchase),
Form::Sales::Questions::Savings.new(nil, nil, self), Form::Sales::Questions::Savings.new(nil, nil, self, joint_purchase: @joint_purchase),
] ]
end end
def depends_on
if @joint_purchase
[{ "joint_purchase?" => true }]
else
[{ "not_joint_purchase?" => true }]
end
end
end end

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

@ -1,13 +1,8 @@
class Form::Sales::Pages::SavingsValueCheck < ::Form::Page class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection, joint_purchase:)
super super(id, hsh, subsection)
@depends_on = [
{
"savings_over_soft_max?" => true,
},
]
@title_text = { @title_text = {
"translation" => "soft_validations.savings.title_text", "translation" => "soft_validations.savings.title_text.#{joint_purchase ? 'two' : 'one'}",
"arguments" => [ "arguments" => [
{ {
"key" => "field_formatted_as_currency", "key" => "field_formatted_as_currency",
@ -20,6 +15,7 @@ class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
"translation" => "soft_validations.savings.hint_text", "translation" => "soft_validations.savings.hint_text",
"arguments" => [], "arguments" => [],
} }
@joint_purchase = joint_purchase
end end
def questions def questions
@ -31,4 +27,12 @@ class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
def interruption_screen_question_ids def interruption_screen_question_ids
%w[savings] %w[savings]
end end
def depends_on
if @joint_purchase
[{ "joint_purchase?" => true, "savings_over_soft_max?" => true }]
else
[{ "not_joint_purchase?" => true, "savings_over_soft_max?" => true }]
end
end
end end

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

@ -1,8 +1,8 @@
class Form::Sales::Questions::Savings < ::Form::Question class Form::Sales::Questions::Savings < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page, joint_purchase:)
super super(id, hsh, page)
@id = "savings" @id = "savings"
@check_answer_label = "Buyer’s total savings before any deposit paid" @check_answer_label = "#{joint_purchase ? 'Buyers’' : 'Buyer’s'} total savings before any deposit paid"
@header = "Enter their total savings to the nearest £10" @header = "Enter their total savings to the nearest £10"
@type = "numeric" @type = "numeric"
@width = 5 @width = 5

8
app/models/form/sales/questions/savings_nk.rb

@ -1,9 +1,9 @@
class Form::Sales::Questions::SavingsNk < ::Form::Question class Form::Sales::Questions::SavingsNk < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page, joint_purchase:)
super super(id, hsh, page)
@id = "savingsnk" @id = "savingsnk"
@check_answer_label = "Buyer’s total savings known?" @check_answer_label = "#{joint_purchase ? 'Buyers’' : 'Buyer’s'} total savings known?"
@header = "Do you know how much the buyer had in savings before they paid any deposit for the property?" @header = "Do you know how much the #{joint_purchase ? 'buyers' : 'buyer'} had in savings before they paid any deposit for the property?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@conditional_for = { @conditional_for = {

9
app/models/form/sales/subsections/income_benefits_and_savings.rb

@ -24,9 +24,12 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2), Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2),
Form::Sales::Pages::HousingBenefits.new("housing_benefits_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::HousingBenefits.new("housing_benefits_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::HousingBenefits.new("housing_benefits_not_joint_purchase", nil, self, joint_purchase: false), Form::Sales::Pages::HousingBenefits.new("housing_benefits_not_joint_purchase", nil, self, joint_purchase: false),
Form::Sales::Pages::Savings.new(nil, nil, self), Form::Sales::Pages::Savings.new("savings_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::SavingsValueCheck.new("savings_value_check", nil, self), Form::Sales::Pages::Savings.new("savings", nil, self, joint_purchase: false),
Form::Sales::Pages::DepositValueCheck.new("savings_deposit_value_check", nil, self), Form::Sales::Pages::SavingsValueCheck.new("savings_joint_purchase_value_check", nil, self, joint_purchase: true),
Form::Sales::Pages::SavingsValueCheck.new("savings_value_check", nil, self, joint_purchase: false),
Form::Sales::Pages::DepositValueCheck.new("savings_deposit_joint_purchase_value_check", nil, self, joint_purchase: true),
Form::Sales::Pages::DepositValueCheck.new("savings_deposit_value_check", nil, self, joint_purchase: false),
Form::Sales::Pages::PreviousOwnership.new("previous_ownership_joint_purchase", nil, self, joint_purchase: true), 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), Form::Sales::Pages::PreviousOwnership.new("previous_ownership_not_joint_purchase", nil, self, joint_purchase: false),
previous_shared_page, previous_shared_page,

14
spec/models/form/sales/pages/savings_spec.rb

@ -1,9 +1,9 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::Savings, type: :model do RSpec.describe Form::Sales::Pages::Savings, 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) { nil } let(:page_id) { "savings" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection) }
@ -28,6 +28,14 @@ RSpec.describe Form::Sales::Pages::Savings, type: :model do
end end
it "has correct depends_on" do 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, joint_purchase: true) }
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "joint_purchase?" => true }])
end
end end
end end

18
spec/models/form/sales/pages/savings_value_check_spec.rb

@ -1,7 +1,7 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::SavingsValueCheck, type: :model do RSpec.describe Form::Sales::Pages::SavingsValueCheck, 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) { "savings_value_check" } let(:page_id) { "savings_value_check" }
let(:page_definition) { nil } let(:page_definition) { nil }
@ -25,9 +25,8 @@ RSpec.describe Form::Sales::Pages::SavingsValueCheck, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ { "not_joint_purchase?" => true,
"savings_over_soft_max?" => true, "savings_over_soft_max?" => true },
},
]) ])
end end
@ -38,4 +37,15 @@ RSpec.describe Form::Sales::Pages::SavingsValueCheck, type: :model do
it "has the correct interruption_screen_question_ids" do it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[savings]) expect(page.interruption_screen_question_ids).to eq(%w[savings])
end end
context "with joint purchase" do
subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) }
it "has correct depends_on" do
expect(page.depends_on).to eq([
{ "joint_purchase?" => true,
"savings_over_soft_max?" => true },
])
end
end
end end

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

@ -1,7 +1,7 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Questions::SavingsNk, type: :model do RSpec.describe Form::Sales::Questions::SavingsNk, 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: false) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }

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

@ -1,7 +1,7 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Questions::Savings, type: :model do RSpec.describe Form::Sales::Questions::Savings, 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: false) }
let(:question_id) { nil } let(:question_id) { nil }
let(:question_definition) { nil } let(:question_definition) { nil }

6
spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

@ -36,8 +36,11 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
buyer_2_mortgage_value_check buyer_2_mortgage_value_check
housing_benefits_joint_purchase housing_benefits_joint_purchase
housing_benefits_not_joint_purchase housing_benefits_not_joint_purchase
savings_joint_purchase
savings savings
savings_joint_purchase_value_check
savings_value_check savings_value_check
savings_deposit_joint_purchase_value_check
savings_deposit_value_check savings_deposit_value_check
previous_ownership_joint_purchase previous_ownership_joint_purchase
previous_ownership_not_joint_purchase previous_ownership_not_joint_purchase
@ -68,8 +71,11 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
buyer_2_mortgage_value_check buyer_2_mortgage_value_check
housing_benefits_joint_purchase housing_benefits_joint_purchase
housing_benefits_not_joint_purchase housing_benefits_not_joint_purchase
savings_joint_purchase
savings savings
savings_joint_purchase_value_check
savings_value_check savings_value_check
savings_deposit_joint_purchase_value_check
savings_deposit_value_check savings_deposit_value_check
previous_ownership_joint_purchase previous_ownership_joint_purchase
previous_ownership_not_joint_purchase previous_ownership_not_joint_purchase

Loading…
Cancel
Save