From e598ca46d1f733a17cb89a993f66150aca588d68 Mon Sep 17 00:00:00 2001 From: Kat Date: Thu, 28 Oct 2021 10:57:29 +0100 Subject: [PATCH] Add net income known field --- config/forms/2021_2022.json | 15 +++++++++++++++ .../20211028095000_add_net_income_known_field.rb | 7 +++++++ db/schema.rb | 3 ++- docs/api/DLUHC-CORE-Data.v1.json | 14 ++++++++++++-- spec/fixtures/complete_case_log.json | 1 + spec/models/case_log_spec.rb | 5 +++-- 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20211028095000_add_net_income_known_field.rb diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index f4cf447c3..6f26e887d 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1458,6 +1458,21 @@ "header": "", "description": "", "questions": { + "net_income_known": { + "check_answer_label": "Income known", + "header": "Do you know the tenant and their partner's net income?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": "Yes", + "1": "No", + "2": "Tenant prefers no to say" + }, + "conditional_for": { + "net_income": ["Yes"], + "net_income_frequency": ["Yes"] + } + }, "net_income": { "check_answer_label": "Income", "header": "What is the tenant’s /and partner’s combined income after tax?", diff --git a/db/migrate/20211028095000_add_net_income_known_field.rb b/db/migrate/20211028095000_add_net_income_known_field.rb new file mode 100644 index 000000000..89e82c29f --- /dev/null +++ b/db/migrate/20211028095000_add_net_income_known_field.rb @@ -0,0 +1,7 @@ +class AddNetIncomeKnownField < ActiveRecord::Migration[6.1] + def change + change_table :case_logs, bulk: true do |t| + t.column :net_income_known, :string + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e7038ce2a..5c4ffd1ea 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_10_28_083105) do +ActiveRecord::Schema.define(version: 2021_10_28_095000) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -133,6 +133,7 @@ ActiveRecord::Schema.define(version: 2021_10_28_083105) do t.boolean "reasonable_preference_reason_do_not_know" t.datetime "discarded_at" t.string "other_tenancy_type" + t.string "net_income_known" t.index ["discarded_at"], name: "index_case_logs_on_discarded_at" end diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json index 7a4d495e2..3820d9aee 100644 --- a/docs/api/DLUHC-CORE-Data.v1.json +++ b/docs/api/DLUHC-CORE-Data.v1.json @@ -937,6 +937,15 @@ "property_wheelchair_accessible": { "type": "boolean" }, + "net_income_known": { + "type": "string", + "minLength": 1, + "enum": [ + "Yes", + "No", + "Tenant prefers not to say" + ] + }, "net_income": { "type": "number" }, @@ -1208,7 +1217,8 @@ "reasonable_preference_reason_medical_grounds", "reasonable_preference_reason_avoid_hardship", "reasonable_preference_reason_do_not_know", - "other_tenancy-type" + "other_tenancy-type", + "net_income_known" ] } }, @@ -1225,4 +1235,4 @@ } } } -} \ No newline at end of file +} diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index 9238bba6a..45e402f4e 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -68,6 +68,7 @@ "property_major_repairs_date": "05/05/2020", "property_number_of_times_relet": 2, "property_wheelchair_accessible": true, + "net_income_known": "Yes", "net_income": 0, "net_income_frequency": null, "net_income_uc_proportion": "Some", diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index 5d1f07918..5e42ebce9 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -198,10 +198,11 @@ RSpec.describe Form, type: :model do # Crossover over tests here as injured must be answered as well for no error it "must be answered if ever served in the forces as a regular" do - expect { + expect do CaseLog.create!(armed_forces: "Yes - a regular", armed_forces_active: "Yes", - armed_forces_injured: "Yes")} + armed_forces_injured: "Yes") + end end end