Browse Source

feat: add updated error messages and casing

pull/946/head
natdeanlewissoftwire 3 years ago
parent
commit
4f57f5869c
  1. 7
      app/helpers/interruption_screen_helper.rb
  2. 21
      app/models/validations/financial_validations.rb
  3. 22
      config/locales/en.yml

7
app/helpers/interruption_screen_helper.rb

@ -5,7 +5,12 @@ module InterruptionScreenHelper
translation_params = {} translation_params = {}
informative_text["arguments"].each do |argument| informative_text["arguments"].each do |argument|
value = if argument["label"] value = if argument["label"]
lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log).downcase pre_casing_value = lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log)
if argument["key"] == "la"
pre_casing_value
else
pre_casing_value.downcase
end
else else
lettings_log.public_send(argument["key"]) lettings_log.public_send(argument["key"])
end end

21
app/models/validations/financial_validations.rb

@ -184,12 +184,21 @@ private
rent_range = LaRentRange.find_by(start_year: collection_year, la: record.la, beds: record.beds, lettype: record.lettype) rent_range = LaRentRange.find_by(start_year: collection_year, la: record.la, beds: record.beds, lettype: record.lettype)
if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max) && record.brent.present? && record.period.present? if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max) && record.brent.present? && record.period.present?
record.errors.add :brent, I18n.t("validations.financial.brent.not_in_range") if record.weekly_value(record["brent"]) < rent_range.hard_min
record.errors.add :beds, I18n.t("validations.financial.brent.beds.not_in_range") record.errors.add :brent, I18n.t("validations.financial.brent.below_hard_min")
record.errors.add :la, I18n.t("validations.financial.brent.la.not_in_range") record.errors.add :beds, I18n.t("validations.financial.brent.beds.below_hard_min")
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.not_in_range") record.errors.add :la, I18n.t("validations.financial.brent.la.below_hard_min")
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.not_in_range") record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.below_hard_min")
record.errors.add :period, I18n.t("validations.financial.brent.period.not_in_range") record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.below_hard_min")
record.errors.add :period, I18n.t("validations.financial.brent.period.below_hard_min")
else
record.errors.add :brent, I18n.t("validations.financial.brent.above_hard_max")
record.errors.add :beds, I18n.t("validations.financial.brent.beds.above_hard_max")
record.errors.add :la, I18n.t("validations.financial.brent.la.above_hard_max")
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.above_hard_max")
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.above_hard_max")
record.errors.add :period, I18n.t("validations.financial.brent.period.above_hard_max")
end
end end
end end
end end

22
config/locales/en.yml

@ -188,17 +188,23 @@ en:
general_needs: "Enter a value for the support charge between £0 and £60 per week if the landlord is a local authority and it is a general needs letting" general_needs: "Enter a value for the support charge between £0 and £60 per week if the landlord is a local authority and it is a general needs letting"
supported_housing: "Enter a value for the support charge between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting" supported_housing: "Enter a value for the support charge between £0 and £120 per week if the landlord is a local authority and it is a supported housing letting"
brent: brent:
not_in_range: "Basic rent is outside of the expected range based on the lettings type, local authority and number of bedrooms" below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period, local authority and (if general needs) number of bedrooms"
la: la:
not_in_range: "Basic rent is outside of the expected range based on this local authority" below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this local authority"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this local authority"
beds: beds:
not_in_range: "Basic rent is outside of the expected range based on this number of bedrooms" below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this number of bedrooms"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this number of bedrooms"
needstype: needstype:
not_in_range: "Basic rent is outside of the expected range based on this lettings type" below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type"
rent_type: rent_type:
not_in_range: "Basic rent is outside of the expected range based on this lettings type" below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type"
period: period:
not_in_range: "Basic rent is outside of the expected range based on this period" below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this period"
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this period"
charges: charges:
complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’" complete_1_of_3: "Answer either the ‘household rent and charges’ question or ‘is this accommodation a care home‘, or select ‘no’ for ‘does the household pay rent or charges for the accommodation?’"
tcharge: tcharge:
@ -307,10 +313,10 @@ en:
rent: rent:
min: min:
title_text: "You told us the rent is %{brent}" title_text: "You told us the rent is %{brent}"
hint_text: "The minimum rent for this type of property in %{la} is £%{soft_min_for_period}." hint_text: "The minimum rent expected for this type of property in %{la} is £%{soft_min_for_period}."
max: max:
title_text: "You told us the rent is %{brent}" title_text: "You told us the rent is %{brent}"
hint_text: "The maximum rent for this type of property in %{la} is £%{soft_max_for_period}." hint_text: "The maximum rent expected for this type of property in %{la} is £%{soft_max_for_period}."
retirement: retirement:
min: min:
title: "You told us this person is under %{age} and retired" title: "You told us this person is under %{age} and retired"

Loading…
Cancel
Save