Browse Source

Update error message

pull/2198/head
Kat 2 years ago
parent
commit
5498355185
  1. 4
      app/models/validations/sales/financial_validations.rb
  2. 2
      config/locales/en.yml
  3. 4
      spec/models/validations/sales/financial_validations_spec.rb

4
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? return unless record.saledate && record.form.start_year_after_2024?
if record.stairbought == record.stairowned 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 :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: 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: sprintf("%g", record.stairbought), stairowned: sprintf("%g", record.stairowned))
end end
end end

2
config/locales/en.yml

@ -427,7 +427,7 @@ en:
staircasing: 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_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_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: monthly_leasehold_charges:
not_zero: "Monthly leasehold charges cannot be £0 if the property has monthly charges" not_zero: "Monthly leasehold charges cannot be £0 if the property has monthly charges"
equity: equity:

4
spec/models/validations/sales/financial_validations_spec.rb

@ -176,8 +176,8 @@ RSpec.describe Validations::Sales::FinancialValidations do
record.stairbought = 30 record.stairbought = 30
record.stairowned = 30 record.stairowned = 30
financial_validator.validate_percentage_bought_not_equal_percentage_owned(record) 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["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.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% and the percentage owned in total is 30%. These figures cannot be the same.")
end end
it "does not add an error to stairowned and not stairbought if the percentage bought is more than the percentage owned" do it "does not add an error to stairowned and not stairbought if the percentage bought is more than the percentage owned" do

Loading…
Cancel
Save