Browse Source

Add two-step source of referral for letting questions

CLDC-3843-Lettings-household-situation-change-question-format
Manny Dinssa 6 days ago
parent
commit
64027560a1
  1. 7
      app/models/derived_variables/lettings_log_variables.rb
  2. 11
      app/models/form/lettings/pages/referral_direct.rb
  3. 11
      app/models/form/lettings/pages/referral_hsc.rb
  4. 11
      app/models/form/lettings/pages/referral_justice.rb
  5. 11
      app/models/form/lettings/pages/referral_la.rb
  6. 11
      app/models/form/lettings/pages/referral_prp.rb
  7. 10
      app/models/form/lettings/pages/referral_type.rb
  8. 26
      app/models/form/lettings/questions/referral_direct.rb
  9. 32
      app/models/form/lettings/questions/referral_hsc.rb
  10. 23
      app/models/form/lettings/questions/referral_justice.rb
  11. 29
      app/models/form/lettings/questions/referral_la.rb
  12. 26
      app/models/form/lettings/questions/referral_prp.rb
  13. 38
      app/models/form/lettings/questions/referral_type.rb
  14. 2
      app/models/form/lettings/subsections/household_situation.rb
  15. 61
      config/locales/forms/2025/lettings/household_situation.en.yml

7
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

11
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

11
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

11
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

11
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

11
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

10
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

26
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

32
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

23
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

29
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

26
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

38
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

2
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),

61
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?"

Loading…
Cancel
Save