Browse Source

Only display shared ownership hint in some occations

pull/1250/head
Jack S 3 years ago
parent
commit
d2f7f9e482
  1. 2
      app/models/form/sales/pages/about_price_not_rtb.rb
  2. 2
      app/models/form/sales/pages/about_price_rtb.rb
  3. 3
      app/models/form/sales/pages/purchase_price.rb
  4. 18
      app/models/form/sales/pages/purchase_price_discounted_ownership.rb
  5. 14
      app/models/form/sales/pages/purchase_price_outright_ownership.rb
  6. 1
      app/models/form/sales/questions/purchase_price.rb
  7. 13
      app/models/form/sales/questions/purchase_price_discounted_ownership.rb
  8. 12
      app/models/form/sales/questions/purchase_price_outright_ownership.rb
  9. 4
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  10. 2
      app/models/form/sales/subsections/outright_sale.rb
  11. 4
      app/models/sales_log.rb
  12. 8
      spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb
  13. 3
      spec/models/form/sales/pages/purchase_price_spec.rb
  14. 51
      spec/models/form/sales/questions/purchase_price_discounted_ownership_spec.rb
  15. 4
      spec/models/form/sales/questions/purchase_price_spec.rb
  16. 3
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb

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

@ -11,7 +11,7 @@ class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::Value.new(nil, nil, self), Form::Sales::Questions::PurchasePrice.new(nil, nil, self),
Form::Sales::Questions::Grant.new(nil, nil, self), Form::Sales::Questions::Grant.new(nil, nil, self),
] ]
end end

2
app/models/form/sales/pages/about_price_rtb.rb

@ -10,7 +10,7 @@ class Form::Sales::Pages::AboutPriceRtb < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::PurchasePriceDiscountedOwnership.new(nil, nil, self), Form::Sales::Questions::PurchasePrice.new(nil, nil, self),
Form::Sales::Questions::Discount.new(nil, nil, self), Form::Sales::Questions::Discount.new(nil, nil, self),
] ]
end end

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

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

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

@ -1,18 +0,0 @@
class Form::Sales::Pages::PurchasePriceDiscountedOwnership < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [
{ "ownershipsch" => 2 },
{ "type" => 8 },
{ "type" => 29 },
{ "type" => 21 },
{ "type" => 22 },
]
end
def questions
@questions ||= [
Form::Sales::Questions::PurchasePriceDiscountedOwnership.new(nil, nil, self),
]
end
end

14
app/models/form/sales/pages/purchase_price_outright_ownership.rb

@ -0,0 +1,14 @@
class Form::Sales::Pages::PurchasePriceOutrightOwnership < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [
{ "outright_sale_or_discounted_with_full_ownership?" => true },
]
end
def questions
@questions ||= [
Form::Sales::Questions::PurchasePriceOutrightOwnership.new(nil, nil, self),
]
end
end

1
app/models/form/sales/questions/purchase_price.rb

@ -8,5 +8,6 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
@min = 0 @min = 0
@width = 5 @width = 5
@prefix = "£" @prefix = "£"
@hint_text = "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount"
end end
end end

13
app/models/form/sales/questions/purchase_price_discounted_ownership.rb

@ -1,13 +0,0 @@
class Form::Sales::Questions::PurchasePriceDiscountedOwnership < ::Form::Question
def initialize(id, hsh, page)
super
@id = "value"
@check_answer_label = "Purchase price"
@header = "What is the full purchase price?"
@type = "numeric"
@min = 0
@width = 5
@prefix = "£"
@hint_text = "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount"
end
end

12
app/models/form/sales/questions/purchase_price_outright_ownership.rb

@ -0,0 +1,12 @@
class Form::Sales::Questions::PurchasePriceOutrightOwnership < ::Form::Question
def initialize(id, hsh, page)
super
@id = "value"
@check_answer_label = "Purchase price"
@header = "What is the full purchase price?"
@type = "numeric"
@min = 0
@width = 5
@prefix = "£"
end
end

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

