From c6a1be61c6c41781c9cb31d984dbee43bad1ce0f Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 9 Nov 2021 14:26:00 +0000 Subject: [PATCH] Update housing benefits fields --- app/admin/case_logs.rb | 2 +- app/constants/db_enums.rb | 12 ++++++++++++ app/models/case_log.rb | 2 ++ app/validations/financial_validations.rb | 8 ++++---- config/forms/2021_2022.json | 11 ++++++----- .../20211108134601_further_core_migrations.rb | 6 ++++++ .../20211108143649_change_reason_type.rb | 6 ++++++ db/schema.rb | 6 +++--- docs/api/DLUHC-CORE-Data.v1.json | 18 +++++++++--------- spec/features/case_log_spec.rb | 2 +- spec/fixtures/complete_case_log.json | 7 ++++--- spec/fixtures/forms/test_form.json | 2 +- spec/helpers/check_answers_helper_spec.rb | 2 +- spec/helpers/tasklist_helper_spec.rb | 2 +- spec/models/case_log_spec.rb | 8 ++++---- spec/models/form_spec.rb | 2 +- 16 files changed, 62 insertions(+), 34 deletions(-) diff --git a/app/admin/case_logs.rb b/app/admin/case_logs.rb index c81eb643e..c3716ad6d 100644 --- a/app/admin/case_logs.rb +++ b/app/admin/case_logs.rb @@ -2,7 +2,7 @@ ActiveAdmin.register CaseLog do # See permitted parameters documentation: # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters permit_params do - permitted = %i[status tenant_code age1 sex1 tenant_ethnic_group tenant_nationality previous_housing_situation armed_forces ecstat1 hhmemb relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 person_7_gender ecstat7 relat8 age8 sex8 ecstat8 homelessness reason benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured armed_forces_partner medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider la previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date property_major_repairs property_major_repairs_date property_number_of_times_relet property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion housing_benefit rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge outstanding_amount time_lived_in_la time_on_la_waiting_list prevloc property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting outstanding_rent_or_charges other_reason accessibility_requirements_fully_wheelchair_accessible_housing accessibility_requirements_wheelchair_access_to_essential_rooms accessibility_requirements_level_access_housing accessibility_requirements_other_disability_requirements accessibility_requirements_no_disability_requirements accessibility_requirements_do_not_know accessibility_requirements_prefer_not_to_say condition_effects_vision condition_effects_hearing condition_effects_mobility condition_effects_dexterity condition_effects_stamina condition_effects_learning condition_effects_memory condition_effects_mental_health condition_effects_social_or_behavioral condition_effects_other condition_effects_prefer_not_to_say reasonable_preference_reason_homeless reasonable_preference_reason_unsatisfactory_housing reasonable_preference_reason_medical_grounds reasonable_preference_reason_avoid_hardship reasonable_preference_reason_do_not_know other_tenancy_type override_net_income_validation net_income_known] + permitted = %i[status tenant_code age1 sex1 tenant_ethnic_group tenant_nationality previous_housing_situation armed_forces ecstat1 hhmemb relat2 age2 sex2 ecstat2 relat3 age3 sex3 ecstat3 relat4 age4 sex4 ecstat4 relat5 age5 sex5 ecstat5 relat6 age6 sex6 ecstat6 relat7 age7 person_7_gender ecstat7 relat8 age8 sex8 ecstat8 homelessness reason benefit_cap_spare_room_subsidy armed_forces_active armed_forces_injured armed_forces_partner medical_conditions pregnancy accessibility_requirements condition_effects tenancy_code tenancy_start_date starter_tenancy fixed_term_tenancy tenancy_type letting_type letting_provider la previous_postcode property_relet property_vacancy_reason property_reference property_unit_type property_building_type property_number_of_bedrooms property_void_date property_major_repairs property_major_repairs_date property_number_of_times_relet property_wheelchair_accessible net_income net_income_frequency net_income_uc_proportion hb rent_frequency basic_rent service_charge personal_service_charge support_charge total_charge tshortfall time_lived_in_la time_on_la_waiting_list prevloc property_postcode reasonable_preference reasonable_preference_reason cbl_letting chr_letting cap_letting hbrentshortfall other_reason accessibility_requirements_fully_wheelchair_accessible_housing accessibility_requirements_wheelchair_access_to_essential_rooms accessibility_requirements_level_access_housing accessibility_requirements_other_disability_requirements accessibility_requirements_no_disability_requirements accessibility_requirements_do_not_know accessibility_requirements_prefer_not_to_say condition_effects_vision condition_effects_hearing condition_effects_mobility condition_effects_dexterity condition_effects_stamina condition_effects_learning condition_effects_memory condition_effects_mental_health condition_effects_social_or_behavioral condition_effects_other condition_effects_prefer_not_to_say reasonable_preference_reason_homeless reasonable_preference_reason_unsatisfactory_housing reasonable_preference_reason_medical_grounds reasonable_preference_reason_avoid_hardship reasonable_preference_reason_do_not_know other_tenancy_type override_net_income_validation net_income_known] permitted end diff --git a/app/constants/db_enums.rb b/app/constants/db_enums.rb index 41486713b..0b2f6ea40 100644 --- a/app/constants/db_enums.rb +++ b/app/constants/db_enums.rb @@ -260,6 +260,18 @@ module DbEnums } end + def self.housing_benefit + { + "Housing Benefit, but not Universal Credit" => 1, + "Universal Credit with housing element, but not Housing Benefit" => 6, + "Universal Credit without housing element and no Housing Benefit" => 7, + "Universal Credit and Housing Benefit" => 8, + "Not Housing Benefit or Universal Credit" => 9, + "Do not know" => 3, + "Prefer not to say" => 100, + } + end + def self.reason { "Permanently decanted from another property owned by this landlord" => 1, diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 046008d68..201f64aae 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -105,6 +105,8 @@ class CaseLog < ApplicationRecord enum la: DbEnums.la, _suffix: true enum prevloc: DbEnums.la, _suffix: true enum majorrepairs: DbEnums.polar, _suffix: true + enum hb: DbEnums.housing_benefit, _suffix: true + enum hbrentshortfall: DbEnums.polar_with_unknown, _suffix: true AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze diff --git a/app/validations/financial_validations.rb b/app/validations/financial_validations.rb index dd4b58baf..3d2ce8732 100644 --- a/app/validations/financial_validations.rb +++ b/app/validations/financial_validations.rb @@ -2,11 +2,11 @@ module FinancialValidations # Validations methods need to be called 'validate_' to run on model save # or 'validate_' to run on submit as well def validate_outstanding_rent_amount(record) - if record.outstanding_rent_or_charges == "Yes" && record.outstanding_amount.blank? - record.errors.add :outstanding_amount, "You must answer the oustanding amout question if you have outstanding rent or charges." + if record.hbrentshortfall == "Yes" && record.tshortfall.blank? + record.errors.add :tshortfall, "You must answer the oustanding amout question if you have outstanding rent or charges." end - if record.outstanding_rent_or_charges == "No" && record.outstanding_amount.present? - record.errors.add :outstanding_amount, "You must not answer the oustanding amout question if you don't have outstanding rent or charges." + if record.hbrentshortfall == "No" && record.tshortfall.present? + record.errors.add :tshortfall, "You must not answer the oustanding amout question if you don't have outstanding rent or charges." end end diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 9aa50caa5..37c61a63c 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1700,7 +1700,7 @@ "header": "", "description": "", "questions": { - "housing_benefit": { + "hb": { "check_answer_label": "Universal Credit & Housing Benefit", "header": "Is the tenant likely to be in receipt of any of these housing-related benefits?", "hint_text": "", @@ -1813,20 +1813,21 @@ "step": 1, "readonly": true }, - "outstanding_rent_or_charges": { + "hbrentshortfall": { "check_answer_label": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?", "header": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?", "hint_text": "", "type": "radio", "answer_options": { "0": "Yes", - "1": "No" + "1": "No", + "2": "Do not know" }, "conditional_for": { - "outstanding_amount": ["Yes"] + "tshortfall": ["Yes"] } }, - "outstanding_amount": { + "tshortfall": { "check_answer_label": "Outstanding amount", "header": "What do you expect the amount to be?", "hint_text": "If the amount is unknown you can estimate", diff --git a/db/migrate/20211108134601_further_core_migrations.rb b/db/migrate/20211108134601_further_core_migrations.rb index b657157ff..3f58d6b8c 100644 --- a/db/migrate/20211108134601_further_core_migrations.rb +++ b/db/migrate/20211108134601_further_core_migrations.rb @@ -6,6 +6,9 @@ class FurtherCoreMigrations < ActiveRecord::Migration[6.1] rename_column :case_logs, :property_major_repairs, :majorrepairs rename_column :case_logs, :property_location, :la rename_column :case_logs, :previous_la, :prevloc + rename_column :case_logs, :housing_benefit, :hb + rename_column :case_logs, :outstanding_rent_or_charges, :hbrentshortfall + rename_column :case_logs, :outstanding_amount, :tshortfall add_column :case_logs, :postcode, :string add_column :case_logs, :postcod2, :string end @@ -17,6 +20,9 @@ class FurtherCoreMigrations < ActiveRecord::Migration[6.1] rename_column :case_logs, :majorrepairs, :property_major_repairs rename_column :case_logs, :la, :property_location rename_column :case_logs, :prevloc, :previous_la + rename_column :case_logs, :hb, :housing_benefit + rename_column :case_logs, :hbrentshortfall, :outstanding_rent_or_charges + rename_column :case_logs, :tshortfall, :outstanding_amount remove_column :case_logs, :postcode remove_column :case_logs, :postcod2 end diff --git a/db/migrate/20211108143649_change_reason_type.rb b/db/migrate/20211108143649_change_reason_type.rb index da159550b..3679f4cc5 100644 --- a/db/migrate/20211108143649_change_reason_type.rb +++ b/db/migrate/20211108143649_change_reason_type.rb @@ -3,6 +3,9 @@ class ChangeReasonType < ActiveRecord::Migration[6.1] change_table :case_logs, bulk: true do |t| t.change :reason, "integer USING reason::integer" t.change :majorrepairs, "integer USING majorrepairs::integer" + t.change :hb, "integer USING hb::integer" + t.change :hbrentshortfall, "integer USING hbrentshortfall::integer" + t.change :tshortfall, "integer USING tshortfall::integer" end end @@ -10,6 +13,9 @@ class ChangeReasonType < ActiveRecord::Migration[6.1] change_table :case_logs, bulk: true do |t| t.change :reason, :string t.change :majorrepairs, :string + t.change :hb, :string + t.change :hbrentshortfall, :string + t.change :tshortfall, :string end end end diff --git a/db/schema.rb b/db/schema.rb index dbc3ea5e3..2228ee418 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -89,14 +89,14 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do t.integer "earnings" t.integer "incfreq" t.integer "benefits" - t.string "housing_benefit" + t.integer "hb" t.integer "period" t.integer "brent" t.integer "scharge" t.integer "pscharge" t.integer "supcharg" t.integer "tcharge" - t.string "outstanding_amount" + t.integer "tshortfall" t.integer "layear" t.integer "lawaitlist" t.string "prevloc" @@ -106,7 +106,7 @@ ActiveRecord::Schema.define(version: 2021_11_08_143649) do t.integer "cbl" t.integer "chr" t.integer "cap" - t.string "outstanding_rent_or_charges" + t.integer "hbrentshortfall" t.string "other_reason_for_leaving_last_settled_home" t.integer "housingneeds_a" t.integer "housingneeds_b" diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json index 1fae7e5e7..654307a59 100644 --- a/docs/api/DLUHC-CORE-Data.v1.json +++ b/docs/api/DLUHC-CORE-Data.v1.json @@ -325,14 +325,14 @@ "earnings": 1000, "incfreq": "Monthly", "benefits": "Some", - "housing_benefit": "Universal Credit with housing element, but not Housing Benefit", + "hb": "Universal Credit with housing element, but not Housing Benefit", "period": "Weekly", "brent": 200, "scharge": 50, "pscharge": 40, "supcharg": 35, "tcharge": 325, - "outstanding_amount": "Yes", + "tshortfall": "Yes", "layear": "1 to 2 years", "lawaitlist": "Less than 1 year", "prevloc": "Ashford", @@ -342,7 +342,7 @@ "cbl": true, "chr": false, "cap": false, - "outstanding_rent_or_charges": 25, + "hbrentshortfall": "Yes", "other_reason_for_leaving_last_settled_home": "Other reason", "housingneeds_a": true, "housingneeds_b": false, @@ -902,7 +902,7 @@ "minLength": 1, "enum": ["All", "Some", "None", "Do not know"] }, - "housing_benefit": { + "hb": { "type": "string", "minLength": 1 }, @@ -925,7 +925,7 @@ "tcharge": { "type": "number" }, - "outstanding_amount": { + "tshortfall": { "type": "string", "minLength": 1 }, @@ -962,7 +962,7 @@ "cap": { "type": "boolean" }, - "outstanding_rent_or_charges": { + "hbrentshortfall": { "type": "number" }, "other_reason_for_leaving_last_settled_home": { @@ -1114,14 +1114,14 @@ "earnings", "incfreq", "benefits", - "housing_benefit", + "hb", "period", "brent", "scharge", "pscharge", "supcharg", "tcharge", - "outstanding_amount", + "tshortfall", "layear", "lawaitlist", "prevloc", @@ -1131,7 +1131,7 @@ "cbl", "chr", "cap", - "outstanding_rent_or_charges", + "hbrentshortfall", "other_reason_for_leaving_last_settled_home", "housingneeds_a", "housingneeds_b", diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index 5a8ebe211..7fae84756 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -25,7 +25,7 @@ RSpec.describe "Test Features" do click_button("Save and continue") choose("case-log-benefits-all-field") click_button("Save and continue") - choose("case-log-housing-benefit-housing-benefit-but-not-universal-credit-field") + choose("case-log-hb-housing-benefit-but-not-universal-credit-field") click_button("Save and continue") end diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index 4d87a702e..5429b2f4f 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -71,7 +71,7 @@ "earnings": 0, "incfreq": null, "benefits": "Some", - "housing_benefit": "Universal Credit with housing element, but not Housing Benefit", + "hb": "Universal Credit with housing element, but not Housing Benefit", "period": "Fortnightly", "brent": 200, "scharge": 50, @@ -88,7 +88,8 @@ "cbl": "Yes", "chr": "Yes", "cap": "No", - "outstanding_rent_or_charges": 25, + "hbrentshortfall": "Yes", + "tshortfall": 12, "other_reason_for_leaving_last_settled_home": null, "housingneeds_a": "Yes", "housingneeds_b": "No", @@ -127,7 +128,7 @@ "sale_completion_date": "", "purchaser_code": "", "propcode": "123", - "majorrepairs": "yes", + "majorrepairs": "Yes", "postcode": "a1", "postcod2": "w3" } diff --git a/spec/fixtures/forms/test_form.json b/spec/fixtures/forms/test_form.json index 3f428fbf7..1e7fe69ab 100644 --- a/spec/fixtures/forms/test_form.json +++ b/spec/fixtures/forms/test_form.json @@ -348,7 +348,7 @@ }, "housing_benefit": { "questions": { - "housing_benefit": { + "hb": { "check_answer_label": "Universal Credit & Housing Benefit", "header": "Is the tenant likely to be in receipt of any of these housing-related benefits?", "type": "radio", diff --git a/spec/helpers/check_answers_helper_spec.rb b/spec/helpers/check_answers_helper_spec.rb index fb8deec77..7ad04f081 100644 --- a/spec/helpers/check_answers_helper_spec.rb +++ b/spec/helpers/check_answers_helper_spec.rb @@ -127,7 +127,7 @@ RSpec.describe CheckAnswersHelper do it "returns total questions" do result = total_questions(subsection, case_log, form) expect(result.class).to eq(Hash) - expected_keys = %w[earnings incfreq benefits housing_benefit] + expected_keys = %w[earnings incfreq benefits hb] expect(result.keys).to eq(expected_keys) end diff --git a/spec/helpers/tasklist_helper_spec.rb b/spec/helpers/tasklist_helper_spec.rb index db9ac3cae..e900363f2 100644 --- a/spec/helpers/tasklist_helper_spec.rb +++ b/spec/helpers/tasklist_helper_spec.rb @@ -33,7 +33,7 @@ RSpec.describe TasklistHelper do case_log["earnings"] = "value" case_log["incfreq"] = "Weekly" case_log["benefits"] = "All" - case_log["housing_benefit"] = "Do not know" + case_log["hb"] = "Do not know" status = get_subsection_status("income_and_benefits", case_log, income_and_benefits_questions) expect(status).to eq(:completed) diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 3d0422d57..438bf3c55 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -139,15 +139,15 @@ RSpec.describe Form, type: :model do context "outstanding rent or charges validation" do it "must be anwered if answered yes to outstanding rent or charges" do expect { - CaseLog.create!(outstanding_rent_or_charges: "Yes", - outstanding_amount: nil) + CaseLog.create!(hbrentshortfall: "Yes", + tshortfall: nil) }.to raise_error(ActiveRecord::RecordInvalid) end it "must be not be anwered if answered no to outstanding rent or charges" do expect { - CaseLog.create!(outstanding_rent_or_charges: "No", - outstanding_amount: 99) + CaseLog.create!(hbrentshortfall: "No", + tshortfall: 99) }.to raise_error(ActiveRecord::RecordInvalid) end end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index f4e554356..18e15c6b4 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -39,7 +39,7 @@ RSpec.describe Form, type: :model do it "returns all questions for subsection" do result = form.questions_for_subsection(subsection) expect(result.length).to eq(4) - expect(result.keys).to eq(%w[earnings incfreq benefits housing_benefit]) + expect(result.keys).to eq(%w[earnings incfreq benefits hb]) end end end