From 57af5eef8a3558521c519bd233ff4c07dcb7210a Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Wed, 12 Jan 2022 16:44:41 +0000
Subject: [PATCH] Cldc 632 income and benefits section (#213)
* Update hb question options
* add has benefits field
* derive has_benefits
* update benefit question options
* Add nocharge field
* Add rent period question and check multiple condition sets for depends_on
* update rent period answer options
* Add carehome questions and move the remaining rent questions to income and benefits section
* Reset incfreq and incref and update rent routing based on periods
---
README.md | 8 +-
app/models/case_log.rb | 13 +
app/models/constants/case_log.rb | 26 +-
app/models/form/page.rb | 6 +-
app/models/form/subsection.rb | 6 +-
.../validations/financial_validations.rb | 14 +-
config/forms/2021_2022.json | 779 +++++++++++++++---
.../20220110115720_add_has_benefits_field.rb | 7 +
.../20220110161957_add_nocharge_field.rb | 7 +
...20111140400_add_care_home_charge_fields.rb | 8 +
...220112151048_add_household_charge_field.rb | 7 +
db/schema.rb | 7 +-
docs/api/DLUHC-CORE-Data.v1.json | 2 +-
spec/factories/case_log.rb | 6 +-
spec/features/form/helpers.rb | 2 +-
spec/fixtures/complete_case_log.json | 10 +-
spec/fixtures/forms/2021_2022.json | 22 +-
spec/fixtures/forms/2022_2023.json | 14 +-
spec/fixtures/forms/test_validator.json | 2 +-
spec/models/case_log_spec.rb | 9 +
spec/models/form/question_spec.rb | 2 +-
spec/requests/form_controller_spec.rb | 16 +
22 files changed, 817 insertions(+), 156 deletions(-)
create mode 100644 db/migrate/20220110115720_add_has_benefits_field.rb
create mode 100644 db/migrate/20220110161957_add_nocharge_field.rb
create mode 100644 db/migrate/20220111140400_add_care_home_charge_fields.rb
create mode 100644 db/migrate/20220112151048_add_household_charge_field.rb
diff --git a/README.md b/README.md
index 26c2431fb..26ab070d9 100644
--- a/README.md
+++ b/README.md
@@ -141,7 +141,7 @@ The JSON should follow the structure:
}
}
},
- "depends_on": { "question_key": "answer_value_required_for_this_page_to_be_shown" }
+ "depends_on": [{ "question_key": "answer_value_required_for_this_page_to_be_shown" }]
}
}
}
@@ -171,9 +171,9 @@ Assumptions made by the format:
```jsonc
"page_1": { "questions": { "question_1: "answer_options": ["A", "B"] } },
- "page_2": { "questions": { "question_2: "answer_options": ["C", "D"] }, "depends_on": { "question_1": "A" } },
- "page_3": { "questions": { "question_3: "answer_options": ["E", "F"] }, "depends_on": { "question_1": "A" } },
- "page_4": { "questions": { "question_4: "answer_options": ["G", "H"] }, "depends_on": { "question_1": "B" } },
+ "page_2": { "questions": { "question_2: "answer_options": ["C", "D"] }, "depends_on": [{ "question_1": "A" }] },
+ "page_3": { "questions": { "question_3: "answer_options": ["E", "F"] }, "depends_on": [{ "question_1": "A" }] },
+ "page_4": { "questions": { "question_4: "answer_options": ["G", "H"] }, "depends_on": [{ "question_1": "B" }] },
```
## JSON Form Validation against Schema
diff --git a/app/models/case_log.rb b/app/models/case_log.rb
index 3657628ae..5e8380e7a 100644
--- a/app/models/case_log.rb
+++ b/app/models/case_log.rb
@@ -135,6 +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 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
@@ -239,12 +242,16 @@ private
case net_income_known
when "Yes – the household has a weekly income"
self.incfreq = "Weekly"
+ self.incref = nil
when "Yes – the household has a monthly income"
self.incfreq = "Monthly"
+ self.incref = nil
when "Yes – the household has a yearly income"
self.incfreq = "Yearly"
+ self.incref = nil
when "Tenant prefers not to say"
self.incref = 1
+ self.incfreq = nil
end
self.hhmemb = other_hhmemb + 1 if other_hhmemb.present?
self.renttype = RENT_TYPE_MAPPING[rent_type]
@@ -253,6 +260,8 @@ private
self.totelder = get_totelder
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!
@@ -303,6 +312,10 @@ private
end
end
+ def get_has_benefits
+ return "Yes" if HAS_BENEFITS_OPTIONS.include?(hb)
+ end
+
def all_fields_completed?
mandatory_fields.none? { |field| public_send(field).nil? if respond_to?(field) }
end
diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb
index 36b2d8cdb..bf9fc55fa 100644
--- a/app/models/constants/case_log.rb
+++ b/app/models/constants/case_log.rb
@@ -206,15 +206,14 @@ module Constants::CaseLog
PERIOD = {
"Weekly for 52 weeks" => 1,
- "Fortnightly" => 2,
- "Four-weekly" => 3,
- "Calendar monthly" => 4,
+ "Every 2 weeks" => 2,
+ "Every 4 weeks" => 3,
+ "Every calendar month" => 4,
"Weekly for 50 weeks" => 5,
"Weekly for 49 weeks" => 6,
"Weekly for 48 weeks" => 7,
"Weekly for 47 weeks" => 8,
"Weekly for 46 weeks" => 9,
- "Weekly for 53 weeks" => 10,
}.freeze
LATIME = {
@@ -229,13 +228,13 @@ module Constants::CaseLog
}.freeze
HOUSING_BENEFIT = {
- "Housing Benefit, but not Universal Credit" => 1,
- "Universal Credit with housing element, but not Housing Benefit" => 6,
- "Universal Credit without housing element and no Housing Benefit" => 7,
- "Universal Credit and Housing Benefit" => 8,
- "Not Housing Benefit or Universal Credit" => 9,
- "Don’t know" => 3,
- "Prefer not to say" => 100,
+ "Housing benefit" => 1,
+ "Universal Credit with housing element (excluding housing benefit)" => 6,
+ "Universal Credit (without housing element)" => 7,
+ "Housing benefit and Universal Credit (without housing element)" => 8,
+ "None" => 9,
+ "Don't know" => 3,
+ "Tenant prefers not to say" => 100,
}.freeze
REASON = {
@@ -1077,4 +1076,9 @@ module Constants::CaseLog
"Yes – the household has a yearly income" => 2,
"Tenant prefers not to say" => 3,
}.freeze
+
+ HAS_BENEFITS_OPTIONS = ["Housing benefit",
+ "Universal Credit with housing element (excluding housing benefit)",
+ "Universal Credit (without housing element)",
+ "Housing benefit and Universal Credit (without housing element)"].freeze
end
diff --git a/app/models/form/page.rb b/app/models/form/page.rb
index c550114a2..2fe6c00d0 100644
--- a/app/models/form/page.rb
+++ b/app/models/form/page.rb
@@ -32,8 +32,10 @@ private
def depends_on_met(case_log)
return true unless depends_on
- depends_on.all? do |question, value|
- !case_log[question].nil? && case_log[question] == value
+ depends_on.any? do |conditions_set|
+ conditions_set.all? do |question, value|
+ value.nil? ? case_log[question] == value : !case_log[question].nil? && case_log[question] == value
+ end
end
end
end
diff --git a/app/models/form/subsection.rb b/app/models/form/subsection.rb
index d0445348c..36afa531f 100644
--- a/app/models/form/subsection.rb
+++ b/app/models/form/subsection.rb
@@ -18,8 +18,10 @@ class Form::Subsection
def enabled?(case_log)
return true unless depends_on
- depends_on.all? do |subsection_id, dependent_status|
- form.get_subsection(subsection_id).status(case_log) == dependent_status.to_sym
+ depends_on.any? do |conditions_set|
+ conditions_set.all? do |subsection_id, dependent_status|
+ form.get_subsection(subsection_id).status(case_log) == dependent_status.to_sym
+ end
end
end
diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb
index e2b54bd5a..e5681dda6 100644
--- a/app/models/validations/financial_validations.rb
+++ b/app/models/validations/financial_validations.rb
@@ -38,15 +38,15 @@ module Validations::FinancialValidations
def validate_hbrentshortfall(record)
is_present = record.hbrentshortfall.present?
is_yes = record.hbrentshortfall == "Yes"
- hb_donotknow = record.hb == "Don’t know"
- hb_no_hb_or_uc = record.hb == "Not Housing Benefit or Universal Credit"
- hb_uc_no_hb = record.hb == "Universal Credit without housing element and no Housing Benefit"
- hb_no_uc = record.hb == "Housing Benefit, but not Universal Credit"
- hb_uc_no_he_hb = record.hb == "Universal Credit with housing element, but not Housing Benefit"
- hb_and_uc = record.hb == "Universal Credit and Housing Benefit"
+ hb_donotknow = record.hb == "Don't know"
+ hb_none = record.hb == "None"
+ hb_uc_no_hb = record.hb == "Universal Credit (without housing element)"
+ hb_no_uc = record.hb == "Housing benefit"
+ hb_uc_no_he_hb = record.hb == "Universal Credit with housing element (excluding housing benefit)"
+ hb_and_uc = record.hb == "Housing benefit and Universal Credit (without housing element)"
conditions = [
- { condition: is_yes && (hb_donotknow || hb_no_hb_or_uc || hb_uc_no_hb), error: "Outstanding amount for basic rent and/or benefit eligible charges can not be 'Yes' if tenant is not in receipt of housing benefit or universal benefit or if benefit is unknown" },
+ { condition: is_yes && (hb_donotknow || hb_none || hb_uc_no_hb), error: "Outstanding amount for basic rent and/or benefit eligible charges can not be 'Yes' if tenant is not in receipt of housing benefit or universal benefit or if benefit is unknown" },
{ condition: (hb_no_uc || hb_uc_no_he_hb || hb_and_uc) && !is_present, error: "Must be completed if Universal credit and/or Housing Benefit received" },
]
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 559730ae5..5b1659927 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -31,7 +31,7 @@
"hint_text": "",
"description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.
Go to your logs",
"questions": {},
- "depends_on": { "gdpr_acceptance": "No" }
+ "depends_on": [{ "gdpr_acceptance": "No" }]
},
"organisation_details": {
"header": "Organisation details",
@@ -58,7 +58,7 @@
}
}
},
- "depends_on": { "gdpr_acceptance": "Yes" }
+ "depends_on": [{ "gdpr_acceptance": "Yes" }]
},
"sale_or_letting": {
"header": "",
@@ -75,7 +75,7 @@
}
}
},
- "depends_on": { "gdpr_acceptance": "Yes" }
+ "depends_on": [{ "gdpr_acceptance": "Yes" }]
},
"tenant_same_property_renewal": {
"header": "",
@@ -92,10 +92,10 @@
}
}
},
- "depends_on": {
+ "depends_on": [{
"gdpr_acceptance": "Yes",
"sale_or_letting": "Letting"
- }
+ }]
},
"startdate": {
"header": "",
@@ -108,10 +108,10 @@
"type": "date"
}
},
- "depends_on": {
+ "depends_on": [{
"gdpr_acceptance": "Yes",
"sale_or_letting": "Letting"
- }
+ }]
},
"about_this_letting": {
"header": "Tell us about this letting",
@@ -152,10 +152,10 @@
}
}
},
- "depends_on": {
+ "depends_on": [{
"gdpr_acceptance": "Yes",
"sale_or_letting": "Letting"
- }
+ }]
},
"tenant_code": {
"header": "",
@@ -169,10 +169,10 @@
"width": 10
}
},
- "depends_on": {
+ "depends_on": [{
"gdpr_acceptance": "Yes",
"sale_or_letting": "Letting"
- }
+ }]
},
"property_reference": {
"header": "",
@@ -186,7 +186,7 @@
"width": 10
}
},
- "depends_on": { "gdpr_acceptance": "Yes" }
+ "depends_on": [{ "gdpr_acceptance": "Yes" }]
},
"sale_completion_date": {
"header": "",
@@ -199,10 +199,10 @@
"type": "date"
}
},
- "depends_on": {
+ "depends_on": [{
"gdpr_acceptance": "Yes",
"sale_or_letting": "Sale"
- }
+ }]
},
"purchaser_code": {
"header": "",
@@ -216,10 +216,10 @@
"width": 10
}
},
- "depends_on": {
+ "depends_on": [{
"gdpr_acceptance": "Yes",
"sale_or_letting": "Sale"
- }
+ }]
}
}
}
@@ -230,7 +230,7 @@
"subsections": {
"household_characteristics": {
"label": "Household characteristics",
- "depends_on": { "about_this_log": "completed" },
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"person_1_age": {
"header": "",
@@ -779,7 +779,7 @@
},
"household_situation": {
"label": "Household situation",
- "depends_on": { "about_this_log": "completed" },
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"previous_housing_situation": {
"header": "",
@@ -907,7 +907,7 @@
},
"household_needs": {
"label": "Household needs",
- "depends_on": { "about_this_log": "completed" },
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"armed_forces": {
"header": "Experience of the UK Armed Forces",
@@ -1052,7 +1052,7 @@
"subsections": {
"tenancy_information": {
"label": "Tenancy information",
- "depends_on": { "about_this_log": "completed" },
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"starter_tenancy": {
"header": "",
@@ -1133,7 +1133,7 @@
},
"property_information": {
"label": "Property information",
- "depends_on": { "about_this_log": "completed" },
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"property_postcode": {
"header": "",
@@ -1182,7 +1182,7 @@
}
}
},
- "depends_on": { "is_la_inferred": false }
+ "depends_on": [{ "is_la_inferred": false }]
},
"select_local_authority": {
"header": "",
@@ -1514,7 +1514,7 @@
}
}
},
- "depends_on": { "la_known": "Yes", "is_la_inferred": false }
+ "depends_on": [{ "la_known": "Yes", "is_la_inferred": false }]
},
"why_dont_you_know_la": {
"header": "",
@@ -1527,7 +1527,7 @@
"type": "textarea"
}
},
- "depends_on": { "la_known": "No", "is_la_inferred": false }
+ "depends_on": [{ "la_known": "No", "is_la_inferred": false }]
},
"first_time_property_let_as_social_housing": {
"header": "",
@@ -1544,7 +1544,7 @@
}
}
},
- "depends_on": { "tenant_same_property_renewal": "No" }
+ "depends_on": [{ "tenant_same_property_renewal": "No" }]
},
"unitletas": {
"header": "",
@@ -1564,10 +1564,10 @@
}
}
},
- "depends_on": {
+ "depends_on": [{
"first_time_property_let_as_social_housing": "No",
"tenant_same_property_renewal": "No"
- }
+ }]
},
"property_vacancy_reason_not_first_let": {
"header": "",
@@ -1593,10 +1593,10 @@
}
}
},
- "depends_on": {
+ "depends_on": [{
"first_time_property_let_as_social_housing": "No",
"tenant_same_property_renewal": "No"
- }
+ }]
},
"property_vacancy_reason_first_let": {
"header": "",
@@ -1614,10 +1614,10 @@
}
}
},
- "depends_on": {
+ "depends_on": [{
"first_time_property_let_as_social_housing": "Yes",
"tenant_same_property_renewal": "No"
- }
+ }]
},
"property_number_of_times_relet_not_social_let": {
"header": "",
@@ -1634,10 +1634,10 @@
"width": 2
}
},
- "depends_on": {
+ "depends_on": [{
"first_time_property_let_as_social_housing": "No",
"tenant_same_property_renewal": "No"
- }
+ }]
},
"property_number_of_times_relet_social_let": {
"header": "",
@@ -1654,10 +1654,10 @@
"width": 2
}
},
- "depends_on": {
+ "depends_on": [{
"first_time_property_let_as_social_housing": "Yes",
"tenant_same_property_renewal": "No"
- }
+ }]
},
"property_unit_type": {
"header": "",
@@ -1728,7 +1728,7 @@
"width": 2
}
},
- "depends_on": { "needstype": "General needs" }
+ "depends_on": [{ "needstype": "General needs" }]
},
"void_or_renewal_date": {
"header": "",
@@ -1741,10 +1741,10 @@
"type": "date"
}
},
- "depends_on": {
+ "depends_on": [{
"rsnvac": "First let of new-build property",
"tenant_same_property_renewal": "No"
- }
+ }]
},
"new_build_handover_date": {
"header": "",
@@ -1757,13 +1757,13 @@
"type": "date"
}
},
- "depends_on": {
+ "depends_on": [{
"tenant_same_property_renewal": "No",
"rsnvac": [
"First let of conversion, rehabilitation or acquired property?",
"First let of leased property"
]
- }
+ }]
},
"property_major_repairs": {
"header": "",
@@ -1789,21 +1789,21 @@
"type": "date"
}
},
- "depends_on": {
+ "depends_on": [{
"rsnvac": "First let of new-build property",
"tenant_same_property_renewal": "No"
- }
+ }]
}
}
}
}
},
"rent_and_charges": {
- "label": "Rent and charges",
+ "label": "Finances",
"subsections": {
"income_and_benefits": {
- "label": "Income and benefits",
- "depends_on": { "about_this_log": "completed" },
+ "label": "Income, benefits and outgoings",
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"net_income_known": {
"header": "Household’s combined income",
@@ -1826,7 +1826,7 @@
}
},
"weekly_net_income": {
- "depends_on": { "net_income_known": "Yes – the household has a weekly income" },
+ "depends_on": [{ "net_income_known": "Yes – the household has a weekly income" }],
"header": "",
"description": "",
"questions": {
@@ -1852,7 +1852,7 @@
}
},
"monthly_net_income": {
- "depends_on": { "net_income_known": "Yes – the household has a monthly income" },
+ "depends_on": [{ "net_income_known": "Yes – the household has a monthly income" }],
"header": "",
"description": "",
"questions": {
@@ -1878,7 +1878,7 @@
}
},
"yearly_net_income": {
- "depends_on": { "net_income_known": "Yes – the household has a yearly income" },
+ "depends_on": [{ "net_income_known": "Yes – the household has a yearly income" }],
"header": "",
"description": "",
"questions": {
@@ -1903,14 +1903,36 @@
}
}
},
+ "housing_benefit": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "hb": {
+ "check_answer_label": "Universal Credit & Housing Benefit",
+ "header": "Is the household likely to be receiving any of these housing-related benefits?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "0": "Housing benefit",
+ "1": "Universal Credit with housing element (excluding housing benefit)",
+ "2": "Housing benefit and Universal Credit (without housing element)",
+ "3": "Universal Credit (without housing element)",
+ "4": "None",
+ "divider": true,
+ "5": "Don't know",
+ "6": "Tenant prefers not to say"
+ }
+ }
+ }
+ },
"net_income_uc_proportion": {
"header": "",
"description": "",
"questions": {
"benefits": {
"check_answer_label": "Benefits as a proportion of income",
- "header": "How much of the tenant’s income is from Universal Credit, state pensions or benefits?",
- "hint_text": "",
+ "header": "How much of the household's income is from Universal Credit, state pensions or benefits?",
+ "hint_text": "This excludes child and housing benefit, council tax support and tax credits.",
"type": "radio",
"answer_options": {
"0": "All",
@@ -1922,60 +1944,248 @@
}
}
},
- "housing_benefit": {
+ "rent_or_other_charges": {
"header": "",
"description": "",
"questions": {
- "hb": {
- "check_answer_label": "Housing-related benefits received",
- "header": "Is the tenant likely to be in receipt of any of these housing-related benefits?",
+ "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": "",
"type": "radio",
"answer_options": {
- "0": "Housing Benefit, but not Universal Credit",
- "1": "Universal Credit with housing element, but not Housing Benefit",
- "2": "Universal Credit without housing element and no Housing Benefit",
- "3": "Universal Credit and Housing Benefit",
- "4": "Not Housing Benefit or Universal Credit",
- "divider": true,
- "5": "Don’t know",
- "6": "Prefer not to say"
+ "0": "Yes",
+ "1": "No"
}
}
- }
- }
- }
- },
- "rent": {
- "label": "Rent",
- "depends_on": { "about_this_log": "completed" },
- "pages": {
- "rent": {
+ },
+ "depends_on": [{ "needstype": "Supported housing" }]
+ },
+ "rent_period": {
"header": "",
"description": "",
"questions": {
"period": {
"check_answer_label": "Rent Period",
- "header": "Which period are rent and other charges due?",
+ "header": "How often does the household pay rent and other charges?",
"hint_text": "",
"type": "radio",
"answer_options": {
"0": "Weekly for 52 weeks",
- "1": "Fortnightly",
- "2": "Four-weekly",
- "3": "Calendar monthly",
+ "1": "Every 2 weeks",
+ "2": "Every 4 weeks",
+ "3": "Every calendar month",
"4": "Weekly for 50 weeks",
"5": "Weekly for 49 weeks",
"6": "Weekly for 48 weeks",
"7": "Weekly for 47 weeks",
- "8": "Weekly for 46 weeks",
- "9": "Weekly for 53 weeks"
+ "8": "Weekly for 46 weeks"
+ }
+ }
+ },
+ "depends_on" : [{
+ "household_charge": "Yes"
+ },{
+ "household_charge": null
+ }]
+ },
+ "care_home_weekly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "is_carehome": {
+ "check_answer_label": "Is this accommodation a care home?",
+ "header": "Is this accommodation a care home?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "1": "Yes",
+ "0": "No"
+ },
+ "conditional_for": {
+ "chcharge": ["Yes"]
}
},
+ "chcharge": {
+ "check_answer_label": "How much does the household pay every week?",
+ "header": "How much does the household pay every week?",
+ "hint_text": "",
+ "type": "numeric",
+ "width": 5,
+ "prefix": "£",
+ "suffix": "every week"
+ }
+ },
+ "depends_on" : [{
+ "period": "Weekly for 52 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Weekly for 52 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ },{
+ "period": "Weekly for 50 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Weekly for 50 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ },{
+ "period": "Weekly for 49 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Weekly for 49 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ },{
+ "period": "Weekly for 48 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Weekly for 48 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ },{
+ "period": "Weekly for 47 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Weekly for 47 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ },{
+ "period": "Weekly for 46 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Weekly for 46 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ }
+ ]
+ },
+ "care_home_bi_weekly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "is_carehome": {
+ "check_answer_label": "Is this accommodation a care home?",
+ "header": "Is this accommodation a care home?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "1": "Yes",
+ "0": "No"
+ },
+ "conditional_for": {
+ "chcharge": ["Yes"]
+ }
+ },
+ "chcharge": {
+ "check_answer_label": "How much does the household pay every 2 weeks?",
+ "header": "How much does the household pay every 2 weeks?",
+ "hint_text": "",
+ "type": "numeric",
+ "width": 5,
+ "prefix": "£",
+ "suffix": "every 2 weeks"
+ }
+ },
+ "depends_on" : [{
+ "period": "Every 2 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Every 2 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ }]
+ },
+ "care_home_4_weekly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "is_carehome": {
+ "check_answer_label": "Is this accommodation a care home?",
+ "header": "Is this accommodation a care home?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "1": "Yes",
+ "0": "No"
+ },
+ "conditional_for": {
+ "chcharge": ["Yes"]
+ }
+ },
+ "chcharge": {
+ "check_answer_label": "How much does the household pay every 4 weeks?",
+ "header": "How much does the household pay every 4 weeks?",
+ "hint_text": "",
+ "type": "numeric",
+ "width": 5,
+ "prefix": "£",
+ "suffix": "every 4 weeks"
+ }
+ },
+ "depends_on" : [{
+ "period": "Every 4 weeks",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Every 4 weeks",
+ "needstype": "Supported housing",
+ "household_charge": null
+ }]
+ },
+ "care_home_monthly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "is_carehome": {
+ "check_answer_label": "Is this accommodation a care home?",
+ "header": "Is this accommodation a care home?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "1": "Yes",
+ "0": "No"
+ },
+ "conditional_for": {
+ "chcharge": ["Yes"]
+ }
+ },
+ "chcharge": {
+ "check_answer_label": "How much does the household pay every month?",
+ "header": "How much does the household pay every month?",
+ "hint_text": "",
+ "type": "numeric",
+ "width": 5,
+ "prefix": "£",
+ "suffix": "month"
+ }
+ },
+ "depends_on" : [{
+ "period": "Every calendar month",
+ "needstype": "Supported housing",
+ "household_charge": "Yes"
+ },{
+ "period": "Every calendar month",
+ "needstype": "Supported housing",
+ "household_charge": null
+ }]
+ },
+ "rent_weekly": {
+ "header": "",
+ "description": "",
+ "questions": {
"brent": {
"check_answer_label": "Basic Rent",
- "header": "What is the basic rent?",
- "hint_text": "Eligible for housing benefit or Universal Credit",
+ "header": "What is the basic rent every week?",
+ "hint_text": "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent.",
"type": "numeric",
"min": 0,
"step": 1,
@@ -1987,7 +2197,7 @@
"scharge": {
"check_answer_label": "Service Charge",
"header": "What is the service charge?",
- "hint_text": "Eligible for housing benefit or Universal Credit",
+ "hint_text": "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge.",
"type": "numeric",
"min": 0,
"step": 1,
@@ -1999,7 +2209,7 @@
"pscharge": {
"check_answer_label": "Personal Service Charge",
"header": "What is the personal service charge?",
- "hint_text": "Not eligible for housing benefit or Universal Credit. For example, hot water excluding water rates.",
+ "hint_text": "For example, for heating or hot water. This doesn't include housing benefit or Universal Credit.",
"type": "numeric",
"min": 0,
"step": 1,
@@ -2011,7 +2221,7 @@
"supcharg": {
"check_answer_label": "Support Charge",
"header": "What is the support charge?",
- "hint_text": "This is to fund housing-related support services included in the tenancy agreement",
+ "hint_text": "This is any charge made to fund housing-related support services included in the tenancy agreement.",
"type": "numeric",
"min": 0,
"step": 1,
@@ -2022,8 +2232,8 @@
},
"tcharge": {
"check_answer_label": "Total Charge",
- "header": "Total charge?",
- "hint_text": "This is the total of rent and all charges",
+ "header": "Total charge",
+ "hint_text": "This is the total for rent and all charges.",
"type": "numeric",
"min": 0,
"step": 1,
@@ -2031,31 +2241,394 @@
"suffix": "every week",
"readonly": true,
"requires_js": true
+ }
+ },
+ "depends_on" : [{
+ "period": "Weekly for 52 weeks",
+ "household_charge": "Yes",
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 52 weeks",
+ "household_charge": null,
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 50 weeks",
+ "household_charge": "Yes",
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 50 weeks",
+ "household_charge": null,
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 49 weeks",
+ "household_charge": "Yes",
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 49 weeks",
+ "household_charge": null,
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 48 weeks",
+ "household_charge": "Yes",
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 48 weeks",
+ "household_charge": null,
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 47 weeks",
+ "household_charge": "Yes",
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 47 weeks",
+ "household_charge": null,
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 46 weeks",
+ "household_charge": "Yes",
+ "is_carehome": "No"
+ },{
+ "period": "Weekly for 46 weeks",
+ "household_charge": null,
+ "is_carehome": "No"
+ },
+ {
+ "period": "Weekly for 52 weeks",
+ "household_charge": "Yes",
+ "is_carehome": null
+ },{
+ "period": "Weekly for 52 weeks",
+ "household_charge": null,
+ "is_carehome": null
+ },{
+ "period": "Weekly for 50 weeks",
+ "household_charge": "Yes",
+ "is_carehome": null
+ },{
+ "period": "Weekly for 50 weeks",
+ "household_charge": null,
+ "is_carehome": null
+ },{
+ "period": "Weekly for 49 weeks",
+ "household_charge": "Yes",
+ "is_carehome": null
+ },{
+ "period": "Weekly for 49 weeks",
+ "household_charge": null,
+ "is_carehome": null
+ },{
+ "period": "Weekly for 48 weeks",
+ "household_charge": "Yes",
+ "is_carehome": null
+ },{
+ "period": "Weekly for 48 weeks",
+ "household_charge": null,
+ "is_carehome": null
+ },{
+ "period": "Weekly for 47 weeks",
+ "household_charge": "Yes",
+ "is_carehome": null
+ },{
+ "period": "Weekly for 47 weeks",
+ "household_charge": null,
+ "is_carehome": null
+ },{
+ "period": "Weekly for 46 weeks",
+ "household_charge": "Yes",
+ "is_carehome": null
+ },{
+ "period": "Weekly for 46 weeks",
+ "household_charge": null,
+ "is_carehome": null
+ }
+ ]
+ },
+ "rent_bi_weekly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "brent": {
+ "check_answer_label": "Basic Rent",
+ "header": "What is the basic rent every 2 weeks?",
+ "hint_text": "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 2 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
},
- "hbrentshortfall": {
- "check_answer_label": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
- "header": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
- "hint_text": "",
- "type": "radio",
- "answer_options": {
- "0": "Yes",
- "1": "No",
- "divider": true,
- "2": "Don’t know"
- },
- "conditional_for": {
- "tshortfall": ["Yes"]
- }
+ "scharge": {
+ "check_answer_label": "Service Charge",
+ "header": "What is the service charge?",
+ "hint_text": "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 2 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "pscharge": {
+ "check_answer_label": "Personal Service Charge",
+ "header": "What is the personal service charge?",
+ "hint_text": "For example, for heating or hot water. This doesn't include housing benefit or Universal Credit.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 2 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "supcharg": {
+ "check_answer_label": "Support Charge",
+ "header": "What is the support charge?",
+ "hint_text": "This is any charge made to fund housing-related support services included in the tenancy agreement.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 2 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "tcharge": {
+ "check_answer_label": "Total Charge",
+ "header": "Total charge",
+ "hint_text": "This is the total for rent and all charges.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 2 weeks",
+ "readonly": true,
+ "requires_js": true
+ }
+ },
+ "depends_on" : [{
+ "household_charge": "Yes",
+ "period": "Every 2 weeks",
+ "is_carehome": "No"
+ },{
+ "household_charge": null,
+ "period": "Every 2 weeks",
+ "is_carehome": "No"
+ },
+ {
+ "household_charge": "Yes",
+ "period": "Every 2 weeks",
+ "is_carehome": null
+ },{
+ "household_charge": null,
+ "period": "Every 2 weeks",
+ "is_carehome": null
+ }]
+ },
+ "rent_4_weekly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "brent": {
+ "check_answer_label": "Basic Rent",
+ "header": "What is the basic rent every 4 weeks?",
+ "hint_text": "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 4 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "scharge": {
+ "check_answer_label": "Service Charge",
+ "header": "What is the service charge?",
+ "hint_text": "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 4 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "pscharge": {
+ "check_answer_label": "Personal Service Charge",
+ "header": "What is the personal service charge?",
+ "hint_text": "For example, for heating or hot water. This doesn't include housing benefit or Universal Credit.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 4 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "supcharg": {
+ "check_answer_label": "Support Charge",
+ "header": "What is the support charge?",
+ "hint_text": "This is any charge made to fund housing-related support services included in the tenancy agreement.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 4 weeks",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "tcharge": {
+ "check_answer_label": "Total Charge",
+ "header": "Total charge",
+ "hint_text": "This is the total for rent and all charges.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every 4 weeks",
+ "readonly": true,
+ "requires_js": true
+ }
+ },
+ "depends_on" : [{
+ "household_charge": "Yes",
+ "period": "Every 4 weeks",
+ "is_carehome": "No"
+ },{
+ "household_charge": null,
+ "period": "Every 4 weeks",
+ "is_carehome": "No"
+ },
+ {
+ "household_charge": "Yes",
+ "period": "Every 4 weeks",
+ "is_carehome": null
+ },{
+ "household_charge": null,
+ "period": "Every 4 weeks",
+ "is_carehome": null
+ }]
+ },
+ "rent_monthly": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "brent": {
+ "check_answer_label": "Basic Rent",
+ "header": "What is the basic rent every month?",
+ "hint_text": "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every month",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "scharge": {
+ "check_answer_label": "Service Charge",
+ "header": "What is the service charge?",
+ "hint_text": "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every month",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "pscharge": {
+ "check_answer_label": "Personal Service Charge",
+ "header": "What is the personal service charge?",
+ "hint_text": "For example, for heating or hot water. This doesn't include housing benefit or Universal Credit.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every month",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
+ },
+ "supcharg": {
+ "check_answer_label": "Support Charge",
+ "header": "What is the support charge?",
+ "hint_text": "This is any charge made to fund housing-related support services included in the tenancy agreement.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every month",
+ "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "result-field": "tcharge"
},
+ "tcharge": {
+ "check_answer_label": "Total Charge",
+ "header": "Total charge",
+ "hint_text": "This is the total for rent and all charges.",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "prefix": "£",
+ "suffix": "every month",
+ "readonly": true,
+ "requires_js": true
+ }
+ },
+ "depends_on" : [{
+ "household_charge": "Yes",
+ "period": "Every calendar month",
+ "is_carehome": "No"
+ },{
+ "household_charge": null,
+ "period": "Every calendar month",
+ "is_carehome": "No"
+ },
+ {
+ "household_charge": "Yes",
+ "period": "Every calendar month",
+ "is_carehome": null
+ },{
+ "household_charge": null,
+ "period": "Every calendar month",
+ "is_carehome": null
+ }
+ ]
+ },
+ "rent_shortfall":{
+ "header": "",
+ "description": "",
+ "questions": {
+ "hbrentshortfall": {
+ "check_answer_label": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
+ "header": "After housing benefit and/or housing element of UC payment is received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "0": "Yes",
+ "1": "No"
+ }
+ }
+ },
+ "depends_on": [{ "has_benefits": "Yes", "household_charge": "Yes" },{ "has_benefits": "yes", "household_charge": null }]
+ },
+ "rent_shortfall_amount":{
+ "header": "",
+ "description": "",
+ "questions": {
"tshortfall": {
"check_answer_label": "Outstanding amount",
"header": "What do you expect the amount to be?",
- "hint_text": "If the amount is unknown you can estimate",
+ "hint_text": "Give an estimated amount if you don't know the exact figure.",
"type": "numeric",
"min": 0,
"step": 1
}
- }
+ },
+ "depends_on": [{"has_benefits": "Yes",
+ "hbrentshortfall": "Yes"
+ }]
}
}
}
@@ -2066,7 +2639,7 @@
"subsections": {
"local_authority": {
"label": "Local authority",
- "depends_on": { "about_this_log": "completed" },
+ "depends_on": [{ "about_this_log": "completed" }],
"pages": {
"time_lived_in_la": {
"header": "",
@@ -2604,7 +3177,7 @@
"subsections": {
"declaration": {
"label": "Declaration",
- "depends_on": {
+ "depends_on": [{
"about_this_log": "completed",
"household_characteristics": "completed",
"household_situation": "completed",
@@ -2614,7 +3187,7 @@
"income_and_benefits": "completed",
"rent": "completed",
"local_authority": "completed"
- },
+ }],
"pages": {
"declaration": {
"header": "",
diff --git a/db/migrate/20220110115720_add_has_benefits_field.rb b/db/migrate/20220110115720_add_has_benefits_field.rb
new file mode 100644
index 000000000..87ccdd983
--- /dev/null
+++ b/db/migrate/20220110115720_add_has_benefits_field.rb
@@ -0,0 +1,7 @@
+class AddHasBenefitsField < ActiveRecord::Migration[7.0]
+ def change
+ change_table :case_logs, bulk: true do |t|
+ t.column :has_benefits, :string
+ end
+ end
+end
diff --git a/db/migrate/20220110161957_add_nocharge_field.rb b/db/migrate/20220110161957_add_nocharge_field.rb
new file mode 100644
index 000000000..b5fbf4f53
--- /dev/null
+++ b/db/migrate/20220110161957_add_nocharge_field.rb
@@ -0,0 +1,7 @@
+class AddNochargeField < ActiveRecord::Migration[7.0]
+ def change
+ change_table :case_logs, bulk: true do |t|
+ t.column :nocharge, :integer
+ end
+ end
+end
diff --git a/db/migrate/20220111140400_add_care_home_charge_fields.rb b/db/migrate/20220111140400_add_care_home_charge_fields.rb
new file mode 100644
index 000000000..cb2292913
--- /dev/null
+++ b/db/migrate/20220111140400_add_care_home_charge_fields.rb
@@ -0,0 +1,8 @@
+class AddCareHomeChargeFields < ActiveRecord::Migration[7.0]
+ def change
+ change_table :case_logs, bulk: true do |t|
+ t.column :is_carehome, :integer
+ t.column :chcharge, :decimal
+ end
+ end
+end
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 45a2d88f0..2a89c3629 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_07_103143) 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"
@@ -178,6 +178,11 @@ ActiveRecord::Schema.define(version: 2022_01_07_103143) do
t.integer "totelder"
t.integer "totadult"
t.integer "net_income_known"
+ t.string "has_benefits"
+ 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"
diff --git a/docs/api/DLUHC-CORE-Data.v1.json b/docs/api/DLUHC-CORE-Data.v1.json
index 298d7ac1e..c400a0077 100644
--- a/docs/api/DLUHC-CORE-Data.v1.json
+++ b/docs/api/DLUHC-CORE-Data.v1.json
@@ -323,7 +323,7 @@
"earnings": 1000,
"incfreq": "Monthly",
"benefits": "Some",
- "hb": "Universal Credit with housing element, but not Housing Benefit",
+ "hb": "Universal Credit with housing element (excluding housing benefit)",
"period": "Weekly",
"brent": 200,
"scharge": 50,
diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb
index c472d6f40..8f00d862e 100644
--- a/spec/factories/case_log.rb
+++ b/spec/factories/case_log.rb
@@ -72,7 +72,7 @@ FactoryBot.define do
wchair { "Yes" }
earnings { 68 }
benefits { "Some" }
- period { "Fortnightly" }
+ period { "Every 2 weeks" }
brent { 200 }
scharge { 50 }
pscharge { 40 }
@@ -148,6 +148,10 @@ FactoryBot.define do
armedforces { 1 }
builtype { 1 }
unitletas { 2 }
+ household_charge { "Yes" }
+ has_benefits { "Yes" }
+ is_carehome { "No" }
+ chcharge { 7 }
end
created_at { Time.zone.now }
updated_at { Time.zone.now }
diff --git a/spec/features/form/helpers.rb b/spec/features/form/helpers.rb
index 8f43b76e6..426e7a560 100644
--- a/spec/features/form/helpers.rb
+++ b/spec/features/form/helpers.rb
@@ -12,7 +12,7 @@ module Helpers
click_button("Save and continue")
choose("case-log-benefits-all-field")
click_button("Save and continue")
- choose("case-log-hb-prefer-not-to-say-field")
+ choose("case-log-hb-tenant-prefers-not-to-say-field")
click_button("Save and continue")
end
diff --git a/spec/fixtures/complete_case_log.json b/spec/fixtures/complete_case_log.json
index 1c8b61097..fc31d6330 100644
--- a/spec/fixtures/complete_case_log.json
+++ b/spec/fixtures/complete_case_log.json
@@ -77,8 +77,8 @@
"net_income_known": "Yes – the household has a weekly income",
"earnings": 150,
"benefits": "Some",
- "hb": "Universal Credit with housing element, but not Housing Benefit",
- "period": "Fortnightly",
+ "hb": "Universal Credit with housing element (excluding housing benefit)",
+ "period": "Every 2 weeks",
"brent": 200,
"scharge": 50,
"pscharge": 40,
@@ -144,6 +144,10 @@
"property_wheelchair_accessible": "Yes",
"void_or_renewal_date": "05/05/2020",
"tenant_same_property_renewal": "Yes",
- "new_build_handover_date": "01/01/2019"
+ "new_build_handover_date": "01/01/2019",
+ "has_benefits": "Yes",
+ "household_charge": "Yes",
+ "is_carehome": "Yes",
+ "chcharge": "6"
}
}
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 6edb3608b..e6763ba96 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -276,7 +276,7 @@
}
}
},
- "depends_on": {"is_la_inferred": false}
+ "depends_on": [{"is_la_inferred": false}]
},
"property_wheelchair_accessible": {
"questions": {
@@ -321,7 +321,7 @@
}
}
},
- "depends_on": { "preg_occ": "Yes" }
+ "depends_on": [{ "preg_occ": "Yes" }, { "wchair" : "Yes" }]
},
"conditional_question_no_page": {
"questions": {
@@ -335,7 +335,7 @@
}
}
},
- "depends_on": { "preg_occ": "No" }
+ "depends_on": [{ "preg_occ": "No" }]
},
"conditional_question_no_second_page": {
"questions": {
@@ -349,7 +349,7 @@
}
}
},
- "depends_on": { "preg_occ": "No", "sex1": "Male" }
+ "depends_on": [{ "preg_occ": "No", "sex1": "Male" }]
}
}
}
@@ -417,11 +417,11 @@
"header": "Is the tenant likely to be in receipt of any of these housing-related benefits?",
"type": "radio",
"answer_options": {
- "0": "Housing Benefit, but not Universal Credit",
- "1": "Prefer not to say"
+ "0": "Housing benefit",
+ "1": "Tenant prefers not to say"
},
"conditional_for": {
- "conditional_question": ["Housing Benefit, but not Universal Credit"]
+ "conditional_question": ["Housing benefit"]
}
},
"conditional_question": {
@@ -436,7 +436,7 @@
}
},
"dependent_page": {
- "depends_on": { "incfreq": "Weekly" },
+ "depends_on": [{ "incfreq": "Weekly" }],
"questions": {
"dependent_question": {
"check_answer_label": "Dependent Question",
@@ -462,7 +462,7 @@
"type": "radio",
"answer_options": {
"0": "Weekly for 52 weeks",
- "1": "Fortnightly"
+ "1": "Every 2 weeks"
}
},
"brent": {
@@ -642,7 +642,7 @@
"subsections": {
"declaration": {
"label": "Declaration",
- "depends_on": {
+ "depends_on": [{
"household_characteristics": "completed",
"household_needs": "completed",
"tenancy_information": "completed",
@@ -650,7 +650,7 @@
"income_and_benefits": "completed",
"rent": "completed",
"local_authority": "completed"
- },
+ }],
"pages": {
"declaration": {
"questions": {
diff --git a/spec/fixtures/forms/2022_2023.json b/spec/fixtures/forms/2022_2023.json
index fc0ba89f1..bcbb74854 100644
--- a/spec/fixtures/forms/2022_2023.json
+++ b/spec/fixtures/forms/2022_2023.json
@@ -29,7 +29,7 @@
"description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.",
"questions": {
},
- "depends_on": { "gdpr_acceptance": "No" }
+ "depends_on": [{ "gdpr_acceptance": "No" }]
},
"sale_or_letting": {
"header": "",
@@ -46,7 +46,7 @@
}
}
},
- "depends_on": { "gdpr_acceptance": "Yes" }
+ "depends_on": [{ "gdpr_acceptance": "Yes" }]
},
"tenant_same_property_renewal": {
"header": "",
@@ -63,7 +63,7 @@
}
}
},
- "depends_on": { "gdpr_acceptance": "Yes", "sale_or_letting": "Letting" }
+ "depends_on": [{ "gdpr_acceptance": "Yes", "sale_or_letting": "Letting" }]
},
"startdate": {
"header": "",
@@ -76,7 +76,7 @@
"type": "date"
}
},
- "depends_on": { "gdpr_acceptance": "Yes", "sale_or_letting": "Letting" }
+ "depends_on": [{ "gdpr_acceptance": "Yes", "sale_or_letting": "Letting" }]
},
"about_this_letting": {
"header": "Tell us about this letting",
@@ -115,7 +115,7 @@
}
}
},
- "depends_on": { "gdpr_acceptance": "Yes", "sale_or_letting": "Letting" }
+ "depends_on": [{ "gdpr_acceptance": "Yes", "sale_or_letting": "Letting" }]
},
"sale_completion_date": {
"header": "",
@@ -128,7 +128,7 @@
"type": "date"
}
},
- "depends_on": { "gdpr_acceptance": "Yes", "sale_or_letting": "Sale" }
+ "depends_on": [{ "gdpr_acceptance": "Yes", "sale_or_letting": "Sale" }]
},
"purchaser_code": {
"header": "",
@@ -142,7 +142,7 @@
"width": 10
}
},
- "depends_on": { "gdpr_acceptance": "Yes", "sale_or_letting": "Sale" }
+ "depends_on": [{ "gdpr_acceptance": "Yes", "sale_or_letting": "Sale" }]
}
}
}
diff --git a/spec/fixtures/forms/test_validator.json b/spec/fixtures/forms/test_validator.json
index 6771b995c..2af164aee 100644
--- a/spec/fixtures/forms/test_validator.json
+++ b/spec/fixtures/forms/test_validator.json
@@ -22,7 +22,7 @@
"type": "text"
}
},
- "depends_on": {"test": "Yes"}
+ "depends_on": [{"test": "Yes"}]
},
"person_1_age": {
"header": "",
diff --git a/spec/models/case_log_spec.rb b/spec/models/case_log_spec.rb
index b0fd2dd6b..c040ade7c 100644
--- a/spec/models/case_log_spec.rb
+++ b/spec/models/case_log_spec.rb
@@ -1038,6 +1038,8 @@ RSpec.describe Form, type: :model do
other_hhmemb: 6,
rent_type: "London living rent",
needstype: "General needs",
+ hb: "Housing benefit",
+ hbrentshortfall: "No",
})
end
@@ -1218,5 +1220,12 @@ RSpec.describe Form, type: :model do
expect(record_from_db["totadult"]).to eq(3)
end
end
+
+ it "correctly derives and saves has_benefits" do
+ case_log.reload
+
+ record_from_db = ActiveRecord::Base.connection.execute("select has_benefits from case_logs where id=#{case_log.id}").to_a[0]
+ expect(record_from_db["has_benefits"]).to eq("Yes")
+ end
end
end
diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb
index cc35ba516..009a107ba 100644
--- a/spec/models/form/question_spec.rb
+++ b/spec/models/form/question_spec.rb
@@ -145,7 +145,7 @@ RSpec.describe Form::Question, type: :model do
end
it "knows whether it is enabled or not for met conditions" do
- case_log.hb = "Housing Benefit, but not Universal Credit"
+ case_log.hb = "Housing benefit"
expect(subject.enabled?(case_log)).to be true
end
end
diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb
index 75c796b14..40293a321 100644
--- a/spec/requests/form_controller_spec.rb
+++ b/spec/requests/form_controller_spec.rb
@@ -269,6 +269,16 @@ RSpec.describe FormController, type: :request do
}
end
+ let(:case_log_form_conditional_question_wchair_yes_params) do
+ {
+ id: case_log.id,
+ case_log: {
+ page: "property_wheelchair_accessible",
+ wchair: "Yes",
+ },
+ }
+ end
+
it "routes to the appropriate conditional page based on the question answer of the current page" do
post "/logs/#{case_log.id}/form", params: case_log_form_conditional_question_yes_params
expect(response).to redirect_to("/logs/#{case_log.id}/conditional-question-yes-page")
@@ -276,6 +286,12 @@ RSpec.describe FormController, type: :request do
post "/logs/#{case_log.id}/form", params: case_log_form_conditional_question_no_params
expect(response).to redirect_to("/logs/#{case_log.id}/conditional-question-no-page")
end
+
+ it "routes to the page if at least one of the condition sets is met" do
+ post "/logs/#{case_log.id}/form", params: case_log_form_conditional_question_wchair_yes_params
+ post "/logs/#{case_log.id}/form", params: case_log_form_conditional_question_no_params
+ expect(response).to redirect_to("/logs/#{case_log.id}/conditional-question-yes-page")
+ end
end
context "case logs that are not owned or managed by your organisation" do