From 12aa3ccfaf3d3fce1180fcc03caf2cf5e46c65ba Mon Sep 17 00:00:00 2001 From: Jack <113976590+bibblobcode@users.noreply.github.com> Date: Fri, 14 Apr 2023 09:52:42 +0100 Subject: [PATCH] CLDC-1975 format money amounts with currency and 2 decimals (#1525) * Allow interruption screens to format money values * Remove formatting from saleslog method * Use money flag * Use pre exhisting method to format values * Update config/locales/en.yml Co-authored-by: Arthur Campbell <51094020+arfacamble@users.noreply.github.com> --------- Co-authored-by: Arthur Campbell <51094020+arfacamble@users.noreply.github.com> --- .../lettings/pages/max_rent_value_check.rb | 12 ++- .../lettings/pages/min_rent_value_check.rb | 10 ++- .../lettings/pages/net_income_value_check.rb | 12 ++- .../pages/discounted_sale_value_check.rb | 16 +++- .../shared_ownership_deposit_value_check.rb | 4 +- app/models/log.rb | 5 ++ app/models/sales_log.rb | 7 +- config/locales/en.yml | 14 ++-- .../interruption_screen_helper_spec.rb | 73 ++++++++++++++++--- .../pages/max_rent_value_check_spec.rb | 37 ++++++++++ .../pages/min_rent_value_check_spec.rb | 48 ++++++++++++ .../pages/net_income_value_check_spec.rb | 40 ++++++++++ .../pages/about_price_value_check_spec.rb | 54 ++++++++++++++ .../pages/discounted_sale_value_check_spec.rb | 4 +- ...ared_ownership_deposit_value_check_spec.rb | 8 +- spec/models/sales_log_spec.rb | 2 +- .../lettings_logs_import_service_spec.rb | 10 +-- 17 files changed, 304 insertions(+), 52 deletions(-) create mode 100644 spec/models/form/lettings/pages/max_rent_value_check_spec.rb create mode 100644 spec/models/form/lettings/pages/min_rent_value_check_spec.rb create mode 100644 spec/models/form/lettings/pages/net_income_value_check_spec.rb create mode 100644 spec/models/form/sales/pages/about_price_value_check_spec.rb diff --git a/app/models/form/lettings/pages/max_rent_value_check.rb b/app/models/form/lettings/pages/max_rent_value_check.rb index 59b2d14fe..8ae9b7d9c 100644 --- a/app/models/form/lettings/pages/max_rent_value_check.rb +++ b/app/models/form/lettings/pages/max_rent_value_check.rb @@ -5,14 +5,20 @@ class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page @depends_on = [{ "rent_in_soft_max_range?" => true }] @title_text = { "translation" => "soft_validations.rent.outside_range_title", - "arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent" }], + "arguments" => [ + { + "key" => "brent", + "label" => true, + "i18n_template" => "brent", + }, + ], } @informative_text = { "translation" => "soft_validations.rent.max_hint_text", "arguments" => [ { - "key" => "soft_max_for_period", - "label" => false, + "key" => "field_formatted_as_currency", + "arguments_for_key" => "soft_max_for_period", "i18n_template" => "soft_max_for_period", }, ], diff --git a/app/models/form/lettings/pages/min_rent_value_check.rb b/app/models/form/lettings/pages/min_rent_value_check.rb index ed5ede781..eda8819ee 100644 --- a/app/models/form/lettings/pages/min_rent_value_check.rb +++ b/app/models/form/lettings/pages/min_rent_value_check.rb @@ -5,14 +5,18 @@ class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page @depends_on = [{ "rent_in_soft_min_range?" => true }] @title_text = { "translation" => "soft_validations.rent.outside_range_title", - "arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent" }], + "arguments" => [{ + "key" => "brent", + "label" => true, + "i18n_template" => "brent", + }], } @informative_text = { "translation" => "soft_validations.rent.min_hint_text", "arguments" => [ { - "key" => "soft_min_for_period", - "label" => false, + "key" => "field_formatted_as_currency", + "arguments_for_key" => "soft_min_for_period", "i18n_template" => "soft_min_for_period", }, ], diff --git a/app/models/form/lettings/pages/net_income_value_check.rb b/app/models/form/lettings/pages/net_income_value_check.rb index 9a9c1061f..0569b86e9 100644 --- a/app/models/form/lettings/pages/net_income_value_check.rb +++ b/app/models/form/lettings/pages/net_income_value_check.rb @@ -7,8 +7,16 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page @informative_text = { "translation" => "soft_validations.net_income.hint_text", "arguments" => [ - { "key" => "ecstat1", "label" => true, "i18n_template" => "ecstat1" }, - { "key" => "earnings", "label" => true, "i18n_template" => "earnings" }, + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "ecstat1", + "i18n_template" => "ecstat1", + }, + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "earnings", + "i18n_template" => "earnings", + }, ], } end diff --git a/app/models/form/sales/pages/discounted_sale_value_check.rb b/app/models/form/sales/pages/discounted_sale_value_check.rb index 8ff48a0bd..3c1b010f2 100644 --- a/app/models/form/sales/pages/discounted_sale_value_check.rb +++ b/app/models/form/sales/pages/discounted_sale_value_check.rb @@ -4,11 +4,23 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page @depends_on = depends_on @title_text = { "translation" => "soft_validations.discounted_sale_value.title_text", - "arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount" }], + "arguments" => [ + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "value_with_discount", + "i18n_template" => "value_with_discount", + }, + ], } @informative_text = { "translation" => "soft_validations.discounted_sale_value.informative_text", - "arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total" }], + "arguments" => [ + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "mortgage_deposit_and_grant_total", + "i18n_template" => "mortgage_deposit_and_grant_total", + }, + ], } @person_index = person_index @depends_on = [ diff --git a/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb b/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb index be2126482..4730248ed 100644 --- a/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb +++ b/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb @@ -11,8 +11,8 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page "translation" => "soft_validations.shared_ownership_deposit.title_text", "arguments" => [ { - "key" => "expected_shared_ownership_deposit_value", - "label" => false, + "key" => "field_formatted_as_currency", + "arguments_for_key" => "expected_shared_ownership_deposit_value", "i18n_template" => "expected_shared_ownership_deposit_value", }, ], diff --git a/app/models/log.rb b/app/models/log.rb index 6a36b948d..96896bf3d 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -126,6 +126,11 @@ class Log < ApplicationRecord end end + def field_formatted_as_currency(field_name) + field_value = public_send(field_name) + format_as_currency(field_value) + end + private def plural_gender_for_person(person_num) diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 38beb850f..a47edea0f 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -216,7 +216,7 @@ class SalesLog < Log def expected_shared_ownership_deposit_value return unless value && equity - format_as_currency(value * equity / 100) + value * equity / 100 end def process_postcode(postcode, postcode_known_key, la_inferred_key, la_key) @@ -323,11 +323,6 @@ class SalesLog < Log format_as_currency(soft_min) end - def field_formatted_as_currency(field_name) - field_value = public_send(field_name) - format_as_currency(field_value) - end - def should_process_uprn_change? uprn_changed? && saledate && saledate.year >= 2023 end diff --git a/config/locales/en.yml b/config/locales/en.yml index e223c7fc9..dc36f5f64 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -283,7 +283,7 @@ en: general_needs: "Enter a value for the support charge between £0 and £60 per week if the landlord is a local authority and it is a general needs letting" supported_housing: "Enter a value for the support charge between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting" ecstat: - over_hard_max: "Net income of £%{hard_max} per week is too high for given the tenant’s working situation" + over_hard_max: "Net income of %{hard_max} per week is too high given the tenant’s working situation" brent: below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms" above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms" @@ -314,7 +314,7 @@ en: charges: complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’" tcharge: - under_10: "Enter a total charge that is at least £10 per week" + under_10: "Enter a total charge that is at least £10.00 per week" rent_period: invalid_for_org: "%{org_name} does not charge rent %{rent_period}" carehome: @@ -516,8 +516,8 @@ en: under_soft_min_for_economic_status: "You said income was %{income}, which is below this working situation's minimum (%{minimum})" rent: outside_range_title: "You told us the rent is %{brent}" - min_hint_text: "The minimum rent expected for this type of property in this local authority is £%{soft_min_for_period}." - max_hint_text: "The maximum rent expected for this type of property in this local authority is £%{soft_max_for_period}." + min_hint_text: "The minimum rent expected for this type of property in this local authority is %{soft_min_for_period}." + max_hint_text: "The maximum rent expected for this type of property in this local authority is %{soft_max_for_period}." purchase_price: title_text: "You told us the purchase price is %{value}" hint_text: "The %{min_or_max} purchase price expected for this type of property in this local authority is %{soft_min_or_soft_max}" @@ -539,7 +539,7 @@ en: void_date: title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years" shared_ownership_deposit: - title_text: "Mortgage, deposit and cash discount total should equal £%{expected_shared_ownership_deposit_value}" + title_text: "Mortgage, deposit and cash discount total should equal %{expected_shared_ownership_deposit_value}" old_persons_shared_ownership: "At least one buyer should be aged over 64 for Older persons’ shared ownership scheme" staircase_bought_seems_high: "You said %{percentage}% was bought in this staircasing transaction, which seems high. Are you sure?" monthly_charges_over_soft_max: @@ -547,8 +547,8 @@ en: student_not_child: title_text: "You told us this person is a student aged beween 16 and 19" discounted_sale_value: - title_text: "Mortgage, deposit, and grant total must equal £%{value_with_discount}" - informative_text: "Your given mortgage, deposit and grant total is £%{mortgage_deposit_and_grant_total}" + title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}" + informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}" care_home_charges: title_text: "Care home charges should be provided if this is a care home accommodation" diff --git a/spec/helpers/interruption_screen_helper_spec.rb b/spec/helpers/interruption_screen_helper_spec.rb index fba8782da..33553f39f 100644 --- a/spec/helpers/interruption_screen_helper_spec.rb +++ b/spec/helpers/interruption_screen_helper_spec.rb @@ -4,9 +4,9 @@ RSpec.describe InterruptionScreenHelper do form_handler = FormHandler.instance let(:form) { form_handler.get_form("test_form") } let(:subsection) { form.get_subsection("household_characteristics") } - let(:user) { FactoryBot.create(:user) } + let(:user) { create(:user) } let(:lettings_log) do - FactoryBot.create( + create( :lettings_log, :in_progress, ecstat1: 1, @@ -14,6 +14,7 @@ RSpec.describe InterruptionScreenHelper do incfreq: 1, created_by: user, sex1: "F", + brent: 12_345, ) end @@ -45,7 +46,13 @@ RSpec.describe InterruptionScreenHelper do ], } expect(display_informative_text(informative_text, lettings_log)) - .to eq(I18n.t("soft_validations.net_income.hint_text", ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase, earnings: lettings_log.form.get_question("earnings", lettings_log).answer_label(lettings_log))) + .to eq( + I18n.t( + "soft_validations.net_income.hint_text", + ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase, + earnings: lettings_log.form.get_question("earnings", lettings_log).answer_label(lettings_log), + ), + ) end end @@ -62,7 +69,12 @@ RSpec.describe InterruptionScreenHelper do ], } expect(display_informative_text(informative_text, lettings_log)) - .to eq(I18n.t("test.one_argument", ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase)) + .to eq( + I18n.t( + "test.one_argument", + ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase, + ), + ) end end @@ -84,7 +96,12 @@ RSpec.describe InterruptionScreenHelper do ], } expect(display_informative_text(informative_text, lettings_log)) - .to eq(I18n.t("test.one_argument", ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase)) + .to eq( + I18n.t( + "test.one_argument", + ecstat1: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase, + ), + ) end end @@ -126,15 +143,15 @@ RSpec.describe InterruptionScreenHelper do informative_text_hash = { "arguments" => [ { - "key" => "retirement_age_for_person", - "arguments_for_key" => 1, + "key" => "field_formatted_as_currency", + "arguments_for_key" => "brent", "i18n_template" => "argument", }, ], } - allow(lettings_log).to receive(:retirement_age_for_person) + allow(lettings_log).to receive(:field_formatted_as_currency) display_informative_text(informative_text_hash, lettings_log) - expect(lettings_log).to have_received(:retirement_age_for_person).with(1) + expect(lettings_log).to have_received(:field_formatted_as_currency).with("brent") end it "returns the correct text" do @@ -143,13 +160,13 @@ RSpec.describe InterruptionScreenHelper do "translation" => translation, "arguments" => [ { - "key" => "retirement_age_for_person", - "arguments_for_key" => 1, + "key" => "field_formatted_as_currency", + "arguments_for_key" => "brent", "i18n_template" => "argument", }, ], } - expect(display_informative_text(informative_text_hash, lettings_log)).to eq(I18n.t(translation, argument: lettings_log.retirement_age_for_person(1))) + expect(display_informative_text(informative_text_hash, lettings_log)).to eq("You said this: £12,345.00") end end end @@ -178,6 +195,38 @@ RSpec.describe InterruptionScreenHelper do expect(display_title_text(title_text, lettings_log)) .to eq(I18n.t("test.title_text.one_argument", argument: lettings_log.form.get_question("ecstat1", lettings_log).answer_label(lettings_log).downcase)) end + + context "when and argument is given with a key and arguments for the key" do + it "makes the correct method call" do + title_text = { + "arguments" => [ + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "brent", + "i18n_template" => "argument", + }, + ], + } + allow(lettings_log).to receive(:field_formatted_as_currency) + display_title_text(title_text, lettings_log) + expect(lettings_log).to have_received(:field_formatted_as_currency).with("brent") + end + + it "returns the correct text" do + translation = "test.title_text.one_argument" + title_text = { + "translation" => translation, + "arguments" => [ + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "brent", + "i18n_template" => "argument", + }, + ], + } + expect(display_title_text(title_text, lettings_log)).to eq("You said this: £12,345.00") + end + end end context "when title text is not defined" do diff --git a/spec/models/form/lettings/pages/max_rent_value_check_spec.rb b/spec/models/form/lettings/pages/max_rent_value_check_spec.rb new file mode 100644 index 000000000..7a3a5544f --- /dev/null +++ b/spec/models/form/lettings/pages/max_rent_value_check_spec.rb @@ -0,0 +1,37 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "shared_ownership_deposit_value_check" } + 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[rent_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("max_rent_value_check") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "rent_in_soft_max_range?" => true }]) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], "translation" => "soft_validations.rent.outside_range_title" }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ "arguments" => [{ "arguments_for_key" => "soft_max_for_period", "i18n_template" => "soft_max_for_period", "key" => "field_formatted_as_currency" }], "translation" => "soft_validations.rent.max_hint_text" }) + end +end diff --git a/spec/models/form/lettings/pages/min_rent_value_check_spec.rb b/spec/models/form/lettings/pages/min_rent_value_check_spec.rb new file mode 100644 index 000000000..4e68a09c7 --- /dev/null +++ b/spec/models/form/lettings/pages/min_rent_value_check_spec.rb @@ -0,0 +1,48 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + 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 questions" do + expect(page.questions.map(&:id)).to eq(%w[rent_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("min_rent_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "rent_in_soft_min_range?" => true }], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.rent.outside_range_title", + "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "arguments" => [{ "arguments_for_key" => "soft_min_for_period", "i18n_template" => "soft_min_for_period", "key" => "field_formatted_as_currency" }], + "translation" => "soft_validations.rent.min_hint_text", + }) + end +end diff --git a/spec/models/form/lettings/pages/net_income_value_check_spec.rb b/spec/models/form/lettings/pages/net_income_value_check_spec.rb new file mode 100644 index 000000000..c43eb3381 --- /dev/null +++ b/spec/models/form/lettings/pages/net_income_value_check_spec.rb @@ -0,0 +1,40 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::NetIncomeValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "shared_ownership_deposit_value_check" } + 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[net_income_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("net_income_value_check") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "net_income_soft_validation_triggered?" => true }]) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ "translation" => "soft_validations.net_income.title_text" }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "arguments" => [{ "arguments_for_key" => "ecstat1", "i18n_template" => "ecstat1", "key" => "field_formatted_as_currency" }, { "arguments_for_key" => "earnings", "i18n_template" => "earnings", "key" => "field_formatted_as_currency" }], + "translation" => "soft_validations.net_income.hint_text", + }) + end +end diff --git a/spec/models/form/sales/pages/about_price_value_check_spec.rb b/spec/models/form/sales/pages/about_price_value_check_spec.rb new file mode 100644 index 000000000..6c8d27463 --- /dev/null +++ b/spec/models/form/sales/pages/about_price_value_check_spec.rb @@ -0,0 +1,54 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "savings_value_check" } + 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_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("savings_value_check") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "purchase_price_out_of_soft_range?" => true }]) + end + + it "is interruption screen page" do + expect(page.interruption_screen?).to eq(true) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "value", "key" => "value", "label" => true }], "translation" => "soft_validations.purchase_price.title_text" }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.purchase_price.hint_text", + "arguments" => [ + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "purchase_price_soft_min_or_soft_max", + "i18n_template" => "soft_min_or_soft_max", + }, + { + "key" => "purchase_price_min_or_max_text", + "i18n_template" => "min_or_max", + }, + ], + }) + end +end diff --git a/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb b/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb index ddd4bc33c..d086542dc 100644 --- a/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb +++ b/spec/models/form/sales/pages/discounted_sale_value_check_spec.rb @@ -27,14 +27,14 @@ RSpec.describe Form::Sales::Pages::DiscountedSaleValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ "translation" => "soft_validations.discounted_sale_value.title_text", - "arguments" => [{ "key" => "value_with_discount", "label" => false, "i18n_template" => "value_with_discount" }], + "arguments" => [{ "arguments_for_key" => "value_with_discount", "i18n_template" => "value_with_discount", "key" => "field_formatted_as_currency" }], }) end it "has the correct informative_text" do expect(page.informative_text).to eq({ "translation" => "soft_validations.discounted_sale_value.informative_text", - "arguments" => [{ "key" => "mortgage_deposit_and_grant_total", "label" => false, "i18n_template" => "mortgage_deposit_and_grant_total" }], + "arguments" => [{ "arguments_for_key" => "mortgage_deposit_and_grant_total", "i18n_template" => "mortgage_deposit_and_grant_total", "key" => "field_formatted_as_currency" }], }) end diff --git a/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb b/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb index 893a5cb5b..45744cde4 100644 --- a/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb +++ b/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb @@ -34,13 +34,7 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode it "has the correct title_text" do expect(page.title_text).to eq({ "translation" => "soft_validations.shared_ownership_deposit.title_text", - "arguments" => [ - { - "key" => "expected_shared_ownership_deposit_value", - "label" => false, - "i18n_template" => "expected_shared_ownership_deposit_value", - }, - ], + "arguments" => [{ "arguments_for_key" => "expected_shared_ownership_deposit_value", "i18n_template" => "expected_shared_ownership_deposit_value", "key" => "field_formatted_as_currency" }], }) end diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 0632af547..ca72794a5 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -498,7 +498,7 @@ RSpec.describe SalesLog, type: :model do let!(:completed_sales_log) { create(:sales_log, :completed, ownershipsch: 1, type: 2, value: 1000, equity: 50) } it "is set to completed for a completed sales log" do - expect(completed_sales_log.expected_shared_ownership_deposit_value).to eq("£500.00") + expect(completed_sales_log.expected_shared_ownership_deposit_value).to eq(500) end end diff --git a/spec/services/imports/lettings_logs_import_service_spec.rb b/spec/services/imports/lettings_logs_import_service_spec.rb index deccde0c0..fb5c1227c 100644 --- a/spec/services/imports/lettings_logs_import_service_spec.rb +++ b/spec/services/imports/lettings_logs_import_service_spec.rb @@ -532,11 +532,11 @@ RSpec.describe Imports::LettingsLogsImportService do end it "intercepts the relevant validation error" do - expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing brent with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") - expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing scharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") - expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing pscharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") - expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing supcharg with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") - expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing tcharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10 per week") + expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing brent with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week") + expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing scharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week") + expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing pscharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week") + expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing supcharg with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week") + expect(logger).to receive(:warn).with("Log 0b4a68df-30cc-474a-93c0-a56ce8fdad3b: Removing tcharge with error: Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’, Enter a total charge that is at least £10.00 per week") expect { lettings_log_service.send(:create_log, lettings_log_xml) } .not_to raise_error end