Browse Source

CLDC-1849 Add hint to discounted ownership purchase price question (#1250)

* CLDC-1849 Add hint to discounted ownership purchase price

* Use PurchasePriceDiscountedOwnership in rtb page

* show question with updated hint to certain types of answers

* rubocop

* Only display shared ownership hint in some occations
pull/1270/head
Jack 2 years ago committed by GitHub
parent
commit
45ed2e6ea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 14
      app/models/form/sales/pages/purchase_price_outright_ownership.rb
  5. 1
      app/models/form/sales/questions/purchase_price.rb
  6. 12
      app/models/form/sales/questions/purchase_price_outright_ownership.rb
  7. 1
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  8. 2
      app/models/form/sales/subsections/outright_sale.rb
  9. 4
      app/models/sales_log.rb
  10. 21
      app/views/form/page.html.erb
  11. 35
      spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb
  12. 3
      spec/models/form/sales/pages/purchase_price_spec.rb
  13. 4
      spec/models/form/sales/questions/purchase_price_spec.rb
  14. 2
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
  15. 4
      spec/models/form_handler_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::Value.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

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

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

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

@ -14,6 +14,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
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("purchase_price_discounted_ownership", nil, self), Form::Sales::Pages::PurchasePrice.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

21
app/views/form/page.html.erb

@ -34,9 +34,26 @@
<%= govuk_section_break(visible: true, size: "m") %> <%= govuk_section_break(visible: true, size: "m") %>
<% end %> <% end %>
<% if question.type == "interruption_screen" %> <% if question.type == "interruption_screen" %>
<%= render partial: "form/#{question.type}_question", locals: { question:, caption_text: @subsection.label, page_header: @page.header, lettings_log: @log, title_text: @page.title_text, informative_text: @page.informative_text, form: @form, f:, conditional: false } %> <%= render partial: "form/#{question.type}_question", locals: {
question:,
caption_text: @subsection.label,
page_header: @page.header,
lettings_log: @log,
title_text: @page.title_text,
informative_text: @page.informative_text,
form: @form,
f:,
conditional: false,
} %>
<% else %> <% else %>
<%= render partial: "form/#{question.type}_question", locals: { question:, caption_text: @page.header_partial.present? ? nil : @subsection.label, page_header: @page.header, lettings_log: @log, f:, conditional: false } %> <%= render partial: "form/#{question.type}_question", locals: {
question:,
caption_text: @page.header_partial.present? ? nil : @subsection.label,
page_header: @page.header,
lettings_log: @log,
f:,
conditional: false,
} %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>

35
spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb

@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PurchasePriceOutrightOwnership, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "purchase_price" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[value])
end
it "has the correct id" do
expect(page.id).to eq("purchase_price")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has correct depends_on" do
expect(page.depends_on).to eq([
{ "outright_sale_or_discounted_with_full_ownership?" => true },
])
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

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

2
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
@ -20,6 +21,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
about_price_not_rtb about_price_not_rtb
grant_value_check grant_value_check
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

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(209) expect(form.pages.count).to eq(210)
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(209) expect(form.pages.count).to eq(210)
expect(form.name).to eq("2021_2022_sales") expect(form.name).to eq("2021_2022_sales")
end end
end end

Loading…
Cancel
Save