From 64027560a164fd8119d99cdb7efa518f8604c340 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 25 Feb 2025 18:44:44 +0000 Subject: [PATCH] Add two-step source of referral for letting questions --- .../lettings_log_variables.rb | 7 +++ .../form/lettings/pages/referral_direct.rb | 11 ++++ .../form/lettings/pages/referral_hsc.rb | 11 ++++ .../form/lettings/pages/referral_justice.rb | 11 ++++ app/models/form/lettings/pages/referral_la.rb | 11 ++++ .../form/lettings/pages/referral_prp.rb | 11 ++++ .../form/lettings/pages/referral_type.rb | 10 +++ .../lettings/questions/referral_direct.rb | 26 ++++++++ .../form/lettings/questions/referral_hsc.rb | 32 ++++++++++ .../lettings/questions/referral_justice.rb | 23 +++++++ .../form/lettings/questions/referral_la.rb | 29 +++++++++ .../form/lettings/questions/referral_prp.rb | 26 ++++++++ .../form/lettings/questions/referral_type.rb | 38 ++++++++++++ .../subsections/household_situation.rb | 2 +- .../2025/lettings/household_situation.en.yml | 61 +++++++++++-------- 15 files changed, 282 insertions(+), 27 deletions(-) create mode 100644 app/models/form/lettings/pages/referral_direct.rb create mode 100644 app/models/form/lettings/pages/referral_hsc.rb create mode 100644 app/models/form/lettings/pages/referral_justice.rb create mode 100644 app/models/form/lettings/pages/referral_la.rb create mode 100644 app/models/form/lettings/pages/referral_prp.rb create mode 100644 app/models/form/lettings/pages/referral_type.rb create mode 100644 app/models/form/lettings/questions/referral_direct.rb create mode 100644 app/models/form/lettings/questions/referral_hsc.rb create mode 100644 app/models/form/lettings/questions/referral_justice.rb create mode 100644 app/models/form/lettings/questions/referral_la.rb create mode 100644 app/models/form/lettings/questions/referral_prp.rb create mode 100644 app/models/form/lettings/questions/referral_type.rb diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index f584b6238..901a97180 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -141,6 +141,10 @@ module DerivedVariables::LettingsLogVariables self.is_la_inferred = false end + if referral_type == 7 || referral_type == 16 + self.referral = referral_type + end + reset_address_fields! if is_supported_housing? set_checkbox_values! @@ -208,6 +212,9 @@ private if form.start_year_2024_or_later? && (unittype_gn_changed? && unittype_gn_was == 2) self.beds = nil end + if referral_type_changed? && (referral_type_was == 7 || referral_type_was == 16) + self.referral = nil + end end def get_totelder diff --git a/app/models/form/lettings/pages/referral_direct.rb b/app/models/form/lettings/pages/referral_direct.rb new file mode 100644 index 000000000..176842aa8 --- /dev/null +++ b/app/models/form/lettings/pages/referral_direct.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralDirect < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_direct" + @depends_on = [{ "referral_type" => 101 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralDirect.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_hsc.rb b/app/models/form/lettings/pages/referral_hsc.rb new file mode 100644 index 000000000..a50ae4def --- /dev/null +++ b/app/models/form/lettings/pages/referral_hsc.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralHsc < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_hsc" + @depends_on = [{ "referral_type" => 104 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralHsc.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_justice.rb b/app/models/form/lettings/pages/referral_justice.rb new file mode 100644 index 000000000..121742438 --- /dev/null +++ b/app/models/form/lettings/pages/referral_justice.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralJustice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_justice" + @depends_on = [{ "referral_type" => 105 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralJustice.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_la.rb b/app/models/form/lettings/pages/referral_la.rb new file mode 100644 index 000000000..b7ad89905 --- /dev/null +++ b/app/models/form/lettings/pages/referral_la.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralLa < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_la" + @depends_on = [{ "referral_type" => 102 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralLa.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_prp.rb b/app/models/form/lettings/pages/referral_prp.rb new file mode 100644 index 000000000..b962f2bf6 --- /dev/null +++ b/app/models/form/lettings/pages/referral_prp.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralPrp < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_prp" + @depends_on = [{ "referral_type" => 103 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralPrp.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_type.rb b/app/models/form/lettings/pages/referral_type.rb new file mode 100644 index 000000000..0836d0fb7 --- /dev/null +++ b/app/models/form/lettings/pages/referral_type.rb @@ -0,0 +1,10 @@ +class Form::Lettings::Pages::ReferralType < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral" + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralType.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/questions/referral_direct.rb b/app/models/form/lettings/questions/referral_direct.rb new file mode 100644 index 000000000..3f67cd36c --- /dev/null +++ b/app/models/form/lettings/questions/referral_direct.rb @@ -0,0 +1,26 @@ +class Form::Lettings::Questions::ReferralDirect < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @copy_key = "lettings.household_situation.referral.direct" + @type = "radio" + @check_answers_card_number = 0 + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + end + + def answer_options + { + "20" => { + "value" => "Homeless households owed a duty and not on a housing register or waiting list", + }, + "2" => { + "value" => "Tenant applied directly for an available property", + }, + "6" => { + "value" => "Relocated through official housing mobility scheme", + }, + }.freeze + end + + QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze +end diff --git a/app/models/form/lettings/questions/referral_hsc.rb b/app/models/form/lettings/questions/referral_hsc.rb new file mode 100644 index 000000000..a5b9c32f0 --- /dev/null +++ b/app/models/form/lettings/questions/referral_hsc.rb @@ -0,0 +1,32 @@ +class Form::Lettings::Questions::ReferralHsc < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @copy_key = "lettings.household_situation.referral.hsc" + @type = "radio" + @check_answers_card_number = 0 + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + end + + def answer_options + { + "15" => { + "value" => "Health service", + }, + "9" => { + "value" => "Community learning disability team", + }, + "14" => { + "value" => "Community mental health team", + }, + "24" => { + "value" => "Adult social services", + }, + "17" => { + "value" => "Children's social care", + }, + }.freeze + end + + QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze +end diff --git a/app/models/form/lettings/questions/referral_justice.rb b/app/models/form/lettings/questions/referral_justice.rb new file mode 100644 index 000000000..0e02e0c42 --- /dev/null +++ b/app/models/form/lettings/questions/referral_justice.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Questions::ReferralJustice < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @copy_key = "lettings.household_situation.referral.justice" + @type = "radio" + @check_answers_card_number = 0 + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + end + + def answer_options + { + "18" => { + "value" => "With a custodial sentence", + }, + "19" => { + "value" => "No custodial sentence", + }, + }.freeze + end + + QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze +end diff --git a/app/models/form/lettings/questions/referral_la.rb b/app/models/form/lettings/questions/referral_la.rb new file mode 100644 index 000000000..7a654df88 --- /dev/null +++ b/app/models/form/lettings/questions/referral_la.rb @@ -0,0 +1,29 @@ +class Form::Lettings::Questions::ReferralLa < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @copy_key = "lettings.household_situation.referral.la" + @type = "radio" + @check_answers_card_number = 0 + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + end + + def answer_options + { + "21" => { + "value" => "Local authority lettings", + }, + "3" => { + "value" => "PRP lettings nominated by a local authority", + }, + "4" => { + "value" => "PRP support lettings referred by a local authority", + }, + "22" => { + "value" => "Other", + }, + }.freeze + end + + QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze +end diff --git a/app/models/form/lettings/questions/referral_prp.rb b/app/models/form/lettings/questions/referral_prp.rb new file mode 100644 index 000000000..44799bb8c --- /dev/null +++ b/app/models/form/lettings/questions/referral_prp.rb @@ -0,0 +1,26 @@ +class Form::Lettings::Questions::ReferralPrp < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @copy_key = "lettings.household_situation.referral.prp" + @type = "radio" + @check_answers_card_number = 0 + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + end + + def answer_options + { + "1" => { + "value" => "Internal transfer from another property with the same landlord", + }, + "10" => { + "value" => "A different PRP landlord", + }, + "23" => { + "value" => "Other", + }, + }.freeze + end + + QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze +end diff --git a/app/models/form/lettings/questions/referral_type.rb b/app/models/form/lettings/questions/referral_type.rb new file mode 100644 index 000000000..fbcb25bc8 --- /dev/null +++ b/app/models/form/lettings/questions/referral_type.rb @@ -0,0 +1,38 @@ +class Form::Lettings::Questions::ReferralType < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral_type" + @copy_key = "lettings.household_situation.referral" + @type = "radio" + @check_answers_card_number = 0 + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + end + + def answer_options + { + "101" => { + "value" => "Direct", + }, + "102" => { + "value" => "From a local authority housing register or waiting list", + }, + "103" => { + "value" => "From a PRP-only housing register or waiting list (no local authority involvement)", + }, + "104" => { + "value" => "Health and social care services", + }, + "105" => { + "value" => "Police, probation, prison or youth offending team", + }, + "7" => { + "value" => "Voluntary agency", + }, + "16" => { + "value" => "Other", + }, + }.freeze + end + + QUESTION_NUMBER_FROM_YEAR = { 2025 => 84 }.freeze +end diff --git a/app/models/form/lettings/subsections/household_situation.rb b/app/models/form/lettings/subsections/household_situation.rb index 8197485b9..3eb4e7691 100644 --- a/app/models/form/lettings/subsections/household_situation.rb +++ b/app/models/form/lettings/subsections/household_situation.rb @@ -28,7 +28,7 @@ class Form::Lettings::Subsections::HouseholdSituation < ::Form::Subsection def referral_questions if form.start_year_2025_or_later? [ - Form::Lettings::Pages::ReferralGroup.new(nil, nil, self), + Form::Lettings::Pages::ReferralType.new(nil, nil, self), Form::Lettings::Pages::ReferralDirect.new(nil, nil, self), Form::Lettings::Pages::ReferralLa.new(nil, nil, self), Form::Lettings::Pages::ReferralPrp.new(nil, nil, self), diff --git a/config/locales/forms/2025/lettings/household_situation.en.yml b/config/locales/forms/2025/lettings/household_situation.en.yml index fbbdcf657..2d8794899 100644 --- a/config/locales/forms/2025/lettings/household_situation.en.yml +++ b/config/locales/forms/2025/lettings/household_situation.en.yml @@ -112,29 +112,38 @@ en: question_text: "How was this letting allocated?" referral: - supported_housing: - prp: - page_header: "" - check_answer_label: "Source of referral for letting" - check_answer_prompt: "" - hint_text: "" - question_text: "What was the source of referral for this letting?" - la: - page_header: "" - check_answer_label: "Source of referral for letting" - check_answer_prompt: "" - hint_text: "You told us that you are a local authority. We have removed some options because of this." - question_text: "What was the source of referral for this letting?" - general_needs: - prp: - page_header: "" - check_answer_label: "Source of referral for letting" - check_answer_prompt: "" - hint_text: "You told us that the needs type is general needs. We have removed some options because of this." - question_text: "What was the source of referral for this letting?" - la: - page_header: "" - check_answer_label: "Source of referral for letting" - check_answer_prompt: "" - hint_text: "You told us that you are a local authority and that the needs type is general needs. We have removed some options because of this." - question_text: "What was the source of referral for this letting?" + page_header: "" + check_answer_label: "Source of referral type" + check_answer_prompt: "Select source of referral" + hint_text: "" + question_text: "What was the source of referral for this letting?" + direct: + page_header: "" + check_answer_label: "Source of referral for letting" + check_answer_prompt: "Select source of referral" + hint_text: "You answered that the referral source was direct, please specify." + question_text: "What was the source of referral for this letting?" + la: + page_header: "" + check_answer_label: "Source of referral for letting" + check_answer_prompt: "Select source of referral" + hint_text: "You answered that the referral source was the local authority, please specify." + question_text: "What was the source of referral for this letting?" + prp: + page_header: "" + check_answer_label: "Source of referral for letting" + check_answer_prompt: "Select source of referral" + hint_text: "You answered that the referral source was a private registered provider, please specify." + question_text: "What was the source of referral for this letting?" + hsc: + page_header: "" + check_answer_label: "Source of referral for letting" + check_answer_prompt: "Select source of referral" + hint_text: "You answered that the referral source was health and social care services, please specify." + question_text: "What was the source of referral for this letting?" + justice: + page_header: "" + check_answer_label: "Source of referral for letting" + check_answer_prompt: "Select source of referral" + hint_text: "You answered that the referral source was either police, probation, prison or youth offending team, please specify." + question_text: "What was the source of referral for this letting?"