@ -13,8 +13,8 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_price_value_check", nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_price_value_check", nil, self),
Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self),
Form::Sales::Pages::GrantValueCheck.new(nil, nil, self), Form::Sales::Pages::GrantValueCheck.new(nil, nil, self),
Form::Sales::Pages::PurchasePrice.new("outright_purchase_price", nil, self), Form::Sales::Pages::PurchasePrice.new("purchase_price_discounted_ownership", nil, self),
Form::Sales::Pages::PurchasePriceDiscountedOwnership.new("purchase_price_discounted_ownership", nil, self), Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_ownership", nil, self),
Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount", 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::MortgageValueCheck.new("discounted_ownership_mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("discounted_ownership_mortgage_used_mortgage_value_check", 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("purchase_price_outright_sale", nil, self), Form::Sales::Pages::PurchasePriceOutrightOwnership.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::MortgageValueCheck.new("outright_sale_mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_used_mortgage_value_check", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self),

4
app/models/sales_log.rb

@ -132,6 +132,10 @@ class SalesLog < Log
type == 29 type == 29
end end
def outright_sale_or_discounted_with_full_ownership?
ownershipsch == 3 || (ownershipsch == 2 && rent_to_buy_full_ownership?)
end
def is_type_discount? def is_type_discount?
type == 18 type == 18
end end

8
spec/models/form/sales/pages/purchase_price_discounted_ownership_spec.rb → spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::PurchasePriceDiscountedOwnership, type: :model do RSpec.describe Form::Sales::Pages::PurchasePriceOutrightOwnership, 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) { "purchase_price" } let(:page_id) { "purchase_price" }
@ -29,11 +29,7 @@ RSpec.describe Form::Sales::Pages::PurchasePriceDiscountedOwnership, type: :mode
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([ expect(page.depends_on).to eq([
{ "ownershipsch" => 2 }, { "outright_sale_or_discounted_with_full_ownership?" => true },
{ "type" => 8 },
{ "type" => 29 },
{ "type" => 21 },
{ "type" => 22 },
]) ])
end end
end end

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

@ -29,8 +29,7 @@ RSpec.describe Form::Sales::Pages::PurchasePrice, 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([
{ "ownershipsch" => 3 }, { "ownershipsch" => 2, "rent_to_buy_full_ownership?" => false },
{ "rent_to_buy_full_ownership?" => true },
]) ])
end end
end end

51
spec/models/form/sales/questions/purchase_price_discounted_ownership_spec.rb

@ -1,51 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PurchasePriceDiscountedOwnership, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("value")
end
it "has the correct header" do
expect(question.header).to eq("What is the full purchase price?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Purchase price")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to eq(
"For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount",
)
end
it "has correct width" do
expect(question.width).to eq(5)
end
it "has correct prefix" do
expect(question.prefix).to eq("£")
end
it "has correct min" do
expect(question.min).to eq(0)
end
end

4
spec/models/form/sales/questions/purchase_price_spec.rb

@ -32,7 +32,9 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
end end
it "has the correct hint" do it "has the correct hint" do
expect(question.hint_text).to be_nil expect(question.hint_text).to eq(
"For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount",
)
end end
it "has correct width" do it "has correct width" do

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

@ -12,6 +12,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
end end
it "has correct pages" do it "has correct pages" do
puts discounted_ownership_scheme.pages.map(&:id)
expect(discounted_ownership_scheme.pages.map(&:id)).to eq( expect(discounted_ownership_scheme.pages.map(&:id)).to eq(
%w[ %w[
living_before_purchase_discounted_ownership living_before_purchase_discounted_ownership
@ -19,8 +20,8 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
extra_borrowing_price_value_check extra_borrowing_price_value_check
about_price_not_rtb about_price_not_rtb
grant_value_check grant_value_check
outright_purchase_price
purchase_price_discounted_ownership purchase_price_discounted_ownership
purchase_price_outright_ownership
discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount
mortgage_used_discounted_ownership mortgage_used_discounted_ownership
discounted_ownership_mortgage_used_mortgage_value_check discounted_ownership_mortgage_used_mortgage_value_check

Loading…
Cancel
Save