Browse Source

Update guidance partial

pull/2547/head
Kat 2 years ago
parent
commit
5c18960a0e
  1. 5
      app/models/form/sales/questions/deposit_amount.rb
  2. 1
      app/models/form/sales/questions/discount.rb
  3. 1
      app/models/form/sales/questions/grant.rb
  4. 7
      app/models/form/sales/questions/mortgage_amount.rb
  5. 1
      app/models/form/sales/questions/purchase_price.rb
  6. 10
      app/views/form/guidance/_financial_calculations_dicsounted_ownership.html.erb
  7. 2
      app/views/form/guidance/_financial_calculations_shared_ownership.html.erb

5
app/models/form/sales/questions/deposit_amount.rb

@ -32,4 +32,9 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question
"Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan" "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan"
end end
end end
def top_guidance_partial
return "financial_calculations_shared_ownership" if @ownershipsch == 1
return "financial_calculations_discounted_ownership" if @ownershipsch == 2
end
end end

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

@ -14,6 +14,7 @@ class Form::Sales::Questions::Discount < ::Form::Question
If discount capped, enter capped %</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." 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"
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 102, 2024 => 103 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 102, 2024 => 103 }.freeze

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

@ -12,6 +12,7 @@ class Form::Sales::Questions::Grant < ::Form::Question
@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" @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"
end end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 101, 2024 => 102 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 101, 2024 => 102 }.freeze

7
app/models/form/sales/questions/mortgage_amount.rb

@ -12,7 +12,7 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question
@hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound." @hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound."
@ownershipsch = ownershipsch @ownershipsch = 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 = "financial_calculations_shared_ownership" if ownershipsch == 1 @top_guidance_partial = top_guidance_partial
end end
QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = { QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = {
@ -23,4 +23,9 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question
def derived?(log) def derived?(log)
log&.mortgage_not_used? log&.mortgage_not_used?
end end
def top_guidance_partial
return "financial_calculations_shared_ownership" if ownershipsch == 1
return "financial_calculations_discounted_ownership" if ownershipsch == 2
end
end end

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

@ -12,6 +12,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
@hint_text = hint_text @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 = "financial_calculations_discounted_ownership" if ownershipsch == 2
end end
QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = { QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = {

10
app/views/form/guidance/_financial_calculations_dicsounted_ownership.html.erb

@ -0,0 +1,10 @@
<%= govuk_details(summary_text: "How the financial values are calculated") do %>
<p class="govuk-body">
The mortgage amount (<%= govuk_link_to "Q105", send("#{log.class.name.underscore}_#{log.form.get_question('mortgage', log).page.id}_path", log) %>),
cash deposit (<%= govuk_link_to "Q109", send("#{log.class.name.underscore}_#{log.form.get_question('deposit', log).page.id}_path", log) %>)
and grant (<%= govuk_link_to "Q102", send("#{log.class.name.underscore}_#{log.form.get_question('grant', log).page.id}_path", log) %>)
added together must equal
the purchase price (<%= govuk_link_to "Q101", send("#{log.class.name.underscore}_#{log.form.get_question('value', log).page.id}_path", log) %>)
multiplied by the discount stake (<%= govuk_link_to "103", send("#{log.class.name.underscore}_#{log.form.get_question('discount', log).page.id}_path", log) %>)
</p>
<% end %>

2
app/views/form/guidance/_financial_calculations_shared_ownership.html.erb

@ -1,4 +1,4 @@
<%= govuk_details(summary_text: "How the financial values are calculated") do %> <%= govuk_details(summary_text: "How the financial values are calculated") do %>
<p class="govuk-body"> <p class="govuk-body">
The mortgage amount (<%= govuk_link_to "Q92", send("#{log.class.name.underscore}_#{log.form.get_question('mortgage', log).page.id}_path", log) %>), The mortgage amount (<%= govuk_link_to "Q92", send("#{log.class.name.underscore}_#{log.form.get_question('mortgage', log).page.id}_path", log) %>),
cash deposit (<%= govuk_link_to "Q95", send("#{log.class.name.underscore}_#{log.form.get_question('deposit', log).page.id}_path", log) %>) cash deposit (<%= govuk_link_to "Q95", send("#{log.class.name.underscore}_#{log.form.get_question('deposit', log).page.id}_path", log) %>)

Loading…
Cancel
Save