diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 0bb32ca53..d563477bc 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -139,6 +139,24 @@ module Validations::Sales::FinancialValidations end end + def validate_newservicecharges(record) + return unless record.newservicecharges + + if record.newservicecharges.negative? + record.errors.add :newservicecharges, I18n.t("validations.sales.financial.newservicecharges.negative") + elsif record.newservicecharges > 9999.99 + record.errors.add :newservicecharges, I18n.t("validations.sales.financial.newservicecharges.over_max") + end + end + + def validate_newservicecharges_different_from_mscharge(record) + return unless record.hasservicechargeschanged == 1 && record.newservicecharges && record.mscharge + + if record.newservicecharges == record.mscharge + record.errors.add :newservicecharges, I18n.t("validations.sales.financial.newservicecharges.same_as_previous") + end + end + private def is_relationship_child?(relationship) diff --git a/config/locales/validations/sales/financial.en.yml b/config/locales/validations/sales/financial.en.yml index 6e248e6e0..2b31fa509 100644 --- a/config/locales/validations/sales/financial.en.yml +++ b/config/locales/validations/sales/financial.en.yml @@ -49,6 +49,11 @@ en: monthly_leasehold_charges: not_zero: "Monthly leasehold charges cannot be £0 if the property has monthly charges." + newservicecharges: + negative: "Service charge cannot be negative." + over_max: "Service charge cannot be higher than £9,999.99." + same_as_previous: "You said that the service charge will change and you entered the same amount as the previous question. If the service charge will not change, answer 'No'." + resale: equity_over_max: "The maximum initial equity stake is %{max_equity}%."