Browse Source

Update "all other shared ownership" errors

pull/2550/head
Manny Dinssa 2 years ago
parent
commit
39a7980520
  1. 54
      app/models/validations/sales/sale_information_validations.rb
  2. 2
      app/views/form/_numeric_question.html.erb
  3. 32
      app/views/form/guidance/_financial_calculations_shared_ownership.html.erb
  4. 10
      config/locales/en.yml

54
app/models/validations/sales/sale_information_validations.rb

@ -177,7 +177,7 @@ module Validations::Sales::SaleInformationValidations
cashdis: record.field_formatted_as_currency("cashdis"), cashdis: record.field_formatted_as_currency("cashdis"),
equity: "#{record.equity}%", equity: "#{record.equity}%",
mortgage_deposit_and_discount_total: record.field_formatted_as_currency("mortgage_deposit_and_discount_total"), mortgage_deposit_and_discount_total: record.field_formatted_as_currency("mortgage_deposit_and_discount_total"),
expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")) expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe
end end
elsif record.mortgage_not_used? elsif record.mortgage_not_used?
if over_tolerance?(record.deposit_and_discount_total, record.expected_shared_ownership_deposit_value, 1) if over_tolerance?(record.deposit_and_discount_total, record.expected_shared_ownership_deposit_value, 1)
@ -207,16 +207,34 @@ module Validations::Sales::SaleInformationValidations
if over_tolerance?(record.mortgage_and_deposit_total, record.expected_shared_ownership_deposit_value, 1) if over_tolerance?(record.mortgage_and_deposit_total, record.expected_shared_ownership_deposit_value, 1)
%i[mortgage value deposit equity].each do |field| %i[mortgage value deposit equity].each do |field|
record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")) record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used",
mortgage: record.field_formatted_as_currency("mortgage"),
deposit: record.field_formatted_as_currency("deposit"),
mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"),
value: record.field_formatted_as_currency("value"),
equity: "#{record.equity}%",
expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe
end end
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")) record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used",
mortgage: record.field_formatted_as_currency("mortgage"),
deposit: record.field_formatted_as_currency("deposit"),
mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"),
value: record.field_formatted_as_currency("value"),
equity: "#{record.equity}%",
expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe
end end
elsif record.mortgage_not_used? elsif record.mortgage_not_used?
if over_tolerance?(record.deposit, record.expected_shared_ownership_deposit_value, 1) if over_tolerance?(record.deposit, record.expected_shared_ownership_deposit_value, 1)
%i[mortgageused value deposit equity].each do |field| %i[mortgageused value deposit equity].each do |field|
record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")) record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used",
deposit: record.field_formatted_as_currency("deposit"),
value: record.field_formatted_as_currency("value"),
expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe
end end
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")) record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used",
deposit: record.field_formatted_as_currency("deposit"),
value: record.field_formatted_as_currency("value"),
expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe
end end
end end
end end
@ -273,15 +291,33 @@ module Validations::Sales::SaleInformationValidations
if over_tolerance?(record.mortgage_and_deposit_total, record.stairbought_part_of_value, 1) if over_tolerance?(record.mortgage_and_deposit_total, record.stairbought_part_of_value, 1)
%i[mortgage value deposit stairbought type].each do |field| %i[mortgage value deposit stairbought type].each do |field|
record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")) record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used",
mortgage: record.field_formatted_as_currency("mortgage"),
deposit: record.field_formatted_as_currency("deposit"),
mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"),
value: record.field_formatted_as_currency("value"),
equity: "#{record.equity}%",
stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe
end end
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")) record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used",
mortgage: record.field_formatted_as_currency("mortgage"),
deposit: record.field_formatted_as_currency("deposit"),
mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"),
value: record.field_formatted_as_currency("value"),
equity: "#{record.equity}%",
stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe
end end
elsif over_tolerance?(record.deposit, record.stairbought_part_of_value, 1) elsif over_tolerance?(record.deposit, record.stairbought_part_of_value, 1)
%i[mortgageused value deposit stairbought type].each do |field| %i[mortgageused value deposit stairbought type].each do |field|
record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")) record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used",
deposit: record.field_formatted_as_currency("deposit"),
value: record.field_formatted_as_currency("value"),
stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe
end end
record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")) record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used",
deposit: record.field_formatted_as_currency("deposit"),
value: record.field_formatted_as_currency("value"),
stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe
end end
end end

