From 5498355185e4b6150cbf63ee25ef8862feb415a3 Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 1 Feb 2024 15:46:06 +0000 Subject: [PATCH] Update error message --- app/models/validations/sales/financial_validations.rb | 4 ++-- config/locales/en.yml | 2 +- spec/models/validations/sales/financial_validations_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 476878c4a..8ca0ee775 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -57,8 +57,8 @@ module Validations::Sales::FinancialValidations return unless record.saledate && record.form.start_year_after_2024? if record.stairbought == record.stairowned - record.errors.add :stairbought, I18n.t("validations.financial.staircasing.percentage_bought_equal_percentage_owned", stairbought: record.field_formatted_as_currency("stairbought"), stairowned: record.field_formatted_as_currency("stairowned")) - record.errors.add :stairowned, I18n.t("validations.financial.staircasing.percentage_bought_equal_percentage_owned", stairbought: record.field_formatted_as_currency("stairbought"), stairowned: record.field_formatted_as_currency("stairowned")) + record.errors.add :stairbought, I18n.t("validations.financial.staircasing.percentage_bought_equal_percentage_owned", stairbought: sprintf("%g", record.stairbought), stairowned: sprintf("%g", record.stairowned)) + record.errors.add :stairowned, I18n.t("validations.financial.staircasing.percentage_bought_equal_percentage_owned", stairbought: sprintf("%g", record.stairbought), stairowned: sprintf("%g", record.stairowned)) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 29b4b7bc3..01000c8b6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -427,7 +427,7 @@ en: staircasing: percentage_bought_must_be_greater_than_percentage_owned: "Total percentage buyer now owns must be more than percentage bought in this transaction" percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}%" - percentage_bought_equal_percentage_owned: "The percentage bought is %{stairbought} and the percentage owned in total is %{stairowned}. These figures cannot be the same." + percentage_bought_equal_percentage_owned: "The percentage bought is %{stairbought}% and the percentage owned in total is %{stairowned}%. These figures cannot be the same." monthly_leasehold_charges: not_zero: "Monthly leasehold charges cannot be £0 if the property has monthly charges" equity: diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index cbf34afc9..4e0590735 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/spec/models/validations/sales/financial_validations_spec.rb @@ -176,8 +176,8 @@ RSpec.describe Validations::Sales::FinancialValidations do record.stairbought = 30 record.stairowned = 30 financial_validator.validate_percentage_bought_not_equal_percentage_owned(record) - expect(record.errors["stairowned"]).to include("The percentage bought is £30.00 and the percentage owned in total is £30.00. These figures cannot be the same.") - expect(record.errors["stairbought"]).to include("The percentage bought is £30.00 and the percentage owned in total is £30.00. These figures cannot be the same.") + expect(record.errors["stairowned"]).to include("The percentage bought is 30% and the percentage owned in total is 30%. These figures cannot be the same.") + expect(record.errors["stairbought"]).to include("The percentage bought is 30% and the percentage owned in total is 30%. These figures cannot be the same.") end it "does not add an error to stairowned and not stairbought if the percentage bought is more than the percentage owned" do