Browse Source

CLDC-4095: Ensure errors are added to Q89 dependent fields

this ensures that the user is always shown an error if they complete the form in a different order to the question set

not doing this leads to the user submitting an answer and nothing happening
Samuel Young 2 months ago
parent
commit
a308af77af
  1. 2
      app/models/validations/financial_validations.rb
  2. 3
      config/locales/validations/lettings/financial.en.yml

2
app/models/validations/financial_validations.rb

@ -20,6 +20,8 @@ module Validations::FinancialValidations
is_partner_or_main = relationship == "P" || n == 1 is_partner_or_main = relationship == "P" || n == 1
if is_employed && is_partner_or_main && record.benefits == 1 if is_employed && is_partner_or_main && record.benefits == 1
record.errors.add :benefits, I18n.t("validations.lettings.financial.benefits.part_or_full_time") record.errors.add :benefits, I18n.t("validations.lettings.financial.benefits.part_or_full_time")
record.errors.add "ecstat#{n}", I18n.t("validations.lettings.financial.ecstat.part_or_full_time")
record.errors.add "relat#{n}", I18n.t("validations.lettings.financial.relat.part_or_full_time", person_num: n) if n > 1
end end
end end
end end

3
config/locales/validations/lettings/financial.en.yml

@ -24,6 +24,9 @@ en:
ecstat: ecstat:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high given the household’s working situation." earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high given the household’s working situation."
earnings_under_hard_min: "The household’s income of %{earnings} %{frequency} is too low given the household’s working situation." earnings_under_hard_min: "The household’s income of %{earnings} %{frequency} is too low given the household’s working situation."
part_or_full_time: "Answer cannot be ‘full-time’ or ‘part-time’ if ‘all’ household income is from Universal Credit, state pensions or benefits."
relat:
part_or_full_time: "Tenant %{person_num} cannot be the partner of tenant 1 if ‘all’ household income is from Universal Credit, state pensions or benefits and tenant %{person_num} works full-time or part-time."
age: age:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for the number of adults. Change either the household income or the age of the tenants." earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for the number of adults. Change either the household income or the age of the tenants."
incfreq: incfreq:

Loading…
Cancel
Save