Browse Source

Ask address and UPRN questions for 2026 and later logs

CLDC-4159-address-uprn-for-supported-housing
oscar-richardson-softwire 7 days ago
parent
commit
2209bfec70
  1. 5
      app/models/derived_variables/lettings_log_variables.rb
  2. 2
      app/models/form/lettings/pages/address_fallback.rb
  3. 2
      app/models/form/lettings/pages/address_search.rb
  4. 8
      app/models/lettings_log.rb
  5. 10
      app/models/validations/property_validations.rb
  6. 2
      config/locales/validations/lettings/property_information.en.yml

5
app/models/derived_variables/lettings_log_variables.rb

@ -170,7 +170,10 @@ module DerivedVariables::LettingsLogVariables
self.referral = 7 if referral_type == 6
self.referral = 16 if referral_type == 7
reset_address_fields! if is_supported_housing?
if location_changed?
reset_address_fields!
self.la = nil
end
set_checkbox_values!
end

2
app/models/form/lettings/pages/address_fallback.rb

@ -3,7 +3,7 @@ class Form::Lettings::Pages::AddressFallback < ::Form::Page
super
@id = "address"
@copy_key = "lettings.property_information.address"
@depends_on = [{ "is_supported_housing?" => false, "manual_address_entry_selected" => true }]
@depends_on = [{ "is_address_asked?" => true, "manual_address_entry_selected" => true }]
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

2
app/models/form/lettings/pages/address_search.rb

@ -3,7 +3,7 @@ class Form::Lettings::Pages::AddressSearch < ::Form::Page
super
@id = "address_search"
@copy_key = "sales.property_information.address_search"
@depends_on = [{ "is_supported_housing?" => false, "manual_address_entry_selected" => false }]
@depends_on = [{ "is_address_asked?" => true, "manual_address_entry_selected" => false }]
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

8
app/models/lettings_log.rb

@ -184,7 +184,7 @@ class LettingsLog < Log
end
def la
if location
if (!form.start_year_2026_or_later? && location) || (form.start_year_2026_or_later? && !super)
location.linked_local_authorities.active(form.start_date).first&.code || location.location_code
else
super
@ -192,7 +192,7 @@ class LettingsLog < Log
end
def postcode_full
if location
if (!form.start_year_2026_or_later? && location) || (form.start_year_2026_or_later? && !super)
location.postcode
else
super
@ -773,6 +773,10 @@ class LettingsLog < Log
rsnvac != 15 && rsnvac_was == 15
end
def is_address_asked?
form.start_year_2026_or_later? || !is_supported_housing?
end
private
def reset_invalid_unresolved_log_fields!

10
app/models/validations/property_validations.rb

@ -50,6 +50,16 @@ module Validations::PropertyValidations
error_message = I18n.t("validations.lettings.property.postcode_full.invalid")
record.errors.add :postcode_full, :wrong_format, message: error_message
end
return unless record.form.start_year_2026_or_later?
location_postcode = record.location&.postcode
return unless location_postcode
if postcode != location_postcode
record.errors.add :uprn, I18n.t("validations.lettings.property.uprn.postcode_does_not_match_scheme_location_postcode")
record.errors.add :postcode_full, I18n.t("validations.lettings.property.postcode_full.does_not_match_scheme_location_postcode")
end
end
# see also: this validation in sales/property_validations.rb

2
config/locales/validations/lettings/property_information.en.yml

@ -6,6 +6,7 @@ en:
invalid: "Enter a postcode in the correct format, for example AA1 1AA."
not_in_england: "It looks like you have an entered a postcode outside of England. Only create logs for lettings in England."
la_not_valid_for_date: "%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
does_not_match_scheme_location_postcode: "The postcode in the address does not match the postcode for the location in the scheme. Please review your answers to the address or UPRN question (whichever you answered) and the location question."
rsnvac:
non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary."
referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting."
@ -24,6 +25,7 @@ en:
invalid: "UPRN must be 12 digits or less."
not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
la_not_valid_for_date: "%{la} does not exist on the tenancy start date, due to a change in local authority names and boundaries. Please enter the local authority name in use on the tenancy start date"
postcode_does_not_match_scheme_location_postcode: "The postcode in the address does not match the postcode for the location in the scheme. Please review your answers to the address or UPRN question (whichever you answered) and the location question."
uprn_confirmation: # legacy question
not_in_england: "It looks like you have entered an address outside of England. Only create logs for lettings in England."
uprn_selection:

Loading…
Cancel
Save