Browse Source

Update referral type options

pull/2958/head
Manny Dinssa 2 months ago
parent
commit
e8a8c4f276
  1. 7
      app/models/derived_variables/lettings_log_variables.rb
  2. 2
      app/models/form/lettings/pages/referral_direct.rb
  3. 2
      app/models/form/lettings/pages/referral_hsc.rb
  4. 2
      app/models/form/lettings/pages/referral_justice.rb
  5. 2
      app/models/form/lettings/pages/referral_la.rb
  6. 2
      app/models/form/lettings/pages/referral_prp.rb
  7. 14
      app/models/form/lettings/questions/referral_type.rb
  8. 2
      spec/factories/lettings_log.rb
  9. 18
      spec/models/validations/household_validations_spec.rb
  10. 2
      spec/models/validations/property_validations_spec.rb

7
app/models/derived_variables/lettings_log_variables.rb

@ -141,9 +141,8 @@ module DerivedVariables::LettingsLogVariables
self.is_la_inferred = false self.is_la_inferred = false
end end
if referral_type == 7 || referral_type == 16 self.referral = 7 if referral_type == 6
self.referral = referral_type self.referral = 16 if referral_type == 7
end
reset_address_fields! if is_supported_housing? reset_address_fields! if is_supported_housing?
@ -212,7 +211,7 @@ private
if form.start_year_2024_or_later? && (unittype_gn_changed? && unittype_gn_was == 2) if form.start_year_2024_or_later? && (unittype_gn_changed? && unittype_gn_was == 2)
self.beds = nil self.beds = nil
end end
if referral_type_changed? && (referral_type_was == 7 || referral_type_was == 16) if referral_type_changed?
self.referral = nil self.referral = nil
end end
end end

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

@ -2,7 +2,7 @@ class Form::Lettings::Pages::ReferralDirect < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_direct" @id = "referral_direct"
@depends_on = [{ "referral_type" => 101 }] @depends_on = [{ "referral_type" => 1 }]
end end
def questions def questions

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

@ -2,7 +2,7 @@ class Form::Lettings::Pages::ReferralHsc < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_hsc" @id = "referral_hsc"
@depends_on = [{ "referral_type" => 104 }] @depends_on = [{ "referral_type" => 4 }]
end end
def questions def questions

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

@ -2,7 +2,7 @@ class Form::Lettings::Pages::ReferralJustice < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_justice" @id = "referral_justice"
@depends_on = [{ "referral_type" => 105 }] @depends_on = [{ "referral_type" => 5 }]
end end
def questions def questions

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

@ -2,7 +2,7 @@ class Form::Lettings::Pages::ReferralLa < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_la" @id = "referral_la"
@depends_on = [{ "referral_type" => 102 }] @depends_on = [{ "referral_type" => 2 }]
end end
def questions def questions

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

@ -2,7 +2,7 @@ class Form::Lettings::Pages::ReferralPrp < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_prp" @id = "referral_prp"
@depends_on = [{ "referral_type" => 103 }] @depends_on = [{ "referral_type" => 3 }]
end end
def questions def questions

14
app/models/form/lettings/questions/referral_type.rb

@ -10,25 +10,25 @@ class Form::Lettings::Questions::ReferralType < ::Form::Question
def answer_options def answer_options
{ {
"101" => { "1" => {
"value" => "Direct", "value" => "Direct",
}, },
"102" => { "2" => {
"value" => "From a local authority housing register or waiting list", "value" => "From a local authority housing register or waiting list",
}, },
"103" => { "3" => {
"value" => "From a PRP-only housing register or waiting list (no local authority involvement)", "value" => "From a PRP-only housing register or waiting list (no local authority involvement)",
}, },
"104" => { "4" => {
"value" => "Health and social care services", "value" => "Health and social care services",
}, },
"105" => { "5" => {
"value" => "Police, probation, prison or youth offending team", "value" => "Police, probation, prison or youth offending team",
}, },
"7" => { "6" => {
"value" => "Voluntary agency", "value" => "Voluntary agency",
}, },
"16" => { "7" => {
"value" => "Other", "value" => "Other",
}, },
}.freeze }.freeze

2
spec/factories/lettings_log.rb

@ -159,7 +159,7 @@ FactoryBot.define do
is_carehome { 0 } is_carehome { 0 }
declaration { 1 } declaration { 1 }
first_time_property_let_as_social_housing { 0 } first_time_property_let_as_social_housing { 0 }
referral_type { 101 } referral_type { 1 }
referral { 2 } referral { 2 }
uprn_known { 0 } uprn_known { 0 }
joint { 3 } joint { 3 }

