Browse Source

CLDC-4175: add reverse validation

pull/3200/head
Nat Dean-Lewis 2 months ago
parent
commit
c12ed35bb4
  1. 1
      app/models/validations/sales/financial_validations.rb
  2. 1
      config/locales/validations/sales/financial.en.yml
  3. 1
      spec/models/validations/sales/financial_validations_spec.rb

1
app/models/validations/sales/financial_validations.rb

@ -154,6 +154,7 @@ module Validations::Sales::FinancialValidations
if record.newservicecharges == record.mscharge
record.errors.add :newservicecharges, I18n.t("validations.sales.financial.newservicecharges.same_as_previous")
record.errors.add :mscharge, I18n.t("validations.sales.financial.mscharge.same_as_new")
end
end

1
config/locales/validations/sales/financial.en.yml

@ -48,6 +48,7 @@ en:
mscharge:
monthly_leasehold_charges:
not_zero: "Monthly leasehold charges cannot be £0 if the property has monthly charges."
same_as_new: "You said that the service charge will change and you entered the same amount as the new service charge. If the service charge will not change, answer 'No' to 'Will the service charge change after this staircasing transaction takes place?'."
newservicecharges:
negative: "Service charge cannot be negative."

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

@ -568,6 +568,7 @@ RSpec.describe Validations::Sales::FinancialValidations do
record.mscharge = 100
financial_validator.validate_newservicecharges_different_from_mscharge(record)
expect(record.errors["newservicecharges"]).to include(match I18n.t("validations.sales.financial.newservicecharges.same_as_previous"))
expect(record.errors["mscharge"]).to include(match I18n.t("validations.sales.financial.mscharge.same_as_new"))
end
end
end

Loading…
Cancel
Save