Browse Source

Update net income frequency answer options;

pull/228/head
Kat 3 years ago
parent
commit
5e9ba5d450
  1. 8
      app/models/case_log.rb
  2. 6
      app/models/constants/case_log.rb
  3. 2
      app/models/form/subsection.rb
  4. 21
      config/forms/2021_2022.json
  5. 2
      spec/factories/case_log.rb
  6. 2
      spec/fixtures/complete_case_log.json
  7. 4
      spec/fixtures/forms/2021_2022.json
  8. 6
      spec/models/case_log_spec.rb
  9. 4
      spec/models/form/question_spec.rb

8
app/models/case_log.rb

@ -241,18 +241,20 @@ private
self.year = startdate.year self.year = startdate.year
end end
case net_income_known case net_income_known
when "Yes – the household has a weekly income" when "Weekly"
self.incfreq = "Weekly" self.incfreq = "Weekly"
self.incref = nil self.incref = nil
when "Yes – the household has a monthly income" when "Monthly"
self.incfreq = "Monthly" self.incfreq = "Monthly"
self.incref = nil self.incref = nil
when "Yes – the household has a yearly income" when "Annually"
self.incfreq = "Yearly" self.incfreq = "Yearly"
self.incref = nil self.incref = nil
when "Tenant prefers not to say" when "Tenant prefers not to say"
self.incref = 1 self.incref = 1
self.incfreq = nil self.incfreq = nil
when "Don’t know"
self.incfreq = nil
end end
self.hhmemb = other_hhmemb + 1 if other_hhmemb.present? self.hhmemb = other_hhmemb + 1 if other_hhmemb.present?
self.renttype = RENT_TYPE_MAPPING[rent_type] self.renttype = RENT_TYPE_MAPPING[rent_type]

6
app/models/constants/case_log.rb

@ -1071,9 +1071,9 @@ module Constants::CaseLog
}.freeze }.freeze
NET_INCOME_KNOWN = { NET_INCOME_KNOWN = {
"Yes – the household has a weekly income" => 0, "Weekly" => 0,
"Yes – the household has a monthly income" => 1, "Monthly" => 1,
"Yes – the household has a yearly income" => 2, "Annually" => 2,
"Tenant prefers not to say" => 3, "Tenant prefers not to say" => 3,
}.freeze }.freeze

2
app/models/form/subsection.rb

@ -31,7 +31,7 @@ class Form::Subsection
end end
qs = applicable_questions(case_log) 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) } return :completed if qs.all? { |question| question.completed?(case_log) }
:in_progress :in_progress

21
config/forms/2021_2022.json