18
spec/models/validations/household_validations_spec.rb

@ -129,7 +129,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when referral is not internal transfer" do context "when referral is not internal transfer" do
it "cannot be permanently decanted from another property owned by this landlord" do it "cannot be permanently decanted from another property owned by this landlord" do
record.reason = 1 record.reason = 1
record.referral_type = 101 record.referral_type = 1
record.referral = 2 record.referral = 2
household_validator.validate_reason_for_leaving_last_settled_home(record) household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reason"]) expect(record.errors["reason"])
@ -144,7 +144,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when referral is internal transfer" do context "when referral is internal transfer" do
it "can be permanently decanted from another property owned by this landlord" do it "can be permanently decanted from another property owned by this landlord" do
record.reason = 1 record.reason = 1
record.referral_type = 103 record.referral_type = 3
record.referral = 1 record.referral = 1
household_validator.validate_reason_for_leaving_last_settled_home(record) household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reason"]) expect(record.errors["reason"])
@ -158,7 +158,7 @@ RSpec.describe Validations::HouseholdValidations do
it "cannot have a PRP as landlord and Housing situation before this letting cannot be LA general needs" do it "cannot have a PRP as landlord and Housing situation before this letting cannot be LA general needs" do
record.owning_organisation.provider_type = "PRP" record.owning_organisation.provider_type = "PRP"
record.prevten = 30 record.prevten = 30
record.referral_type = 103 record.referral_type = 3
record.referral = 1 record.referral = 1
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]) expect(record.errors["referral"])
@ -614,7 +614,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when homelessness is assessed" do context "when homelessness is assessed" do
it "can be internal transfer" do it "can be internal transfer" do
record.homeless = 11 record.homeless = 11
record.referral_type = 103 record.referral_type = 3
record.referral = 1 record.referral = 1
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
@ -625,7 +625,7 @@ RSpec.describe Validations::HouseholdValidations do
it "can be non internal transfer" do it "can be non internal transfer" do
record.owning_organisation.provider_type = "PRP" record.owning_organisation.provider_type = "PRP"
record.homeless = 0 record.homeless = 0
record.referral_type = 102 record.referral_type = 2
record.referral = 3 record.referral = 3
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
@ -636,7 +636,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when homelessness is other" do context "when homelessness is other" do
it "cannot be internal transfer" do it "cannot be internal transfer" do
record.referral_type = 103 record.referral_type = 3
record.referral = 1 record.referral = 1
record.homeless = 7 record.homeless = 7
household_validator.validate_referral(record) household_validator.validate_referral(record)
@ -647,7 +647,7 @@ RSpec.describe Validations::HouseholdValidations do
it "can be non internal transfer" do it "can be non internal transfer" do
record.owning_organisation.provider_type = "PRP" record.owning_organisation.provider_type = "PRP"
record.referral_type = 102 record.referral_type = 2
record.referral = 3 record.referral = 3
record.homeless = 1 record.homeless = 1
household_validator.validate_referral(record) household_validator.validate_referral(record)
@ -734,7 +734,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the referral is internal transfer" do context "when the referral is internal transfer" do
it "prevten can be 9" do it "prevten can be 9" do
record.referral_type = 103 record.referral_type = 3
record.referral = 1 record.referral = 1
record.prevten = 9 record.prevten = 9
household_validator.validate_previous_housing_situation(record) household_validator.validate_previous_housing_situation(record)
@ -762,7 +762,7 @@ RSpec.describe Validations::HouseholdValidations do
{ code: 29, label: "Prison or approved probation hostel" }, { code: 29, label: "Prison or approved probation hostel" },
].each do |prevten| ].each do |prevten|
it "prevten cannot be #{prevten[:code]}" do it "prevten cannot be #{prevten[:code]}" do
record.referral_type = 103 record.referral_type = 3
record.referral = 1 record.referral = 1
record.prevten = prevten[:code] record.prevten = prevten[:code]
household_validator.validate_previous_housing_situation(record) household_validator.validate_previous_housing_situation(record)

2
spec/models/validations/property_validations_spec.rb

@ -168,7 +168,7 @@ RSpec.describe Validations::PropertyValidations do
it "expects that the letting source can be a referral" do it "expects that the letting source can be a referral" do
log.prevten = 0 log.prevten = 0
log.referral_type = 101 log.referral_type = 1
log.referral = 2 log.referral = 2
property_validator.validate_rsnvac(log) property_validator.validate_rsnvac(log)
expect(log.errors["rsnvac"]).to be_empty expect(log.errors["rsnvac"]).to be_empty

Loading…
Cancel
Save