From 5e9ba5d45095e7514dc2c4118919b284d2b450e3 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 18 Jan 2022 09:39:16 +0000 Subject: [PATCH] Update net income frequency answer options; --- app/models/case_log.rb | 8 +++++--- app/models/constants/case_log.rb | 6 +++--- app/models/form/subsection.rb | 2 +- config/forms/2021_2022.json | 21 +++++++++++---------- spec/factories/case_log.rb | 2 +- spec/fixtures/complete_case_log.json | 2 +- spec/fixtures/forms/2021_2022.json | 4 ++-- spec/models/case_log_spec.rb | 6 +++--- spec/models/form/question_spec.rb | 4 ++-- 9 files changed, 29 insertions(+), 26 deletions(-) diff --git a/app/models/case_log.rb b/app/models/case_log.rb index 7f5527fc5..e689768ac 100644 --- a/app/models/case_log.rb +++ b/app/models/case_log.rb @@ -241,18 +241,20 @@ private self.year = startdate.year end case net_income_known - when "Yes – the household has a weekly income" + when "Weekly" self.incfreq = "Weekly" self.incref = nil - when "Yes – the household has a monthly income" + when "Monthly" self.incfreq = "Monthly" self.incref = nil - when "Yes – the household has a yearly income" + when "Annually" self.incfreq = "Yearly" self.incref = nil when "Tenant prefers not to say" self.incref = 1 self.incfreq = nil + when "Don’t know" + self.incfreq = nil end self.hhmemb = other_hhmemb + 1 if other_hhmemb.present? self.renttype = RENT_TYPE_MAPPING[rent_type] diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb index 633d8e15c..9f7577d29 100644 --- a/app/models/constants/case_log.rb +++ b/app/models/constants/case_log.rb @@ -1071,9 +1071,9 @@ module Constants::CaseLog }.freeze NET_INCOME_KNOWN = { - "Yes – the household has a weekly income" => 0, - "Yes – the household has a monthly income" => 1, - "Yes – the household has a yearly income" => 2, + "Weekly" => 0, + "Monthly" => 1, + "Annually" => 2, "Tenant prefers not to say" => 3, }.freeze diff --git a/app/models/form/subsection.rb b/app/models/form/subsection.rb index aa0fc0704..3bd7892fc 100644 --- a/app/models/form/subsection.rb +++ b/app/models/form/subsection.rb @@ -31,7 +31,7 @@ class Form::Subsection end qs = applicable_questions(case_log) - return :not_started if qs.all? { |question| case_log[question.id].blank? } + return :not_started if qs.all? { |question| case_log[question.id].blank? || question.read_only? } return :completed if qs.all? { |question| question.completed?(case_log) } :in_progress diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index a0abf50e7..6da00789f 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -1843,23 +1843,24 @@ "description": "", "questions": { "net_income_known": { - "check_answer_label": "Household’s combined income after tax", + "check_answer_label": "How often household receives income", "header": "Do you know the household’s combined income after tax?", "guidance_partial": "what_counts_as_income", "hint_text": "", "type": "radio", "answer_options": { - "0": "Yes – the household has a weekly income", - "1": "Yes – the household has a monthly income", - "2": "Yes – the household has a yearly income", + "0": "Weekly", + "1": "Monthly", + "2": "Annually", "divider_a": true, - "3": "Tenant prefers not to say" + "3": "Don't know", + "4": "Tenant prefers not to say" } } } }, "weekly_net_income": { - "depends_on": [{ "net_income_known": "Yes – the household has a weekly income" }], + "depends_on": [{ "net_income_known": "Weekly" }], "header": "", "description": "", "questions": { @@ -1886,12 +1887,12 @@ } }, "monthly_net_income": { - "depends_on": [{ "net_income_known": "Yes – the household has a monthly income" }], + "depends_on": [{ "net_income_known": "Monthly" }], "header": "", "description": "", "questions": { "earnings": { - "check_answer_label": "Income", + "check_answer_label": "Total household income", "header": "How much income does the household have in total every month?", "hint_text": "", "type": "numeric", @@ -1913,12 +1914,12 @@ } }, "yearly_net_income": { - "depends_on": [{ "net_income_known": "Yes – the household has a yearly income" }], + "depends_on": [{ "net_income_known": "Annually" }], "header": "", "description": "", "questions": { "earnings": { - "check_answer_label": "Income", + "check_answer_label": "Total household income", "header": "How much income does the household have in total every year?", "hint_text": "", "type": "numeric", diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index fe0074824..8fc0b4958 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -112,7 +112,7 @@ FactoryBot.define do discarded_at { nil } tenancyother { nil } override_net_income_validation { nil } - net_income_known { "Yes – the household has a weekly income" } + net_income_known { "Weekly" } gdpr_acceptance { "Yes" } gdpr_declined { "No" } property_owner_organisation { "Test" } diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json index e5cd83d04..29b926456 100644 --- a/spec/fixtures/complete_case_log.json +++ b/spec/fixtures/complete_case_log.json @@ -74,7 +74,7 @@ "mrcyear": 2020, "offered": 2, "wchair": "Yes", - "net_income_known": "Yes – the household has a weekly income", + "net_income_known": "Weekly", "earnings": 150, "benefits": "Some", "hb": "Universal Credit with housing element (excluding housing benefit)", diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json index aa4e83e0a..356258eff 100644 --- a/spec/fixtures/forms/2021_2022.json +++ b/spec/fixtures/forms/2021_2022.json @@ -451,7 +451,7 @@ } } }, - "rent": { + "rent_and_charges": { "label": "Rent", "pages": { "rent": { @@ -648,7 +648,7 @@ "tenancy_information": "completed", "property_information": "completed", "income_and_benefits": "completed", - "rent": "completed", + "rent_and_charges": "completed", "local_authority": "completed" }], "pages": { diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb index e23c28d33..6c339650b 100644 --- a/spec/models/case_log_spec.rb +++ b/spec/models/case_log_spec.rb @@ -1118,11 +1118,11 @@ RSpec.describe Form, type: :model do context "net_income" do it "infers the income frequency" do - case_log.update!(net_income_known: "Yes – the household has a weekly income") + case_log.update!(net_income_known: "Weekly") expect(case_log.reload.incfreq).to eq("Weekly") - case_log.update!(net_income_known: "Yes – the household has a monthly income") + case_log.update!(net_income_known: "Monthly") expect(case_log.reload.incfreq).to eq("Monthly") - case_log.update!(net_income_known: "Yes – the household has a yearly income") + case_log.update!(net_income_known: "Annually") expect(case_log.reload.incfreq).to eq("Yearly") end end diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb index 009a107ba..f84d682aa 100644 --- a/spec/models/form/question_spec.rb +++ b/spec/models/form/question_spec.rb @@ -74,7 +74,7 @@ RSpec.describe Form::Question, type: :model do end context "when the question is read only" do - let(:subsection_id) { "rent" } + let(:subsection_id) { "rent_and_charges" } let(:page_id) { "rent" } let(:question_id) { "tcharge" } @@ -101,7 +101,7 @@ RSpec.describe Form::Question, type: :model do it "has an answer label" do case_log.earnings = 100 - expect(subject.answer_label(case_log)).to eq("100") + expect(subject.answer_label(case_log)).to eq("100.0") end it "has an update answer link text helper" do