diff --git a/app/models/case_log.rb b/app/models/case_log.rb index b74297ed5..5e8380e7a 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -135,8 +135,9 @@ class CaseLog < ApplicationRecord enum postcode_known: POLAR, _suffix: true enum la_known: POLAR, _suffix: true enum net_income_known: NET_INCOME_KNOWN, _suffix: true - enum nocharge: POLAR3, _suffix: true + enum household_charge: POLAR, _suffix: true enum is_carehome: POLAR, _suffix: true + enum nocharge: POLAR, _suffix: true AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing].freeze @@ -260,6 +261,7 @@ private self.totadult = get_totadult self.tcharge = brent.to_i + scharge.to_i + pscharge.to_i + supcharg.to_i self.has_benefits = get_has_benefits + self.nocharge = household_charge == "Yes" ? "No" : "Yes" end def process_postcode_changes! diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index cc51ad710..5b1659927 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1948,7 +1948,7 @@ "header": "", "description": "", "questions": { - "nocharge": { + "household_charge": { "check_answer_label": "Does the household pay rent or other charges for the accommodation?", "header": "Does the household pay rent or other charges for the accommodation?", "hint_text": "", @@ -1984,9 +1984,9 @@ } }, "depends_on" : [{ - "nocharge": "Yes" + "household_charge": "Yes" },{ - "nocharge": null + "household_charge": null }] }, "care_home_weekly": { @@ -2019,51 +2019,51 @@ "depends_on" : [{ "period": "Weekly for 52 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Weekly for 52 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null },{ "period": "Weekly for 50 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Weekly for 50 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null },{ "period": "Weekly for 49 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Weekly for 49 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null },{ "period": "Weekly for 48 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Weekly for 48 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null },{ "period": "Weekly for 47 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Weekly for 47 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null },{ "period": "Weekly for 46 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Weekly for 46 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null } ] }, @@ -2097,11 +2097,11 @@ "depends_on" : [{ "period": "Every 2 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Every 2 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null }] }, "care_home_4_weekly": { @@ -2134,11 +2134,11 @@ "depends_on" : [{ "period": "Every 4 weeks", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Every 4 weeks", "needstype": "Supported housing", - "nocharge": null + "household_charge": null }] }, "care_home_monthly": { @@ -2171,11 +2171,11 @@ "depends_on" : [{ "period": "Every calendar month", "needstype": "Supported housing", - "nocharge": "Yes" + "household_charge": "Yes" },{ "period": "Every calendar month", "needstype": "Supported housing", - "nocharge": null + "household_charge": null }] }, "rent_weekly": { @@ -2245,100 +2245,100 @@ }, "depends_on" : [{ "period": "Weekly for 52 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": "No" },{ "period": "Weekly for 52 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": "No" },{ "period": "Weekly for 50 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": "No" },{ "period": "Weekly for 50 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": "No" },{ "period": "Weekly for 49 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": "No" },{ "period": "Weekly for 49 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": "No" },{ "period": "Weekly for 48 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": "No" },{ "period": "Weekly for 48 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": "No" },{ "period": "Weekly for 47 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": "No" },{ "period": "Weekly for 47 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": "No" },{ "period": "Weekly for 46 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": "No" },{ "period": "Weekly for 46 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": "No" }, { "period": "Weekly for 52 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": null },{ "period": "Weekly for 52 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": null },{ "period": "Weekly for 50 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": null },{ "period": "Weekly for 50 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": null },{ "period": "Weekly for 49 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": null },{ "period": "Weekly for 49 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": null },{ "period": "Weekly for 48 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": null },{ "period": "Weekly for 48 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": null },{ "period": "Weekly for 47 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": null },{ "period": "Weekly for 47 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": null },{ "period": "Weekly for 46 weeks", - "nocharge": "Yes", + "household_charge": "Yes", "is_carehome": null },{ "period": "Weekly for 46 weeks", - "nocharge": null, + "household_charge": null, "is_carehome": null } ] @@ -2409,20 +2409,20 @@ } }, "depends_on" : [{ - "nocharge": "Yes", + "household_charge": "Yes", "period": "Every 2 weeks", "is_carehome": "No" },{ - "nocharge": null, + "household_charge": null, "period": "Every 2 weeks", "is_carehome": "No" }, { - "nocharge": "Yes", + "household_charge": "Yes", "period": "Every 2 weeks", "is_carehome": null },{ - "nocharge": null, + "household_charge": null, "period": "Every 2 weeks", "is_carehome": null }] @@ -2493,20 +2493,20 @@ } }, "depends_on" : [{ - "nocharge": "Yes", + "household_charge": "Yes", "period": "Every 4 weeks", "is_carehome": "No" },{ - "nocharge": null, + "household_charge": null, "period": "Every 4 weeks", "is_carehome": "No" }, { - "nocharge": "Yes", + "household_charge": "Yes", "period": "Every 4 weeks", "is_carehome": null },{ - "nocharge": null, + "household_charge": null, "period": "Every 4 weeks", "is_carehome": null }] @@ -2577,20 +2577,20 @@ } }, "depends_on" : [{ - "nocharge": "Yes", + "household_charge": "Yes", "period": "Every calendar month", "is_carehome": "No" },{ - "nocharge": null, + "household_charge": null, "period": "Every calendar month", "is_carehome": "No" }, { - "nocharge": "Yes", + "household_charge": "Yes", "period": "Every calendar month", "is_carehome": null },{ - "nocharge": null, + "household_charge": null, "period": "Every calendar month", "is_carehome": null } @@ -2611,7 +2611,7 @@ } } }, - "depends_on": [{ "has_benefits": "Yes", "nocharge": "Yes" },{ "has_benefits": "yes", "nocharge": null }] + "depends_on": [{ "has_benefits": "Yes", "household_charge": "Yes" },{ "has_benefits": "yes", "household_charge": null }] }, "rent_shortfall_amount":{ "header": "", diff --git a/db/migrate/20220112151048_add_household_charge_field.rb b/db/migrate/20220112151048_add_household_charge_field.rb new file mode 100644 index 000000000..2647d0a42 --- /dev/null +++ b/db/migrate/20220112151048_add_household_charge_field.rb @@ -0,0 +1,7 @@ +class AddHouseholdChargeField < ActiveRecord::Migration[7.0] + def change + change_table :case_logs, bulk: true do |t| + t.column :household_charge, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index e4718b1ef..ccf1158ec 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: 2022_01_11_140400) do +ActiveRecord::Schema.define(version: 2022_01_12_151048) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -19,8 +19,8 @@ ActiveRecord::Schema.define(version: 2022_01_11_140400) do t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" + t.datetime "reset_password_sent_at", precision: 6 + t.datetime "remember_created_at", precision: 6 t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end @@ -124,7 +124,7 @@ ActiveRecord::Schema.define(version: 2022_01_11_140400) do t.integer "rp_medwel" t.integer "rp_hardship" t.integer "rp_dontknow" - t.datetime "discarded_at" + t.datetime "discarded_at", precision: 6 t.string "tenancyother" t.integer "override_net_income_validation" t.string "gdpr_acceptance" @@ -149,22 +149,22 @@ ActiveRecord::Schema.define(version: 2022_01_11_140400) do t.string "ppostc1" t.string "ppostc2" t.integer "property_relet" - t.datetime "mrcdate" + t.datetime "mrcdate", precision: 6 t.integer "mrcday" t.integer "mrcmonth" t.integer "mrcyear" t.integer "other_hhmemb" t.integer "incref" - t.datetime "sale_completion_date" - t.datetime "startdate" + t.datetime "sale_completion_date", precision: 6 + t.datetime "startdate", precision: 6 t.integer "armedforces" t.integer "first_time_property_let_as_social_housing" t.string "why_dont_you_know_la" t.integer "unitletas" t.integer "builtype" - t.datetime "property_void_date" t.bigint "owning_organisation_id" t.bigint "managing_organisation_id" + t.datetime "property_void_date", precision: 6 t.integer "renttype" t.integer "needstype" t.integer "lettype" @@ -182,6 +182,7 @@ ActiveRecord::Schema.define(version: 2022_01_11_140400) do t.integer "nocharge" t.integer "is_carehome" t.decimal "chcharge" + t.integer "household_charge" 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" @@ -206,15 +207,15 @@ ActiveRecord::Schema.define(version: 2022_01_11_140400) do t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" + t.datetime "reset_password_sent_at", precision: 6 + t.datetime "remember_created_at", precision: 6 t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.string "name" t.bigint "organisation_id" t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" + t.datetime "current_sign_in_at", precision: 6 + t.datetime "last_sign_in_at", precision: 6 t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.integer "role" diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index 4e2392c84..8f00d862e 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -148,7 +148,8 @@ FactoryBot.define do armedforces { 1 } builtype { 1 } unitletas { 2 } - nocharge { "No" } + household_charge { "Yes" } + has_benefits { "Yes" } is_carehome { "No" } chcharge { 7 } end diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index 7fd858f44..fc31d6330 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -145,7 +145,8 @@ "void_or_renewal_date": "05/05/2020", "tenant_same_property_renewal": "Yes", "new_build_handover_date": "01/01/2019", - "nocharge": "No", + "has_benefits": "Yes", + "household_charge": "Yes", "is_carehome": "Yes", "chcharge": "6" }