2
app/views/form/_numeric_question.html.erb

@ -14,7 +14,7 @@
suffix_text: question.suffix_label(@log), suffix_text: question.suffix_label(@log),
value: format_money_input(log: @log, question:), value: format_money_input(log: @log, question:),
inputmode: "numeric", inputmode: "numeric",
pattern: "\d*\.?\d*", pattern: "\\d*\\.?\\d*",
**stimulus_html_attributes(question), **stimulus_html_attributes(question),
) %> ) %>

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

@ -1,16 +1,28 @@
<% mortgage_page = log.form.get_question("mortgage", log).page %>
<% deposit_page = log.form.get_question("deposit", log).page %>
<% equity_page = log.form.get_question("equity", log).page %>
<% value_page = log.form.get_question("value", log).page %>
<%= 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 <%= question_link("mortgage", log, current_user) %>, <% if log.type == 18 %>
cash deposit <%= question_link("deposit", log, current_user) %>, The mortgage amount <%= question_link("mortgage", log, current_user) %>,
and cash discount <%= question_link("cashdis", log, current_user) %> cash deposit <%= question_link("deposit", log, current_user) %>,
added together must equal and cash discount <%= question_link("cashdis", log, current_user) %>
the purchase price <%= question_link("value", log, current_user) %> added together must equal
<% stairbought_page = log.form.get_question("stairbought", log).page %> the purchase price <%= question_link("value", log, current_user) %>
<% equity_page = log.form.get_question("equity", log).page %> <% stairbought_page = log.form.get_question("stairbought", log).page %>
<% if stairbought_page.routed_to?(log, current_user) %> <% equity_page = log.form.get_question("equity", log).page %>
multiplied by the percentage bought <%= question_link("stairbought", log, current_user) %> <% if stairbought_page.routed_to?(log, current_user) %>
multiplied by the percentage bought <%= question_link("stairbought", log, current_user) %>
<% else %>
multiplied by the percentage equity stake <%= question_link("equity", log, current_user) %>
<% end %>
<% else %> <% else %>
multiplied by the percentage equity stake <%= question_link("equity", log, current_user) %> The mortgage amount <%= "(#{govuk_link_to 'Q92', send("#{log.class.name.underscore}_#{mortgage_page.id}_path", log)})".html_safe %>
deposit <%= "(#{govuk_link_to 'Q96', send("#{log.class.name.underscore}_#{deposit_page.id}_path", log)})".html_safe %>
added together must equal
the purchase price (<%= govuk_link_to 'Q88', send("#{log.class.name.underscore}_#{value_page.id}_path", log) %>)
multiplied by the percentage equity stake <%= "(#{govuk_link_to 'Q89', send("#{log.class.name.underscore}_#{equity_page.id}_path", log)}).".html_safe %>
<% end %> <% end %>
</p> </p>
<% end %> <% end %>

10
config/locales/en.yml

@ -656,13 +656,13 @@ en:
over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London."
over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London."
non_staircasing_mortgage: non_staircasing_mortgage:
mortgage_used: "The mortgage and deposit added together is %{mortgage_and_deposit_total}. The value multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}. These figures should be the same." mortgage_used: "The mortgage (%{mortgage}) and deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.</br></br>These two amounts should be the same."
mortgage_not_used: "The deposit is %{deposit} and the value multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}. These figures should be the same." mortgage_not_used: "The deposit is %{deposit}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.</br></br>These two amounts should be the same."
mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.</br></br> These two amounts should be the same." mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.</br></br>These two amounts should be the same."
mortgage_not_used_socialhomebuy: "The deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.</br></br>These two amounts should be the same." mortgage_not_used_socialhomebuy: "The deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.</br></br>These two amounts should be the same."
staircasing_mortgage: staircasing_mortgage:
mortgage_used: "The mortgage and deposit added together is %{mortgage_and_deposit_total}. The value multiplied by the percentage bought is %{stairbought_part_of_value}. These figures should be the same." mortgage_used: "The mortgage (%{mortgage}) and deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_not_used: "The deposit is %{deposit} and the value multiplied by the percentage bought is %{stairbought_part_of_value}. These figures should be the same." mortgage_not_used: "The deposit is %{deposit}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same." mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_not_used_socialhomebuy: "The deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same." mortgage_not_used_socialhomebuy: "The deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
stairowned: stairowned:

Loading…
Cancel
Save