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
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]

6
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

2
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

21
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",

2
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" }

2
spec/fixtures/complete_case_log.json vendored

@ -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)",

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

@ -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": {

6
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

4
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

Loading…
Cancel
Save