diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 934841492..1dbcc54a6 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -161,8 +161,8 @@ class CaseLog < ApplicationRecord end def is_supported_housing? - # 0: Supported Housing - !!needstype&.zero? + # 2: Supported Housing + needstype == 2 end def has_hbrentshortfall? diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index a85042996..49dfe5357 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -116,7 +116,7 @@ private }.freeze LANDLORD_VALUES = { 1 => :this_landlord, 2 => :other_landlord }.freeze - NEEDSTYPE_VALUES = { 0 => :supported_housing, 1 => :general_needs }.freeze + NEEDSTYPE_VALUES = { 2 => :supported_housing, 1 => :general_needs }.freeze def validate_charges(record) %i[scharge pscharge supcharg].each do |charge| diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 8061bc2bd..f1a1abcd5 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -22,7 +22,7 @@ "1": { "value": "General needs" }, - "0": { + "2": { "value": "Supported housing" } } @@ -1090,7 +1090,7 @@ }, "depends_on": [ { - "needstype": 0 + "needstype": 2 } ] } @@ -3587,7 +3587,7 @@ "depends_on": [ { "renewal": 1, - "needstype": 0 + "needstype": 2 } ] }, @@ -4383,7 +4383,7 @@ "depends_on": [ { "managing_organisation.provider_type": "LA", - "needstype": 0, + "needstype": 2, "renewal": 0 } ] @@ -4443,7 +4443,7 @@ "depends_on": [ { "managing_organisation.provider_type": "PRP", - "needstype": 0, + "needstype": 2, "renewal": 0 } ] @@ -4658,7 +4658,7 @@ }, "depends_on": [ { - "needstype": 0 + "needstype": 2 } ] }, @@ -4748,62 +4748,62 @@ "depends_on": [ { "period": 1, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 1, - "needstype": 0, + "needstype": 2, "household_charge": null }, { "period": 5, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 5, - "needstype": 0, + "needstype": 2, "household_charge": null }, { "period": 6, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 6, - "needstype": 0, + "needstype": 2, "household_charge": null }, { "period": 7, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 7, - "needstype": 0, + "needstype": 2, "household_charge": null }, { "period": 8, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 8, - "needstype": 0, + "needstype": 2, "household_charge": null }, { "period": 9, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 9, - "needstype": 0, + "needstype": 2, "household_charge": null } ] @@ -4845,12 +4845,12 @@ "depends_on": [ { "period": 2, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 2, - "needstype": 0, + "needstype": 2, "household_charge": null } ] @@ -4892,12 +4892,12 @@ "depends_on": [ { "period": 3, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 3, - "needstype": 0, + "needstype": 2, "household_charge": null } ] @@ -4939,12 +4939,12 @@ "depends_on": [ { "period": 4, - "needstype": 0, + "needstype": 2, "household_charge": 0 }, { "period": 4, - "needstype": 0, + "needstype": 2, "household_charge": null } ] diff --git a/spec/fixtures/exports/case_logs.xml b/spec/fixtures/exports/case_logs.xml index 72feac2f4..560d362d6 100644 --- a/spec/fixtures/exports/case_logs.xml +++ b/spec/fixtures/exports/case_logs.xml @@ -44,7 +44,7 @@ 0 5 1 - 3 + 2 SE26RT 6 7 diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 96e3be018..210b476b4 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -255,7 +255,7 @@ RSpec.describe CaseLog do before { case_log.owning_organisation.update!(provider_type: 2) } context "when the rent type is intermediate rent and supported housing" do it "correctly derives and saves lettype" do - case_log.update!(rent_type: 4, needstype: 0) + case_log.update!(rent_type: 4, needstype: 2) record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0] expect(case_log.lettype).to eq(10) expect(record_from_db["lettype"]).to eq(10) @@ -273,7 +273,7 @@ RSpec.describe CaseLog do context "when the rent type is affordable rent and supported housing" do it "correctly derives and saves lettype" do - case_log.update!(rent_type: 2, needstype: 0) + case_log.update!(rent_type: 2, needstype: 2) record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0] expect(case_log.lettype).to eq(6) expect(record_from_db["lettype"]).to eq(6) @@ -291,7 +291,7 @@ RSpec.describe CaseLog do context "when the rent type is social rent and supported housing" do it "correctly derives and saves lettype" do - case_log.update!(rent_type: 0, needstype: 0) + case_log.update!(rent_type: 0, needstype: 2) record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0] expect(case_log.lettype).to eq(2) expect(record_from_db["lettype"]).to eq(2) @@ -1051,7 +1051,7 @@ RSpec.describe CaseLog do context "when the rent type is intermediate rent and supported housing" do it "correctly derives and saves lettype" do - case_log.update!(rent_type: 4, needstype: 0) + case_log.update!(rent_type: 4, needstype: 2) record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0] expect(case_log.lettype).to eq(12) expect(record_from_db["lettype"]).to eq(12) @@ -1069,7 +1069,7 @@ RSpec.describe CaseLog do context "when the rent type is affordable rent and supported housing" do it "correctly derives and saves lettype" do - case_log.update!(rent_type: 2, needstype: 0) + case_log.update!(rent_type: 2, needstype: 2) record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0] expect(case_log.lettype).to eq(8) expect(record_from_db["lettype"]).to eq(8) @@ -1087,7 +1087,7 @@ RSpec.describe CaseLog do context "when the rent type is social rent and supported housing" do it "correctly derives and saves lettype" do - case_log.update!(rent_type: 0, needstype: 0) + case_log.update!(rent_type: 0, needstype: 2) record_from_db = ActiveRecord::Base.connection.execute("select lettype from case_logs where id=#{case_log.id}").to_a[0] expect(case_log.lettype).to eq(4) expect(record_from_db["lettype"]).to eq(4) @@ -1477,7 +1477,7 @@ RSpec.describe CaseLog do described_class.create({ managing_organisation: owning_organisation, owning_organisation:, - needstype: 0, + needstype: 2, }) end diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index 2ab76fb1b..56ba77479 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/spec/models/validations/financial_validations_spec.rb @@ -301,7 +301,7 @@ RSpec.describe Validations::FinancialValidations do context "when needstype is supported housing" do before do - record.needstype = 0 + record.needstype = 2 record.landlord = 1 end @@ -497,7 +497,7 @@ RSpec.describe Validations::FinancialValidations do context "when needstype is supported housing" do before do - record.needstype = 0 + record.needstype = 2 record.landlord = 2 end