@ -1843,23 +1843,24 @@
"description": "", "description": "",
"questions": { "questions": {
"net_income_known": { "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?", "header": "Do you know the household’s combined income after tax?",
"guidance_partial": "what_counts_as_income", "guidance_partial": "what_counts_as_income",
"hint_text": "", "hint_text": "",
"type": "radio", "type": "radio",
"answer_options": { "answer_options": {
"0": "Yes – the household has a weekly income", "0": "Weekly",
"1": "Yes – the household has a monthly income", "1": "Monthly",
"2": "Yes – the household has a yearly income", "2": "Annually",
"divider_a": true, "divider_a": true,
"3": "Tenant prefers not to say" "3": "Don't know",
"4": "Tenant prefers not to say"
} }
} }
} }
}, },
"weekly_net_income": { "weekly_net_income": {
"depends_on": [{ "net_income_known": "Yes – the household has a weekly income" }], "depends_on": [{ "net_income_known": "Weekly" }],
"header": "", "header": "",
"description": "", "description": "",
"questions": { "questions": {
@ -1886,12 +1887,12 @@
} }
}, },
"monthly_net_income": { "monthly_net_income": {
"depends_on": [{ "net_income_known": "Yes – the household has a monthly income" }], "depends_on": [{ "net_income_known": "Monthly" }],
"header": "", "header": "",
"description": "", "description": "",
"questions": { "questions": {
"earnings": { "earnings": {
"check_answer_label": "Income", "check_answer_label": "Total household income",
"header": "How much income does the household have in total every month?", "header": "How much income does the household have in total every month?",
"hint_text": "", "hint_text": "",
"type": "numeric", "type": "numeric",
@ -1913,12 +1914,12 @@
} }
}, },
"yearly_net_income": { "yearly_net_income": {
"depends_on": [{ "net_income_known": "Yes – the household has a yearly income" }], "depends_on": [{ "net_income_known": "Annually" }],
"header": "", "header": "",
"description": "", "description": "",
"questions": { "questions": {
"earnings": { "earnings": {
"check_answer_label": "Income", "check_answer_label": "Total household income",
"header": "How much income does the household have in total every year?", "header": "How much income does the household have in total every year?",
"hint_text": "", "hint_text": "",
"type": "numeric", "type": "numeric",

2
spec/factories/case_log.rb

@ -112,7 +112,7 @@ FactoryBot.define do
discarded_at { nil } discarded_at { nil }
tenancyother { nil } tenancyother { nil }
override_net_income_validation { nil } override_net_income_validation { nil }
net_income_known { "Yes – the household has a weekly income" } net_income_known { "Weekly" }
gdpr_acceptance { "Yes" } gdpr_acceptance { "Yes" }
gdpr_declined { "No" } gdpr_declined { "No" }
property_owner_organisation { "Test" } property_owner_organisation { "Test" }

2
spec/fixtures/complete_case_log.json vendored

@ -74,7 +74,7 @@
"mrcyear": 2020, "mrcyear": 2020,
"offered": 2, "offered": 2,
"wchair": "Yes", "wchair": "Yes",
"net_income_known": "Yes – the household has a weekly income", "net_income_known": "Weekly",
"earnings": 150, "earnings": 150,
"benefits": "Some", "benefits": "Some",
"hb": "Universal Credit with housing element (excluding housing benefit)", "hb": "Universal Credit with housing element (excluding housing benefit)",

4
spec/fixtures/forms/2021_2022.json vendored

@ -451,7 +451,7 @@
} }
} }
}, },
"rent": { "rent_and_charges": {
"label": "Rent", "label": "Rent",
"pages": { "pages": {
"rent": { "rent": {
@ -648,7 +648,7 @@
"tenancy_information": "completed", "tenancy_information": "completed",
"property_information": "completed", "property_information": "completed",
"income_and_benefits": "completed", "income_and_benefits": "completed",
"rent": "completed", "rent_and_charges": "completed",
"local_authority": "completed" "local_authority": "completed"
}], }],
"pages": { "pages": {

6
spec/models/case_log_spec.rb

@ -1118,11 +1118,11 @@ RSpec.describe Form, type: :model do
context "net_income" do context "net_income" do
it "infers the income frequency" 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") 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") 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") expect(case_log.reload.incfreq).to eq("Yearly")
end end
end end

4
spec/models/form/question_spec.rb

@ -74,7 +74,7 @@ RSpec.describe Form::Question, type: :model do
end end
context "when the question is read only" do context "when the question is read only" do
let(:subsection_id) { "rent" } let(:subsection_id) { "rent_and_charges" }
let(:page_id) { "rent" } let(:page_id) { "rent" }
let(:question_id) { "tcharge" } let(:question_id) { "tcharge" }
@ -101,7 +101,7 @@ RSpec.describe Form::Question, type: :model do
it "has an answer label" do it "has an answer label" do
case_log.earnings = 100 case_log.earnings = 100
expect(subject.answer_label(case_log)).to eq("100") expect(subject.answer_label(case_log)).to eq("100.0")
end end
it "has an update answer link text helper" do it "has an update answer link text helper" do

Loading…
Cancel
Save