From 680e9add68766a3912c7500e043be7c94aaddbf5 Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Fri, 30 Sep 2022 12:29:51 +0100
Subject: [PATCH 01/16] Cldc 1482 sales log buyer company (#893)
* feat: add boyer_company page and question (migration still to be committed)
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* tests: add tests for question and page
* refactor: spacing
* feat: update schema
* feat: add boyer_company page and question (migration still to be committed)
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* tests: add tests for question and page
* refactor: spacing
* feat: update test
* feat: add boyer_company page and question (migration still to be committed)
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* tests: add tests for question and page
* refactor: spacing
* feat: add boyer_company page and question (migration still to be committed)
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* tests: add tests for question and page
* refactor: spacing
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* feat: add migration and updated schema
* feat: update tests (and add housingneeds_type to schema that was previously missing)
* test: update tests
---
app/models/form/sales/pages/buyer_company.rb | 15 +++++++
.../form/sales/questions/buyer_company.rb | 17 ++++++++
app/models/form/sales/subsections/setup.rb | 1 +
spec/factories/sales_log.rb | 1 +
.../form/sales/pages/buyer_company_spec.rb | 29 ++++++++++++++
.../sales/questions/buyer_company_spec.rb | 40 +++++++++++++++++++
.../form/sales/subsections/setup_spec.rb | 2 +-
spec/models/form_handler_spec.rb | 4 +-
spec/models/form_spec.rb | 4 +-
9 files changed, 108 insertions(+), 5 deletions(-)
create mode 100644 app/models/form/sales/pages/buyer_company.rb
create mode 100644 app/models/form/sales/questions/buyer_company.rb
create mode 100644 spec/models/form/sales/pages/buyer_company_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer_company_spec.rb
diff --git a/app/models/form/sales/pages/buyer_company.rb b/app/models/form/sales/pages/buyer_company.rb
new file mode 100644
index 000000000..6985a3908
--- /dev/null
+++ b/app/models/form/sales/pages/buyer_company.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::BuyerCompany < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_company"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::BuyerCompany.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/buyer_company.rb b/app/models/form/sales/questions/buyer_company.rb
new file mode 100644
index 000000000..70c732866
--- /dev/null
+++ b/app/models/form/sales/questions/buyer_company.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Questions::BuyerCompany < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "companybuy"
+ @check_answer_label = "Company buyer"
+ @header = "Is the buyer a company?"
+ @hint_text = ""
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb
index 7601bbb51..b9ba89dcf 100644
--- a/app/models/form/sales/subsections/setup.rb
+++ b/app/models/form/sales/subsections/setup.rb
@@ -16,6 +16,7 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection
Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self),
Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self),
+ Form::Sales::Pages::BuyerCompany.new(nil, nil, self),
Form::Sales::Pages::BuyerLive.new(nil, nil, self),
Form::Sales::Pages::JointPurchase.new(nil, nil, self),
Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self),
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 670131681..0a8a56ee0 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -16,6 +16,7 @@ FactoryBot.define do
ownershipsch { 2 }
type { 8 }
saledate { Time.utc(2022, 2, 2, 10, 36, 49) }
+ companybuy { 1 }
jointpur { 1 }
beds { 2 }
jointmore { 1 }
diff --git a/spec/models/form/sales/pages/buyer_company_spec.rb b/spec/models/form/sales/pages/buyer_company_spec.rb
new file mode 100644
index 000000000..94b42c28b
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer_company_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::BuyerCompany, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[companybuy])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_company")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer_company_spec.rb b/spec/models/form/sales/questions/buyer_company_spec.rb
new file mode 100644
index 000000000..1d7d98940
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer_company_spec.rb
@@ -0,0 +1,40 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::BuyerCompany, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("companybuy")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Is the buyer a company?")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb
index ca63d092d..ec7ff4ada 100644
--- a/spec/models/form/sales/subsections/setup_spec.rb
+++ b/spec/models/form/sales/subsections/setup_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
it "has correct pages" do
expect(setup.pages.map(&:id)).to eq(
- %w[organisation created_by completion_date purchaser_code ownership_scheme shared_ownership_type discounted_ownership_type outright_ownership_type buyer_live joint_purchase number_joint_buyers builtype],
+ %w[organisation created_by completion_date purchaser_code ownership_scheme shared_ownership_type discounted_ownership_type outright_ownership_type buyer_company buyer_live joint_purchase number_joint_buyers builtype],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index b991a0278..e323fdaea 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(19)
+ expect(form.pages.count).to eq(20)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(19)
+ expect(form.pages.count).to eq(20)
expect(form.name).to eq("2021_2022_sales")
end
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index c4da6ecf4..571e7930e 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -218,9 +218,9 @@ RSpec.describe Form, type: :model do
expect(form.sections[0].class).to eq(Form::Sales::Sections::Setup)
expect(form.subsections.count).to eq(1)
expect(form.subsections.first.id).to eq("setup")
- expect(form.pages.count).to eq(12)
+ expect(form.pages.count).to eq(13)
expect(form.pages.first.id).to eq("organisation")
- expect(form.questions.count).to eq(13)
+ expect(form.questions.count).to eq(14)
expect(form.questions.first.id).to eq("owning_organisation_id")
expect(form.start_date).to eq(Time.zone.parse("2022-04-01"))
expect(form.end_date).to eq(Time.zone.parse("2023-07-01"))
From a7652131786cd77292217b47cce821938fbda2fc Mon Sep 17 00:00:00 2001
From: Jack S <113976590+bibblobcode@users.noreply.github.com>
Date: Fri, 30 Sep 2022 14:44:52 +0100
Subject: [PATCH 02/16] Format JSON files to improve readability (#923)
---
config/forms/2021_2022.json | 585 +++++++++--
config/forms/2022_2023.json | 589 ++++++++---
config/forms/schema/2021_2022.json | 16 +-
config/forms/schema/generic.json | 21 +-
spec/fixtures/forms/2021_2022.json | 1251 ++++++++++++-----------
spec/fixtures/forms/2022_2023.json | 96 +-
spec/fixtures/forms/test_validator.json | 6 +-
7 files changed, 1712 insertions(+), 852 deletions(-)
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 2ed0f3fdc..4292d1d3a 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -32,15 +32,19 @@
}
},
"conditional_for": {
- "postcode_full": [1]
+ "postcode_full": [
+ 1
+ ]
},
"hidden_in_check_answers": {
- "depends_on": [{
- "postcode_known": 0
- },
- {
- "postcode_known": 1
- }]
+ "depends_on": [
+ {
+ "postcode_known": 0
+ },
+ {
+ "postcode_known": 1
+ }
+ ]
}
},
"postcode_full": {
@@ -772,7 +776,11 @@
]
},
"void_date_value_check": {
- "depends_on": [{ "voiddate_in_soft_range?": true }],
+ "depends_on": [
+ {
+ "voiddate_in_soft_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.void_date.title_text"
},
@@ -839,7 +847,9 @@
}
},
"conditional_for": {
- "mrcdate": [1]
+ "mrcdate": [
+ 1
+ ]
}
},
"mrcdate": {
@@ -901,7 +911,11 @@
]
},
"property_major_repairs_value_check": {
- "depends_on": [{ "major_repairs_date_in_soft_range?": true }],
+ "depends_on": [
+ {
+ "major_repairs_date_in_soft_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.major_repairs_date.title_text"
},
@@ -989,7 +1003,9 @@
}
},
"conditional_for": {
- "tenancyother": [3]
+ "tenancyother": [
+ 3
+ ]
}
},
"tenancyother": {
@@ -1031,7 +1047,9 @@
}
},
"conditional_for": {
- "tenancyother": [3]
+ "tenancyother": [
+ 3
+ ]
}
},
"tenancyother": {
@@ -1153,10 +1171,18 @@
"width": 2
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"no_females_pregnant_household_lead_hhmemb_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1255,7 +1281,9 @@
}
},
"conditional_for": {
- "age1": [0]
+ "age1": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -1285,10 +1313,18 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"no_females_pregnant_household_lead_age_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1398,10 +1434,18 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"no_females_pregnant_household_lead_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1517,7 +1561,11 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"lead_tenant_ethnic_background_arab": {
"header": "",
@@ -1539,7 +1587,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 4 }]
+ "depends_on": [
+ {
+ "ethnic_group": 4
+ }
+ ]
},
"lead_tenant_ethnic_background_asian": {
"header": "",
@@ -1570,7 +1622,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 2 }]
+ "depends_on": [
+ {
+ "ethnic_group": 2
+ }
+ ]
},
"lead_tenant_ethnic_background_black": {
"header": "",
@@ -1595,7 +1651,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 3 }]
+ "depends_on": [
+ {
+ "ethnic_group": 3
+ }
+ ]
},
"lead_tenant_ethnic_background_mixed": {
"header": "",
@@ -1623,7 +1683,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 1 }]
+ "depends_on": [
+ {
+ "ethnic_group": 1
+ }
+ ]
},
"lead_tenant_ethnic_background_white": {
"header": "",
@@ -1651,7 +1715,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 0 }]
+ "depends_on": [
+ {
+ "ethnic_group": 0
+ }
+ ]
},
"lead_tenant_nationality": {
"header": "",
@@ -1719,7 +1787,11 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"lead_tenant_working_situation": {
"header": "",
@@ -1768,10 +1840,18 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"lead_tenant_under_retirement_value_check": {
- "depends_on": [{ "person_1_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_1_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -1826,7 +1906,9 @@
},
"lead_tenant_over_retirement_value_check": {
"depends_on": [
- { "person_1_not_retired_over_soft_max_age?": true }
+ {
+ "person_1_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -1978,7 +2060,9 @@
}
},
"conditional_for": {
- "age2": [0]
+ "age2": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -2016,7 +2100,10 @@
},
"no_females_pregnant_household_person_2_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age2_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age2_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -2260,8 +2347,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age2_known": 1 },
- { "age2": { "operator": "<", "operand": 16 } }
+ {
+ "age2_known": 1
+ },
+ {
+ "age2": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -2291,7 +2385,11 @@
]
},
"person_2_under_retirement_value_check": {
- "depends_on": [{ "person_2_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_2_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -2346,7 +2444,9 @@
},
"person_2_over_retirement_value_check": {
"depends_on": [
- { "person_2_not_retired_over_soft_max_age?": true }
+ {
+ "person_2_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -2495,7 +2595,9 @@
}
},
"conditional_for": {
- "age3": [0]
+ "age3": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -2533,7 +2635,10 @@
},
"no_females_pregnant_household_person_3_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age3_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age3_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -2777,8 +2882,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age3_known": 1 },
- { "age3": { "operator": "<", "operand": 16 } }
+ {
+ "age3_known": 1
+ },
+ {
+ "age3": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -2808,7 +2920,11 @@
]
},
"person_3_under_retirement_value_check": {
- "depends_on": [{ "person_3_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_3_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -2863,7 +2979,9 @@
},
"person_3_over_retirement_value_check": {
"depends_on": [
- { "person_3_not_retired_over_soft_max_age?": true }
+ {
+ "person_3_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -3009,7 +3127,9 @@
}
},
"conditional_for": {
- "age4": [0]
+ "age4": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -3047,7 +3167,10 @@
},
"no_females_pregnant_household_person_4_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age4_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age4_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -3291,8 +3414,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age4_known": 1 },
- { "age4": { "operator": "<", "operand": 16 } }
+ {
+ "age4_known": 1
+ },
+ {
+ "age4": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -3322,7 +3452,11 @@
]
},
"person_4_under_retirement_value_check": {
- "depends_on": [{ "person_4_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_4_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -3377,7 +3511,9 @@
},
"person_4_over_retirement_value_check": {
"depends_on": [
- { "person_4_not_retired_over_soft_max_age?": true }
+ {
+ "person_4_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -3520,7 +3656,9 @@
}
},
"conditional_for": {
- "age5": [0]
+ "age5": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -3558,7 +3696,10 @@
},
"no_females_pregnant_household_person_5_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age5_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age5_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -3802,8 +3943,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age5_known": 1 },
- { "age5": { "operator": "<", "operand": 16 } }
+ {
+ "age5_known": 1
+ },
+ {
+ "age5": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -3833,7 +3981,11 @@
]
},
"person_5_under_retirement_value_check": {
- "depends_on": [{ "person_5_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_5_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -3888,7 +4040,9 @@
},
"person_5_over_retirement_value_check": {
"depends_on": [
- { "person_5_not_retired_over_soft_max_age?": true }
+ {
+ "person_5_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -4028,7 +4182,9 @@
}
},
"conditional_for": {
- "age6": [0]
+ "age6": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -4066,7 +4222,10 @@
},
"no_females_pregnant_household_person_6_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age6_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age6_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -4310,8 +4469,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age6_known": 1 },
- { "age6": { "operator": "<", "operand": 16 } }
+ {
+ "age6_known": 1
+ },
+ {
+ "age6": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -4341,7 +4507,11 @@
]
},
"person_6_under_retirement_value_check": {
- "depends_on": [{ "person_6_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_6_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -4396,7 +4566,9 @@
},
"person_6_over_retirement_value_check": {
"depends_on": [
- { "person_6_not_retired_over_soft_max_age?": true }
+ {
+ "person_6_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -4533,7 +4705,9 @@
}
},
"conditional_for": {
- "age7": [0]
+ "age7": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -4571,7 +4745,10 @@
},
"no_females_pregnant_household_person_7_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age7_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age7_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -4815,8 +4992,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age7_known": 1 },
- { "age7": { "operator": "<", "operand": 16 } }
+ {
+ "age7_known": 1
+ },
+ {
+ "age7": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -4846,7 +5030,11 @@
]
},
"person_7_under_retirement_value_check": {
- "depends_on": [{ "person_7_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_7_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -4901,7 +5089,9 @@
},
"person_7_over_retirement_value_check": {
"depends_on": [
- { "person_7_not_retired_over_soft_max_age?": true }
+ {
+ "person_7_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -5035,7 +5225,9 @@
}
},
"conditional_for": {
- "age8": [0]
+ "age8": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -5073,7 +5265,10 @@
},
"no_females_pregnant_household_person_8_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age8_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age8_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -5317,8 +5512,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age8_known": 1 },
- { "age8": { "operator": "<", "operand": 16 } }
+ {
+ "age8_known": 1
+ },
+ {
+ "age8": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -5348,7 +5550,11 @@
]
},
"person_8_under_retirement_value_check": {
- "depends_on": [{ "person_8_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_8_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -5403,7 +5609,9 @@
},
"person_8_over_retirement_value_check": {
"depends_on": [
- { "person_8_not_retired_over_soft_max_age?": true }
+ {
+ "person_8_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -5594,7 +5802,11 @@
}
},
"no_females_pregnant_household_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -5662,7 +5874,8 @@
"pregnancy_value_check": {
"check_answer_label": "Pregnancy confirmation",
"hidden_in_check_answers": {
- "depends_on": [{
+ "depends_on": [
+ {
"pregnancy_value_check": 0
},
{
@@ -6052,7 +6265,9 @@
}
},
"conditional_for": {
- "reasonother": [20]
+ "reasonother": [
+ 20
+ ]
}
},
"reasonother": {
@@ -6283,7 +6498,9 @@
}
},
"conditional_for": {
- "ppostcode_full": [1]
+ "ppostcode_full": [
+ 1
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -6344,7 +6561,9 @@
}
},
"conditional_for": {
- "prevloc": [1]
+ "prevloc": [
+ 1
+ ]
}
},
"prevloc": {
@@ -7175,7 +7394,11 @@
}
},
"net_income_value_check": {
- "depends_on": [{ "net_income_soft_validation_triggered?": true }],
+ "depends_on": [
+ {
+ "net_income_soft_validation_triggered?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.net_income.title_text"
},
@@ -7376,7 +7599,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7471,7 +7696,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7516,7 +7743,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7561,7 +7790,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7602,7 +7833,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7616,7 +7852,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7630,7 +7871,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7644,7 +7890,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7660,7 +7911,12 @@
"suffix": " every week",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -7800,7 +8056,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7814,7 +8075,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7828,7 +8094,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7842,7 +8113,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7858,7 +8134,12 @@
"suffix": " every 2 weeks",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -7898,7 +8179,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7912,7 +8198,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7926,7 +8217,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7940,7 +8236,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7956,7 +8257,12 @@
"suffix": " every 4 weeks",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -7996,7 +8302,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -8010,7 +8321,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -8024,7 +8340,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -8038,7 +8359,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -8054,7 +8380,12 @@
"suffix": " every month",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -8081,7 +8412,11 @@
]
},
"min_rent_value_check": {
- "depends_on": [{ "rent_in_soft_min_range?": true }],
+ "depends_on": [
+ {
+ "rent_in_soft_min_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.rent.min.title_text",
"arguments": [
@@ -8134,7 +8469,11 @@
}
},
"max_rent_value_check": {
- "depends_on": [{ "rent_in_soft_max_range?": true }],
+ "depends_on": [
+ {
+ "rent_in_soft_max_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.rent.max.title_text",
"arguments": [
@@ -8253,7 +8592,9 @@
}
},
"conditional_for": {
- "tshortfall": [0]
+ "tshortfall": [
+ 0
+ ]
}
},
"tshortfall": {
@@ -8267,39 +8608,57 @@
"suffix": [
{
"label": " every 2 weeks",
- "depends_on": { "period": 2 }
+ "depends_on": {
+ "period": 2
+ }
},
{
"label": " every 4 weeks",
- "depends_on": { "period": 3 }
+ "depends_on": {
+ "period": 3
+ }
},
{
"label": " every calendar month",
- "depends_on": { "period": 4 }
+ "depends_on": {
+ "period": 4
+ }
},
{
"label": " every week for 50 weeks",
- "depends_on": { "period": 5 }
+ "depends_on": {
+ "period": 5
+ }
},
{
"label": " every week for 49 weeks",
- "depends_on": { "period": 6 }
+ "depends_on": {
+ "period": 6
+ }
},
{
"label": " every week for 48 weeks",
- "depends_on": { "period": 7 }
+ "depends_on": {
+ "period": 7
+ }
},
{
"label": " every week for 47 weeks",
- "depends_on": { "period": 8 }
+ "depends_on": {
+ "period": 8
+ }
},
{
"label": " every week for 46 weeks",
- "depends_on": { "period": 9 }
+ "depends_on": {
+ "period": 9
+ }
},
{
"label": " every week for 52 weeks",
- "depends_on": { "period": 1 }
+ "depends_on": {
+ "period": 1
+ }
}
]
}
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index 190fa04bd..b30461a84 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -32,15 +32,19 @@
}
},
"conditional_for": {
- "postcode_full": [1]
+ "postcode_full": [
+ 1
+ ]
},
"hidden_in_check_answers": {
- "depends_on": [{
- "postcode_known": 0
- },
- {
- "postcode_known": 1
- }]
+ "depends_on": [
+ {
+ "postcode_known": 0
+ },
+ {
+ "postcode_known": 1
+ }
+ ]
}
},
"postcode_full": {
@@ -772,7 +776,11 @@
]
},
"void_date_value_check": {
- "depends_on": [{ "voiddate_in_soft_range?": true }],
+ "depends_on": [
+ {
+ "voiddate_in_soft_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.void_date.title_text"
},
@@ -839,7 +847,9 @@
}
},
"conditional_for": {
- "mrcdate": [1]
+ "mrcdate": [
+ 1
+ ]
}
},
"mrcdate": {
@@ -901,7 +911,11 @@
]
},
"property_major_repairs_value_check": {
- "depends_on": [{ "major_repairs_date_in_soft_range?": true }],
+ "depends_on": [
+ {
+ "major_repairs_date_in_soft_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.major_repairs_date.title_text"
},
@@ -1018,7 +1032,9 @@
}
},
"conditional_for": {
- "tenancyother": [3]
+ "tenancyother": [
+ 3
+ ]
}
},
"tenancyother": {
@@ -1063,7 +1079,9 @@
}
},
"conditional_for": {
- "tenancyother": [3]
+ "tenancyother": [
+ 3
+ ]
}
},
"tenancyother": {
@@ -1188,10 +1206,18 @@
"width": 2
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"no_females_pregnant_household_lead_hhmemb_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1290,7 +1316,9 @@
}
},
"conditional_for": {
- "age1": [0]
+ "age1": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -1320,10 +1348,18 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"no_females_pregnant_household_lead_age_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1433,10 +1469,18 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"no_females_pregnant_household_lead_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1552,7 +1596,11 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"lead_tenant_ethnic_background_arab": {
"header": "",
@@ -1574,7 +1622,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 4 }]
+ "depends_on": [
+ {
+ "ethnic_group": 4
+ }
+ ]
},
"lead_tenant_ethnic_background_asian": {
"header": "",
@@ -1605,7 +1657,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 2 }]
+ "depends_on": [
+ {
+ "ethnic_group": 2
+ }
+ ]
},
"lead_tenant_ethnic_background_black": {
"header": "",
@@ -1630,7 +1686,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 3 }]
+ "depends_on": [
+ {
+ "ethnic_group": 3
+ }
+ ]
},
"lead_tenant_ethnic_background_mixed": {
"header": "",
@@ -1658,7 +1718,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 1 }]
+ "depends_on": [
+ {
+ "ethnic_group": 1
+ }
+ ]
},
"lead_tenant_ethnic_background_white": {
"header": "",
@@ -1686,7 +1750,11 @@
}
}
},
- "depends_on": [{ "ethnic_group": 0 }]
+ "depends_on": [
+ {
+ "ethnic_group": 0
+ }
+ ]
},
"lead_tenant_nationality": {
"header": "",
@@ -1718,7 +1786,11 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"lead_tenant_working_situation": {
"header": "",
@@ -1767,10 +1839,18 @@
}
}
},
- "depends_on": [{ "declaration": 1 }]
+ "depends_on": [
+ {
+ "declaration": 1
+ }
+ ]
},
"lead_tenant_under_retirement_value_check": {
- "depends_on": [{ "person_1_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_1_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -1825,7 +1905,9 @@
},
"lead_tenant_over_retirement_value_check": {
"depends_on": [
- { "person_1_not_retired_over_soft_max_age?": true }
+ {
+ "person_1_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -1977,7 +2059,9 @@
}
},
"conditional_for": {
- "age2": [0]
+ "age2": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -2015,7 +2099,10 @@
},
"no_females_pregnant_household_person_2_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age2_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age2_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -2259,8 +2346,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age2_known": 1 },
- { "age2": { "operator": "<", "operand": 16 } }
+ {
+ "age2_known": 1
+ },
+ {
+ "age2": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -2290,7 +2384,11 @@
]
},
"person_2_under_retirement_value_check": {
- "depends_on": [{ "person_2_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_2_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -2345,7 +2443,9 @@
},
"person_2_over_retirement_value_check": {
"depends_on": [
- { "person_2_not_retired_over_soft_max_age?": true }
+ {
+ "person_2_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -2494,7 +2594,9 @@
}
},
"conditional_for": {
- "age3": [0]
+ "age3": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -2532,7 +2634,10 @@
},
"no_females_pregnant_household_person_3_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age3_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age3_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -2776,8 +2881,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age3_known": 1 },
- { "age3": { "operator": "<", "operand": 16 } }
+ {
+ "age3_known": 1
+ },
+ {
+ "age3": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -2807,7 +2919,11 @@
]
},
"person_3_under_retirement_value_check": {
- "depends_on": [{ "person_3_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_3_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -2862,7 +2978,9 @@
},
"person_3_over_retirement_value_check": {
"depends_on": [
- { "person_3_not_retired_over_soft_max_age?": true }
+ {
+ "person_3_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -3008,7 +3126,9 @@
}
},
"conditional_for": {
- "age4": [0]
+ "age4": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -3046,7 +3166,10 @@
},
"no_females_pregnant_household_person_4_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age4_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age4_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -3290,8 +3413,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age4_known": 1 },
- { "age4": { "operator": "<", "operand": 16 } }
+ {
+ "age4_known": 1
+ },
+ {
+ "age4": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -3321,7 +3451,11 @@
]
},
"person_4_under_retirement_value_check": {
- "depends_on": [{ "person_4_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_4_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -3376,7 +3510,9 @@
},
"person_4_over_retirement_value_check": {
"depends_on": [
- { "person_4_not_retired_over_soft_max_age?": true }
+ {
+ "person_4_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -3519,7 +3655,9 @@
}
},
"conditional_for": {
- "age5": [0]
+ "age5": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -3557,7 +3695,10 @@
},
"no_females_pregnant_household_person_5_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age5_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age5_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -3801,8 +3942,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age5_known": 1 },
- { "age5": { "operator": "<", "operand": 16 } }
+ {
+ "age5_known": 1
+ },
+ {
+ "age5": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -3832,7 +3980,11 @@
]
},
"person_5_under_retirement_value_check": {
- "depends_on": [{ "person_5_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_5_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -3887,7 +4039,9 @@
},
"person_5_over_retirement_value_check": {
"depends_on": [
- { "person_5_not_retired_over_soft_max_age?": true }
+ {
+ "person_5_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -4027,7 +4181,9 @@
}
},
"conditional_for": {
- "age6": [0]
+ "age6": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -4065,7 +4221,10 @@
},
"no_females_pregnant_household_person_6_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age6_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age6_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -4309,8 +4468,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age6_known": 1 },
- { "age6": { "operator": "<", "operand": 16 } }
+ {
+ "age6_known": 1
+ },
+ {
+ "age6": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -4340,7 +4506,11 @@
]
},
"person_6_under_retirement_value_check": {
- "depends_on": [{ "person_6_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_6_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -4395,7 +4565,9 @@
},
"person_6_over_retirement_value_check": {
"depends_on": [
- { "person_6_not_retired_over_soft_max_age?": true }
+ {
+ "person_6_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -4532,7 +4704,9 @@
}
},
"conditional_for": {
- "age7": [0]
+ "age7": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -4570,7 +4744,10 @@
},
"no_females_pregnant_household_person_7_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age7_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age7_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -4814,8 +4991,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age7_known": 1 },
- { "age7": { "operator": "<", "operand": 16 } }
+ {
+ "age7_known": 1
+ },
+ {
+ "age7": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -4845,7 +5029,11 @@
]
},
"person_7_under_retirement_value_check": {
- "depends_on": [{ "person_7_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_7_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -4900,7 +5088,9 @@
},
"person_7_over_retirement_value_check": {
"depends_on": [
- { "person_7_not_retired_over_soft_max_age?": true }
+ {
+ "person_7_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -5034,7 +5224,9 @@
}
},
"conditional_for": {
- "age8": [0]
+ "age8": [
+ 0
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -5072,7 +5264,10 @@
},
"no_females_pregnant_household_person_8_age_value_check": {
"depends_on": [
- { "no_females_in_a_pregnant_household?": true, "age8_known": 0 }
+ {
+ "no_females_in_a_pregnant_household?": true,
+ "age8_known": 0
+ }
],
"title_text": {
"translation": "soft_validations.pregnancy.title",
@@ -5316,8 +5511,15 @@
"9": {
"value": "Child under 16",
"depends_on": [
- { "age8_known": 1 },
- { "age8": { "operator": "<", "operand": 16 } }
+ {
+ "age8_known": 1
+ },
+ {
+ "age8": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
]
},
"0": {
@@ -5347,7 +5549,11 @@
]
},
"person_8_under_retirement_value_check": {
- "depends_on": [{ "person_8_retired_under_soft_min_age?": true }],
+ "depends_on": [
+ {
+ "person_8_retired_under_soft_min_age?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.retirement.min.title",
"arguments": [
@@ -5402,7 +5608,9 @@
},
"person_8_over_retirement_value_check": {
"depends_on": [
- { "person_8_not_retired_over_soft_max_age?": true }
+ {
+ "person_8_not_retired_over_soft_max_age?": true
+ }
],
"title_text": {
"translation": "soft_validations.retirement.max.title",
@@ -5596,7 +5804,11 @@
}
},
"no_females_pregnant_household_value_check": {
- "depends_on": [{ "no_females_in_a_pregnant_household?": true }],
+ "depends_on": [
+ {
+ "no_females_in_a_pregnant_household?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -5664,7 +5876,8 @@
"pregnancy_value_check": {
"check_answer_label": "Pregnancy confirmation",
"hidden_in_check_answers": {
- "depends_on": [{
+ "depends_on": [
+ {
"pregnancy_value_check": 0
},
{
@@ -6051,7 +6264,9 @@
}
},
"conditional_for": {
- "reasonother": [20]
+ "reasonother": [
+ 20
+ ]
}
},
"reasonother": {
@@ -6242,7 +6457,9 @@
}
},
"conditional_for": {
- "ppostcode_full": [1]
+ "ppostcode_full": [
+ 1
+ ]
},
"hidden_in_check_answers": {
"depends_on": [
@@ -6303,7 +6520,9 @@
}
},
"conditional_for": {
- "prevloc": [1]
+ "prevloc": [
+ 1
+ ]
}
},
"prevloc": {
@@ -7134,8 +7353,14 @@
}
},
"net_income_value_check": {
- "depends_on": [{ "net_income_soft_validation_triggered?": true }],
- "title_text": { "translation": "soft_validations.net_income.title_text" },
+ "depends_on": [
+ {
+ "net_income_soft_validation_triggered?": true
+ }
+ ],
+ "title_text": {
+ "translation": "soft_validations.net_income.title_text"
+ },
"informative_text": {
"translation": "soft_validations.net_income.hint_text",
"arguments": [
@@ -7330,7 +7555,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7425,7 +7652,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7470,7 +7699,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7515,7 +7746,9 @@
}
},
"conditional_for": {
- "chcharge": [1]
+ "chcharge": [
+ 1
+ ]
}
},
"chcharge": {
@@ -7556,7 +7789,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7570,7 +7808,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7584,7 +7827,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7598,7 +7846,12 @@
"width": 5,
"prefix": "£",
"suffix": " every week",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7614,7 +7867,12 @@
"suffix": " every week",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -7754,7 +8012,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7768,7 +8031,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7782,7 +8050,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7796,7 +8069,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 2 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7812,7 +8090,12 @@
"suffix": " every 2 weeks",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -7852,7 +8135,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7866,7 +8154,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7880,7 +8173,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7894,7 +8192,12 @@
"width": 5,
"prefix": "£",
"suffix": " every 4 weeks",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7910,7 +8213,12 @@
"suffix": " every 4 weeks",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -7950,7 +8258,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7964,7 +8277,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7978,7 +8296,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -7992,7 +8315,12 @@
"width": 5,
"prefix": "£",
"suffix": " every month",
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge",
"hidden_in_check_answers": true
},
@@ -8008,7 +8336,12 @@
"suffix": " every month",
"readonly": true,
"requires_js": true,
- "fields_added": ["brent", "scharge", "pscharge", "supcharg"]
+ "fields_added": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ]
}
},
"depends_on": [
@@ -8035,7 +8368,11 @@
]
},
"min_rent_value_check": {
- "depends_on": [{ "rent_in_soft_min_range?": true }],
+ "depends_on": [
+ {
+ "rent_in_soft_min_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.rent.min.title_text",
"arguments": [
@@ -8088,7 +8425,11 @@
}
},
"max_rent_value_check": {
- "depends_on": [{ "rent_in_soft_max_range?": true }],
+ "depends_on": [
+ {
+ "rent_in_soft_max_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.rent.max.title_text",
"arguments": [
@@ -8199,7 +8540,9 @@
}
},
"conditional_for": {
- "tshortfall": [0]
+ "tshortfall": [
+ 0
+ ]
}
},
"tshortfall": {
@@ -8213,39 +8556,57 @@
"suffix": [
{
"label": " every 2 weeks",
- "depends_on": { "period": 2 }
+ "depends_on": {
+ "period": 2
+ }
},
{
"label": " every 4 weeks",
- "depends_on": { "period": 3 }
+ "depends_on": {
+ "period": 3
+ }
},
{
"label": " every calendar month",
- "depends_on": { "period": 4 }
+ "depends_on": {
+ "period": 4
+ }
},
{
"label": " every week for 50 weeks",
- "depends_on": { "period": 5 }
+ "depends_on": {
+ "period": 5
+ }
},
{
"label": " every week for 49 weeks",
- "depends_on": { "period": 6 }
+ "depends_on": {
+ "period": 6
+ }
},
{
"label": " every week for 48 weeks",
- "depends_on": { "period": 7 }
+ "depends_on": {
+ "period": 7
+ }
},
{
"label": " every week for 47 weeks",
- "depends_on": { "period": 8 }
+ "depends_on": {
+ "period": 8
+ }
},
{
"label": " every week for 46 weeks",
- "depends_on": { "period": 9 }
+ "depends_on": {
+ "period": 9
+ }
},
{
"label": " every week for 52 weeks",
- "depends_on": { "period": 1 }
+ "depends_on": {
+ "period": 1
+ }
}
]
}
diff --git a/config/forms/schema/2021_2022.json b/config/forms/schema/2021_2022.json
index d91600c4d..326394391 100644
--- a/config/forms/schema/2021_2022.json
+++ b/config/forms/schema/2021_2022.json
@@ -4,7 +4,12 @@
"title": "Form",
"description": "A form",
"type": "object",
- "required": ["form_type", "start_year", "end_year", "sections"],
+ "required": [
+ "form_type",
+ "start_year",
+ "end_year",
+ "sections"
+ ],
"properties": {
"form_type": {
"description": "",
@@ -35,7 +40,9 @@
"[a-z_]+": {
"description": "",
"type": "object",
- "required": ["label"],
+ "required": [
+ "label"
+ ],
"properties": {
"label": {
"description": "",
@@ -62,7 +69,10 @@
"[a-z_]+": {
"description": "",
"type": "object",
- "required": ["header", "check_answer_label"],
+ "required": [
+ "header",
+ "check_answer_label"
+ ],
"properties": {
"check_answer_label": {
"description": "",
diff --git a/config/forms/schema/generic.json b/config/forms/schema/generic.json
index 7535ca339..97552a5f4 100644
--- a/config/forms/schema/generic.json
+++ b/config/forms/schema/generic.json
@@ -4,7 +4,12 @@
"title": "Form",
"description": "A form",
"type": "object",
- "required": ["form_type", "start_year", "end_year", "sections"],
+ "required": [
+ "form_type",
+ "start_year",
+ "end_year",
+ "sections"
+ ],
"properties": {
"form_type": {
"description": "",
@@ -35,7 +40,9 @@
"[a-z_]+": {
"description": "SubSection Name",
"type": "object",
- "required": ["label"],
+ "required": [
+ "label"
+ ],
"properties": {
"label": {
"description": "",
@@ -47,7 +54,10 @@
"^(?!(depends_on))[a-z_]+$": {
"description": "Page Name",
"type": "object",
- "required": ["header", "questions"],
+ "required": [
+ "header",
+ "questions"
+ ],
"properties": {
"header": {
"description": "",
@@ -63,7 +73,10 @@
"[a-z_]+": {
"description": "Question Name",
"type": "object",
- "required": ["header", "type"],
+ "required": [
+ "header",
+ "type"
+ ],
"properties": {
"header": {
"description": "",
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 99b4d8713..faab8e674 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -1,638 +1,702 @@
{
- "form_type": "lettings",
- "start_date": "2021-04-01T00:00:00.000+01:00",
- "end_date": "2022-07-01T00:00:00.000+01:00",
- "sections": {
- "household": {
- "label": "About the household",
- "description": "Make sure the tenant has seen the privacy notice.",
- "subsections": {
- "household_characteristics": {
- "label": "Household characteristics",
- "pages": {
- "tenant_code_test": {
- "questions": {
- "tenancycode": {
- "check_answers_card_number": 0,
- "check_answer_label": "Tenant code",
- "header": "What is the tenant code?",
- "hint_text": "This is how you usually refer to this tenancy on your own systems.",
- "type": "text",
- "width": 10
- }
- },
- "depends_on": [
- {
- "housingneeds_a": 1
- },
- {
- "housingneeds_a": null
- }
- ]},
- "person_1_age": {
- "questions": {
- "age1": {
- "check_answers_card_number": 1,
- "check_answer_label": "Lead tenant’s age",
- "header": "What is the tenant’s age?",
- "type": "numeric",
- "min": 16,
- "max": 120,
- "step": 1,
- "width": 2
- }
+ "form_type": "lettings",
+ "start_date": "2021-04-01T00:00:00.000+01:00",
+ "end_date": "2022-07-01T00:00:00.000+01:00",
+ "sections": {
+ "household": {
+ "label": "About the household",
+ "description": "Make sure the tenant has seen the privacy notice.",
+ "subsections": {
+ "household_characteristics": {
+ "label": "Household characteristics",
+ "pages": {
+ "tenant_code_test": {
+ "questions": {
+ "tenancycode": {
+ "check_answers_card_number": 0,
+ "check_answer_label": "Tenant code",
+ "header": "What is the tenant code?",
+ "hint_text": "This is how you usually refer to this tenancy on your own systems.",
+ "type": "text",
+ "width": 10
+ }
+ },
+ "depends_on": [
+ {
+ "housingneeds_a": 1
},
- "depends_on": [
- {
- "housingneeds_a": 1
- },
- {
- "housingneeds_a": null
- }
- ]
+ {
+ "housingneeds_a": null
+ }
+ ]
+ },
+ "person_1_age": {
+ "questions": {
+ "age1": {
+ "check_answers_card_number": 1,
+ "check_answer_label": "Lead tenant’s age",
+ "header": "What is the tenant’s age?",
+ "type": "numeric",
+ "min": 16,
+ "max": 120,
+ "step": 1,
+ "width": 2
+ }
},
- "person_1_gender": {
- "questions": {
- "sex1": {
- "check_answers_card_number": 1,
- "check_answer_label": "Lead tenant’s gender identity",
- "header": "Which of these best describes the tenant’s gender identity?",
- "type": "radio",
- "answer_options": {
- "F": {
- "value": "Female"
- },
- "M": {
- "value": "Male"
- },
- "X": {
- "value": "Non-binary"
- },
- "R": {
- "value": "Prefer not to say"
- }
+ "depends_on": [
+ {
+ "housingneeds_a": 1
+ },
+ {
+ "housingneeds_a": null
+ }
+ ]
+ },
+ "person_1_gender": {
+ "questions": {
+ "sex1": {
+ "check_answers_card_number": 1,
+ "check_answer_label": "Lead tenant’s gender identity",
+ "header": "Which of these best describes the tenant’s gender identity?",
+ "type": "radio",
+ "answer_options": {
+ "F": {
+ "value": "Female"
+ },
+ "M": {
+ "value": "Male"
+ },
+ "X": {
+ "value": "Non-binary"
+ },
+ "R": {
+ "value": "Prefer not to say"
}
}
}
- },
- "person_1_working_situation": {
- "header": "",
- "description": "",
- "questions": {
- "ecstat1": {
- "check_answers_card_number": 1,
- "check_answer_label": "Lead tenant’s working situation",
- "header": "Which of these best describes the lead tenant’s socks?",
- "hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Part-time – Less than 30 hours"
- },
- "1": {
- "value": "Full-time – 30 hours or more"
- },
- "2": {
- "value": "Full-time student"
- },
- "3": {
- "value": "In government training into work, such as New Deal"
- },
- "4": {
- "value": "Jobseeker"
- },
- "5": {
- "value": "Not seeking work"
- },
- "6": {
- "value": "Unable to work because of long term sick or disability"
- },
- "7": {
- "value": "Retired"
- },
- "8": {
- "value": "Child under 16"
- },
- "9": {
- "value": "Other"
- },
- "divider": {
- "value": true
- },
- "10": {
- "value": "Tenant prefers not to say"
- }
+ }
+ },
+ "person_1_working_situation": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "ecstat1": {
+ "check_answers_card_number": 1,
+ "check_answer_label": "Lead tenant’s working situation",
+ "header": "Which of these best describes the lead tenant’s socks?",
+ "hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Part-time – Less than 30 hours"
+ },
+ "1": {
+ "value": "Full-time – 30 hours or more"
+ },
+ "2": {
+ "value": "Full-time student"
+ },
+ "3": {
+ "value": "In government training into work, such as New Deal"
+ },
+ "4": {
+ "value": "Jobseeker"
+ },
+ "5": {
+ "value": "Not seeking work"
+ },
+ "6": {
+ "value": "Unable to work because of long term sick or disability"
+ },
+ "7": {
+ "value": "Retired"
+ },
+ "8": {
+ "value": "Child under 16"
+ },
+ "9": {
+ "value": "Other"
+ },
+ "divider": {
+ "value": true
+ },
+ "10": {
+ "value": "Tenant prefers not to say"
}
}
}
- },
- "household_number_of_members": {
- "questions": {
- "hhmemb": {
- "check_answers_card_number": 0,
- "check_answer_label": "Number of Household Members",
- "header": "How many people are there in the household?",
- "hint_text": "The maximum number of members is 8",
- "type": "numeric",
- "min": 0,
- "max": 8,
- "step": 1,
- "width": 2,
- "conditional_for": {
- "relat2": ">1",
- "age2": ">1",
- "sex2": ">1"
- }
- },
- "relat2": {
- "check_answers_card_number": 2,
- "check_answer_label": "Person 2’s relationship to lead tenant",
- "header": "What is person 2’s relationship to lead tenant",
- "type": "radio",
- "answer_options": {
- "X": {
- "value": "Other"
- },
- "R": {
- "value": "Prefer not to say"
- }
+ }
+ },
+ "household_number_of_members": {
+ "questions": {
+ "hhmemb": {
+ "check_answers_card_number": 0,
+ "check_answer_label": "Number of Household Members",
+ "header": "How many people are there in the household?",
+ "hint_text": "The maximum number of members is 8",
+ "type": "numeric",
+ "min": 0,
+ "max": 8,
+ "step": 1,
+ "width": 2,
+ "conditional_for": {
+ "relat2": ">1",
+ "age2": ">1",
+ "sex2": ">1"
+ }
+ },
+ "relat2": {
+ "check_answers_card_number": 2,
+ "check_answer_label": "Person 2’s relationship to lead tenant",
+ "header": "What is person 2’s relationship to lead tenant",
+ "type": "radio",
+ "answer_options": {
+ "X": {
+ "value": "Other"
+ },
+ "R": {
+ "value": "Prefer not to say"
}
- },
- "age2": {
- "check_answers_card_number": 2,
- "check_answer_label": "Person 2’s age",
- "header": "Do you know person 2’s age?",
- "type": "numeric",
- "min": 1,
- "max": 120,
- "step": 1,
- "width": 2
- },
- "sex2": {
- "check_answers_card_number": 2,
- "check_answer_label": "Person 2’s gender identity",
- "header": "Which of these best describes person 2’s gender identity?",
- "type": "radio",
- "answer_options": {
- "F": {
- "value": "Female"
- },
- "M": {
- "value": "Male"
- },
- "X": {
- "value": "Non-binary"
- },
- "R": {
- "value": "Prefer not to say"
- }
+ }
+ },
+ "age2": {
+ "check_answers_card_number": 2,
+ "check_answer_label": "Person 2’s age",
+ "header": "Do you know person 2’s age?",
+ "type": "numeric",
+ "min": 1,
+ "max": 120,
+ "step": 1,
+ "width": 2
+ },
+ "sex2": {
+ "check_answers_card_number": 2,
+ "check_answer_label": "Person 2’s gender identity",
+ "header": "Which of these best describes person 2’s gender identity?",
+ "type": "radio",
+ "answer_options": {
+ "F": {
+ "value": "Female"
+ },
+ "M": {
+ "value": "Male"
+ },
+ "X": {
+ "value": "Non-binary"
+ },
+ "R": {
+ "value": "Prefer not to say"
}
}
}
- },
- "retirement_value_check": {
- "questions": {
- "retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
- "header": "Are you sure this person is retired?",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Yes"
- },
- "1": {
- "value": "No"
- }
+ }
+ },
+ "retirement_value_check": {
+ "questions": {
+ "retirement_value_check": {
+ "check_answer_label": "Retirement age soft validation",
+ "hidden_in_check_answers": true,
+ "header": "Are you sure this person is retired?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
}
}
- },
- "depends_on": [
- {
- "age2": { "operator": ">", "operand": 50 }
- }
- ]
+ }
},
- "person_2_working_situation": {
- "header": "",
- "description": "",
- "questions": {
- "ecstat2": {
- "check_answers_card_number": 2,
- "check_answer_label": "Person 2’s Work",
- "header": "Which of these best describes person 2’s working situation?",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Other"
- },
- "9": {
- "value": "Child under 16",
- "depends_on": [
- { "age2_known": 1 },
- { "age2": { "operator": "<", "operand": 16 } }
- ]
- },
- "1": {
- "value": "Prefer not to say"
- }
- }
+ "depends_on": [
+ {
+ "age2": {
+ "operator": ">",
+ "operand": 50
}
- },
- "depends_on": [
- {
- "age2": { "operator": ">", "operand": 15 }
+ }
+ ]
+ },
+ "person_2_working_situation": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "ecstat2": {
+ "check_answers_card_number": 2,
+ "check_answer_label": "Person 2’s Work",
+ "header": "Which of these best describes person 2’s working situation?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Other"
+ },
+ "9": {
+ "value": "Child under 16",
+ "depends_on": [
+ {
+ "age2_known": 1
+ },
+ {
+ "age2": {
+ "operator": "<",
+ "operand": 16
+ }
+ }
+ ]
+ },
+ "1": {
+ "value": "Prefer not to say"
+ }
}
- ]
+ }
},
- "propcode": {
- "questions": {
- "propcode": {
- "check_answers_card_number": 0,
- "check_answer_label": "",
- "header": "property reference?",
- "type": "text"
+ "depends_on": [
+ {
+ "age2": {
+ "operator": ">",
+ "operand": 15
}
}
+ ]
+ },
+ "propcode": {
+ "questions": {
+ "propcode": {
+ "check_answers_card_number": 0,
+ "check_answer_label": "",
+ "header": "property reference?",
+ "type": "text"
+ }
}
}
- },
- "household_needs": {
- "label": "Household needs",
- "pages": {
- "armed_forces": {
- "header": "Experience of the UK Armed Forces",
- "questions": {
- "armedforces": {
- "header": "Does anybody in the household have any links to the UK armed forces?",
- "hint_text": "This excludes national service. If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner.",
- "type": "radio",
- "check_answer_label": "Household links to UK armed forces",
- "answer_options": {
- "1": {
- "value": "Yes, the person is a current or former regular"
- },
- "4": {
- "value": "Yes, the person is a current or former reserve"
- },
- "5": {
- "value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years"
- },
- "2": {
- "value": "No"
- },
- "3": {
- "value": "Person prefers not to say"
- }
+ }
+ },
+ "household_needs": {
+ "label": "Household needs",
+ "pages": {
+ "armed_forces": {
+ "header": "Experience of the UK Armed Forces",
+ "questions": {
+ "armedforces": {
+ "header": "Does anybody in the household have any links to the UK armed forces?",
+ "hint_text": "This excludes national service. If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner.",
+ "type": "radio",
+ "check_answer_label": "Household links to UK armed forces",
+ "answer_options": {
+ "1": {
+ "value": "Yes, the person is a current or former regular"
+ },
+ "4": {
+ "value": "Yes, the person is a current or former reserve"
},
- "conditional_for": {
- "leftreg": [1]
+ "5": {
+ "value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years"
+ },
+ "2": {
+ "value": "No"
+ },
+ "3": {
+ "value": "Person prefers not to say"
}
},
- "leftreg": {
- "header": "Are they still serving?",
- "hint_text": "",
- "type": "text",
- "check_answer_label": "When did they leave the Armed Forces?"
+ "conditional_for": {
+ "leftreg": [
+ 1
+ ]
}
+ },
+ "leftreg": {
+ "header": "Are they still serving?",
+ "hint_text": "",
+ "type": "text",
+ "check_answer_label": "When did they leave the Armed Forces?"
}
- },
- "medical_conditions": {
- "questions": {
- "illness": {
- "header": "Does anyone in the household have any of the following that they expect to last for 12 months or more:
- Physical Condition
- Mental Health Condition
- Other Illness
",
- "type": "radio",
- "check_answer_label": "Physical, mental health or illness in the household",
- "answer_options": {
- "1": {
- "value": "Yes"
- },
- "2": {
- "value": "No"
- },
- "3": {
- "value": "Don’t know"
- }
+ }
+ },
+ "medical_conditions": {
+ "questions": {
+ "illness": {
+ "header": "Does anyone in the household have any of the following that they expect to last for 12 months or more:- Physical Condition
- Mental Health Condition
- Other Illness
",
+ "type": "radio",
+ "check_answer_label": "Physical, mental health or illness in the household",
+ "answer_options": {
+ "1": {
+ "value": "Yes"
+ },
+ "2": {
+ "value": "No"
+ },
+ "3": {
+ "value": "Don’t know"
}
}
}
- },
- "accessibility_requirements": {
- "questions": {
- "accessibility_requirements": {
- "header": "Are any of these affected by their condition or illness?",
- "hint_text": "Select all that apply",
- "type": "checkbox",
- "check_answer_label": "Disability requirements",
- "answer_options": {
- "housingneeds_a": {
- "value": "Fully wheelchair accessible housing"
- },
- "housingneeds_b": {
- "value": "Wheelchair access to essential rooms"
- },
- "housingneeds_c": {
- "value": "Level access housing"
- },
- "divider": {
- "value": true
- },
- "housingneeds_h": {
- "value": "Don’t know"
- }
+ }
+ },
+ "accessibility_requirements": {
+ "questions": {
+ "accessibility_requirements": {
+ "header": "Are any of these affected by their condition or illness?",
+ "hint_text": "Select all that apply",
+ "type": "checkbox",
+ "check_answer_label": "Disability requirements",
+ "answer_options": {
+ "housingneeds_a": {
+ "value": "Fully wheelchair accessible housing"
+ },
+ "housingneeds_b": {
+ "value": "Wheelchair access to essential rooms"
+ },
+ "housingneeds_c": {
+ "value": "Level access housing"
+ },
+ "divider": {
+ "value": true
+ },
+ "housingneeds_h": {
+ "value": "Don’t know"
}
}
}
- },
- "accessible_select": {
- "questions": {
- "prevloc": {
- "header": "Select options",
- "hint_text": "Type ahead to filter the options",
- "type": "select",
- "check_answer_label": "Accessible Select",
- "answer_options": {
- "" : "Select an option",
- "E07000223": "Adur",
- "E09000023": "Lewisham",
- "E08000003": "Manchester",
- "E07000178": "Oxford",
- "E07000114": "Thanet",
- "E09000033": "Westminster",
- "E06000014": "The one and only york town"
- }
- }
- },
- "depends_on": [
- {
- "previous_la_known": 1,
- "is_previous_la_inferred": false
+ }
+ },
+ "accessible_select": {
+ "questions": {
+ "prevloc": {
+ "header": "Select options",
+ "hint_text": "Type ahead to filter the options",
+ "type": "select",
+ "check_answer_label": "Accessible Select",
+ "answer_options": {
+ "": "Select an option",
+ "E07000223": "Adur",
+ "E09000023": "Lewisham",
+ "E08000003": "Manchester",
+ "E07000178": "Oxford",
+ "E07000114": "Thanet",
+ "E09000033": "Westminster",
+ "E06000014": "The one and only york town"
}
- ]
+ }
},
- "condition_effects": {
- "questions": {
- "condition_effects": {
- "header": "Are any of these affected by their condition or illness?",
- "hint_text": "Select all that apply",
- "type": "checkbox",
- "check_answer_label": "Conditions or illnesses",
- "answer_options": {
- "illness_type_1": {
- "value": "Vision - such as blindness or partial sight"
- },
- "illness_type_2": {
- "value": "Hearing - such as deafness or partial hearing"
- }
+ "depends_on": [
+ {
+ "previous_la_known": 1,
+ "is_previous_la_inferred": false
+ }
+ ]
+ },
+ "condition_effects": {
+ "questions": {
+ "condition_effects": {
+ "header": "Are any of these affected by their condition or illness?",
+ "hint_text": "Select all that apply",
+ "type": "checkbox",
+ "check_answer_label": "Conditions or illnesses",
+ "answer_options": {
+ "illness_type_1": {
+ "value": "Vision - such as blindness or partial sight"
+ },
+ "illness_type_2": {
+ "value": "Hearing - such as deafness or partial hearing"
}
}
+ }
+ },
+ "depends_on": [
+ {
+ "illness": 1
},
- "depends_on": [
- {
- "illness": 1
- },
- {
- "illness": 100
- }
- ]
- }
+ {
+ "illness": 100
+ }
+ ]
}
}
}
- },
- "tenancy_and_property": {
- "label": "Tenancy and property information",
- "subsections": {
- "property_information": {
- "label": "Property information",
- "pages": {
- "accessible_select_too": {
- "questions": {
- "la": {
- "header": "Select options",
- "hint_text": "Type ahead to filter the options",
- "type": "select",
- "check_answer_label": "Accessible Select",
- "answer_options": {
- "" : "Select an option",
- "E07000223": "Adur",
- "E09000023": "Lewisham",
- "E08000003": "Manchester",
- "E07000178": "Oxford",
- "E07000114": "Thanet",
- "E09000033": "Westminster",
- "E06000014": "York"
- }
- }
- },
- "depends_on": [
- {
- "is_la_inferred": false
+ }
+ },
+ "tenancy_and_property": {
+ "label": "Tenancy and property information",
+ "subsections": {
+ "property_information": {
+ "label": "Property information",
+ "pages": {
+ "accessible_select_too": {
+ "questions": {
+ "la": {
+ "header": "Select options",
+ "hint_text": "Type ahead to filter the options",
+ "type": "select",
+ "check_answer_label": "Accessible Select",
+ "answer_options": {
+ "": "Select an option",
+ "E07000223": "Adur",
+ "E09000023": "Lewisham",
+ "E08000003": "Manchester",
+ "E07000178": "Oxford",
+ "E07000114": "Thanet",
+ "E09000033": "Westminster",
+ "E06000014": "York"
}
- ]
+ }
},
- "property_postcode": {
- "header": "",
- "description": "",
- "questions": {
- "postcode_known": {
- "check_answer_label": "Do you know the property postcode?",
- "header": "Do you know the property’s postcode?",
- "hint_text": "",
- "type": "radio",
- "answer_options": {
- "1": {
- "value": "Yes"
- },
- "0": {
- "value": "No"
- }
- },
- "conditional_for": {
- "postcode_full": [
- 1
- ]
+ "depends_on": [
+ {
+ "is_la_inferred": false
+ }
+ ]
+ },
+ "property_postcode": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "postcode_known": {
+ "check_answer_label": "Do you know the property postcode?",
+ "header": "Do you know the property’s postcode?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "1": {
+ "value": "Yes"
},
- "hidden_in_check_answers": true
+ "0": {
+ "value": "No"
+ }
+ },
+ "conditional_for": {
+ "postcode_full": [
+ 1
+ ]
},
- "postcode_full": {
- "check_answer_label": "Postcode",
- "header": "",
- "hint_text": "",
- "type": "text",
- "width": 5,
- "inferred_answers": { "la": { "is_la_inferred": true } },
- "inferred_check_answers_value": {
- "condition": { "postcode_known": 0 },
- "value": "Not known"
+ "hidden_in_check_answers": true
+ },
+ "postcode_full": {
+ "check_answer_label": "Postcode",
+ "header": "",
+ "hint_text": "",
+ "type": "text",
+ "width": 5,
+ "inferred_answers": {
+ "la": {
+ "is_la_inferred": true
}
+ },
+ "inferred_check_answers_value": {
+ "condition": {
+ "postcode_known": 0
+ },
+ "value": "Not known"
}
}
- },
- "do_you_know_the_local_authority": {
- "header": "",
- "description": "",
- "questions": {
- "previous_la_known": {
- "check_answer_label": "Do you know what local authority the property is located in?",
- "header": "Do you know what local authority the property is located in?",
- "hint_text": "",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "No"
- },
- "1": {
- "value": "Yes"
- }
+ }
+ },
+ "do_you_know_the_local_authority": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "previous_la_known": {
+ "check_answer_label": "Do you know what local authority the property is located in?",
+ "header": "Do you know what local authority the property is located in?",
+ "hint_text": "",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "No"
+ },
+ "1": {
+ "value": "Yes"
}
}
- },
- "depends_on": [{"is_la_inferred": false}]
+ }
},
- "property_wheelchair_accessible": {
- "questions": {
- "wchair": {
- "check_answer_label": "Wheelchair adaptation",
- "header": "Is the property built or adapted to wheelchair-user standards?",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Yes"
- },
- "1": {
- "value": "No"
- }
+ "depends_on": [
+ {
+ "is_la_inferred": false
+ }
+ ]
+ },
+ "property_wheelchair_accessible": {
+ "questions": {
+ "wchair": {
+ "check_answer_label": "Wheelchair adaptation",
+ "header": "Is the property built or adapted to wheelchair-user standards?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
}
}
}
}
}
- },
- "conditional_question": {
- "label": "Conditional question",
- "pages": {
- "conditional_question": {
- "questions": {
- "preg_occ": {
- "check_answer_label": "Has the condition been met?",
- "header": "Has the condition been met?",
- "type": "radio",
- "answer_options": {
- "1": {
- "value": "Yes"
- },
- "2": {
- "value": "No"
- }
+ }
+ },
+ "conditional_question": {
+ "label": "Conditional question",
+ "pages": {
+ "conditional_question": {
+ "questions": {
+ "preg_occ": {
+ "check_answer_label": "Has the condition been met?",
+ "header": "Has the condition been met?",
+ "type": "radio",
+ "answer_options": {
+ "1": {
+ "value": "Yes"
+ },
+ "2": {
+ "value": "No"
}
}
}
- },
- "conditional_question_yes_page": {
- "questions": {
- "cbl": {
- "check_answer_label": "Has the next condition been met?",
- "header": "Has the next condition been met?",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Yes"
- }
+ }
+ },
+ "conditional_question_yes_page": {
+ "questions": {
+ "cbl": {
+ "check_answer_label": "Has the next condition been met?",
+ "header": "Has the next condition been met?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
}
}
- },
- "depends_on": [{ "preg_occ": 1 }, { "wchair" : 1 }]
+ }
},
- "conditional_question_no_page": {
- "questions": {
- "cbl": {
- "check_answer_label": "Has the condition not been met?",
- "header": "Has the next condition not been met?",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Yes"
- },
- "1": {
- "value": "No"
- }
+ "depends_on": [
+ {
+ "preg_occ": 1
+ },
+ {
+ "wchair": 1
+ }
+ ]
+ },
+ "conditional_question_no_page": {
+ "questions": {
+ "cbl": {
+ "check_answer_label": "Has the condition not been met?",
+ "header": "Has the next condition not been met?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
}
}
- },
- "depends_on": [{ "preg_occ": 2 }]
+ }
},
- "conditional_question_no_second_page": {
- "questions": {
- "conditional_question_no_second_question": {
- "check_answer_label": "Has the condition not been met again?",
- "header": "Has the next condition not been met again?",
- "type": "radio",
- "answer_options": {
- "0": {
- "value": "Yes"
- },
- "1": {
- "value": "No"
- }
+ "depends_on": [
+ {
+ "preg_occ": 2
+ }
+ ]
+ },
+ "conditional_question_no_second_page": {
+ "questions": {
+ "conditional_question_no_second_question": {
+ "check_answer_label": "Has the condition not been met again?",
+ "header": "Has the next condition not been met again?",
+ "type": "radio",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
}
}
- },
- "depends_on": [{ "preg_occ": 2, "sex1": "M" }]
- }
+ }
+ },
+ "depends_on": [
+ {
+ "preg_occ": 2,
+ "sex1": "M"
+ }
+ ]
}
}
}
- },
- "rent_and_charges": {
- "label": "Rent and charges",
- "subsections": {
- "income_and_benefits": {
- "label": "Income and benefits",
- "pages": {
- "net_income": {
- "header": "Test header",
- "description": "Some extra text for the page",
- "questions": {
- "earnings": {
- "check_answer_label": "Income",
- "header": "What is the tenant’s /and partner’s combined income after tax?",
- "guidance_partial": "what_counts_as_income",
- "type": "numeric",
- "min": 0,
- "step": 1,
- "width": 5,
- "prefix": "£",
- "suffix": [
- { "label": " every week", "depends_on" : { "incfreq": 1 } },
- { "label": " every month", "depends_on" : { "incfreq": 2 } },
- { "label": " every year", "depends_on" : { "incfreq": 3 } }
- ]
- },
- "incfreq": {
- "check_answer_label": "Income Frequency",
- "header": "How often do they receive this income?",
- "type": "radio",
- "answer_options": {
- "1": {
- "value": "Weekly"
- },
- "2": {
- "value": "Monthly"
- },
- "3": {
- "value": "Yearly"
+ }
+ },
+ "rent_and_charges": {
+ "label": "Rent and charges",
+ "subsections": {
+ "income_and_benefits": {
+ "label": "Income and benefits",
+ "pages": {
+ "net_income": {
+ "header": "Test header",
+ "description": "Some extra text for the page",
+ "questions": {
+ "earnings": {
+ "check_answer_label": "Income",
+ "header": "What is the tenant’s /and partner’s combined income after tax?",
+ "guidance_partial": "what_counts_as_income",
+ "type": "numeric",
+ "min": 0,
+ "step": 1,
+ "width": 5,
+ "prefix": "£",
+ "suffix": [
+ {
+ "label": " every week",
+ "depends_on": {
+ "incfreq": 1
+ }
+ },
+ {
+ "label": " every month",
+ "depends_on": {
+ "incfreq": 2
+ }
+ },
+ {
+ "label": " every year",
+ "depends_on": {
+ "incfreq": 3
}
}
+ ]
+ },
+ "incfreq": {
+ "check_answer_label": "Income Frequency",
+ "header": "How often do they receive this income?",
+ "type": "radio",
+ "answer_options": {
+ "1": {
+ "value": "Weekly"
+ },
+ "2": {
+ "value": "Monthly"
+ },
+ "3": {
+ "value": "Yearly"
+ }
}
}
+ }
+ },
+ "net_income_value_check": {
+ "depends_on": [
+ {
+ "net_income_soft_validation_triggered?": true
+ }
+ ],
+ "title_text": {
+ "translation": "soft_validations.net_income.title_text"
},
- "net_income_value_check": {
- "depends_on": [{ "net_income_soft_validation_triggered?": true }],
- "title_text": { "translation": "soft_validations.net_income.title_text" },
- "informative_text": {
- "translation": "soft_validations.net_income.hint_text",
- "arguments": [{
+ "informative_text": {
+ "translation": "soft_validations.net_income.hint_text",
+ "arguments": [
+ {
"key": "ecstat1",
"label": true,
"i18n_template": "ecstat1"
@@ -693,7 +757,9 @@
}
},
"conditional_for": {
- "conditional_question": [0]
+ "conditional_question": [
+ 0
+ ]
}
},
"conditional_question": {
@@ -712,7 +778,11 @@
}
},
"dependent_page": {
- "depends_on": [{ "incfreq": 1 }],
+ "depends_on": [
+ {
+ "incfreq": 1
+ }
+ ],
"questions": {
"dependent_question": {
"check_answer_label": "Dependent Question",
@@ -757,7 +827,12 @@
"min": 0,
"step": 1,
"width": 4,
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge"
},
"scharge": {
@@ -768,7 +843,12 @@
"min": 0,
"step": 1,
"width": 4,
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge"
},
"pscharge": {
@@ -779,7 +859,12 @@
"min": 0,
"step": 1,
"width": 4,
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge"
},
"supcharg": {
@@ -791,7 +876,12 @@
"max": 300,
"step": 1,
"width": 4,
- "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"],
+ "fields-to-add": [
+ "brent",
+ "scharge",
+ "pscharge",
+ "supcharg"
+ ],
"result-field": "tcharge"
},
"tcharge": {
@@ -836,7 +926,11 @@
"width": 4
}
},
- "depends_on": [{ "period": 3 }]
+ "depends_on": [
+ {
+ "period": 3
+ }
+ ]
},
"care_home_charge_bi_weekly": {
"questions": {
@@ -850,7 +944,11 @@
"width": 4
}
},
- "depends_on": [{ "period": 2 }]
+ "depends_on": [
+ {
+ "period": 2
+ }
+ ]
}
}
}
@@ -898,11 +996,22 @@
}
},
"hidden_in_check_answers": {
- "depends_on": [{ "layear": 0 }, { "layear": 1 }]
+ "depends_on": [
+ {
+ "layear": 0
+ },
+ {
+ "layear": 1
+ }
+ ]
}
}
},
- "depends_on": [{ "renewal": 0 }]
+ "depends_on": [
+ {
+ "renewal": 0
+ }
+ ]
},
"time_on_la_waiting_list": {
"questions": {
@@ -950,7 +1059,9 @@
"hint_text": "If the household has moved from settled accommodation immediately prior to being re-housed",
"type": "text",
"width": 5,
- "conditional_for": { "fake_key": "fake_condition" }
+ "conditional_for": {
+ "fake_key": "fake_condition"
+ }
},
"ppostcode_full": {
"check_answer_label": "Postcode of previous accommodation if the household has moved from settled accommodation",
diff --git a/spec/fixtures/forms/2022_2023.json b/spec/fixtures/forms/2022_2023.json
index 81c190a46..a704a9229 100644
--- a/spec/fixtures/forms/2022_2023.json
+++ b/spec/fixtures/forms/2022_2023.json
@@ -1,55 +1,57 @@
{
- "form_type": "lettings",
- "start_date": "2022-04-01T00:00:00.000+01:00",
- "end_date": "2023-07-01T00:00:00.000+01:00",
- "sections": {
- "household": {
- "label": "About the household",
- "subsections": {
- "household_characteristics": {
- "label": "Household characteristics",
- "pages": {
- "tenant_code_test": {
- "questions": {
- "tenancycode": {
- "check_answer_label": "Tenant code",
- "header": "Different question header text for this year - 2023",
- "type": "text",
- "width": 10
- }
+ "form_type": "lettings",
+ "start_date": "2022-04-01T00:00:00.000+01:00",
+ "end_date": "2023-07-01T00:00:00.000+01:00",
+ "sections": {
+ "household": {
+ "label": "About the household",
+ "subsections": {
+ "household_characteristics": {
+ "label": "Household characteristics",
+ "pages": {
+ "tenant_code_test": {
+ "questions": {
+ "tenancycode": {
+ "check_answer_label": "Tenant code",
+ "header": "Different question header text for this year - 2023",
+ "type": "text",
+ "width": 10
}
- },
- "outstanding_amount_known": {
- "header": "",
- "description": "",
- "questions": {
- "tshortfall_known": {
- "check_answer_label": "",
- "header": "",
- "hint_text": "",
- "hidden_in_check_answers": true,
- "type": "radio",
- "derived": true,
- "answer_options": {
- "0": {
- "value": "Yes"
- },
- "1": {
- "value": "No"
- }
- }
- }
- },
- "depends_on": [false]
}
},
- "depends_on": [
- {
- "setup": "completed"
- }
- ]
- }
+ "outstanding_amount_known": {
+ "header": "",
+ "description": "",
+ "questions": {
+ "tshortfall_known": {
+ "check_answer_label": "",
+ "header": "",
+ "hint_text": "",
+ "hidden_in_check_answers": true,
+ "type": "radio",
+ "derived": true,
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
+ }
+ }
+ }
+ },
+ "depends_on": [
+ false
+ ]
+ }
+ },
+ "depends_on": [
+ {
+ "setup": "completed"
+ }
+ ]
}
}
}
}
+}
diff --git a/spec/fixtures/forms/test_validator.json b/spec/fixtures/forms/test_validator.json
index 512298a5d..e6edc4d16 100644
--- a/spec/fixtures/forms/test_validator.json
+++ b/spec/fixtures/forms/test_validator.json
@@ -22,7 +22,11 @@
"type": "text"
}
},
- "depends_on": [{"test": "Yes"}]
+ "depends_on": [
+ {
+ "test": "Yes"
+ }
+ ]
},
"person_1_age": {
"header": "",
From 43b9c44c00bdbbfcd7e67f63d53e615b2d4a4b99 Mon Sep 17 00:00:00 2001
From: Jack S <113976590+bibblobcode@users.noreply.github.com>
Date: Fri, 30 Sep 2022 16:04:50 +0100
Subject: [PATCH 03/16] [CLDC-1486] Add ethnic group and background questions
(#922)
* Add derived variables to sales log
* Add ethnic background question
* Add inferred question response
* Test inferred check questions of lettings logs
---
.../derived_variables/sales_log_variables.rb | 5 ++
app/models/form/question.rb | 6 ++-
.../pages/buyer1_ethnic_background_arab.rb | 18 +++++++
.../pages/buyer1_ethnic_background_asian.rb | 18 +++++++
.../pages/buyer1_ethnic_background_black.rb | 18 +++++++
.../pages/buyer1_ethnic_background_mixed.rb | 18 +++++++
.../pages/buyer1_ethnic_background_white.rb | 18 +++++++
.../form/sales/pages/buyer1_ethnic_group.rb | 15 ++++++
.../buyer1_ethnic_background_arab.rb | 17 +++++++
.../buyer1_ethnic_background_asian.rb | 20 ++++++++
.../buyer1_ethnic_background_black.rb | 18 +++++++
.../buyer1_ethnic_background_mixed.rb | 19 +++++++
.../buyer1_ethnic_background_white.rb | 19 +++++++
.../sales/questions/buyer1_ethnic_group.rb | 28 +++++++++++
.../subsections/household_characteristics.rb | 6 +++
app/models/lettings_log.rb | 4 --
app/models/log.rb | 4 ++
app/models/sales_log.rb | 5 ++
...20927100350_add_background_to_sales_log.rb | 6 +++
db/schema.rb | 2 +
spec/factories/sales_log.rb | 2 +
spec/fixtures/forms/2021_2022.json | 6 +++
spec/models/form/question_spec.rb | 23 +++++++++
.../buyer1_ethnic_background_arab_spec.rb | 33 +++++++++++++
.../buyer1_ethnic_background_asian_spec.rb | 33 +++++++++++++
.../buyer1_ethnic_background_black_spec.rb | 33 +++++++++++++
.../buyer1_ethnic_background_mixed_spec.rb | 33 +++++++++++++
.../buyer1_ethnic_background_white_spec.rb | 29 +++++++++++
.../sales/pages/buyer1_ethnic_group_spec.rb | 33 +++++++++++++
.../buyer1_ethnic_background_arab_spec.rb | 44 +++++++++++++++++
.../buyer1_ethnic_background_asian_spec.rb | 47 ++++++++++++++++++
.../buyer1_ethnic_background_black_spec.rb | 45 +++++++++++++++++
.../buyer1_ethnic_background_mixed_spec.rb | 46 +++++++++++++++++
.../buyer1_ethnic_background_white_spec.rb | 46 +++++++++++++++++
.../questions/buyer1_ethnic_group_spec.rb | 49 +++++++++++++++++++
.../household_characteristics_spec.rb | 14 +++++-
spec/models/form_handler_spec.rb | 4 +-
spec/models/lettings_log_spec.rb | 3 ++
spec/models/sales_log_spec.rb | 3 ++
.../shared_examples_for_derived_fields.rb | 17 +++++++
40 files changed, 798 insertions(+), 9 deletions(-)
create mode 100644 app/models/derived_variables/sales_log_variables.rb
create mode 100644 app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
create mode 100644 app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
create mode 100644 app/models/form/sales/pages/buyer1_ethnic_background_black.rb
create mode 100644 app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
create mode 100644 app/models/form/sales/pages/buyer1_ethnic_background_white.rb
create mode 100644 app/models/form/sales/pages/buyer1_ethnic_group.rb
create mode 100644 app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
create mode 100644 app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
create mode 100644 app/models/form/sales/questions/buyer1_ethnic_background_black.rb
create mode 100644 app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
create mode 100644 app/models/form/sales/questions/buyer1_ethnic_background_white.rb
create mode 100644 app/models/form/sales/questions/buyer1_ethnic_group.rb
create mode 100644 db/migrate/20220927100350_add_background_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
create mode 100644 spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
create mode 100644 spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
create mode 100644 spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
create mode 100644 spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
create mode 100644 spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb
create mode 100644 spec/shared/shared_examples_for_derived_fields.rb
diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb
new file mode 100644
index 000000000..2b3542813
--- /dev/null
+++ b/app/models/derived_variables/sales_log_variables.rb
@@ -0,0 +1,5 @@
+module DerivedVariables::SalesLogVariables
+ def set_derived_fields!
+ self.ethnic = 17 if ethnic_refused?
+ end
+end
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index 4478f63fd..7449d6932 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -50,9 +50,11 @@ class Form::Question
answer = label_from_value(log[id]) if log[id].present?
answer_label = [prefix, format_value(answer), suffix_label(log)].join("") if answer
- return answer_label if answer_label
- has_inferred_check_answers_value?(log) ? inferred_check_answers_value["value"] : ""
+ inferred = inferred_check_answers_value["value"] if has_inferred_check_answers_value?(log)
+ return inferred if inferred.present?
+
+ answer_label
end
def get_inferred_answers(log)
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
new file mode 100644
index 000000000..93fb1afe0
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::Buyer1EthnicBackgroundArab < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_ethnic_background_arab"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "ethnic_group" => 4,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1EthnicBackgroundArab.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
new file mode 100644
index 000000000..dd6802a99
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::Buyer1EthnicBackgroundAsian < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_ethnic_background_asian"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "ethnic_group" => 2,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1EthnicBackgroundAsian.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_black.rb b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb
new file mode 100644
index 000000000..ce6cf3a0b
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::Buyer1EthnicBackgroundBlack < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_ethnic_background_black"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "ethnic_group" => 3,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1EthnicBackgroundBlack.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
new file mode 100644
index 000000000..5225feed1
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::Buyer1EthnicBackgroundMixed < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_ethnic_background_mixed"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "ethnic_group" => 1,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1EthnicBackgroundMixed.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_white.rb b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb
new file mode 100644
index 000000000..6351e50d7
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::Buyer1EthnicBackgroundWhite < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_ethnic_background_white"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "ethnic_group" => 0,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/buyer1_ethnic_group.rb b/app/models/form/sales/pages/buyer1_ethnic_group.rb
new file mode 100644
index 000000000..4daad4f1d
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_ethnic_group.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::Buyer1EthnicGroup < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_ethnic_group"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1EthnicGroup.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
new file mode 100644
index 000000000..f6bf163b0
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Questions::Buyer1EthnicBackgroundArab < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ethnic"
+ @check_answer_label = "Buyer 1’s ethnic background"
+ @header = "Which of the following best describes the buyer 1’s Arab background?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ end
+
+ ANSWER_OPTIONS = {
+ "19" => { "value" => "Arab" },
+ "16" => { "value" => "Other ethnic group" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
new file mode 100644
index 000000000..a6b8ea64f
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
@@ -0,0 +1,20 @@
+class Form::Sales::Questions::Buyer1EthnicBackgroundAsian < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ethnic"
+ @check_answer_label = "Buyer 1’s ethnic background"
+ @header = "Which of the following best describes the buyer 1’s Asian or Asian British background?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ end
+
+ ANSWER_OPTIONS = {
+ "10" => { "value" => "Bangladeshi" },
+ "15" => { "value" => "Chinese" },
+ "8" => { "value" => "Indian" },
+ "9" => { "value" => "Pakistani" },
+ "11" => { "value" => "Any other Asian or Asian British background" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb
new file mode 100644
index 000000000..841086ec3
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Questions::Buyer1EthnicBackgroundBlack < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ethnic"
+ @check_answer_label = "Buyer 1’s ethnic background"
+ @header = "Which of the following best describes the buyer 1’s Black, African, Caribbean or Black British background?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ end
+
+ ANSWER_OPTIONS = {
+ "13" => { "value" => "African" },
+ "12" => { "value" => "Caribbean" },
+ "14" => { "value" => "Any other Black, African or Caribbean background" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
new file mode 100644
index 000000000..69451e9e9
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
@@ -0,0 +1,19 @@
+class Form::Sales::Questions::Buyer1EthnicBackgroundMixed < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ethnic"
+ @check_answer_label = "Buyer 1’s ethnic background"
+ @header = "Which of the following best describes the buyer 1’s Mixed or Multiple ethnic groups background?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ end
+
+ ANSWER_OPTIONS = {
+ "4" => { "value" => "White and Black Caribbean" },
+ "5" => { "value" => "White and Black African" },
+ "6" => { "value" => "White and Asian" },
+ "7" => { "value" => "Any other Mixed or Multiple ethnic background" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb
new file mode 100644
index 000000000..cb9f2918f
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb
@@ -0,0 +1,19 @@
+class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ethnic"
+ @check_answer_label = "Buyer 1’s ethnic background"
+ @header = "Which of the following best describes the buyer 1’s White background?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
+ "2" => { "value" => "Irish" },
+ "18" => { "value" => "Gypsy or Irish Traveller" },
+ "3" => { "value" => "Any other White background" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_group.rb b/app/models/form/sales/questions/buyer1_ethnic_group.rb
new file mode 100644
index 000000000..cb1a6da28
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_ethnic_group.rb
@@ -0,0 +1,28 @@
+class Form::Sales::Questions::Buyer1EthnicGroup < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ethnic_group"
+ @check_answer_label = "Buyer 1’s ethnic group"
+ @header = "What is buyer 1’s ethnic group?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ @inferred_check_answers_value = {
+ "condition" => {
+ "ethnic_group" => 17,
+ },
+ "value" => "Prefers not to say",
+ }
+ end
+
+ ANSWER_OPTIONS = {
+ "0" => { "value" => "White" },
+ "1" => { "value" => "Mixed or Multiple ethnic groups" },
+ "2" => { "value" => "Asian or Asian British" },
+ "3" => { "value" => "Black, African, Caribbean or Black British" },
+ "4" => { "value" => "Arab or other ethnic group" },
+ "divider" => { "value" => true },
+ "17" => { "value" => "Buyer 1 prefers not to say" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 6a6cb2824..219547067 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -13,6 +13,12 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1EthnicBackgroundAsian.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1EthnicBackgroundArab.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
Form::Sales::Pages::Age2.new(nil, nil, self),
]
end
diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb
index f97568f59..9e38138eb 100644
--- a/app/models/lettings_log.rb
+++ b/app/models/lettings_log.rb
@@ -372,10 +372,6 @@ class LettingsLog < Log
hb == 7
end
- def ethnic_refused?
- ethnic_group == 17
- end
-
def receives_housing_related_benefits?
if collection_start_year <= 2021
receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? ||
diff --git a/app/models/log.rb b/app/models/log.rb
index e24a205fc..54770515f 100644
--- a/app/models/log.rb
+++ b/app/models/log.rb
@@ -36,6 +36,10 @@ class Log < ApplicationRecord
false
end
+ def ethnic_refused?
+ ethnic_group == 17
+ end
+
private
def update_status!
diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb
index 0f0ca54c7..e1458caa9 100644
--- a/app/models/sales_log.rb
+++ b/app/models/sales_log.rb
@@ -3,10 +3,15 @@ class SalesLogValidator < ActiveModel::Validator
end
class SalesLog < Log
+ include DerivedVariables::SalesLogVariables
+
self.inheritance_column = :_type_disabled
+
has_paper_trail
validates_with SalesLogValidator
+ before_validation :set_derived_fields!
+ before_validation :reset_invalidated_dependent_fields!
scope :filter_by_year, ->(year) { where(saledate: Time.zone.local(year.to_i, 4, 1)...Time.zone.local(year.to_i + 1, 4, 1)) }
scope :search_by, ->(param) { filter_by_id(param) }
diff --git a/db/migrate/20220927100350_add_background_to_sales_log.rb b/db/migrate/20220927100350_add_background_to_sales_log.rb
new file mode 100644
index 000000000..21dc70d82
--- /dev/null
+++ b/db/migrate/20220927100350_add_background_to_sales_log.rb
@@ -0,0 +1,6 @@
+class AddBackgroundToSalesLog < ActiveRecord::Migration[7.0]
+ change_table :sales_logs, bulk: true do |t|
+ t.column :ethnic, :integer
+ t.column :ethnic_group, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fa885644b..f8dbff468 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -345,6 +345,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do
t.string "otherrelat2"
t.integer "age2"
t.integer "age2_known"
+ t.integer "ethnic"
+ t.integer "ethnic_group"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 0a8a56ee0..987f69e2c 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -29,6 +29,8 @@ FactoryBot.define do
age2_known { 0 }
age2 { 35 }
builtype { 1 }
+ ethnic { 3 }
+ ethnic_group { 12 }
end
end
end
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index faab8e674..ac02a62a2 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -303,6 +303,12 @@
"leftreg": [
1
]
+ },
+ "inferred_check_answers_value": {
+ "condition": {
+ "armedforces": 3
+ },
+ "value": "Prefers not to say"
}
},
"leftreg": {
diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb
index da59ad354..637407bc1 100644
--- a/spec/models/form/question_spec.rb
+++ b/spec/models/form/question_spec.rb
@@ -340,6 +340,29 @@ RSpec.describe Form::Question, type: :model do
expect(question.answer_label(lettings_log)).to eq("£500.00 every year")
end
end
+
+ context "with inferred_check_answers_value" do
+ context "when Lettings form" do
+ let(:section_id) { "household" }
+ let(:subsection_id) { "household_needs" }
+ let(:page_id) { "armed_forces" }
+ let(:question_id) { "armedforces" }
+
+ it "returns the inferred label value" do
+ lettings_log.armedforces = 3
+ expect(question.answer_label(lettings_log)).to eq("Prefers not to say")
+ end
+ end
+
+ context "when Sales form" do
+ let(:sales_log) { FactoryBot.create(:sales_log, :completed, ethnic_group: 17) }
+ let(:question) { sales_log.form.get_question("ethnic_group", sales_log) }
+
+ it "returns the inferred label value" do
+ expect(question.answer_label(sales_log)).to eq("Prefers not to say")
+ end
+ end
+ end
end
describe ".completed?" do
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
new file mode 100644
index 000000000..821874a0f
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundArab, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ethnic])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_ethnic_background_arab")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "ethnic_group" => 4 }])
+ end
+end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
new file mode 100644
index 000000000..ad8b47846
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundAsian, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ethnic])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_ethnic_background_asian")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "ethnic_group" => 2 }])
+ end
+end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
new file mode 100644
index 000000000..1f5618a0b
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundBlack, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ethnic])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_ethnic_background_black")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "ethnic_group" => 3 }])
+ end
+end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
new file mode 100644
index 000000000..648734242
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundMixed, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ethnic])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_ethnic_background_mixed")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "ethnic_group" => 1 }])
+ end
+end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
new file mode 100644
index 000000000..620918b0e
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundWhite, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ethnic])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_ethnic_background_white")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
new file mode 100644
index 000000000..406f78676
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ethnic_group])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_ethnic_group")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to be_nil
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb
new file mode 100644
index 000000000..c13eda0c5
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb
@@ -0,0 +1,44 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundArab, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ethnic")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of the following best describes the buyer 1’s Arab background?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s ethnic background")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "16" => { "value" => "Other ethnic group" },
+ "19" => { "value" => "Arab" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb
new file mode 100644
index 000000000..3fe9cee96
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb
@@ -0,0 +1,47 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundAsian, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ethnic")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of the following best describes the buyer 1’s Asian or Asian British background?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s ethnic background")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "10" => { "value" => "Bangladeshi" },
+ "11" => { "value" => "Any other Asian or Asian British background" },
+ "15" => { "value" => "Chinese" },
+ "8" => { "value" => "Indian" },
+ "9" => { "value" => "Pakistani" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb
new file mode 100644
index 000000000..28949b598
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb
@@ -0,0 +1,45 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundBlack, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ethnic")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of the following best describes the buyer 1’s Black, African, Caribbean or Black British background?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s ethnic background")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "12" => { "value" => "Caribbean" },
+ "13" => { "value" => "African" },
+ "14" => { "value" => "Any other Black, African or Caribbean background" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb
new file mode 100644
index 000000000..48ad38fa8
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb
@@ -0,0 +1,46 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundMixed, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ethnic")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of the following best describes the buyer 1’s Mixed or Multiple ethnic groups background?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s ethnic background")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "4" => { "value" => "White and Black Caribbean" },
+ "5" => { "value" => "White and Black African" },
+ "6" => { "value" => "White and Asian" },
+ "7" => { "value" => "Any other Mixed or Multiple ethnic background" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb
new file mode 100644
index 000000000..4b72afb92
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb
@@ -0,0 +1,46 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundWhite, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ethnic")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of the following best describes the buyer 1’s White background?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s ethnic background")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" },
+ "18" => { "value" => "Gypsy or Irish Traveller" },
+ "2" => { "value" => "Irish" },
+ "3" => { "value" => "Any other White background" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb
new file mode 100644
index 000000000..4823b43c8
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb
@@ -0,0 +1,49 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1EthnicGroup, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ethnic_group")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What is buyer 1’s ethnic group?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s ethnic group")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint_text" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "0" => { "value" => "White" },
+ "1" => { "value" => "Mixed or Multiple ethnic groups" },
+ "17" => { "value" => "Buyer 1 prefers not to say" },
+ "2" => { "value" => "Asian or Asian British" },
+ "3" => { "value" => "Black, African, Caribbean or Black British" },
+ "4" => { "value" => "Arab or other ethnic group" },
+ "divider" => { "value" => true },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index 71a8e898d..cde59cfd5 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -13,7 +13,19 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
- %w[buyer_1_age buyer_1_gender_identity buyer_1_live_in_property buyer_2_relationship_to_buyer_1 buyer_2_age],
+ %w[
+ buyer_1_age
+ buyer_1_gender_identity
+ buyer_1_live_in_property
+ buyer_2_relationship_to_buyer_1
+ buyer_1_ethnic_group
+ buyer_1_ethnic_background_black
+ buyer_1_ethnic_background_asian
+ buyer_1_ethnic_background_arab
+ buyer_1_ethnic_background_mixed
+ buyer_1_ethnic_background_white
+ buyer_2_age
+ ],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index e323fdaea..cb9258803 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(20)
+ expect(form.pages.count).to eq(26)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(20)
+ expect(form.pages.count).to eq(26)
expect(form.name).to eq("2021_2022_sales")
end
end
diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb
index 6251e050f..dc4a646fe 100644
--- a/spec/models/lettings_log_spec.rb
+++ b/spec/models/lettings_log_spec.rb
@@ -1,4 +1,5 @@
require "rails_helper"
+require "shared/shared_examples_for_derived_fields"
RSpec.describe LettingsLog do
let(:owning_organisation) { FactoryBot.create(:organisation) }
@@ -10,6 +11,8 @@ RSpec.describe LettingsLog do
allow(FormHandler.instance).to receive(:current_lettings_form).and_return(fake_2021_2022_form)
end
+ include_examples "shared examples for derived fields", :lettings_log
+
it "inherits from log" do
expect(described_class).to be < Log
expect(described_class).to be < ApplicationRecord
diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb
index 31a41d411..3ee033971 100644
--- a/spec/models/sales_log_spec.rb
+++ b/spec/models/sales_log_spec.rb
@@ -1,9 +1,12 @@
require "rails_helper"
+require "shared/shared_examples_for_derived_fields"
RSpec.describe SalesLog, type: :model do
let(:owning_organisation) { FactoryBot.create(:organisation) }
let(:created_by_user) { FactoryBot.create(:user) }
+ include_examples "shared examples for derived fields", :sales_log
+
it "inherits from log" do
expect(described_class).to be < Log
expect(described_class).to be < ApplicationRecord
diff --git a/spec/shared/shared_examples_for_derived_fields.rb b/spec/shared/shared_examples_for_derived_fields.rb
new file mode 100644
index 000000000..6382ef4f4
--- /dev/null
+++ b/spec/shared/shared_examples_for_derived_fields.rb
@@ -0,0 +1,17 @@
+require "rails_helper"
+
+RSpec.shared_examples "shared examples for derived fields" do |log_type|
+ describe "sets ethnic based on the value of ethnic_refused" do
+ it "is set to 17 when ethnic_group is 17" do
+ log = FactoryBot.build(log_type, ethnic_group: 17, ethnic: nil)
+
+ expect { log.set_derived_fields! }.to change(log, :ethnic).from(nil).to(17)
+ end
+
+ it "is is not modified otherwise" do
+ log = FactoryBot.build(log_type, ethnic_group: nil, ethnic: nil)
+
+ expect { log.set_derived_fields! }.not_to change(log, :ethnic)
+ end
+ end
+end
From 04c2e7b6386ec1ae0036ac52096d1999dd5c5f4b Mon Sep 17 00:00:00 2001
From: Dushan <47317567+dushan-madetech@users.noreply.github.com>
Date: Mon, 3 Oct 2022 11:30:18 +0100
Subject: [PATCH 04/16] [CLDC-1524] Add buyer 2 gender question (#926)
* changes for buyer 2 gender
* Rubocop
Co-authored-by: Jack S
---
.../form/sales/pages/gender_identity2.rb | 18 ++++++++
.../form/sales/questions/gender_identity2.rb | 18 ++++++++
.../subsections/household_characteristics.rb | 1 +
...20930134358_add_buyer2_sex_to_sales_log.rb | 5 +++
db/schema.rb | 7 ++--
spec/factories/sales_log.rb | 1 +
.../form/sales/pages/gender_identity2_spec.rb | 35 ++++++++++++++++
.../sales/questions/gender_identity2_spec.rb | 42 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
10 files changed, 127 insertions(+), 5 deletions(-)
create mode 100644 app/models/form/sales/pages/gender_identity2.rb
create mode 100644 app/models/form/sales/questions/gender_identity2.rb
create mode 100644 db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/gender_identity2_spec.rb
create mode 100644 spec/models/form/sales/questions/gender_identity2_spec.rb
diff --git a/app/models/form/sales/pages/gender_identity2.rb b/app/models/form/sales/pages/gender_identity2.rb
new file mode 100644
index 000000000..f5db5aecb
--- /dev/null
+++ b/app/models/form/sales/pages/gender_identity2.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::GenderIdentity2 < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_2_gender_identity"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "jointpur" => 1,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::GenderIdentity2.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/gender_identity2.rb b/app/models/form/sales/questions/gender_identity2.rb
new file mode 100644
index 000000000..2c0946edb
--- /dev/null
+++ b/app/models/form/sales/questions/gender_identity2.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Questions::GenderIdentity2 < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "sex2"
+ @check_answer_label = "Buyer 2’s gender identity"
+ @header = "Which of these best describes buyer 2’s gender identity?"
+ @type = "radio"
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ end
+
+ ANSWER_OPTIONS = {
+ "F" => { "value" => "Female" },
+ "M" => { "value" => "Male" },
+ "X" => { "value" => "Non-binary" },
+ "R" => { "value" => "Buyer prefers not to say" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 219547067..841ad6245 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -20,6 +20,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
Form::Sales::Pages::Age2.new(nil, nil, self),
+ Form::Sales::Pages::GenderIdentity2.new(nil, nil, self),
]
end
end
diff --git a/db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb b/db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb
new file mode 100644
index 000000000..5d45f147e
--- /dev/null
+++ b/db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb
@@ -0,0 +1,5 @@
+class AddBuyer2SexToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ add_column :sales_logs, :sex2, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f8dbff468..2454ad80f 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[7.0].define(version: 2022_09_29_125204) do
+ActiveRecord::Schema[7.0].define(version: 2022_09_30_134358) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -341,12 +341,13 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do
t.integer "buylivein"
t.integer "builtype"
t.integer "proptype"
- t.string "relat2"
- t.string "otherrelat2"
t.integer "age2"
t.integer "age2_known"
t.integer "ethnic"
t.integer "ethnic_group"
+ t.string "relat2"
+ t.string "otherrelat2"
+ t.string "sex2"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 987f69e2c..1f8dfccc2 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -31,6 +31,7 @@ FactoryBot.define do
builtype { 1 }
ethnic { 3 }
ethnic_group { 12 }
+ sex2 { "X" }
end
end
end
diff --git a/spec/models/form/sales/pages/gender_identity2_spec.rb b/spec/models/form/sales/pages/gender_identity2_spec.rb
new file mode 100644
index 000000000..0fdd96e27
--- /dev/null
+++ b/spec/models/form/sales/pages/gender_identity2_spec.rb
@@ -0,0 +1,35 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::GenderIdentity2, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[sex2])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_2_gender_identity")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{
+ "jointpur" => 1,
+ }])
+ end
+end
diff --git a/spec/models/form/sales/questions/gender_identity2_spec.rb b/spec/models/form/sales/questions/gender_identity2_spec.rb
new file mode 100644
index 000000000..e4da94a24
--- /dev/null
+++ b/spec/models/form/sales/questions/gender_identity2_spec.rb
@@ -0,0 +1,42 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::GenderIdentity2, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("sex2")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of these best describes buyer 2’s gender identity?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 2’s gender identity")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "F" => { "value" => "Female" },
+ "M" => { "value" => "Male" },
+ "X" => { "value" => "Non-binary" },
+ "R" => { "value" => "Buyer prefers not to say" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index cde59cfd5..26ddf5184 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -25,6 +25,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_ethnic_background_mixed
buyer_1_ethnic_background_white
buyer_2_age
+ buyer_2_gender_identity
],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index cb9258803..12b7c214b 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(26)
+ expect(form.pages.count).to eq(27)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(26)
+ expect(form.pages.count).to eq(27)
expect(form.name).to eq("2021_2022_sales")
end
end
From 0981ce7c4af6c0287c15bb1133736114af0ffc92 Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Mon, 3 Oct 2022 14:17:15 +0100
Subject: [PATCH 05/16] Cldc 1480 buyer interview (#927)
* feat: add functionality
* test: make old tests pass
* test: add new tests
* [CLDC-1524] Add buyer 2 gender question (#926)
* changes for buyer 2 gender
* Rubocop
Co-authored-by: Jack S
* feat: add updated schema post rebase
* refactor: remove blank line
* test: update tests
Co-authored-by: Dushan <47317567+dushan-madetech@users.noreply.github.com>
Co-authored-by: Jack S
---
.../form/sales/pages/buyer_interview.rb | 15 +++++++
.../form/sales/questions/buyer_interview.rb | 17 +++++++
.../subsections/household_characteristics.rb | 1 +
.../20221003092048_add_noint_to_sales_log.rb | 7 +++
db/schema.rb | 7 +--
spec/factories/sales_log.rb | 1 +
.../form/sales/pages/buyer_interview_spec.rb | 29 ++++++++++++
.../sales/questions/buyer_interview_spec.rb | 44 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
10 files changed, 121 insertions(+), 5 deletions(-)
create mode 100644 app/models/form/sales/pages/buyer_interview.rb
create mode 100644 app/models/form/sales/questions/buyer_interview.rb
create mode 100644 db/migrate/20221003092048_add_noint_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/buyer_interview_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer_interview_spec.rb
diff --git a/app/models/form/sales/pages/buyer_interview.rb b/app/models/form/sales/pages/buyer_interview.rb
new file mode 100644
index 000000000..a781d8a07
--- /dev/null
+++ b/app/models/form/sales/pages/buyer_interview.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::BuyerInterview < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_interview"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::BuyerInterview.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/buyer_interview.rb b/app/models/form/sales/questions/buyer_interview.rb
new file mode 100644
index 000000000..d270d9d33
--- /dev/null
+++ b/app/models/form/sales/questions/buyer_interview.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Questions::BuyerInterview < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "noint"
+ @check_answer_label = "Buyer interviewed in person?"
+ @header = "Was the buyer interviewed for any of the answers you will provide on this log?"
+ @type = "radio"
+ @hint_text = "You should still try to answer all questions even if the buyer wasn't interviewed in person"
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "No" },
+ "2" => { "value" => "Yes" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 841ad6245..55a66b92d 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -9,6 +9,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
def pages
@pages ||= [
+ Form::Sales::Pages::BuyerInterview.new(nil, nil, self),
Form::Sales::Pages::Age1.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
diff --git a/db/migrate/20221003092048_add_noint_to_sales_log.rb b/db/migrate/20221003092048_add_noint_to_sales_log.rb
new file mode 100644
index 000000000..ab21aead6
--- /dev/null
+++ b/db/migrate/20221003092048_add_noint_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddNointToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :noint, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 2454ad80f..73108ade5 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[7.0].define(version: 2022_09_30_134358) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_03_092048) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -341,13 +341,14 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_30_134358) do
t.integer "buylivein"
t.integer "builtype"
t.integer "proptype"
+ t.string "relat2"
+ t.string "otherrelat2"
t.integer "age2"
t.integer "age2_known"
t.integer "ethnic"
t.integer "ethnic_group"
- t.string "relat2"
- t.string "otherrelat2"
t.string "sex2"
+ t.integer "noint"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 1f8dfccc2..221ce0910 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -20,6 +20,7 @@ FactoryBot.define do
jointpur { 1 }
beds { 2 }
jointmore { 1 }
+ noint { 2 }
age1_known { 0 }
age1 { 30 }
sex1 { "X" }
diff --git a/spec/models/form/sales/pages/buyer_interview_spec.rb b/spec/models/form/sales/pages/buyer_interview_spec.rb
new file mode 100644
index 000000000..1347fb782
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer_interview_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[noint])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_interview")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer_interview_spec.rb b/spec/models/form/sales/questions/buyer_interview_spec.rb
new file mode 100644
index 000000000..69c45ee4e
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer_interview_spec.rb
@@ -0,0 +1,44 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("noint")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Was the buyer interviewed for any of the answers you will provide on this log?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer interviewed in person?")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("You should still try to answer all questions even if the buyer wasn't interviewed in person")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "1" => { "value" => "No" },
+ "2" => { "value" => "Yes" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index 26ddf5184..f8e258e20 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -14,6 +14,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
%w[
+ buyer_interview
buyer_1_age
buyer_1_gender_identity
buyer_1_live_in_property
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 12b7c214b..c06b41bf5 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(27)
+ expect(form.pages.count).to eq(28)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(27)
+ expect(form.pages.count).to eq(28)
expect(form.name).to eq("2021_2022_sales")
end
end
From 83e1469b4f0d6befc9167abde280e0d515e2d52b Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Tue, 4 Oct 2022 09:47:32 +0100
Subject: [PATCH 06/16] Cldc 1526 buyer 2 live in (#928)
* feat: add functionality
* tests: make existing tests pass
* tests: add new tests
---
.../sales/pages/buyer2_live_in_property.rb | 15 +++++++
.../questions/buyer2_live_in_property.rb | 17 +++++++
.../subsections/household_characteristics.rb | 1 +
...21003134554_add_buy2livein_to_sales_log.rb | 7 +++
db/schema.rb | 3 +-
spec/factories/sales_log.rb | 1 +
.../pages/buyer2_live_in_property_spec.rb | 29 ++++++++++++
.../questions/buyer2_live_in_property_spec.rb | 44 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
10 files changed, 119 insertions(+), 3 deletions(-)
create mode 100644 app/models/form/sales/pages/buyer2_live_in_property.rb
create mode 100644 app/models/form/sales/questions/buyer2_live_in_property.rb
create mode 100644 db/migrate/20221003134554_add_buy2livein_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer2_live_in_property_spec.rb
diff --git a/app/models/form/sales/pages/buyer2_live_in_property.rb b/app/models/form/sales/pages/buyer2_live_in_property.rb
new file mode 100644
index 000000000..0d2393503
--- /dev/null
+++ b/app/models/form/sales/pages/buyer2_live_in_property.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::Buyer2LiveInProperty < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_2_live_in_property"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer2LiveInProperty.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/buyer2_live_in_property.rb b/app/models/form/sales/questions/buyer2_live_in_property.rb
new file mode 100644
index 000000000..060f52afc
--- /dev/null
+++ b/app/models/form/sales/questions/buyer2_live_in_property.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Questions::Buyer2LiveInProperty < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "buy2livein"
+ @check_answer_label = "Will buyer 2 live in the property?"
+ @header = "Will buyer 2 live in the property?"
+ @type = "radio"
+ @hint_text = ""
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 55a66b92d..e8bdba81f 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -22,6 +22,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
Form::Sales::Pages::Age2.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity2.new(nil, nil, self),
+ Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
]
end
end
diff --git a/db/migrate/20221003134554_add_buy2livein_to_sales_log.rb b/db/migrate/20221003134554_add_buy2livein_to_sales_log.rb
new file mode 100644
index 000000000..ac8d4fbd7
--- /dev/null
+++ b/db/migrate/20221003134554_add_buy2livein_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddBuy2liveinToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :buy2livein, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 73108ade5..86653c655 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[7.0].define(version: 2022_10_03_092048) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_03_134554) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -349,6 +349,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_03_092048) do
t.integer "ethnic_group"
t.string "sex2"
t.integer "noint"
+ t.integer "buy2livein"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 221ce0910..2f3273a81 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -33,6 +33,7 @@ FactoryBot.define do
ethnic { 3 }
ethnic_group { 12 }
sex2 { "X" }
+ buy2livein { "1" }
end
end
end
diff --git a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
new file mode 100644
index 000000000..cfabcf04c
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[buy2livein])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_2_live_in_property")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb b/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb
new file mode 100644
index 000000000..b0d1af779
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb
@@ -0,0 +1,44 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer2LiveInProperty, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("buy2livein")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Will buyer 2 live in the property?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Will buyer 2 live in the property?")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index f8e258e20..23e12ea45 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -27,6 +27,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_ethnic_background_white
buyer_2_age
buyer_2_gender_identity
+ buyer_2_live_in_property
],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index c06b41bf5..527e5edfe 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(28)
+ expect(form.pages.count).to eq(29)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(28)
+ expect(form.pages.count).to eq(29)
expect(form.name).to eq("2021_2022_sales")
end
end
From 23c086d5daf1e317e40b7cf578550f6c9d73fa91 Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Tue, 4 Oct 2022 10:01:33 +0100
Subject: [PATCH 07/16] Cldc 1525 buyer2 working situation (#929)
* feat: add functionality
* tests: make tests pass
* tests: add new tests
* feat: update schema
* tests: update tests
---
.../sales/pages/buyer2_working_situation.rb | 15 ++++++
.../questions/buyer2_working_situation.rb | 26 +++++++++
.../subsections/household_characteristics.rb | 1 +
...20221003150610_add_ecstat2_to_sales_log.rb | 7 +++
db/schema.rb | 3 +-
spec/factories/sales_log.rb | 1 +
.../pages/buyer2_working_situation_spec.rb | 29 ++++++++++
.../buyer2_working_situation_spec.rb | 53 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
10 files changed, 137 insertions(+), 3 deletions(-)
create mode 100644 app/models/form/sales/pages/buyer2_working_situation.rb
create mode 100644 app/models/form/sales/questions/buyer2_working_situation.rb
create mode 100644 db/migrate/20221003150610_add_ecstat2_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/buyer2_working_situation_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer2_working_situation_spec.rb
diff --git a/app/models/form/sales/pages/buyer2_working_situation.rb b/app/models/form/sales/pages/buyer2_working_situation.rb
new file mode 100644
index 000000000..e445a56c1
--- /dev/null
+++ b/app/models/form/sales/pages/buyer2_working_situation.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_2_working_situation"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer2WorkingSituation.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb
new file mode 100644
index 000000000..11b587f92
--- /dev/null
+++ b/app/models/form/sales/questions/buyer2_working_situation.rb
@@ -0,0 +1,26 @@
+class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ecstat2"
+ @check_answer_label = "Buyer 2's working situation"
+ @header = "Which of these best describes buyer 2's working situation?"
+ @type = "radio"
+ @hint_text = ""
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ end
+
+ ANSWER_OPTIONS = {
+ "2" => { "value" => "Part-time - Less than 30 hours" },
+ "1" => { "value" => "Full-time - 30 hours or more" },
+ "3" => { "value" => "In government training into work, such as New Deal" },
+ "4" => { "value" => "Jobseeker" },
+ "6" => { "value" => "Not seeking work" },
+ "8" => { "value" => "Unable to work due to long term sick or disability" },
+ "5" => { "value" => "Retired" },
+ "0" => { "value" => "Other" },
+ "10" => { "value" => "Buyer prefers not to say" },
+ "7" => { "value" => "Full-time student" },
+ "9" => { "value" => "Child under 16" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index e8bdba81f..1e28e4653 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -23,6 +23,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Age2.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity2.new(nil, nil, self),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
+ Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
]
end
end
diff --git a/db/migrate/20221003150610_add_ecstat2_to_sales_log.rb b/db/migrate/20221003150610_add_ecstat2_to_sales_log.rb
new file mode 100644
index 000000000..e6efb825b
--- /dev/null
+++ b/db/migrate/20221003150610_add_ecstat2_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddEcstat2ToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :ecstat2, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 86653c655..b30200da0 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[7.0].define(version: 2022_10_03_134554) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -350,6 +350,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_03_134554) do
t.string "sex2"
t.integer "noint"
t.integer "buy2livein"
+ t.integer "ecstat2"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 2f3273a81..4f9aa07ed 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -34,6 +34,7 @@ FactoryBot.define do
ethnic_group { 12 }
sex2 { "X" }
buy2livein { "1" }
+ ecstat2 { "1" }
end
end
end
diff --git a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb
new file mode 100644
index 000000000..5077ab6f4
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ecstat2])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_2_working_situation")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb
new file mode 100644
index 000000000..0573f02ed
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb
@@ -0,0 +1,53 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ecstat2")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of these best describes buyer 2's working situation?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 2's working situation")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "2" => { "value" => "Part-time - Less than 30 hours" },
+ "1" => { "value" => "Full-time - 30 hours or more" },
+ "3" => { "value" => "In government training into work, such as New Deal" },
+ "4" => { "value" => "Jobseeker" },
+ "6" => { "value" => "Not seeking work" },
+ "8" => { "value" => "Unable to work due to long term sick or disability" },
+ "5" => { "value" => "Retired" },
+ "0" => { "value" => "Other" },
+ "10" => { "value" => "Buyer prefers not to say" },
+ "7" => { "value" => "Full-time student" },
+ "9" => { "value" => "Child under 16" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index 23e12ea45..e8a5bb0db 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -28,6 +28,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_2_age
buyer_2_gender_identity
buyer_2_live_in_property
+ buyer_2_working_situation
],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 527e5edfe..831502602 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(29)
+ expect(form.pages.count).to eq(30)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(29)
+ expect(form.pages.count).to eq(30)
expect(form.name).to eq("2021_2022_sales")
end
end
From 3ef5408451a6538761adb712f0eecea56a705ea4 Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Tue, 4 Oct 2022 10:46:50 +0100
Subject: [PATCH 08/16] Cldc 1525 buyer2 working situation (#930)
* feat: add functionality
* tests: make tests pass
* tests: add new tests
* feat: update schema
* tests: update tests
* feat: fix order of pages
* feat: fix order of pages
---
app/models/form/sales/subsections/household_characteristics.rb | 2 +-
.../form/sales/subsections/household_characteristics_spec.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 1e28e4653..93d084332 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -22,8 +22,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
Form::Sales::Pages::Age2.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity2.new(nil, nil, self),
- Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
+ Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
]
end
end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index e8a5bb0db..364895cc8 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -27,8 +27,8 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_ethnic_background_white
buyer_2_age
buyer_2_gender_identity
- buyer_2_live_in_property
buyer_2_working_situation
+ buyer_2_live_in_property
],
)
end
From b22c6c961a5f98012edb3c0b00589884434958f7 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Wed, 5 Oct 2022 12:27:13 +0300
Subject: [PATCH 09/16] Cldc 1503 lead nationality (#909)
* Add nationality and other nationality questions
* Add nationality page
* Add national columns
* Add hidden_in_check_answers
* Update conditional question controller to work with both log types
* update tests
* lint
* Remove console.log
* tests and migration
* typo
* tests
* tests
* feat: update schema and tests
* Add nationality and other nationality questions
* Add nationality page
* Add national columns
* Add hidden_in_check_answers
* Update conditional question controller to work with both log types
* update tests
* lint
* Remove console.log
* tests and migration
* typo
* tests
* feat: update schema and tests
* tests: update tests
* feat: update schema.rb
Co-authored-by: natdeanlewissoftwire
---
.../conditional_question_controller.js | 8 ++-
app/helpers/question_attribute_helper.rb | 2 +-
app/models/form/sales/pages/nationality1.rb | 16 +++++
.../form/sales/questions/nationality1.rb | 30 +++++++++
.../sales/questions/other_nationality1.rb | 10 +++
.../subsections/household_characteristics.rb | 5 +-
.../20220927082602_add_national_column.rb | 8 +++
db/schema.rb | 14 +++--
spec/factories/sales_log.rb | 1 +
.../form/conditional_questions_spec.rb | 18 ++++++
.../helpers/question_attribute_helper_spec.rb | 4 +-
.../form/sales/pages/nationality1_spec.rb | 33 ++++++++++
.../form/sales/questions/nationality1_spec.rb | 63 +++++++++++++++++++
.../questions/other_nationality1_spec.rb | 37 +++++++++++
.../household_characteristics_spec.rb | 5 +-
spec/models/form_handler_spec.rb | 4 +-
16 files changed, 240 insertions(+), 18 deletions(-)
create mode 100644 app/models/form/sales/pages/nationality1.rb
create mode 100644 app/models/form/sales/questions/nationality1.rb
create mode 100644 app/models/form/sales/questions/other_nationality1.rb
create mode 100644 db/migrate/20220927082602_add_national_column.rb
create mode 100644 spec/models/form/sales/pages/nationality1_spec.rb
create mode 100644 spec/models/form/sales/questions/nationality1_spec.rb
create mode 100644 spec/models/form/sales/questions/other_nationality1_spec.rb
diff --git a/app/frontend/controllers/conditional_question_controller.js b/app/frontend/controllers/conditional_question_controller.js
index 974deeb2e..fb52d07c1 100644
--- a/app/frontend/controllers/conditional_question_controller.js
+++ b/app/frontend/controllers/conditional_question_controller.js
@@ -8,14 +8,16 @@ export default class extends Controller {
displayConditional () {
if (this.element.checked) {
const selectedValue = this.element.value
- const conditionalFor = JSON.parse(this.element.dataset.info)
+ const dataInfo = JSON.parse(this.element.dataset.info)
+ const conditionalFor = dataInfo.conditional_questions
+ const logType = dataInfo.log_type
Object.entries(conditionalFor).forEach(([targetQuestion, conditions]) => {
if (!conditions.map(String).includes(String(selectedValue))) {
- const textNumericInput = document.getElementById(`lettings-log-${targetQuestion.replaceAll('_', '-')}-field`)
+ const textNumericInput = document.getElementById(`${logType}-log-${targetQuestion.replaceAll('_', '-')}-field`)
if (textNumericInput == null) {
const dateInputs = [1, 2, 3].map((idx) => {
- return document.getElementById(`lettings_log_${targetQuestion}_${idx}i`)
+ return document.getElementById(`${logType}_log_${targetQuestion}_${idx}i`)
})
this.clearDateInputs(dateInputs)
} else {
diff --git a/app/helpers/question_attribute_helper.rb b/app/helpers/question_attribute_helper.rb
index f2f148568..857ce5eb1 100644
--- a/app/helpers/question_attribute_helper.rb
+++ b/app/helpers/question_attribute_helper.rb
@@ -27,7 +27,7 @@ private
{
"data-controller": "conditional-question",
"data-action": "click->conditional-question#displayConditional",
- "data-info": question.conditional_for.to_json,
+ "data-info": { conditional_questions: question.conditional_for, log_type: question.form.type }.to_json,
}
end
end
diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb
new file mode 100644
index 000000000..740aa694f
--- /dev/null
+++ b/app/models/form/sales/pages/nationality1.rb
@@ -0,0 +1,16 @@
+class Form::Sales::Pages::Nationality1 < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_nationality"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Nationality1.new(nil, nil, self),
+ Form::Sales::Questions::OtherNationality1.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/nationality1.rb
new file mode 100644
index 000000000..737bfc01e
--- /dev/null
+++ b/app/models/form/sales/questions/nationality1.rb
@@ -0,0 +1,30 @@
+class Form::Sales::Questions::Nationality1 < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "national"
+ @check_answer_label = "Buyer 1’s nationality"
+ @header = "What is buyer 1’s nationality?"
+ @type = "radio"
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ @conditional_for = {
+ "othernational" => [12],
+ }
+ @hidden_in_check_answers = {
+ "depends_on" => [
+ {
+ "national" => 12,
+ },
+ ],
+ }
+ end
+
+ ANSWER_OPTIONS = {
+ "18" => { "value" => "United Kingdom" },
+ "17" => { "value" => "Republic of Ireland" },
+ "19" => { "value" => "European Economic Area (EEA), excluding ROI" },
+ "12" => { "value" => "Other" },
+ "13" => { "value" => "Buyer prefers not to say" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/other_nationality1.rb b/app/models/form/sales/questions/other_nationality1.rb
new file mode 100644
index 000000000..a779d4fc8
--- /dev/null
+++ b/app/models/form/sales/questions/other_nationality1.rb
@@ -0,0 +1,10 @@
+class Form::Sales::Questions::OtherNationality1 < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "othernational"
+ @check_answer_label = "Buyer 1’s nationality"
+ @header = "Nationality"
+ @type = "text"
+ @page = page
+ end
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 93d084332..e389d5e72 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -12,14 +12,15 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::BuyerInterview.new(nil, nil, self),
Form::Sales::Pages::Age1.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
- Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
- Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundAsian.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundArab.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
+ Form::Sales::Pages::Nationality1.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
+ Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
Form::Sales::Pages::Age2.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity2.new(nil, nil, self),
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
diff --git a/db/migrate/20220927082602_add_national_column.rb b/db/migrate/20220927082602_add_national_column.rb
new file mode 100644
index 000000000..d794bc858
--- /dev/null
+++ b/db/migrate/20220927082602_add_national_column.rb
@@ -0,0 +1,8 @@
+class AddNationalColumn < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :national, :integer
+ t.column :othernational, :string
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b30200da0..269091a77 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[7.0].define(version: 2022_10_03_150610) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -329,22 +329,24 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_03_150610) do
t.string "purchid"
t.integer "type"
t.integer "ownershipsch"
- t.string "othtype"
- t.integer "jointmore"
t.integer "jointpur"
+ t.string "othtype"
t.integer "beds"
- t.integer "companybuy"
+ t.integer "jointmore"
t.integer "age1"
t.integer "age1_known"
t.string "sex1"
+ t.integer "national"
+ t.string "othernational"
t.integer "buy1livein"
+ t.integer "companybuy"
t.integer "buylivein"
t.integer "builtype"
t.integer "proptype"
- t.string "relat2"
- t.string "otherrelat2"
t.integer "age2"
t.integer "age2_known"
+ t.string "relat2"
+ t.string "otherrelat2"
t.integer "ethnic"
t.integer "ethnic_group"
t.string "sex2"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 4f9aa07ed..2936d0d06 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -24,6 +24,7 @@ FactoryBot.define do
age1_known { 0 }
age1 { 30 }
sex1 { "X" }
+ national { 18 }
buy1livein { 1 }
relat2 { "P" }
proptype { 1 }
diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb
index 4f3f44b5a..33d99955e 100644
--- a/spec/features/form/conditional_questions_spec.rb
+++ b/spec/features/form/conditional_questions_spec.rb
@@ -12,6 +12,14 @@ RSpec.describe "Form Conditional Questions" do
managing_organisation: user.organisation,
)
end
+ let(:sales_log) do
+ FactoryBot.create(
+ :sales_log,
+ :completed,
+ owning_organisation: user.organisation,
+ managing_organisation: user.organisation,
+ )
+ end
let(:id) { lettings_log.id }
let(:fake_2021_2022_form) { Form.new("spec/fixtures/forms/2021_2022.json") }
@@ -44,5 +52,15 @@ RSpec.describe "Form Conditional Questions" do
visit("/lettings-logs/#{id}/property-postcode")
expect(page).to have_field("lettings-log-postcode-full-field", with: "NW1 6RT")
end
+
+ it "gets cleared if the conditional question is hidden after editing the answer" do
+ sales_log.update!(national: 12, othernational: "other")
+ visit("/sales-logs/#{sales_log.id}/buyer-1-nationality")
+ expect(page).to have_field("sales-log-othernational-field", with: "other")
+
+ choose("sales-log-national-18-field", allow_label_click: true)
+ choose("sales-log-national-12-field", allow_label_click: true)
+ expect(page).to have_field("sales-log-othernational-field", with: "")
+ end
end
end
diff --git a/spec/helpers/question_attribute_helper_spec.rb b/spec/helpers/question_attribute_helper_spec.rb
index 96f2f7ef6..2be903535 100644
--- a/spec/helpers/question_attribute_helper_spec.rb
+++ b/spec/helpers/question_attribute_helper_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe QuestionAttributeHelper do
"conditional_for" => {
"next_question": ">1",
},
- }, nil)
+ }, form.get_page("rent"))
end
let(:expected_attribs) do
{
@@ -48,7 +48,7 @@ RSpec.describe QuestionAttributeHelper do
"data-action": "input->numeric-question#calculateFields click->conditional-question#displayConditional",
"data-target": "lettings-log-#{question.result_field.to_s.dasherize}-field",
"data-calculated": question.fields_to_add.to_json,
- "data-info": question.conditional_for.to_json,
+ "data-info": { conditional_questions: question.conditional_for, log_type: "lettings" }.to_json,
}
end
diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb
new file mode 100644
index 000000000..5d156e041
--- /dev/null
+++ b/spec/models/form/sales/pages/nationality1_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Nationality1, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[national othernational])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_nationality")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to be_nil
+ end
+end
diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/nationality1_spec.rb
new file mode 100644
index 000000000..819d41ae4
--- /dev/null
+++ b/spec/models/form/sales/questions/nationality1_spec.rb
@@ -0,0 +1,63 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Nationality1, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("national")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What is buyer 1’s nationality?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s nationality")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest.")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "18" => { "value" => "United Kingdom" },
+ "17" => { "value" => "Republic of Ireland" },
+ "19" => { "value" => "European Economic Area (EEA), excluding ROI" },
+ "12" => { "value" => "Other" },
+ "13" => { "value" => "Buyer prefers not to say" },
+ })
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to eq({
+ "othernational" => [12],
+ })
+ end
+
+ it "has correct hidden in check answers" do
+ expect(question.hidden_in_check_answers).to eq({
+ "depends_on" => [
+ {
+ "national" => 12,
+ },
+ ],
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/other_nationality1_spec.rb b/spec/models/form/sales/questions/other_nationality1_spec.rb
new file mode 100644
index 000000000..b01928efc
--- /dev/null
+++ b/spec/models/form/sales/questions/other_nationality1_spec.rb
@@ -0,0 +1,37 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::OtherNationality1, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("othernational")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Nationality")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1’s nationality")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("text")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to be_nil
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index 364895cc8..21e496efd 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -17,14 +17,15 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_interview
buyer_1_age
buyer_1_gender_identity
- buyer_1_live_in_property
- buyer_2_relationship_to_buyer_1
buyer_1_ethnic_group
buyer_1_ethnic_background_black
buyer_1_ethnic_background_asian
buyer_1_ethnic_background_arab
buyer_1_ethnic_background_mixed
buyer_1_ethnic_background_white
+ buyer_1_nationality
+ buyer_1_live_in_property
+ buyer_2_relationship_to_buyer_1
buyer_2_age
buyer_2_gender_identity
buyer_2_working_situation
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 831502602..32b6fbc7d 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(30)
+ expect(form.pages.count).to eq(31)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(30)
+ expect(form.pages.count).to eq(31)
expect(form.name).to eq("2021_2022_sales")
end
end
From 9a0629004d306a08038bc5dc1ca20e056722e5a1 Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Wed, 5 Oct 2022 12:02:52 +0100
Subject: [PATCH 10/16] Cldc 1574 privacy notice (#931)
* feat: core functionality
* feat: update schema.rb
* feat: add link for privacy notice, refactor to separate tenant/buyer
* feat: make privacy notices open in new tab
* test: make previous tests pass
* test: add new tests
---
app/models/form/sales/pages/privacy_notice.rb | 18 ++++++++
.../form/sales/questions/privacy_notice.rb | 18 ++++++++
.../subsections/household_characteristics.rb | 1 +
.../form/guidance/_privacy_notice_buyer.erb | 1 +
..._notice.erb => _privacy_notice_tenant.erb} | 2 +-
config/forms/2021_2022.json | 2 +-
config/forms/2022_2023.json | 2 +-
...4095132_add_privacy_notice_to_sales_log.rb | 7 +++
db/schema.rb | 11 ++---
.../form/sales/pages/privacy_notice_spec.rb | 33 ++++++++++++++
.../sales/questions/privacy_notice_spec.rb | 43 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
13 files changed, 133 insertions(+), 10 deletions(-)
create mode 100644 app/models/form/sales/pages/privacy_notice.rb
create mode 100644 app/models/form/sales/questions/privacy_notice.rb
create mode 100644 app/views/form/guidance/_privacy_notice_buyer.erb
rename app/views/form/guidance/{_privacy_notice.erb => _privacy_notice_tenant.erb} (57%)
create mode 100644 db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/privacy_notice_spec.rb
create mode 100644 spec/models/form/sales/questions/privacy_notice_spec.rb
diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb
new file mode 100644
index 000000000..a7e8ca219
--- /dev/null
+++ b/app/models/form/sales/pages/privacy_notice.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::PrivacyNotice < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "privacy_notice"
+ @header = "Department for Levelling Up, Housing and Communities privacy notice"
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "noint" => 1,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::PrivacyNotice.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb
new file mode 100644
index 000000000..e853b38de
--- /dev/null
+++ b/app/models/form/sales/questions/privacy_notice.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Questions::PrivacyNotice < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "privacynotice"
+ @check_answer_label = "Buyer has seen the privacy notice?"
+ @header = "Declaration"
+ @type = "checkbox"
+ @hint_text = ""
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ @guidance_position = GuidancePosition::TOP
+ @guidance_partial = "privacy_notice_buyer"
+ end
+
+ ANSWER_OPTIONS = {
+ "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index e389d5e72..055aca08b 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -10,6 +10,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
def pages
@pages ||= [
Form::Sales::Pages::BuyerInterview.new(nil, nil, self),
+ Form::Sales::Pages::PrivacyNotice.new(nil, nil, self),
Form::Sales::Pages::Age1.new(nil, nil, self),
Form::Sales::Pages::GenderIdentity1.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self),
diff --git a/app/views/form/guidance/_privacy_notice_buyer.erb b/app/views/form/guidance/_privacy_notice_buyer.erb
new file mode 100644
index 000000000..fabe9ced1
--- /dev/null
+++ b/app/views/form/guidance/_privacy_notice_buyer.erb
@@ -0,0 +1 @@
+Make sure the buyer has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.
diff --git a/app/views/form/guidance/_privacy_notice.erb b/app/views/form/guidance/_privacy_notice_tenant.erb
similarity index 57%
rename from app/views/form/guidance/_privacy_notice.erb
rename to app/views/form/guidance/_privacy_notice_tenant.erb
index c6e0b9adc..88b281730 100644
--- a/app/views/form/guidance/_privacy_notice.erb
+++ b/app/views/form/guidance/_privacy_notice_tenant.erb
@@ -1 +1 @@
-Make sure the tenant has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path %> before completing this log.
+Make sure the tenant has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 4292d1d3a..801ab5717 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -1143,7 +1143,7 @@
"questions": {
"declaration": {
"header": "",
- "guidance_partial": "privacy_notice",
+ "guidance_partial": "privacy_notice_tenant",
"check_answer_label": "Tenant has seen the privacy notice",
"check_answers_card_number": 0,
"type": "checkbox",
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index b30461a84..490d28e12 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -1178,7 +1178,7 @@
"questions": {
"declaration": {
"header": "",
- "guidance_partial": "privacy_notice",
+ "guidance_partial": "privacy_notice_tenant",
"check_answer_label": "Tenant has seen the privacy notice",
"check_answers_card_number": 0,
"type": "checkbox",
diff --git a/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb
new file mode 100644
index 000000000..f60b00823
--- /dev/null
+++ b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddPrivacyNoticeToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :privacynotice, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 269091a77..368f1a4e8 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -329,17 +329,19 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
t.string "purchid"
t.integer "type"
t.integer "ownershipsch"
- t.integer "jointpur"
t.string "othtype"
- t.integer "beds"
t.integer "jointmore"
+ t.integer "jointpur"
+ t.integer "beds"
+ t.integer "companybuy"
t.integer "age1"
t.integer "age1_known"
t.string "sex1"
t.integer "national"
t.string "othernational"
+ t.integer "ethnic"
+ t.integer "ethnic_group"
t.integer "buy1livein"
- t.integer "companybuy"
t.integer "buylivein"
t.integer "builtype"
t.integer "proptype"
@@ -347,12 +349,11 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
t.integer "age2_known"
t.string "relat2"
t.string "otherrelat2"
- t.integer "ethnic"
- t.integer "ethnic_group"
t.string "sex2"
t.integer "noint"
t.integer "buy2livein"
t.integer "ecstat2"
+ t.integer "privacynotice"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/models/form/sales/pages/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb
new file mode 100644
index 000000000..9c957b0b5
--- /dev/null
+++ b/spec/models/form/sales/pages/privacy_notice_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[privacynotice])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("privacy_notice")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("Department for Levelling Up, Housing and Communities privacy notice")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{ "noint" => 1 }])
+ end
+end
diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb
new file mode 100644
index 000000000..f90daef1b
--- /dev/null
+++ b/spec/models/form/sales/questions/privacy_notice_spec.rb
@@ -0,0 +1,43 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("privacynotice")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Declaration")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer has seen the privacy notice?")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("checkbox")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index 21e496efd..29874c8e6 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -15,6 +15,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
expect(household_characteristics.pages.map(&:id)).to eq(
%w[
buyer_interview
+ privacy_notice
buyer_1_age
buyer_1_gender_identity
buyer_1_ethnic_group
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 32b6fbc7d..c42b021cd 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(31)
+ expect(form.pages.count).to eq(32)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(31)
+ expect(form.pages.count).to eq(32)
expect(form.name).to eq("2021_2022_sales")
end
end
From a136a7013976986df480fd0c2cc34bf42ea5c810 Mon Sep 17 00:00:00 2001
From: James Rose
Date: Wed, 5 Oct 2022 15:24:35 +0100
Subject: [PATCH 11/16] Check that we have an inferred check answers value
before extracting its value (#933)
It's possible that this method returns true despite not having an `inferred_check_answers_value` set. This is an obvious smell that we will return to fix.
---
app/models/form/question.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index 7449d6932..227e6079e 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -51,7 +51,7 @@ class Form::Question
answer = label_from_value(log[id]) if log[id].present?
answer_label = [prefix, format_value(answer), suffix_label(log)].join("") if answer
- inferred = inferred_check_answers_value["value"] if has_inferred_check_answers_value?(log)
+ inferred = inferred_check_answers_value["value"] if inferred_check_answers_value && has_inferred_check_answers_value?(log)
return inferred if inferred.present?
answer_label
From c34f922d76f180b55608dc09bac92fe672e36ab1 Mon Sep 17 00:00:00 2001
From: Sam
Date: Wed, 5 Oct 2022 15:36:59 +0100
Subject: [PATCH 12/16] CLDC-1505 Buyer 1 working situation (#932)
* CLDC-1505 Buyer 1 working situation
* Update sales log factory
---
.../sales/pages/buyer1_working_situation.rb | 15 ++++++
.../questions/buyer1_working_situation.rb | 26 ++++++++++
.../subsections/household_characteristics.rb | 1 +
...20221004184301_add_ecstat1_to_sales_log.rb | 7 +++
db/schema.rb | 9 ++--
spec/factories/sales_log.rb | 1 +
.../pages/buyer1_working_situation_spec.rb | 25 ++++++++++
.../buyer1_working_situation_spec.rb | 49 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
10 files changed, 132 insertions(+), 6 deletions(-)
create mode 100644 app/models/form/sales/pages/buyer1_working_situation.rb
create mode 100644 app/models/form/sales/questions/buyer1_working_situation.rb
create mode 100644 db/migrate/20221004184301_add_ecstat1_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/buyer1_working_situation_spec.rb
create mode 100644 spec/models/form/sales/questions/buyer1_working_situation_spec.rb
diff --git a/app/models/form/sales/pages/buyer1_working_situation.rb b/app/models/form/sales/pages/buyer1_working_situation.rb
new file mode 100644
index 000000000..caaa0e60f
--- /dev/null
+++ b/app/models/form/sales/pages/buyer1_working_situation.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::Buyer1WorkingSituation < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "buyer_1_working_situation"
+ @header = "Which of these best describes buyer 1's working situation?"
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Buyer1WorkingSituation.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb
new file mode 100644
index 000000000..571ab7366
--- /dev/null
+++ b/app/models/form/sales/questions/buyer1_working_situation.rb
@@ -0,0 +1,26 @@
+class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "ecstat1"
+ @check_answer_label = "Buyer 1's working situation"
+ @header = "Which of these best describes buyer 1's working situation?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it's a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
+ end
+
+ ANSWER_OPTIONS = {
+ "2" => { "value" => "Part-time - Less than 30 hours" },
+ "1" => { "value" => "Full-time - 30 hours or more" },
+ "3" => { "value" => "In government training into work, such as New Deal" },
+ "4" => { "value" => "Jobseeker" },
+ "6" => { "value" => "Not seeking work" },
+ "8" => { "value" => "Unable to work due to long term sick or disability" },
+ "5" => { "value" => "Retired" },
+ "0" => { "value" => "Other" },
+ "10" => { "value" => "Buyer prefers not to say" },
+ "7" => { "value" => "Full-time student" },
+ "9" => { "value" => "Child under 16" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 055aca08b..32a8b16b5 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -20,6 +20,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self),
Form::Sales::Pages::Nationality1.new(nil, nil, self),
+ Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
Form::Sales::Pages::Age2.new(nil, nil, self),
diff --git a/db/migrate/20221004184301_add_ecstat1_to_sales_log.rb b/db/migrate/20221004184301_add_ecstat1_to_sales_log.rb
new file mode 100644
index 000000000..989a4442a
--- /dev/null
+++ b/db/migrate/20221004184301_add_ecstat1_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddEcstat1ToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :ecstat1, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 368f1a4e8..9e0ceb71e 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[7.0].define(version: 2022_10_04_095132) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_04_184301) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -333,12 +333,10 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
t.integer "jointmore"
t.integer "jointpur"
t.integer "beds"
- t.integer "companybuy"
t.integer "age1"
t.integer "age1_known"
+ t.integer "companybuy"
t.string "sex1"
- t.integer "national"
- t.string "othernational"
t.integer "ethnic"
t.integer "ethnic_group"
t.integer "buy1livein"
@@ -353,6 +351,9 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_095132) do
t.integer "noint"
t.integer "buy2livein"
t.integer "ecstat2"
+ t.integer "ecstat1"
+ t.integer "national"
+ t.string "othernational"
t.integer "privacynotice"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 2936d0d06..a091030bc 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -35,6 +35,7 @@ FactoryBot.define do
ethnic_group { 12 }
sex2 { "X" }
buy2livein { "1" }
+ ecstat1 { "1" }
ecstat2 { "1" }
end
end
diff --git a/spec/models/form/sales/pages/buyer1_working_situation_spec.rb b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb
new file mode 100644
index 000000000..2a48f0b0f
--- /dev/null
+++ b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb
@@ -0,0 +1,25 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Buyer1WorkingSituation, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[ecstat1])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("buyer_1_working_situation")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("Which of these best describes buyer 1's working situation?")
+ end
+end
diff --git a/spec/models/form/sales/questions/buyer1_working_situation_spec.rb b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb
new file mode 100644
index 000000000..832c91538
--- /dev/null
+++ b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb
@@ -0,0 +1,49 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("ecstat1")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Which of these best describes buyer 1's working situation?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Buyer 1's working situation")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "2" => { "value" => "Part-time - Less than 30 hours" },
+ "1" => { "value" => "Full-time - 30 hours or more" },
+ "3" => { "value" => "In government training into work, such as New Deal" },
+ "4" => { "value" => "Jobseeker" },
+ "6" => { "value" => "Not seeking work" },
+ "8" => { "value" => "Unable to work due to long term sick or disability" },
+ "5" => { "value" => "Retired" },
+ "0" => { "value" => "Other" },
+ "10" => { "value" => "Buyer prefers not to say" },
+ "7" => { "value" => "Full-time student" },
+ "9" => { "value" => "Child under 16" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index 29874c8e6..aa94e05dd 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -25,6 +25,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_ethnic_background_mixed
buyer_1_ethnic_background_white
buyer_1_nationality
+ buyer_1_working_situation
buyer_1_live_in_property
buyer_2_relationship_to_buyer_1
buyer_2_age
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index c42b021cd..e2ee27419 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(32)
+ expect(form.pages.count).to eq(33)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(32)
+ expect(form.pages.count).to eq(33)
expect(form.name).to eq("2021_2022_sales")
end
end
From 8dc808a7db488593186c78570a7794888b265b9a Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Thu, 6 Oct 2022 09:20:12 +0100
Subject: [PATCH 13/16] Cldc 1527 others in property (#934)
* feat: add functionality and make tests pass
* tests: add new tests
* refactor: appease linting
* feat: update schema
* feat: update test
---
.../pages/number_of_others_in_property.rb | 15 ++++++++
.../questions/number_of_others_in_property.rb | 12 ++++++
.../subsections/household_characteristics.rb | 1 +
...21005125543_add_hholdcount_to_sales_log.rb | 7 ++++
db/schema.rb | 11 +++---
spec/factories/sales_log.rb | 1 +
.../number_of_others_in_property_spec.rb | 29 +++++++++++++++
.../number_of_others_in_property_spec.rb | 37 +++++++++++++++++++
.../household_characteristics_spec.rb | 1 +
spec/models/form_handler_spec.rb | 4 +-
10 files changed, 111 insertions(+), 7 deletions(-)
create mode 100644 app/models/form/sales/pages/number_of_others_in_property.rb
create mode 100644 app/models/form/sales/questions/number_of_others_in_property.rb
create mode 100644 db/migrate/20221005125543_add_hholdcount_to_sales_log.rb
create mode 100644 spec/models/form/sales/pages/number_of_others_in_property_spec.rb
create mode 100644 spec/models/form/sales/questions/number_of_others_in_property_spec.rb
diff --git a/app/models/form/sales/pages/number_of_others_in_property.rb b/app/models/form/sales/pages/number_of_others_in_property.rb
new file mode 100644
index 000000000..b97c70775
--- /dev/null
+++ b/app/models/form/sales/pages/number_of_others_in_property.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::NumberOfOthersInProperty < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "number_of_others_in_property"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::NumberOfOthersInProperty.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/number_of_others_in_property.rb b/app/models/form/sales/questions/number_of_others_in_property.rb
new file mode 100644
index 000000000..ddf2adb31
--- /dev/null
+++ b/app/models/form/sales/questions/number_of_others_in_property.rb
@@ -0,0 +1,12 @@
+class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "hholdcount"
+ @check_answer_label = "Number of other people living in the property"
+ @header = "Besides the buyers, how many other people live in the property?"
+ @type = "numeric"
+ @hint_text = "You can provide details for a maximum of 4 other people."
+ @page = page
+ @width = 2
+ end
+end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 32a8b16b5..7af439221 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -27,6 +27,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::GenderIdentity2.new(nil, nil, self),
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
+ Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self),
]
end
end
diff --git a/db/migrate/20221005125543_add_hholdcount_to_sales_log.rb b/db/migrate/20221005125543_add_hholdcount_to_sales_log.rb
new file mode 100644
index 000000000..c21b6dd8c
--- /dev/null
+++ b/db/migrate/20221005125543_add_hholdcount_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddHholdcountToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :hholdcount, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 9e0ceb71e..1606ecbf3 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[7.0].define(version: 2022_10_04_184301) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_05_125543) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -333,10 +333,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_184301) do
t.integer "jointmore"
t.integer "jointpur"
t.integer "beds"
+ t.integer "companybuy"
t.integer "age1"
t.integer "age1_known"
- t.integer "companybuy"
t.string "sex1"
+ t.integer "national"
+ t.string "othernational"
t.integer "ethnic"
t.integer "ethnic_group"
t.integer "buy1livein"
@@ -351,10 +353,9 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_04_184301) do
t.integer "noint"
t.integer "buy2livein"
t.integer "ecstat2"
- t.integer "ecstat1"
- t.integer "national"
- t.string "othernational"
t.integer "privacynotice"
+ t.integer "hholdcount"
+ t.integer "ecstat1"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index a091030bc..ecf23a72e 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -37,6 +37,7 @@ FactoryBot.define do
buy2livein { "1" }
ecstat1 { "1" }
ecstat2 { "1" }
+ hholdcount { "1" }
end
end
end
diff --git a/spec/models/form/sales/pages/number_of_others_in_property_spec.rb b/spec/models/form/sales/pages/number_of_others_in_property_spec.rb
new file mode 100644
index 000000000..4d7f6862b
--- /dev/null
+++ b/spec/models/form/sales/pages/number_of_others_in_property_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[hholdcount])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("number_of_others_in_property")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+end
diff --git a/spec/models/form/sales/questions/number_of_others_in_property_spec.rb b/spec/models/form/sales/questions/number_of_others_in_property_spec.rb
new file mode 100644
index 000000000..0742a98b6
--- /dev/null
+++ b/spec/models/form/sales/questions/number_of_others_in_property_spec.rb
@@ -0,0 +1,37 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("hholdcount")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Besides the buyers, how many other people live in the property?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Number of other people living in the property")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("numeric")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("You can provide details for a maximum of 4 other people.")
+ end
+end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index aa94e05dd..2efeb640c 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -32,6 +32,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_2_gender_identity
buyer_2_working_situation
buyer_2_live_in_property
+ number_of_others_in_property
],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index e2ee27419..4bd12ba7e 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(33)
+ expect(form.pages.count).to eq(34)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(33)
+ expect(form.pages.count).to eq(34)
expect(form.name).to eq("2021_2022_sales")
end
end
From 333dbfe5bbe5dde2f8807be3c2652a10b378c1dd Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Thu, 6 Oct 2022 09:32:02 +0100
Subject: [PATCH 14/16] Cldc 1522 buyer 2 relationship (#936)
* feat: add buyer 2-1 relationship question and page (migration and schema to come in next commit)
* feat: add buyer 2-1 migration and schema
* feat: update schema
* feat: add depends_on and tests
* feat: add hint text
* tests: add new tests
* refactor: lint appeasing
* test: update no. of pages
* feat: remove text input for Other option
* feat: update schema
---
.../pages/buyer2_relationship_to_buyer1.rb | 1 -
.../buyer2_relationship_to_buyer1.rb | 10 -----
.../other_buyer2_relationship_to_buyer1.rb | 10 -----
...50022_remove_otherrelat2_from_sales_log.rb | 5 +++
db/schema.rb | 5 +--
.../buyer2_relationship_to_buyer1_spec.rb | 2 +-
.../buyer2_relationship_to_buyer1_spec.rb | 16 --------
...ther_buyer2_relationship_to_buyer1_spec.rb | 37 -------------------
8 files changed, 8 insertions(+), 78 deletions(-)
delete mode 100644 app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb
create mode 100644 db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb
delete mode 100644 spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb
diff --git a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
index 7576e947c..8927ddd5a 100644
--- a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
+++ b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
@@ -13,7 +13,6 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
def questions
@questions ||= [
Form::Sales::Questions::Buyer2RelationshipToBuyer1.new(nil, nil, self),
- Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1.new(nil, nil, self),
]
end
end
diff --git a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
index 67db6677d..11c9717ba 100644
--- a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
+++ b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
@@ -8,16 +8,6 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question
@hint_text = ""
@page = page
@answer_options = ANSWER_OPTIONS
- @conditional_for = {
- "otherrelat2" => %w[X],
- }
- @hidden_in_check_answers = {
- "depends_on" => [
- {
- "relat2" => "X",
- },
- ],
- }
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb b/app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb
deleted file mode 100644
index f9959e3bd..000000000
--- a/app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1 < ::Form::Question
- def initialize(id, hsh, page)
- super
- @id = "otherrelat2"
- @check_answer_label = "Buyer 2's relationship to buyer 1"
- @header = "Buyer 2's relationship to buyer 1"
- @type = "text"
- @page = page
- end
-end
diff --git a/db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb b/db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb
new file mode 100644
index 000000000..9cc5a35cf
--- /dev/null
+++ b/db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb
@@ -0,0 +1,5 @@
+class RemoveOtherrelat2FromSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ remove_column :sales_logs, :otherrelat2, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1606ecbf3..58ca51de5 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[7.0].define(version: 2022_10_05_125543) do
+ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -348,14 +348,13 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_05_125543) do
t.integer "age2"
t.integer "age2_known"
t.string "relat2"
- t.string "otherrelat2"
t.string "sex2"
t.integer "noint"
t.integer "buy2livein"
t.integer "ecstat2"
t.integer "privacynotice"
- t.integer "hholdcount"
t.integer "ecstat1"
+ t.integer "hholdcount"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
index 675913419..2e87764d6 100644
--- a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
+++ b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do
end
it "has correct questions" do
- expect(page.questions.map(&:id)).to eq(%w[relat2 otherrelat2])
+ expect(page.questions.map(&:id)).to eq(%w[relat2])
end
it "has the correct id" do
diff --git a/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
index cabd2168a..14bf2cb23 100644
--- a/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
+++ b/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
@@ -43,20 +43,4 @@ RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model
"R" => { "value" => "Buyer prefers not to say" },
})
end
-
- it "has correct conditional for" do
- expect(question.conditional_for).to eq({
- "otherrelat2" => %w[X],
- })
- end
-
- it "has correct hidden in check answers" do
- expect(question.hidden_in_check_answers).to eq({
- "depends_on" => [
- {
- "relat2" => "X",
- },
- ],
- })
- end
end
diff --git a/spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb
deleted file mode 100644
index 1b4b3f91e..000000000
--- a/spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-require "rails_helper"
-
-RSpec.describe Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1, type: :model do
- subject(:question) { described_class.new(question_id, question_definition, page) }
-
- let(:question_id) { nil }
- let(:question_definition) { nil }
- let(:page) { instance_double(Form::Page) }
-
- it "has correct page" do
- expect(question.page).to eq(page)
- end
-
- it "has the correct id" do
- expect(question.id).to eq("otherrelat2")
- end
-
- it "has the correct header" do
- expect(question.header).to eq("Buyer 2's relationship to buyer 1")
- end
-
- it "has the correct check_answer_label" do
- expect(question.check_answer_label).to eq("Buyer 2's relationship to buyer 1")
- end
-
- it "has the correct type" do
- expect(question.type).to eq("text")
- end
-
- it "is not marked as derived" do
- expect(question.derived?).to be false
- end
-
- it "has the correct hint" do
- expect(question.hint_text).to be_nil
- end
-end
From f2716ef0c129f8dcf58fe6d3d2e4c99e9ee70757 Mon Sep 17 00:00:00 2001
From: Jack S <113976590+bibblobcode@users.noreply.github.com>
Date: Thu, 6 Oct 2022 10:26:59 +0100
Subject: [PATCH 15/16] [CLDC-1502] Add household wheelchair question (#935)
---
.../form/sales/pages/household_wheelchair.rb | 15 +++++++++++++++
.../sales/questions/household_wheelchair.rb | 17 +++++++++++++++++
app/models/form/sales/sections/household.rb | 5 ++++-
.../form/sales/subsections/household_needs.rb | 15 +++++++++++++++
.../20221005090129_add_wheel_to_sales_log.rb | 7 +++++++
db/schema.rb | 1 +
spec/factories/sales_log.rb | 1 +
.../form/sales/sections/household_spec.rb | 7 ++++++-
spec/models/form_handler_spec.rb | 4 ++--
9 files changed, 68 insertions(+), 4 deletions(-)
create mode 100644 app/models/form/sales/pages/household_wheelchair.rb
create mode 100644 app/models/form/sales/questions/household_wheelchair.rb
create mode 100644 app/models/form/sales/subsections/household_needs.rb
create mode 100644 db/migrate/20221005090129_add_wheel_to_sales_log.rb
diff --git a/app/models/form/sales/pages/household_wheelchair.rb b/app/models/form/sales/pages/household_wheelchair.rb
new file mode 100644
index 000000000..97d4abc52
--- /dev/null
+++ b/app/models/form/sales/pages/household_wheelchair.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::HouseholdWheelchair < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "household_wheelchair"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::HouseholdWheelchair.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/household_wheelchair.rb b/app/models/form/sales/questions/household_wheelchair.rb
new file mode 100644
index 000000000..43acfcc24
--- /dev/null
+++ b/app/models/form/sales/questions/household_wheelchair.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Questions::HouseholdWheelchair < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "wheel"
+ @header = "Does anyone in the household use a wheelchair?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @hint_text = "This can be inside or outside the home"
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ "3" => { "value" => "Don't know" },
+ }.freeze
+end
diff --git a/app/models/form/sales/sections/household.rb b/app/models/form/sales/sections/household.rb
index b3432522e..e6f71a26d 100644
--- a/app/models/form/sales/sections/household.rb
+++ b/app/models/form/sales/sections/household.rb
@@ -5,6 +5,9 @@ class Form::Sales::Sections::Household < ::Form::Section
@label = "About the household"
@description = ""
@form = form
- @subsections = [Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self)] || []
+ @subsections = [
+ Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self),
+ Form::Sales::Subsections::HouseholdNeeds.new(nil, nil, self),
+ ]
end
end
diff --git a/app/models/form/sales/subsections/household_needs.rb b/app/models/form/sales/subsections/household_needs.rb
new file mode 100644
index 000000000..bf7a5df3a
--- /dev/null
+++ b/app/models/form/sales/subsections/household_needs.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
+ def initialize(id, hsh, section)
+ super
+ @id = "household_needs"
+ @label = "Household needs"
+ @section = section
+ @depends_on = [{ "setup" => "completed" }]
+ end
+
+ def pages
+ @pages ||= [
+ Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/db/migrate/20221005090129_add_wheel_to_sales_log.rb b/db/migrate/20221005090129_add_wheel_to_sales_log.rb
new file mode 100644
index 000000000..33f08d7ff
--- /dev/null
+++ b/db/migrate/20221005090129_add_wheel_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddWheelToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :wheel, :int
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 58ca51de5..7e6c34a26 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -355,6 +355,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do
t.integer "privacynotice"
t.integer "ecstat1"
t.integer "hholdcount"
+ t.integer "wheel"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index ecf23a72e..321c9800f 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -38,6 +38,7 @@ FactoryBot.define do
ecstat1 { "1" }
ecstat2 { "1" }
hholdcount { "1" }
+ wheel { 1 }
end
end
end
diff --git a/spec/models/form/sales/sections/household_spec.rb b/spec/models/form/sales/sections/household_spec.rb
index 53d81f2fb..e415e8f0c 100644
--- a/spec/models/form/sales/sections/household_spec.rb
+++ b/spec/models/form/sales/sections/household_spec.rb
@@ -12,7 +12,12 @@ RSpec.describe Form::Sales::Sections::Household, type: :model do
end
it "has correct subsections" do
- expect(household.subsections.map(&:id)).to eq(%w[household_characteristics])
+ expect(household.subsections.map(&:id)).to eq(
+ %w[
+ household_characteristics
+ household_needs
+ ],
+ )
end
it "has the correct id" do
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 4bd12ba7e..a53ca575f 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -61,14 +61,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(34)
+ expect(form.pages.count).to eq(35)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(34)
+ expect(form.pages.count).to eq(35)
expect(form.name).to eq("2021_2022_sales")
end
end
From c52a30ae0c8cf335965340a1c03915d8068ee2a6 Mon Sep 17 00:00:00 2001
From: Ted-U <92022120+Ted-U@users.noreply.github.com>
Date: Thu, 6 Oct 2022 10:39:05 +0100
Subject: [PATCH 16/16] [CLDC-1467] add type of building question to sales
(#911)
* add type of building question to sales
* update check answer label
* fix tests
* [CLDC-1467] Use correct page ID
Co-authored-by: Jack S
---
...building_type.rb => property_building_type.rb} | 6 +++---
...building_type.rb => property_building_type.rb} | 2 +-
.../sales/subsections/property_information.rb | 1 +
app/models/form/sales/subsections/setup.rb | 1 -
db/schema.rb | 1 +
...ype_spec.rb => property_building_type_spec.rb} | 4 ++--
...ype_spec.rb => property_building_type_spec.rb} | 2 +-
.../subsections/property_information_spec.rb | 6 +++++-
spec/models/form/sales/subsections/setup_spec.rb | 15 ++++++++++++++-
spec/models/form_spec.rb | 6 +++---
10 files changed, 31 insertions(+), 13 deletions(-)
rename app/models/form/sales/pages/{building_type.rb => property_building_type.rb} (51%)
rename app/models/form/sales/questions/{building_type.rb => property_building_type.rb} (86%)
rename spec/models/form/sales/pages/{building_type_spec.rb => property_building_type_spec.rb} (82%)
rename spec/models/form/sales/questions/{building_type_spec.rb => property_building_type_spec.rb} (93%)
diff --git a/app/models/form/sales/pages/building_type.rb b/app/models/form/sales/pages/property_building_type.rb
similarity index 51%
rename from app/models/form/sales/pages/building_type.rb
rename to app/models/form/sales/pages/property_building_type.rb
index f37319ee1..8f93b305c 100644
--- a/app/models/form/sales/pages/building_type.rb
+++ b/app/models/form/sales/pages/property_building_type.rb
@@ -1,7 +1,7 @@
-class Form::Sales::Pages::BuildingType < ::Form::Page
+class Form::Sales::Pages::PropertyBuildingType < ::Form::Page
def initialize(id, hsh, subsection)
super
- @id = "builtype"
+ @id = "property_building_type"
@header = ""
@description = ""
@subsection = subsection
@@ -9,7 +9,7 @@ class Form::Sales::Pages::BuildingType < ::Form::Page
def questions
@questions ||= [
- Form::Sales::Questions::BuildingType.new(nil, nil, self),
+ Form::Sales::Questions::PropertyBuildingType.new(nil, nil, self),
]
end
end
diff --git a/app/models/form/sales/questions/building_type.rb b/app/models/form/sales/questions/property_building_type.rb
similarity index 86%
rename from app/models/form/sales/questions/building_type.rb
rename to app/models/form/sales/questions/property_building_type.rb
index 6673d5a6d..416c9928e 100644
--- a/app/models/form/sales/questions/building_type.rb
+++ b/app/models/form/sales/questions/property_building_type.rb
@@ -1,4 +1,4 @@
-class Form::Sales::Questions::BuildingType < ::Form::Question
+class Form::Sales::Questions::PropertyBuildingType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "builtype"
diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb
index 6a0287de4..61791cb79 100644
--- a/app/models/form/sales/subsections/property_information.rb
+++ b/app/models/form/sales/subsections/property_information.rb
@@ -10,6 +10,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
def pages
@pages ||= [
Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
+ Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
]
end
diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb
index b9ba89dcf..f39926db3 100644
--- a/app/models/form/sales/subsections/setup.rb
+++ b/app/models/form/sales/subsections/setup.rb
@@ -20,7 +20,6 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection
Form::Sales::Pages::BuyerLive.new(nil, nil, self),
Form::Sales::Pages::JointPurchase.new(nil, nil, self),
Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self),
- Form::Sales::Pages::BuildingType.new(nil, nil, self),
]
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 7e6c34a26..eec74a385 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -348,6 +348,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do
t.integer "age2"
t.integer "age2_known"
t.string "relat2"
+ t.string "otherrelat2"
t.string "sex2"
t.integer "noint"
t.integer "buy2livein"
diff --git a/spec/models/form/sales/pages/building_type_spec.rb b/spec/models/form/sales/pages/property_building_type_spec.rb
similarity index 82%
rename from spec/models/form/sales/pages/building_type_spec.rb
rename to spec/models/form/sales/pages/property_building_type_spec.rb
index 03824cb4e..fb5420105 100644
--- a/spec/models/form/sales/pages/building_type_spec.rb
+++ b/spec/models/form/sales/pages/property_building_type_spec.rb
@@ -1,6 +1,6 @@
require "rails_helper"
-RSpec.describe Form::Sales::Pages::BuildingType, type: :model do
+RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
@@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::BuildingType, type: :model do
end
it "has the correct id" do
- expect(page.id).to eq("builtype")
+ expect(page.id).to eq("property_building_type")
end
it "has the correct header" do
diff --git a/spec/models/form/sales/questions/building_type_spec.rb b/spec/models/form/sales/questions/property_building_type_spec.rb
similarity index 93%
rename from spec/models/form/sales/questions/building_type_spec.rb
rename to spec/models/form/sales/questions/property_building_type_spec.rb
index bc81ccda0..1129bf792 100644
--- a/spec/models/form/sales/questions/building_type_spec.rb
+++ b/spec/models/form/sales/questions/property_building_type_spec.rb
@@ -1,6 +1,6 @@
require "rails_helper"
-RSpec.describe Form::Sales::Questions::BuildingType, type: :model do
+RSpec.describe Form::Sales::Questions::PropertyBuildingType, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb
index 76985d7c0..ab33936c5 100644
--- a/spec/models/form/sales/subsections/property_information_spec.rb
+++ b/spec/models/form/sales/subsections/property_information_spec.rb
@@ -13,7 +13,11 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
it "has correct pages" do
expect(property_information.pages.map(&:id)).to eq(
- %w[property_number_of_bedrooms property_unit_type],
+ %w[
+ property_number_of_bedrooms
+ property_building_type
+ property_unit_type
+ ],
)
end
diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb
index ec7ff4ada..36fbf247a 100644
--- a/spec/models/form/sales/subsections/setup_spec.rb
+++ b/spec/models/form/sales/subsections/setup_spec.rb
@@ -13,7 +13,20 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do
it "has correct pages" do
expect(setup.pages.map(&:id)).to eq(
- %w[organisation created_by completion_date purchaser_code ownership_scheme shared_ownership_type discounted_ownership_type outright_ownership_type buyer_company buyer_live joint_purchase number_joint_buyers builtype],
+ %w[
+ organisation
+ created_by
+ completion_date
+ purchaser_code
+ ownership_scheme
+ shared_ownership_type
+ discounted_ownership_type
+ outright_ownership_type
+ buyer_company
+ buyer_live
+ joint_purchase
+ number_joint_buyers
+ ],
)
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index 571e7930e..a062a4aa5 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -206,7 +206,7 @@ RSpec.describe Form, type: :model do
end
end
- describe "when creating a sales log" do
+ describe "when creating a sales log", :aggregate_failures do
it "creates a valid sales form" do
sections = []
form = described_class.new(nil, 2022, sections, "sales")
@@ -218,9 +218,9 @@ RSpec.describe Form, type: :model do
expect(form.sections[0].class).to eq(Form::Sales::Sections::Setup)
expect(form.subsections.count).to eq(1)
expect(form.subsections.first.id).to eq("setup")
- expect(form.pages.count).to eq(13)
+ expect(form.pages.count).to eq(12)
expect(form.pages.first.id).to eq("organisation")
- expect(form.questions.count).to eq(14)
+ expect(form.questions.count).to eq(13)
expect(form.questions.first.id).to eq("owning_organisation_id")
expect(form.start_date).to eq(Time.zone.parse("2022-04-01"))
expect(form.end_date).to eq(Time.zone.parse("2023-07-01"))