From 1f2cdfcc75326826288e589e6280092e84da8f79 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 6 Dec 2021 09:26:15 +0000 Subject: [PATCH] Content and field name fixes --- app/models/case_log.rb | 2 + app/models/constants/case_log.rb | 4 +- .../validations/household_validations.rb | 2 +- config/forms/2021_2022.json | 56 ++++++++----------- .../20211203144855_add_postcode_known.rb | 8 +++ db/schema.rb | 4 +- 6 files changed, 40 insertions(+), 36 deletions(-) create mode 100644 db/migrate/20211203144855_add_postcode_known.rb diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 08ec3ae3a..3408d6f5f 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -113,6 +113,8 @@ class CaseLog < ApplicationRecord enum renttype: RENT_TYPE, _suffix: true enum needstype: NEEDS_TYPE, _suffix: true enum lettype: LET_TYPE, _suffix: true + enum postcode_known: POLAR, _suffix: true + enum la_known: POLAR, _suffix: true AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at renttype lettype].freeze OPTIONAL_FIELDS = %w[do_you_know_the_postcode diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb index 0396e7815..90b96609e 100644 --- a/app/models/constants/case_log.rb +++ b/app/models/constants/case_log.rb @@ -17,7 +17,7 @@ module Constants::CaseLog BUILTYPE = { "Purpose built" => 1, - "Conversion" => 2, + "Converted from previous residential or non-residential property" => 2, }.freeze ECSTAT = { @@ -169,7 +169,7 @@ module Constants::CaseLog "First let of leased property" => 17, "Tenant evicted due to arrears" => 10, "Tenant evicted due to ASB or other reason" => 11, - "Tenant died (no succession)" => 5, + "Previous tenant passed away (no succession)" => 5, "Tenant moved to other social housing provider" => 12, "Tenant abandoned property" => 6, "Tenant moved to private sector or other accommodation" => 8, diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 6f9ed06a3..ba29953e7 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -84,7 +84,7 @@ module Validations::HouseholdValidations record.errors.add :unittype_gn, "A shared house must have 1 to 7 bedrooms" end - if record.unittype_gn.include?("Shared") && !record.beds.to_i.between?(1, 3) + if record.unittype_gn.include?("Shared") && !record.beds.to_i.between?(1, 3) && record.beds.present? record.errors.add :unittype_gn, "A shared house with less than two tenants must have 1 to 3 bedrooms" end end diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index d369344b1..72a954f5e 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1109,7 +1109,7 @@ "header": "", "description": "", "questions": { - "do_you_know_the_postcode": { + "postcode_known": { "check_answer_label": "Do you know the property postcode?", "header": "Do you know the postcode?", "hint_text": "", @@ -1135,7 +1135,7 @@ "header": "", "description": "", "questions": { - "do_you_know_the_local_authority": { + "la_known": { "check_answer_label": "Do you know what local authority the property is located in?", "header": "Do you know what local authority the property is located in?", "hint_text": "", @@ -1473,7 +1473,7 @@ } } }, - "depends_on": { "do_you_know_the_local_authority": "Yes" } + "depends_on": { "la_known": "Yes" } }, "why_dont_you_know_la": { "header": "", @@ -1486,15 +1486,15 @@ "type": "text" } }, - "depends_on": { "do_you_know_the_local_authority": "No" } + "depends_on": { "la_known": "No" } }, "first_time_property_let_as_social_housing": { "header": "", "description": "", "questions": { "first_time_property_let_as_social_housing": { - "check_answer_label": "Which type was the property most recently let as?", - "header": "Is this property a relet?", + "check_answer_label": "Is this the first time the property has been let as social housing?", + "header": "Is this the first time the property has been let as social housing?", "hint_text": "", "type": "radio", "answer_options": { @@ -1674,7 +1674,7 @@ "header": "", "description": "", "questions": { - "beds": { + "property_void_date": { "check_answer_label": "void/renewal date", "header": "What is the void or renewal date?", "hint_text": "", @@ -1683,34 +1683,23 @@ }, "depends_on": { "rsnvac": "First let of newbuild property", "tenant_same_property_renewal": "No" } }, - "property_major_repairs": { + "new_build_handover_date": { "header": "", "description": "", "questions": { - "majorrepairs": { - "check_answer_label": "Were major repairs carried out during the void period?", - "header": "Were any major repairs completed during the void period?", + "property_void_date": { + "check_answer_label": "What is the new build handover date?", + "header": "What is the new build handover date?", "hint_text": "", - "type": "radio", - "answer_options": { - "0": "No", - "1": "Yes" - }, - "conditional_for": { - "mrcdate": ["Yes"] - }, - "depends_on": { "tenant_same_property_renewal": "No" } - }, - "mrcdate": { - "check_answer_label": "What was the major repairs completion date?", - "header": "What was the major repairs completion date?", - "hint_text": "For example, 27 3 2007", "type": "date" } }, - "depends_on": { "rsnvac": "First let of newbuild property" } + "depends_on": { + "tenant_same_property_renewal": "No", + "rsnvac": ["First let of conversion, rehabilitation or acquired property?", "First let of leased property"] + } }, - "new_build_handover_date": { + "property_major_repairs": { "header": "", "description": "", "questions": { @@ -1725,13 +1714,16 @@ }, "conditional_for": { "mrcdate": ["Yes"] - }, - "depends_on": { - "tenant_same_property_renewal": "No", - "rsnvac": ["First let of conversion, rehabilitation or acquired property?", "First let of leased property"] } + }, + "mrcdate": { + "check_answer_label": "What was the major repairs completion date?", + "header": "What was the major repairs completion date?", + "hint_text": "For example, 27 3 2007", + "type": "date" } - } + }, + "depends_on": { "rsnvac": "First let of newbuild property", "tenant_same_property_renewal": "No"} } } } diff --git a/db/migrate/20211203144855_add_postcode_known.rb b/db/migrate/20211203144855_add_postcode_known.rb new file mode 100644 index 000000000..13c6c5f8e --- /dev/null +++ b/db/migrate/20211203144855_add_postcode_known.rb @@ -0,0 +1,8 @@ +class AddPostcodeKnown < ActiveRecord::Migration[6.1] + def change + change_table :case_logs, bulk: true do |t| + t.column :postcode_known, :integer + t.column :la_known, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 255b55aa4..38fe84eb0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_12_02_124802) do +ActiveRecord::Schema.define(version: 2021_12_03_144855) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -169,6 +169,8 @@ ActiveRecord::Schema.define(version: 2021_12_02_124802) do t.integer "renttype" t.integer "needstype" t.integer "lettype" + t.integer "postcode_known" + t.integer "la_known" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_case_logs_on_owning_organisation_id"