From 19a2b967d5edfe6ce0de9bf088c5abeac90b0ef9 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:00:50 +0100 Subject: [PATCH 1/5] Update "all other shared ownership" errors --- .../sales/sale_information_validations.rb | 54 +++++++++++++++---- app/views/form/_numeric_question.html.erb | 2 +- ...ial_calculations_shared_ownership.html.erb | 24 ++++++--- config/locales/en.yml | 10 ++-- 4 files changed, 69 insertions(+), 21 deletions(-) diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index d24e557ae..d58e1cf47 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -177,7 +177,7 @@ module Validations::Sales::SaleInformationValidations cashdis: record.field_formatted_as_currency("cashdis"), equity: "#{record.equity}%", 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 elsif record.mortgage_not_used? 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) %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 - 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 elsif record.mortgage_not_used? if over_tolerance?(record.deposit, record.expected_shared_ownership_deposit_value, 1) %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 - 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 @@ -273,15 +291,33 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_and_deposit_total, record.stairbought_part_of_value, 1) %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 - 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 elsif over_tolerance?(record.deposit, record.stairbought_part_of_value, 1) %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 - 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 diff --git a/app/views/form/_numeric_question.html.erb b/app/views/form/_numeric_question.html.erb index 8bd2ce7bc..6a7446db6 100644 --- a/app/views/form/_numeric_question.html.erb +++ b/app/views/form/_numeric_question.html.erb @@ -14,7 +14,7 @@ suffix_text: question.suffix_label(@log), value: format_money_input(log: @log, question:), inputmode: "numeric", - pattern: "\d*\.?\d*", + pattern: "\\d*\\.?\\d*", **stimulus_html_attributes(question), ) %> diff --git a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb index 1164a3461..1143a001f 100644 --- a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb +++ b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb @@ -1,10 +1,22 @@ +<% 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 %>

- 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) %>) - and cash discount (<%= govuk_link_to "Q97", send("#{log.class.name.underscore}_#{log.form.get_question('cashdis', log).page.id}_path", log) %>) - added together must equal - the purchase price (<%= govuk_link_to "Q88", send("#{log.class.name.underscore}_#{log.form.get_question('value', log).page.id}_path", log) %>) - multiplied by the percentage equity stake (<%= govuk_link_to "Q89", send("#{log.class.name.underscore}_#{log.form.get_question('equity', log).page.id}_path", log) %>) + <% if log.type == 18 %> + The mortgage amount (<%= govuk_link_to "Q92", send("#{log.class.name.underscore}_#{mortgage_page.id}_path", log) %>), + cash deposit (<%= govuk_link_to "Q95", send("#{log.class.name.underscore}_#{deposit_page.id}_path", log) %>) + and cash discount (<%= govuk_link_to "Q97", send("#{log.class.name.underscore}_#{log.form.get_question('cashdis', log).page.id}_path", log) %>) + 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) %>) + <% else %> + 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 %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e3e440bed..6154df8fe 100644 --- a/config/locales/en.yml +++ b/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_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: - 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_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_used_socialhomebuy: "The mortgage amount (%{mortgage}), deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

These two amounts should be the same." + mortgage_used: "The mortgage (%{mortgage}) and deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

These two amounts should be the same." + mortgage_not_used: "The deposit is %{deposit}.

The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

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}.

The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

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}.

The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

These two amounts should be the same." 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_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_used: "The mortgage (%{mortgage}) and deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

These two amounts should be the same." + mortgage_not_used: "The deposit is %{deposit}.

The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

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}.

The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

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}.

The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

These two amounts should be the same." stairowned: From 9ee6b935828c8a6c9ed7283e845f9bd34b69dd79 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:14:28 +0100 Subject: [PATCH 2/5] Change question numbers --- .../_financial_calculations_shared_ownership.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb index 1143a001f..7cc6bb59f 100644 --- a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb +++ b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb @@ -15,8 +15,8 @@ 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 %> + the purchase price (<%= govuk_link_to 'Q89', send("#{log.class.name.underscore}_#{value_page.id}_path", log) %>) + multiplied by the percentage equity stake <%= "(#{govuk_link_to 'Q90', send("#{log.class.name.underscore}_#{equity_page.id}_path", log)}).".html_safe %> <% end %>

