Browse Source

Exctract financial validations (#2740)

pull/2753/head^2
kosiakkatrina 3 months ago committed by GitHub
parent
commit
afc7cf86b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      app/models/lettings_log.rb
  2. 126
      app/models/validations/financial_validations.rb
  3. 67
      config/locales/en.yml
  4. 86
      config/locales/validations/lettings/financial.yml
  5. 105
      spec/models/validations/financial_validations_spec.rb

6
app/models/lettings_log.rb

@ -508,12 +508,6 @@ class LettingsLog < Log
hb == 10 hb == 10
end end
# Option 7 has been removed starting from 22/23
def receives_universal_credit_but_no_housing_benefit?
# 7: Universal Credit (without housing element)
hb == 7
end
def receives_housing_related_benefits? def receives_housing_related_benefits?
if collection_start_year <= 2021 if collection_start_year <= 2021
receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? || receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? ||

126
app/models/validations/financial_validations.rb

@ -6,8 +6,8 @@ module Validations::FinancialValidations
# or 'validate_' to run on submit as well # or 'validate_' to run on submit as well
def validate_outstanding_rent_amount(record) def validate_outstanding_rent_amount(record)
if !record.has_housing_benefit_rent_shortfall? && record.tshortfall.present? if !record.has_housing_benefit_rent_shortfall? && record.tshortfall.present?
record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.tshortfall.outstanding_amount_not_expected") record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.lettings.financial.tshortfall.outstanding_amount_not_expected")
record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.hbrentshortfall.outstanding_amount_not_expected") record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.lettings.financial.hbrentshortfall.outstanding_amount_not_expected")
end end
end end
@ -19,7 +19,7 @@ module Validations::FinancialValidations
relationship = record["relat#{n}"] relationship = record["relat#{n}"]
is_partner_or_main = relationship == "P" || (relationship.nil? && economic_status.present?) is_partner_or_main = relationship == "P" || (relationship.nil? && economic_status.present?)
if is_employed && is_partner_or_main && record.benefits&.zero? if is_employed && is_partner_or_main && record.benefits&.zero?
record.errors.add :benefits, I18n.t("validations.financial.benefits.part_or_full_time") record.errors.add :benefits, I18n.t("validations.lettings.financial.benefits.part_or_full_time")
end end
end end
end end
@ -32,25 +32,25 @@ module Validations::FinancialValidations
record.errors.add( record.errors.add(
:earnings, :earnings,
:over_hard_max, :over_hard_max,
message: I18n.t("validations.financial.earnings.over_hard_max", hard_max:), message: I18n.t("validations.lettings.financial.earnings.over_hard_max", hard_max:),
) )
record.errors.add( record.errors.add(
:hhmemb, :hhmemb,
:over_hard_max, :over_hard_max,
message: I18n.t("validations.financial.hhmemb.earnings.over_hard_max", earnings: format_as_currency(record.earnings), frequency:), message: I18n.t("validations.lettings.financial.hhmemb.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
) )
(1..record.hhmemb).each do |n| (1..record.hhmemb).each do |n|
record.errors.add( record.errors.add(
"ecstat#{n}", "ecstat#{n}",
:over_hard_max, :over_hard_max,
message: I18n.t("validations.financial.ecstat.over_hard_max", earnings: format_as_currency(record.earnings), frequency:), message: I18n.t("validations.lettings.financial.ecstat.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
) )
next unless record["ecstat#{n}"] == 9 next unless record["ecstat#{n}"] == 9
record.errors.add( record.errors.add(
"age#{n}", "age#{n}",
:over_hard_max, :over_hard_max,
message: I18n.t("validations.financial.age.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:), message: I18n.t("validations.lettings.financial.age.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
) )
end end
end end
@ -61,18 +61,18 @@ module Validations::FinancialValidations
record.errors.add( record.errors.add(
:earnings, :earnings,
:under_hard_min, :under_hard_min,
message: I18n.t("validations.financial.earnings.under_hard_min", hard_min:), message: I18n.t("validations.lettings.financial.earnings.under_hard_min", hard_min:),
) )
record.errors.add( record.errors.add(
:hhmemb, :hhmemb,
:under_hard_min, :under_hard_min,
message: I18n.t("validations.financial.hhmemb.earnings.under_hard_min", earnings: format_as_currency(record.earnings), frequency:), message: I18n.t("validations.lettings.financial.hhmemb.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
) )
(1..record.hhmemb).each do |n| (1..record.hhmemb).each do |n|
record.errors.add( record.errors.add(
"ecstat#{n}", "ecstat#{n}",
:under_hard_min, :under_hard_min,
message: I18n.t("validations.financial.ecstat.under_hard_min", earnings: format_as_currency(record.earnings), frequency:), message: I18n.t("validations.lettings.financial.ecstat.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
) )
# N.B. It is not possible for a change to an age field to increase the hard min # N.B. It is not possible for a change to an age field to increase the hard min
end end
@ -80,69 +80,61 @@ module Validations::FinancialValidations
end end
if record.earnings.present? && record.incfreq.blank? if record.earnings.present? && record.incfreq.blank?
record.errors.add :incfreq, I18n.t("validations.financial.earnings.freq_missing") record.errors.add :incfreq, I18n.t("validations.lettings.financial.incfreq.incfreq_missing")
record.errors.add :earnings, I18n.t("validations.financial.earnings.freq_missing") record.errors.add :earnings, I18n.t("validations.lettings.financial.earnings.incfreq_missing")
end end
if record.incfreq.present? && record.earnings.blank? if record.incfreq.present? && record.earnings.blank?
record.errors.add :earnings, I18n.t("validations.financial.earnings.earnings_missing") record.errors.add :earnings, I18n.t("validations.lettings.financial.earnings.earnings_missing")
record.errors.add :incfreq, I18n.t("validations.financial.earnings.earnings_missing") record.errors.add :incfreq, I18n.t("validations.lettings.financial.incfreq.earnings_missing")
end end
end end
def validate_negative_currency(record) def validate_negative_currency(record)
t = %w[earnings brent scharge pscharge supcharg] fields = %w[earnings brent scharge pscharge supcharg]
t.each do |x| fields.each do |field|
if record[x].present? && record[x].negative? if record[field].present? && record[field].negative?
record.errors.add x.to_sym, I18n.t("validations.financial.negative_currency") record.errors.add field.to_sym, I18n.t("validations.lettings.financial.#{field}.negative_currency")
end end
end end
end end
def validate_tshortfall(record) def validate_tshortfall(record)
if record.has_housing_benefit_rent_shortfall? && no_known_benefits?(record) if record.has_housing_benefit_rent_shortfall? && no_known_benefits?(record)
record.errors.add :tshortfall, I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits") record.errors.add :tshortfall, I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits")
end end
end end
def no_known_benefits?(record) def no_known_benefits?(record)
return true unless record.collection_start_year return true unless record.collection_start_year
if record.collection_start_year <= 2021 record.benefits_unknown? || record.receives_no_benefits? || record.tenant_refuses_to_say_benefits?
record.benefits_unknown? ||
record.receives_no_benefits? ||
record.receives_universal_credit_but_no_housing_benefit?
else
record.benefits_unknown? ||
record.receives_no_benefits? ||
record.tenant_refuses_to_say_benefits?
end
end end
def validate_rent_amount(record) def validate_rent_amount(record)
if record.wtshortfall if record.wtshortfall
if record.is_supported_housing? && record.wchchrg && (record.wtshortfall > record.wchchrg) if record.is_supported_housing? && record.wchchrg && (record.wtshortfall > record.wchchrg)
record.errors.add :tshortfall, message: I18n.t("validations.financial.tshortfall.more_than_carehome_charge") record.errors.add :tshortfall, message: I18n.t("validations.lettings.financial.tshortfall.more_than_carehome_charge")
record.errors.add :chcharge, I18n.t("validations.financial.carehome.less_than_shortfall") record.errors.add :chcharge, I18n.t("validations.lettings.financial.chcharge.less_than_shortfall")
end end
if record.wtcharge && (record.wtshortfall > record.wtcharge) if record.wtcharge && (record.wtshortfall > record.wtcharge)
record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.financial.tshortfall.more_than_total_charge") record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.lettings.financial.tshortfall.more_than_total_charge")
record.errors.add :tcharge, I18n.t("validations.financial.tcharge.less_than_shortfall") record.errors.add :tcharge, I18n.t("validations.lettings.financial.tcharge.less_than_shortfall")
elsif record.wtshortfall < 0.01 elsif record.wtshortfall < 0.01
record.errors.add :tshortfall, :must_be_positive, message: I18n.t("validations.financial.tshortfall.must_be_positive") record.errors.add :tshortfall, :must_be_positive, message: I18n.t("validations.lettings.financial.tshortfall.must_be_positive")
end end
end end
if record.tcharge.present? && weekly_value_in_range(record, "tcharge", 0, 9.99) if record.tcharge.present? && weekly_value_in_range(record, "tcharge", 0, 9.99)
record.errors.add :tcharge, :under_10, message: I18n.t("validations.financial.tcharge.under_10") record.errors.add :tcharge, :under_10, message: I18n.t("validations.lettings.financial.tcharge.under_10")
end end
answered_questions = [record.tcharge, record.chcharge].concat(record.household_charge && record.household_charge == 1 ? [record.household_charge] : []) answered_questions = [record.tcharge, record.chcharge].concat(record.household_charge && record.household_charge == 1 ? [record.household_charge] : [])
if answered_questions.count(&:present?) > 1 if answered_questions.count(&:present?) > 1
record.errors.add :tcharge, :complete_1_of_3, message: I18n.t("validations.financial.charges.complete_1_of_3") if record.tcharge.present? record.errors.add :tcharge, :complete_1_of_3, message: I18n.t("validations.lettings.financial.tcharge.complete_1_of_3") if record.tcharge.present?
record.errors.add :chcharge, I18n.t("validations.financial.charges.complete_1_of_3") if record.chcharge.present? record.errors.add :chcharge, I18n.t("validations.lettings.financial.chcharge.complete_1_of_3") if record.chcharge.present?
record.errors.add :household_charge, I18n.t("validations.financial.charges.complete_1_of_3") if record.household_charge.present? record.errors.add :household_charge, I18n.t("validations.lettings.financial.household_charge.complete_1_of_3") if record.household_charge.present?
end end
validate_charges(record) validate_charges(record)
@ -154,12 +146,12 @@ module Validations::FinancialValidations
unless record.managing_organisation.rent_periods.include? record.period unless record.managing_organisation.rent_periods.include? record.period
record.errors.add :period, :wrong_rent_period, message: I18n.t( record.errors.add :period, :wrong_rent_period, message: I18n.t(
"validations.financial.rent_period.invalid_for_org.period", "validations.lettings.financial.period.invalid_period_for_org",
org_name: record.managing_organisation.name, org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase, rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
) )
record.errors.add :managing_organisation_id, :skip_bu_error, message: I18n.t( record.errors.add :managing_organisation_id, :skip_bu_error, message: I18n.t(
"validations.financial.rent_period.invalid_for_org.managing_org", "validations.lettings.financial.managing_organisation_id.invalid_period_for_org",
org_name: record.managing_organisation.name, org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase, rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
) )
@ -169,18 +161,12 @@ module Validations::FinancialValidations
def validate_care_home_charges(record) def validate_care_home_charges(record)
if record.is_carehome? if record.is_carehome?
period = record.form.get_question("period", record).label_from_value(record.period).downcase period = record.form.get_question("period", record).label_from_value(record.period).downcase
# NOTE: This is a temporary change to allow `ccharge` values despite `is_carehome` being true. This value if record.chcharge.present? && !weekly_value_in_range(record, "chcharge", 10, 5000)
# is going to be moved to a soft validation in CLDC-2074, so we can safely do this.
if record.chcharge.blank?
# record.errors.add :is_carehome, I18n.t("validations.financial.carehome.not_provided", period:)
# record.errors.add :chcharge, I18n.t("validations.financial.carehome.not_provided", period:)
elsif !weekly_value_in_range(record, "chcharge", 10, 5000)
max_chcharge = record.weekly_to_value_per_period(5000) max_chcharge = record.weekly_to_value_per_period(5000)
min_chcharge = record.weekly_to_value_per_period(10) min_chcharge = record.weekly_to_value_per_period(10)
message = I18n.t("validations.financial.carehome.out_of_range", period:, min_chcharge:, max_chcharge:)
record.errors.add :period, message record.errors.add :period, I18n.t("validations.lettings.financial.period.chcharge_out_of_range", period:, min_chcharge:, max_chcharge:)
record.errors.add :chcharge, :out_of_range, message: record.errors.add :chcharge, :out_of_range, message: I18n.t("validations.lettings.financial.chcharge.out_of_range", period:, min_chcharge:, max_chcharge:)
end end
end end
end end
@ -202,8 +188,8 @@ private
provider_type_label = PROVIDER_TYPE[provider_type].to_s.humanize(capitalize: false) provider_type_label = PROVIDER_TYPE[provider_type].to_s.humanize(capitalize: false)
maximum_per_period = record.weekly_to_value_per_period(maximum_per_week) maximum_per_period = record.weekly_to_value_per_period(maximum_per_week)
record.errors.add charge, :outside_the_range, message: I18n.t("validations.financial.rent.out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label) record.errors.add charge, :outside_the_range, message: I18n.t("validations.lettings.financial.#{charge}.rent_out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label)
record.errors.add :period, :outside_the_range, message: I18n.t("validations.financial.rent.out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label) record.errors.add :period, :outside_the_range, message: I18n.t("validations.lettings.financial.period.rent_out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label)
end end
end end
@ -225,29 +211,29 @@ private
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?
if record.weekly_value(record["brent"]) < rent_range.hard_min if record.weekly_value(record["brent"]) < rent_range.hard_min
record.errors.add :brent, :below_hard_min, message: I18n.t("validations.financial.brent.below_hard_min") record.errors.add :brent, :below_hard_min, message: I18n.t("validations.lettings.financial.brent.below_hard_min")
record.errors.add :beds, I18n.t("validations.financial.brent.beds.below_hard_min") record.errors.add :beds, I18n.t("validations.lettings.financial.beds.rent_below_hard_min")
record.errors.add :uprn, I18n.t("validations.financial.brent.uprn.below_hard_min") record.errors.add :uprn, I18n.t("validations.lettings.financial.uprn.rent_below_hard_min")
record.errors.add :la, I18n.t("validations.financial.brent.la.below_hard_min") record.errors.add :la, I18n.t("validations.lettings.financial.la.rent_below_hard_min")
record.errors.add :postcode_known, I18n.t("validations.financial.brent.postcode_known.below_hard_min") record.errors.add :postcode_known, I18n.t("validations.lettings.financial.postcode_known.rent_below_hard_min")
record.errors.add :scheme_id, I18n.t("validations.financial.brent.scheme_id.below_hard_min") record.errors.add :scheme_id, I18n.t("validations.lettings.financial.scheme_id.rent_below_hard_min")
record.errors.add :location_id, I18n.t("validations.financial.brent.location_id.below_hard_min") record.errors.add :location_id, I18n.t("validations.lettings.financial.location_id.rent_below_hard_min")
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.below_hard_min") record.errors.add :rent_type, I18n.t("validations.lettings.financial.rent_type.rent_below_hard_min")
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.below_hard_min") record.errors.add :needstype, I18n.t("validations.lettings.financial.needstype.rent_below_hard_min")
record.errors.add :period, I18n.t("validations.financial.brent.period.below_hard_min") record.errors.add :period, I18n.t("validations.lettings.financial.period.rent_below_hard_min")
end end
if record.weekly_value(record["brent"]) > rent_range.hard_max if record.weekly_value(record["brent"]) > rent_range.hard_max
record.errors.add :brent, :over_hard_max, message: I18n.t("validations.financial.brent.above_hard_max") record.errors.add :brent, :over_hard_max, message: I18n.t("validations.lettings.financial.brent.above_hard_max")
record.errors.add :beds, I18n.t("validations.financial.brent.beds.above_hard_max") record.errors.add :beds, I18n.t("validations.lettings.financial.beds.rent_above_hard_max")
record.errors.add :uprn, I18n.t("validations.financial.brent.uprn.above_hard_max") record.errors.add :uprn, I18n.t("validations.lettings.financial.uprn.rent_above_hard_max")
record.errors.add :la, I18n.t("validations.financial.brent.la.above_hard_max") record.errors.add :la, I18n.t("validations.lettings.financial.la.rent_above_hard_max")
record.errors.add :postcode_known, I18n.t("validations.financial.brent.postcode_known.above_hard_max") record.errors.add :postcode_known, I18n.t("validations.lettings.financial.postcode_known.rent_above_hard_max")
record.errors.add :scheme_id, I18n.t("validations.financial.brent.scheme_id.above_hard_max") record.errors.add :scheme_id, I18n.t("validations.lettings.financial.scheme_id.rent_above_hard_max")
record.errors.add :location_id, I18n.t("validations.financial.brent.location_id.above_hard_max") record.errors.add :location_id, I18n.t("validations.lettings.financial.location_id.rent_above_hard_max")
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.above_hard_max") record.errors.add :rent_type, I18n.t("validations.lettings.financial.rent_type.rent_above_hard_max")
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.above_hard_max") record.errors.add :needstype, I18n.t("validations.lettings.financial.needstype.rent_above_hard_max")
record.errors.add :period, I18n.t("validations.financial.brent.period.above_hard_max") record.errors.add :period, I18n.t("validations.lettings.financial.period.rent_above_hard_max")
end end
end end
end end

67
config/locales/en.yml

@ -285,83 +285,16 @@ en:
one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms." one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms."
financial: financial:
tshortfall:
outstanding_amount_not_expected: "You cannot answer the outstanding amount question if you don’t have outstanding rent or charges."
more_than_total_charge: "Enter a value less than the total charge."
more_than_carehome_charge: "Enter a value less than the care home charge."
must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount."
hbrentshortfall:
outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question."
outstanding_no_benefits: "Answer cannot be ‘yes’ to outstanding amount for basic rent or charges if tenant does not receive housing benefit or Universal Credit or you‘re not sure."
benefits:
part_or_full_time: "Answer cannot be ‘all’ for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time."
earnings:
over_hard_max: "The household’s income cannot be greater than %{hard_max} per week given the household’s working situation."
under_hard_min: "The household’s income cannot be less than %{hard_min} per week given the household’s working situation."
freq_missing: "Select how often the household receives income."
earnings_missing: "Enter how much income the household has in total."
income: income:
outside_london_income_range: "Income must be between £0 and £90,000 for properties within a London local authority." outside_london_income_range: "Income must be between £0 and £90,000 for properties within a London local authority."
outside_non_london_income_range: "Income must be between £0 and £80,000 for properties in a non-London local authority." outside_non_london_income_range: "Income must be between £0 and £80,000 for properties in a non-London local authority."
combined_over_hard_max_for_london: "Combined income must be £90,000 or lower for properties within a London local authority." combined_over_hard_max_for_london: "Combined income must be £90,000 or lower for properties within a London local authority."
combined_over_hard_max_for_outside_london: "Combined income must be £80,000 or lower for properties outside London local authorities." combined_over_hard_max_for_outside_london: "Combined income must be £80,000 or lower for properties outside London local authorities."
child_has_income: "Child's income must be £0." child_has_income: "Child's income must be £0."
negative_currency: "Enter an amount above 0."
rent:
out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
ecstat:
over_hard_max: "The household’s income of %{earnings} %{frequency} is too high given the household’s working situation."
under_hard_min: "The household’s income of %{earnings} %{frequency} is too low given the household’s working situation."
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."
hhmemb:
earnings:
over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for this number of tenants. Change either the household income or number of tenants."
under_hard_min: "The household’s income of %{earnings} %{frequency} is too low for this number of tenants. Change either the household income or number of tenants."
brent:
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."
scheme_id:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
location_id:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
postcode_known:
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 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 number of bedrooms."
uprn:
below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this UPRN."
above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this UPRN."
la:
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:
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:
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:
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:
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?’"
missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'." missing_charges: "Please enter the %{sentence_fragment}. If there is no %{sentence_fragment}, please enter '0'."
tcharge:
under_10: "Enter a total charge that is at least £10.00 per week."
less_than_shortfall: "The total charge must be more than the outstanding amount."
rent_period:
invalid_for_org:
period: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation."
managing_org: "%{org_name} does not use %{rent_period} as a rent period. Set another rent period on this log, or a data coordinator can add rent periods to this organisation."
carehome: carehome:
out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
not_provided: "Enter how much rent and other charges the household pays %{period}." not_provided: "Enter how much rent and other charges the household pays %{period}."
less_than_shortfall: "The care home charge must be more than the outstanding amount."
cash_discount_invalid: "Cash discount must be £0 - £999,999." cash_discount_invalid: "Cash discount must be £0 - £999,999."
staircasing: staircasing:
percentage_bought_must_be_greater_than_percentage_owned: "Total percentage %{buyer_now_owns} must be more than percentage bought in this transaction." percentage_bought_must_be_greater_than_percentage_owned: "Total percentage %{buyer_now_owns} must be more than percentage bought in this transaction."

86
config/locales/validations/lettings/financial.yml

@ -0,0 +1,86 @@
en:
validations:
lettings:
financial:
tshortfall:
outstanding_amount_not_expected: "You cannot answer the outstanding amount question if you don’t have outstanding rent or charges."
more_than_total_charge: "Enter a value less than the total charge."
more_than_carehome_charge: "Enter a value less than the care home charge."
must_be_positive: "Enter a value over £0.01 as you told us there is an outstanding amount."
outstanding_no_benefits: "Answer cannot be ‘yes’ to outstanding amount for basic rent or charges if tenant does not receive housing benefit or Universal Credit or you‘re not sure."
hbrentshortfall:
outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question."
benefits:
part_or_full_time: "Answer cannot be ‘all’ for income from Universal Credit, state pensions or benefits if the tenant or their partner works part-time or full-time."
earnings:
over_hard_max: "The household’s income cannot be greater than %{hard_max} per week given the household’s working situation."
under_hard_min: "The household’s income cannot be less than %{hard_min} per week given the household’s working situation."
incfreq_missing: "Select how often the household receives income."
earnings_missing: "Enter how much income the household has in total."
negative_currency: "Enter an amount above 0."
hhmemb:
earnings_over_hard_max: "The household’s income of %{earnings} %{frequency} is too high for this number of tenants. Change either the household income or number of tenants."
earnings_under_hard_min: "The household’s income of %{earnings} %{frequency} is too low for this number of tenants. Change either the household income or number of tenants."
ecstat:
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."
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."
incfreq:
incfreq_missing: "Select how often the household receives income."
earnings_missing: "Enter how much income the household has in total."
brent:
negative_currency: "Enter an amount above 0."
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."
scharge:
negative_currency: "Enter an amount above 0."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
pscharge:
negative_currency: "Enter an amount above 0."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
supcharg:
negative_currency: "Enter an amount above 0."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
chcharge:
less_than_shortfall: "The care home charge must be more than the outstanding amount."
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?’"
out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
tcharge:
under_10: "Enter a total charge that is at least £10.00 per week."
less_than_shortfall: "The total charge must be more than the outstanding amount."
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?’"
household_charge:
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?’"
period:
invalid_period_for_org: "%{org_name} does not use %{rent_period} as a rent period. Choose another rent period, or a data coordinator can add rent periods to your organisation."
chcharge_out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}."
rent_out_of_range: "Enter a value for the %{charge_name} between £0 and %{maximum_per_period} paid %{frequency}. %{maximum_per_period} is the max limit for rent and charges paid %{frequency} for %{letting_type} lettings owned by a %{provider_type}."
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this period."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this period."
managing_organisation_id:
invalid_period_for_org: "%{org_name} does not use %{rent_period} as a rent period. Set another rent period on this log, or a data coordinator can add rent periods to this organisation."
beds:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this number of bedrooms."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this number of bedrooms."
uprn:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this UPRN."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this UPRN."
la:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this local authority."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this local authority."
postcode_known:
rent_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 number of bedrooms."
rent_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 number of bedrooms."
scheme_id:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
location_id:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type. Please check the rent, rent period and local authority."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type. Please check the rent, rent period and local authority."
rent_type:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."
needstype:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings type."
rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."

105
spec/models/validations/financial_validations_spec.rb

@ -17,9 +17,9 @@ RSpec.describe Validations::FinancialValidations do
record.incfreq = nil record.incfreq = nil
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
expect(record.errors["incfreq"]) expect(record.errors["incfreq"])
.to include(match I18n.t("validations.financial.earnings.freq_missing")) .to include(match I18n.t("validations.lettings.financial.incfreq.incfreq_missing"))
expect(record.errors["earnings"]) expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.earnings.freq_missing")) .to include(match I18n.t("validations.lettings.financial.earnings.incfreq_missing"))
end end
it "when income frequency is provided it validates that earnings must be provided" do it "when income frequency is provided it validates that earnings must be provided" do
@ -27,9 +27,9 @@ RSpec.describe Validations::FinancialValidations do
record.incfreq = 1 record.incfreq = 1
financial_validator.validate_net_income(record) financial_validator.validate_net_income(record)
expect(record.errors["earnings"]) expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.earnings.earnings_missing")) .to include(match I18n.t("validations.lettings.financial.earnings.earnings_missing"))
expect(record.errors["incfreq"]) expect(record.errors["incfreq"])
.to include(match I18n.t("validations.financial.earnings.earnings_missing")) .to include(match I18n.t("validations.lettings.financial.earnings.earnings_missing"))
end end
end end
@ -39,14 +39,14 @@ RSpec.describe Validations::FinancialValidations do
record.benefits = 0 record.benefits = 0
record.ecstat1 = 1 record.ecstat1 = 1
financial_validator.validate_net_income_uc_proportion(record) financial_validator.validate_net_income_uc_proportion(record)
expect(record.errors["benefits"]).to include(match I18n.t("validations.financial.benefits.part_or_full_time")) expect(record.errors["benefits"]).to include(match I18n.t("validations.lettings.financial.benefits.part_or_full_time"))
end end
it "validates that the lead tenant is not in part time employment" do it "validates that the lead tenant is not in part time employment" do
record.benefits = 0 record.benefits = 0
record.ecstat1 = 0 record.ecstat1 = 0
financial_validator.validate_net_income_uc_proportion(record) financial_validator.validate_net_income_uc_proportion(record)
expect(record.errors["benefits"]).to include(match I18n.t("validations.financial.benefits.part_or_full_time")) expect(record.errors["benefits"]).to include(match I18n.t("validations.lettings.financial.benefits.part_or_full_time"))
end end
it "expects that the lead tenant is not in full-time or part-time employment" do it "expects that the lead tenant is not in full-time or part-time employment" do
@ -61,7 +61,7 @@ RSpec.describe Validations::FinancialValidations do
record.ecstat2 = 0 record.ecstat2 = 0
record.relat2 = "P" record.relat2 = "P"
financial_validator.validate_net_income_uc_proportion(record) financial_validator.validate_net_income_uc_proportion(record)
expect(record.errors["benefits"]).to include(match I18n.t("validations.financial.benefits.part_or_full_time")) expect(record.errors["benefits"]).to include(match I18n.t("validations.lettings.financial.benefits.part_or_full_time"))
end end
it "expects that the tenant’s partner is not in full-time or part-time employment" do it "expects that the tenant’s partner is not in full-time or part-time employment" do
@ -81,7 +81,7 @@ RSpec.describe Validations::FinancialValidations do
record.tshortfall = 99 record.tshortfall = 99
financial_validator.validate_outstanding_rent_amount(record) financial_validator.validate_outstanding_rent_amount(record)
expect(record.errors["tshortfall"]) expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.outstanding_amount_not_expected")) .to include(match I18n.t("validations.lettings.financial.tshortfall.outstanding_amount_not_expected"))
end end
end end
@ -104,7 +104,7 @@ RSpec.describe Validations::FinancialValidations do
record.set_derived_fields! record.set_derived_fields!
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["tshortfall"]) expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.must_be_positive")) .to include(match I18n.t("validations.lettings.financial.tshortfall.must_be_positive"))
end end
it "validates that total charge is no less than the shortfall" do it "validates that total charge is no less than the shortfall" do
@ -118,9 +118,9 @@ RSpec.describe Validations::FinancialValidations do
record.set_derived_fields! record.set_derived_fields!
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.tcharge.less_than_shortfall")) .to include(match I18n.t("validations.lettings.financial.tcharge.less_than_shortfall"))
expect(record.errors["tshortfall"]) expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.more_than_total_charge")) .to include(match I18n.t("validations.lettings.financial.tshortfall.more_than_total_charge"))
end end
it "validates that carehome charge is no less than the shortfall" do it "validates that carehome charge is no less than the shortfall" do
@ -134,9 +134,9 @@ RSpec.describe Validations::FinancialValidations do
record.set_derived_fields! record.set_derived_fields!
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.carehome.less_than_shortfall")) .to include(match I18n.t("validations.lettings.financial.chcharge.less_than_shortfall"))
expect(record.errors["tshortfall"]) expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.tshortfall.more_than_carehome_charge")) .to include(match I18n.t("validations.lettings.financial.tshortfall.more_than_carehome_charge"))
end end
it "expects that rent can be less than the shortfall if total charge is higher" do it "expects that rent can be less than the shortfall if total charge is higher" do
@ -181,13 +181,13 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_period(record) financial_validator.validate_rent_period(record)
expect(record.errors["period"]) expect(record.errors["period"])
.to include(match I18n.t( .to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org.period", "validations.lettings.financial.period.invalid_period_for_org",
org_name: user.organisation.name, org_name: user.organisation.name,
rent_period: "every 4 weeks", rent_period: "every 4 weeks",
)) ))
expect(record.errors["managing_organisation_id"]) expect(record.errors["managing_organisation_id"])
.to include(match I18n.t( .to include(match I18n.t(
"validations.financial.rent_period.invalid_for_org.managing_org", "validations.lettings.financial.managing_organisation_id.invalid_period_for_org",
org_name: user.organisation.name, org_name: user.organisation.name,
rent_period: "every 4 weeks", rent_period: "every 4 weeks",
)) ))
@ -204,7 +204,7 @@ RSpec.describe Validations::FinancialValidations do
record.hb = 9 record.hb = 9
financial_validator.validate_tshortfall(record) financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"]) expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits")) .to include(match I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits"))
end end
it "validates that housing benefit is not don't know" do it "validates that housing benefit is not don't know" do
@ -212,16 +212,7 @@ RSpec.describe Validations::FinancialValidations do
record.hb = 3 record.hb = 3
financial_validator.validate_tshortfall(record) financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"]) expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits")) .to include(match I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits"))
end
it "validates that housing benefit is not Universal Credit without housing benefit (prior to 22/23)" do
record.startdate = Time.zone.local(2022, 3, 1)
record.hbrentshortfall = 1
record.hb = 7
financial_validator.validate_tshortfall(record)
expect(record.errors["tshortfall"])
.to include(match I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits"))
end end
it "validates that housing benefit is provided" do it "validates that housing benefit is provided" do
@ -375,15 +366,15 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_negative_currency(record) financial_validator.validate_negative_currency(record)
expect(record.errors["earnings"]) expect(record.errors["earnings"])
.to include(match I18n.t("validations.financial.negative_currency")) .to include(match I18n.t("validations.lettings.financial.earnings.negative_currency"))
expect(record.errors["brent"]) expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.negative_currency")) .to include(match I18n.t("validations.lettings.financial.brent.negative_currency"))
expect(record.errors["scharge"]) expect(record.errors["scharge"])
.to include(match I18n.t("validations.financial.negative_currency")) .to include(match I18n.t("validations.lettings.financial.scharge.negative_currency"))
expect(record.errors["pscharge"]) expect(record.errors["pscharge"])
.to include(match I18n.t("validations.financial.negative_currency")) .to include(match I18n.t("validations.lettings.financial.pscharge.negative_currency"))
expect(record.errors["supcharg"]) expect(record.errors["supcharg"])
.to include(match I18n.t("validations.financial.negative_currency")) .to include(match I18n.t("validations.lettings.financial.supcharg.negative_currency"))
end end
end end
@ -466,7 +457,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value] record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]]) expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "private registered provider")) .to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "private registered provider"))
end end
end end
@ -578,7 +569,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value] record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]]) expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "private registered provider")) .to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "private registered provider"))
end end
end end
@ -694,7 +685,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value] record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]]) expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "local authority")) .to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "general needs", provider_type: "local authority"))
end end
end end
@ -806,7 +797,7 @@ RSpec.describe Validations::FinancialValidations do
record[test_case[:charge][:field]] = test_case[:charge][:value] record[test_case[:charge][:field]] = test_case[:charge][:value]
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors[test_case[:charge][:field]]) expect(record.errors[test_case[:charge][:field]])
.to include(match I18n.t("validations.financial.rent.out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "local authority")) .to include(match I18n.t("validations.lettings.financial.#{test_case[:charge][:field]}.rent_out_of_range", charge_name: test_case[:charge_name], maximum_per_period: test_case[:maximum_per_period], frequency: test_case[:period][:label], letting_type: "supported housing", provider_type: "local authority"))
end end
end end
@ -885,7 +876,7 @@ RSpec.describe Validations::FinancialValidations do
record.tcharge = 9 record.tcharge = 9
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.tcharge.under_10")) .to include(match I18n.t("validations.lettings.financial.tcharge.under_10"))
end end
it "allows the total charge to be over 10 per week" do it "allows the total charge to be over 10 per week" do
@ -903,7 +894,7 @@ RSpec.describe Validations::FinancialValidations do
record.tcharge = 19.99 record.tcharge = 19.99
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.tcharge.under_10")) .to include(match I18n.t("validations.lettings.financial.tcharge.under_10"))
end end
it "allows the total charge to be over 10 per week" do it "allows the total charge to be over 10 per week" do
@ -922,11 +913,11 @@ RSpec.describe Validations::FinancialValidations do
record.household_charge = 1 record.household_charge = 1
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.tcharge.complete_1_of_3"))
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.chcharge.complete_1_of_3"))
expect(record.errors["household_charge"]) expect(record.errors["household_charge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.household_charge.complete_1_of_3"))
end end
it "returns an error for tcharge and chcharge types selected" do it "returns an error for tcharge and chcharge types selected" do
@ -936,9 +927,9 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["household_charge"]) expect(record.errors["household_charge"])
.to be_empty .to be_empty
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.tcharge.complete_1_of_3"))
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.chcharge.complete_1_of_3"))
end end
it "returns an error for tcharge type and household_charge not paid selected" do it "returns an error for tcharge type and household_charge not paid selected" do
@ -948,9 +939,9 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to be_empty .to be_empty
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.tcharge.complete_1_of_3"))
expect(record.errors["household_charge"]) expect(record.errors["household_charge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.household_charge.complete_1_of_3"))
end end
it "returns an error for chcharge type and household_charge not paid selected" do it "returns an error for chcharge type and household_charge not paid selected" do
@ -960,9 +951,9 @@ RSpec.describe Validations::FinancialValidations do
expect(record.errors["tcharge"]) expect(record.errors["tcharge"])
.to be_empty .to be_empty
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.chcharge.complete_1_of_3"))
expect(record.errors["household_charge"]) expect(record.errors["household_charge"])
.to include(match I18n.t("validations.financial.charges.complete_1_of_3")) .to include(match I18n.t("validations.lettings.financial.household_charge.complete_1_of_3"))
end end
end end
@ -1038,7 +1029,7 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["brent"]) expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.below_hard_min")) .to include(match I18n.t("validations.lettings.financial.brent.below_hard_min"))
end end
it "validates hard minimum for supported housing" do it "validates hard minimum for supported housing" do
@ -1051,11 +1042,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["brent"]) expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.below_hard_min")) .to include(match I18n.t("validations.lettings.financial.brent.below_hard_min"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field| %w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field]) expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.below_hard_min")) .to include(match I18n.t("validations.lettings.financial.#{field}.rent_below_hard_min"))
end end
end end
@ -1070,11 +1061,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["brent"]) expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.above_hard_max")) .to include(match I18n.t("validations.lettings.financial.brent.above_hard_max"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field| %w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field]) expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.above_hard_max")) .to include(match I18n.t("validations.lettings.financial.#{field}.rent_above_hard_max"))
end end
end end
@ -1088,11 +1079,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["brent"]) expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.above_hard_max")) .to include(match I18n.t("validations.lettings.financial.brent.above_hard_max"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field| %w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field]) expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.above_hard_max")) .to include(match I18n.t("validations.lettings.financial.#{field}.rent_above_hard_max"))
end end
end end
@ -1106,11 +1097,11 @@ RSpec.describe Validations::FinancialValidations do
financial_validator.validate_rent_amount(record) financial_validator.validate_rent_amount(record)
expect(record.errors["brent"]) expect(record.errors["brent"])
.to include(match I18n.t("validations.financial.brent.above_hard_max")) .to include(match I18n.t("validations.lettings.financial.brent.above_hard_max"))
%w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field| %w[beds la postcode_known scheme_id location_id rent_type needstype period].each do |field|
expect(record.errors[field]) expect(record.errors[field])
.to include(match I18n.t("validations.financial.brent.#{field}.above_hard_max")) .to include(match I18n.t("validations.lettings.financial.#{field}.rent_above_hard_max"))
end end
end end
@ -1213,9 +1204,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = nil record.chcharge = nil
financial_validator.validate_care_home_charges(record) financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"]) expect(record.errors["chcharge"])
.to include(match I18n.t("validations.financial.carehome.not_provided", period: "every 4 weeks")) .to include(match I18n.t("validations.lettings.financial.carehome.not_provided", period: "every 4 weeks"))
expect(record.errors["is_carehome"]) expect(record.errors["is_carehome"])
.to include(match I18n.t("validations.financial.carehome.not_provided", period: "every 4 weeks")) .to include(match I18n.t("validations.lettings.financial.carehome.not_provided", period: "every 4 weeks"))
end end
end end

Loading…
Cancel
Save