Browse Source

CLDC-4250: Add a new validation for universal credit and household income sources

CLDC-4250-new-universal-credit-validation
samyou-softwire 4 days ago
parent
commit
f0bf950abe
  1. 21
      app/models/lettings_log.rb
  2. 9
      app/models/validations/financial_validations.rb
  3. 3
      config/locales/validations/lettings/financial.en.yml

21
app/models/lettings_log.rb

@ -542,7 +542,7 @@ class LettingsLog < Log
reason == 1 reason == 1
end end
def receives_housing_benefit_only? def receives_housing_benefit?
# 1: Housing benefit # 1: Housing benefit
hb == 1 hb == 1
end end
@ -551,13 +551,7 @@ class LettingsLog < Log
hb == 3 hb == 3
end end
# Option 8 has been removed starting from 22/23 def receives_universal_credit
def receives_housing_benefit_and_universal_credit?
# 8: Housing benefit and Universal Credit (without housing element)
hb == 8
end
def receives_uc_with_housing_element_excl_housing_benefit?
# 6: Universal Credit with housing element (excluding housing benefit) # 6: Universal Credit with housing element (excluding housing benefit)
hb == 6 hb == 6
end end
@ -572,12 +566,11 @@ class LettingsLog < Log
end end
def receives_housing_related_benefits? def receives_housing_related_benefits?
if collection_start_year <= 2021 receives_housing_benefit? || receives_universal_credit
receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? || end
receives_housing_benefit_and_universal_credit?
else def no_household_income_comes_from_benefits?
receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? benefits == 3
end
end end
def local_housing_referral? def local_housing_referral?

9
app/models/validations/financial_validations.rb

@ -175,6 +175,15 @@ module Validations::FinancialValidations
end end
end end
def validate_housing_universal_credit_matches_income_proportion(record)
return unless record.hb && record.benefits && record.form.start_year_2026_or_later?
if record.receives_universal_credit && record.no_household_income_comes_from_benefits?
record.errors.add :hb, I18n.t("validations.lettings.financial.hb.benefits_received_not_match_income_source")
record.errors.add :benefits, I18n.t("validations.lettings.financial.benefits.benefits_received_not_match_income_source")
end
end
private private
def validate_charges(record) def validate_charges(record)

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

@ -12,6 +12,7 @@ en:
outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question." outstanding_amount_not_expected: "Answer must be ‘yes’ as you have answered the outstanding amount question."
benefits: 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." 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."
benefits_received_not_match_income_source: "You answered that none of the household’s income is from Universal Credit, state pensions or benefits, but also that the tenant is likely to be receiving Universal Credit."
earnings: earnings:
over_hard_max: "The household’s income cannot be greater than %{hard_max} per week given the household’s working situation." 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." under_hard_min: "The household’s income cannot be less than %{hard_min} per week given the household’s working situation."
@ -87,3 +88,5 @@ en:
needstype: needstype:
rent_below_hard_min: "Rent is below the absolute minimum expected for a property of this type based on this lettings 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." rent_above_hard_max: "Rent is higher than the absolute maximum expected for a property of this type based on this lettings type."
hb:
benefits_received_not_match_income_source: "You answered that none of the household’s income is from Universal Credit, state pensions or benefits, but also that the tenant is likely to be receiving Universal Credit."

Loading…
Cancel
Save