Browse Source

Add validation for referral type when permanently decanted from PRP-only housing

pull/3045/head
Manny Dinssa 4 weeks ago
parent
commit
f6c52b5226
  1. 4
      app/models/lettings_log.rb
  2. 9
      app/models/validations/household_validations.rb
  3. 3
      config/locales/validations/lettings/household.en.yml

4
app/models/lettings_log.rb

@ -381,6 +381,10 @@ class LettingsLog < Log
referral == 1
end
def is_from_prp_only_housing_register_or_waiting_list?
referral_type == 3
end
def is_relet_to_temp_tenant?
# 9: Re-let to tenant who occupied same property as temporary accommodation
rsnvac == 9

9
app/models/validations/household_validations.rb

@ -30,11 +30,16 @@ module Validations::HouseholdValidations
end
validate_other_field(record, 20, :reason, :reasonother)
if record.is_reason_permanently_decanted? && record.referral.present? && !record.is_internal_transfer?
if record.is_reason_permanently_decanted?
if record.referral_type.present? && !record.is_from_prp_only_housing_register_or_waiting_list?
record.errors.add :referral_type, I18n.t("validations.lettings.household.referral_type.leaving_last_settled_home.reason_permanently_decanted")
end
if record.referral.present? && !record.is_internal_transfer?
record.errors.add :referral, I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted")
record.errors.add :referral_type, I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted")
record.errors.add :reason, I18n.t("validations.lettings.household.reason.leaving_last_settled_home.not_internal_transfer")
end
end
return unless record.form.start_year_2024_or_later?

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

@ -107,3 +107,6 @@ en:
la_general_needs:
internal_transfer: "Answer cannot be internal transfer as it’s the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting."
referral_type:
leaving_last_settled_home:
reason_permanently_decanted: "Answer must be from a PRP-only housing register or waiting list (no local authority involvement) as the tenant was permanently decanted from another property owned by this landlord."

Loading…
Cancel
Save