Browse Source

CLDC-1842 Display correct price questions for discounted ownership sales (#1175)

* Do not display the grants question if the discounted sale type is rent to buy

* Formatting and test
CLDC-898-monthly-charges-validation v0.2.32
kosiakkatrina 2 years ago committed by GitHub
parent
commit
93e444e3f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/models/form/sales/pages/about_price_not_rtb.rb
  2. 5
      app/models/form/sales/pages/purchase_price.rb
  3. 1
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  4. 2
      app/models/form/sales/subsections/outright_sale.rb
  5. 4
      app/models/sales_log.rb
  6. 1
      spec/models/form/sales/pages/about_price_not_rtb_spec.rb
  7. 7
      spec/models/form/sales/pages/purchase_price_spec.rb
  8. 1
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
  9. 2
      spec/models/form/sales/subsections/outright_sale_spec.rb
  10. 4
      spec/models/form_handler_spec.rb

1
app/models/form/sales/pages/about_price_not_rtb.rb

@ -5,6 +5,7 @@ class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page
@header = "About the price of the property" @header = "About the price of the property"
@depends_on = [{ @depends_on = [{
"right_to_buy?" => false, "right_to_buy?" => false,
"rent_to_buy_full_ownership?" => false,
}] }]
end end

5
app/models/form/sales/pages/purchase_price.rb

@ -1,7 +1,10 @@
class Form::Sales::Pages::PurchasePrice < ::Form::Page class Form::Sales::Pages::PurchasePrice < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "purchase_price" @depends_on = [
{ "ownershipsch" => 3 },
{ "rent_to_buy_full_ownership?" => true },
]
end end
def questions def questions

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

@ -11,6 +11,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self), Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self),
Form::Sales::Pages::AboutPriceRtb.new(nil, nil, self), Form::Sales::Pages::AboutPriceRtb.new(nil, nil, self),
Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self),
Form::Sales::Pages::PurchasePrice.new("purchase_price_discounted_ownership", nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self),
Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self), Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self),

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

@ -8,7 +8,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::PurchasePrice.new(nil, nil, self), Form::Sales::Pages::PurchasePrice.new("purchase_price_outright_sale", nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self),
Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self), Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self),

4
app/models/sales_log.rb

@ -121,6 +121,10 @@ class SalesLog < Log
[9, 14, 27].include?(type) [9, 14, 27].include?(type)
end end
def rent_to_buy_full_ownership?
type == 29
end
def is_type_discount? def is_type_discount?
type == 18 type == 18
end end

1
spec/models/form/sales/pages/about_price_not_rtb_spec.rb

@ -30,6 +30,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceNotRtb, 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([{
"right_to_buy?" => false, "right_to_buy?" => false,
"rent_to_buy_full_ownership?" => false,
}]) }])
end end
end end

7
spec/models/form/sales/pages/purchase_price_spec.rb

@ -3,7 +3,7 @@ require "rails_helper"
RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil } let(:page_id) { "purchase_price" }
let(:page_definition) { nil } let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) } let(:subsection) { instance_double(Form::Subsection) }
@ -28,6 +28,9 @@ RSpec.describe Form::Sales::Pages::PurchasePrice, 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([
{ "ownershipsch" => 3 },
{ "rent_to_buy_full_ownership?" => true },
])
end end
end end

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

@ -17,6 +17,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
living_before_purchase_discounted_ownership living_before_purchase_discounted_ownership
about_price_rtb about_price_rtb
about_price_not_rtb about_price_not_rtb
purchase_price_discounted_ownership
mortgage_used_discounted_ownership mortgage_used_discounted_ownership
mortgage_amount_discounted_ownership mortgage_amount_discounted_ownership
mortgage_lender_discounted_ownership mortgage_lender_discounted_ownership

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

@ -14,7 +14,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
it "has correct pages" do it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq( expect(outright_sale.pages.map(&:id)).to eq(
%w[ %w[
purchase_price purchase_price_outright_sale
mortgage_used_outright_sale mortgage_used_outright_sale
mortgage_amount_outright_sale mortgage_amount_outright_sale
mortgage_lender_outright_sale mortgage_lender_outright_sale

4
spec/models/form_handler_spec.rb

@ -52,14 +52,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do it "is able to load a current sales form" do
form = form_handler.get_form("current_sales") form = form_handler.get_form("current_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(144) expect(form.pages.count).to eq(145)
expect(form.name).to eq("2022_2023_sales") expect(form.name).to eq("2022_2023_sales")
end end
it "is able to load a previous sales form" do it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales") form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form) expect(form).to be_a(Form)
expect(form.pages.count).to eq(144) expect(form.pages.count).to eq(145)
expect(form.name).to eq("2021_2022_sales") expect(form.name).to eq("2021_2022_sales")
end end
end end

Loading…
Cancel
Save