Browse Source

Update outright sale validation message

pull/2549/head
Kat 2 years ago committed by kosiakkatrina
parent
commit
60e7d36abb
  1. 12
      app/models/validations/sales/sale_information_validations.rb
  2. 2
      config/locales/en.yml
  3. 10
      spec/models/validations/sales/sale_information_validations_spec.rb

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

@ -71,9 +71,17 @@ module Validations::Sales::SaleInformationValidations
if over_tolerance?(record.mortgage_and_deposit_total, record.value, 1) if over_tolerance?(record.mortgage_and_deposit_total, record.value, 1)
%i[mortgageused mortgage value deposit].each do |field| %i[mortgageused mortgage value deposit].each do |field|
record.errors.add field, I18n.t("validations.sale_information.outright_sale_value", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), value: record.field_formatted_as_currency("value")) record.errors.add field, I18n.t("validations.sale_information.outright_sale_value",
mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"),
mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "",
deposit: record.field_formatted_as_currency("deposit"),
value: record.field_formatted_as_currency("value")).html_safe
end end
record.errors.add :ownershipsch, :skip_bu_error, message: I18n.t("validations.sale_information.outright_sale_value", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), value: record.field_formatted_as_currency("value")) record.errors.add :ownershipsch, :skip_bu_error, message: I18n.t("validations.sale_information.outright_sale_value",
mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"),
mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "",
deposit: record.field_formatted_as_currency("deposit"),
value: record.field_formatted_as_currency("value")).html_safe
end end
end end

2
config/locales/en.yml

@ -645,7 +645,7 @@ en:
previous_property_type: previous_property_type:
property_type_bedsit: "A bedsit cannot have more than 1 bedroom" property_type_bedsit: "A bedsit cannot have more than 1 bedroom"
discounted_ownership_value: "The mortgage%{mortgage}, cash deposit (%{deposit}), and grant%{grant} added together is %{mortgage_deposit_and_grant_total}.</br></br>The full purchase price%{discount_sentence} is %{value_with_discount}.</br></br>These two amounts should be the same." discounted_ownership_value: "The mortgage%{mortgage}, cash deposit (%{deposit}), and grant%{grant} added together is %{mortgage_deposit_and_grant_total}.</br></br>The full purchase price%{discount_sentence} is %{value_with_discount}.</br></br>These two amounts should be the same."
outright_sale_value: "The mortgage and deposit when added together is %{mortgage_and_deposit_total}, and the purchase price is %{value}. These figures should be the same." outright_sale_value: "The mortgage%{mortgage} and deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.</br></br>The full purchase price is %{value}.</br></br>These two amounts should be the same."
monthly_rent: monthly_rent:
higher_than_expected: "Basic monthly rent must be between £0.00 and £9,999.00" higher_than_expected: "Basic monthly rent must be between £0.00 and £9,999.00"
grant: grant:

10
spec/models/validations/sales/sale_information_validations_spec.rb

@ -538,11 +538,11 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
it "adds errors" do it "adds errors" do
sale_information_validator.validate_outright_sale_value_matches_mortgage_plus_deposit(record) sale_information_validator.validate_outright_sale_value_matches_mortgage_plus_deposit(record)
expect(record.errors["mortgageused"]).to include("The mortgage and deposit when added together is £200,000.00, and the purchase price is £300,000.00. These figures should be the same.") expect(record.errors["mortgageused"]).to include("The mortgage (£100,000.00) and deposit (£100,000.00) when added together is £200,000.00.</br></br>The full purchase price is £300,000.00.</br></br>These two amounts should be the same.")
expect(record.errors["mortgage"]).to include("The mortgage and deposit when added together is £200,000.00, and the purchase price is £300,000.00. These figures should be the same.") expect(record.errors["mortgage"]).to include("The mortgage (£100,000.00) and deposit (£100,000.00) when added together is £200,000.00.</br></br>The full purchase price is £300,000.00.</br></br>These two amounts should be the same.")
expect(record.errors["deposit"]).to include("The mortgage and deposit when added together is £200,000.00, and the purchase price is £300,000.00. These figures should be the same.") expect(record.errors["deposit"]).to include("The mortgage (£100,000.00) and deposit (£100,000.00) when added together is £200,000.00.</br></br>The full purchase price is £300,000.00.</br></br>These two amounts should be the same.")
expect(record.errors["value"]).to include("The mortgage and deposit when added together is £200,000.00, and the purchase price is £300,000.00. These figures should be the same.") expect(record.errors["value"]).to include("The mortgage (£100,000.00) and deposit (£100,000.00) when added together is £200,000.00.</br></br>The full purchase price is £300,000.00.</br></br>These two amounts should be the same.")
expect(record.errors["ownershipsch"]).to include("The mortgage and deposit when added together is £200,000.00, and the purchase price is £300,000.00. These figures should be the same.") expect(record.errors["ownershipsch"]).to include("The mortgage (£100,000.00) and deposit (£100,000.00) when added together is £200,000.00.</br></br>The full purchase price is £300,000.00.</br></br>These two amounts should be the same.")
end end
end end

Loading…
Cancel
Save