Browse Source

Extract discounted ownership copy

pull/2711/head
Kat 8 months ago
parent
commit
b3f9ff17bd
  1. 2
      app/models/form/sales/pages/discount.rb
  2. 2
      app/models/form/sales/pages/grant.rb
  3. 2
      app/models/form/sales/pages/purchase_price.rb
  4. 12
      app/models/form/sales/pages/purchase_price_outright_ownership.rb
  5. 6
      app/models/form/sales/questions/discount.rb
  6. 4
      app/models/form/sales/questions/grant.rb
  7. 16
      app/models/form/sales/questions/purchase_price.rb
  8. 30
      config/locales/forms/2023/sales/sale_information.yml
  9. 30
      config/locales/forms/2024/sales/sale_information.yml

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::Discount < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "discount" @id = "discount"
@header = "About the price of the property" @copy_key = "sales.sale_information.discount"
@depends_on = [{ @depends_on = [{
"right_to_buy?" => true, "right_to_buy?" => true,
}] }]

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::Grant < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "grant" @id = "grant"
@header = "About the price of the property" @copy_key = "sales.sale_information.grant"
@depends_on = [{ @depends_on = [{
"right_to_buy?" => false, "right_to_buy?" => false,
"rent_to_buy_full_ownership?" => false, "rent_to_buy_full_ownership?" => false,

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

@ -2,7 +2,7 @@ class Form::Sales::Pages::PurchasePrice < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "purchase_price" @id = "purchase_price"
@header = "About the price of the property" @copy_key = "sales.sale_information.purchase_price.discounted_ownership"
@depends_on = [{ "right_to_buy?" => true }, @depends_on = [{ "right_to_buy?" => true },
{ {
"right_to_buy?" => false, "right_to_buy?" => false,

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

@ -4,11 +4,21 @@ class Form::Sales::Pages::PurchasePriceOutrightOwnership < ::Form::Page
@depends_on = [ @depends_on = [
{ "outright_sale_or_discounted_with_full_ownership?" => true }, { "outright_sale_or_discounted_with_full_ownership?" => true },
] ]
@header = "About the price of the property"
@top_guidance_partial = "financial_calculations_outright_sale" @top_guidance_partial = "financial_calculations_outright_sale"
@ownershipsch = ownershipsch @ownershipsch = ownershipsch
end end
def copy_key
case @ownershipsch
when 1
"sales.sale_information.purchase_price.shared_ownership"
when 2
"sales.sale_information.purchase_price.discounted_ownership"
when 3
"sales.sale_information.purchase_price.outright_sale"
end
end
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: @ownershipsch), Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: @ownershipsch),

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

@ -2,17 +2,13 @@ class Form::Sales::Questions::Discount < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "discount" @id = "discount"
@check_answer_label = "Percentage discount"
@header = "What was the percentage discount?"
@type = "numeric" @type = "numeric"
@copy_key = "sales.sale_information.discount"
@min = 0 @min = 0
@max = form.start_year_after_2024? ? 70 : 100 @max = form.start_year_after_2024? ? 70 : 100
@step = 0.1 @step = 0.1
@width = 5 @width = 5
@suffix = "%" @suffix = "%"
@hint_text = "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)</br></br>
If discount capped, enter capped %</br></br>
If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given."
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_discounted_ownership" @top_guidance_partial = "financial_calculations_discounted_ownership"
end end

4
app/models/form/sales/questions/grant.rb

@ -2,15 +2,13 @@ class Form::Sales::Questions::Grant < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "grant" @id = "grant"
@check_answer_label = "Amount of any loan, grant or subsidy" @copy_key = "sales.sale_information.grant"
@header = "What was the amount of any loan, grant, discount or subsidy given?"
@type = "numeric" @type = "numeric"
@min = 0 @min = 0
@max = 999_999 @max = 999_999
@step = 1 @step = 1
@width = 5 @width = 5
@prefix = "£" @prefix = "£"
@hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@top_guidance_partial = "financial_calculations_discounted_ownership" @top_guidance_partial = "financial_calculations_discounted_ownership"
end end

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

@ -2,14 +2,11 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
def initialize(id, hsh, page, ownershipsch:) def initialize(id, hsh, page, ownershipsch:)
super(id, hsh, page) super(id, hsh, page)
@id = "value" @id = "value"
@check_answer_label = "Purchase price"
@header = "What is the full purchase price?"
@type = "numeric" @type = "numeric"
@min = 0 @min = 0
@step = 0.01 @step = 0.01
@width = 5 @width = 5
@prefix = "£" @prefix = "£"
@hint_text = hint_text
@ownership_sch = ownershipsch @ownership_sch = ownershipsch
@question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch]
@top_guidance_partial = top_guidance_partial @top_guidance_partial = top_guidance_partial
@ -20,10 +17,15 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
2024 => { 2 => 101, 3 => 111 }, 2024 => { 2 => 101, 3 => 111 },
}.freeze }.freeze
def hint_text def copy_key
return if @ownership_sch == 3 # outright sale case @ownership_sch
when 1
"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" "sales.sale_information.purchase_price.shared_ownership"
when 2
"sales.sale_information.purchase_price.discounted_ownership"
when 3
"sales.sale_information.purchase_price.outright_sale"
end
end end
def top_guidance_partial def top_guidance_partial

30
config/locales/forms/2023/sales/sale_information.yml

@ -176,3 +176,33 @@ en:
check_answer_label: "Monthly leasehold charges" check_answer_label: "Monthly leasehold charges"
hint_text: "" hint_text: ""
question_text: "Enter the total monthly charge" question_text: "Enter the total monthly charge"
purchase_price:
shared_ownership:
page_header: "About the price of the property"
check_answer_label: "Purchase price"
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"
question_text: "What is the full purchase price?"
discounted_ownership:
page_header: "About the price of the property"
check_answer_label: "Purchase price"
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"
question_text: "What is the full purchase price?"
outright_sale:
page_header: "About the price of the property"
check_answer_label: "Purchase price"
hint_text: ""
question_text: "What is the full purchase price?"
discount:
page_header: "About the price of the property"
check_answer_label: "Percentage discount"
hint_text: "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)</br></br>If discount capped, enter capped %</br></br>If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given."
question_text: "What was the percentage discount?"
grant:
page_header: "About the price of the property"
check_answer_label: "Amount of any loan, grant or subsidy"
hint_text: "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy"
question_text: "What was the amount of any loan, grant, discount or subsidy given?"

30
config/locales/forms/2024/sales/sale_information.yml

@ -176,3 +176,33 @@ en:
check_answer_label: "Monthly leasehold charges" check_answer_label: "Monthly leasehold charges"
hint_text: "" hint_text: ""
question_text: "Enter the total monthly charge" question_text: "Enter the total monthly charge"
purchase_price:
shared_ownership:
page_header: "About the price of the property"
check_answer_label: "Purchase price"
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"
question_text: "What is the full purchase price?"
discounted_ownership:
page_header: "About the price of the property"
check_answer_label: "Purchase price"
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"
question_text: "What is the full purchase price?"
outright_sale:
page_header: "About the price of the property"
check_answer_label: "Purchase price"
hint_text: ""
question_text: "What is the full purchase price?"
discount:
page_header: "About the price of the property"
check_answer_label: "Percentage discount"
hint_text: "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB)</br></br>If discount capped, enter capped %</br></br>If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given."
question_text: "What was the percentage discount?"
grant:
page_header: "About the price of the property"
check_answer_label: "Amount of any loan, grant or subsidy"
hint_text: "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy"
question_text: "What was the amount of any loan, grant, discount or subsidy given?"
Loading…
Cancel
Save