<% end %> From 16a91eb1081327cff184621da6ece140a46ac682 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:46:59 +0100 Subject: [PATCH 3/5] Fix lint offences --- .../_financial_calculations_shared_ownership.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb index 7cc6bb59f..a870f10bc 100644 --- a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb +++ b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb @@ -12,11 +12,11 @@ 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) %>) <% else %> - 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 %> + The mortgage amount (<%= govuk_link_to "Q92", send("#{log.class.name.underscore}_#{mortgage_page.id}_path", log) %>) + and deposit (<%= govuk_link_to "Q96", send("#{log.class.name.underscore}_#{deposit_page.id}_path", log) %>) added together must equal - the purchase price (<%= govuk_link_to 'Q89', send("#{log.class.name.underscore}_#{value_page.id}_path", log) %>) - multiplied by the percentage equity stake <%= "(#{govuk_link_to 'Q90', send("#{log.class.name.underscore}_#{equity_page.id}_path", log)}).".html_safe %> + the purchase price (<%= govuk_link_to "Q89", send("#{log.class.name.underscore}_#{value_page.id}_path", log) %>) + multiplied by the percentage equity stake (<%= govuk_link_to "Q90", send("#{log.class.name.underscore}_#{equity_page.id}_path", log) %>) <% end %>

<% end %> From 5fcd52740787ebaa114052407ba75ad39fa4066c Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:14:01 +0100 Subject: [PATCH 4/5] Update tests --- .../sale_information_validations_spec.rb | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index 41b1d842d..1c4ded586 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -868,12 +868,12 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_non_staircasing_mortgage(record) - expect(record.errors["mortgage"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["value"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["deposit"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["equity"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["type"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["cashdis"]).not_to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["equity"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["type"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["cashdis"]).not_to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") end context "and it is a social homebuy" do @@ -884,12 +884,12 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_non_staircasing_mortgage(record) - expect(record.errors["mortgage"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") - expect(record.errors["value"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") - expect(record.errors["deposit"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") - expect(record.errors["equity"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") - expect(record.errors["cashdis"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") - expect(record.errors["type"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["equity"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["cashdis"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(record.errors["type"]).to include("The mortgage amount (£10,000.00), deposit (£5,000.00), and cash discount (£200.00) added together is £15,200.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") end end @@ -968,12 +968,12 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_non_staircasing_mortgage(record) - expect(record.errors["mortgageused"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["value"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["deposit"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["equity"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["type"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["cashdis"]).not_to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") + expect(record.errors["mortgageused"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["value"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["equity"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["type"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["cashdis"]).not_to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") end context "and it is a social homebuy" do @@ -1087,12 +1087,12 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_staircasing_mortgage(record) - expect(record.errors["mortgage"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["value"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["deposit"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["stairbought"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["type"]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["cashdis"]).not_to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["stairbought"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["type"]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["cashdis"]).not_to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") end context "and it is a social homebuy" do @@ -1206,12 +1206,12 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_staircasing_mortgage(record) - expect(record.errors["mortgageused"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["value"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["deposit"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["stairbought"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["type"]).to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(record.errors["cashdis"]).not_to include("The deposit is £5,000.00 and the value multiplied by the percentage bought is £8,400.00. These figures should be the same.") + expect(record.errors["mortgageused"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["value"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["stairbought"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["type"]).to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") + expect(record.errors["cashdis"]).not_to include("The deposit is £5,000.00.

The full purchase price (£30,000.00) multiplied by the percentage bought is £8,400.00.

These two amounts should be the same.") end context "and it is a social homebuy" do From f1e5903ba87e560fb98a5fbfb1e298b1c86edd72 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:09:49 +0100 Subject: [PATCH 5/5] Update tests 2 --- .../bulk_upload/sales/year2024/row_parser_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index c436966de..ccefbe4be 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -1332,10 +1332,10 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "includes errors on other related fields" do parser.valid? - expect(parser.errors[:field_104]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(parser.errors[:field_109]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(parser.errors[:field_101]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") - expect(parser.errors[:field_102]).to include("The mortgage and deposit added together is £15,000.00. The value multiplied by the percentage bought is £8,400.00. These figures should be the same.") + expect(parser.errors[:field_104]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(parser.errors[:field_109]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(parser.errors[:field_101]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") + expect(parser.errors[:field_102]).to include("The mortgage (£10,000.00) and deposit (£5,000.00) added together is £15,000.00.

The full purchase price (£30,000.00) multiplied by the percentage equity stake purchased (28.0%) is £8,400.00.

These two amounts should be the same.") end it "does not add errors to other ownership type fields" do