From 0ff0aa31fe2b14451413cf63b9213657ae3fece5 Mon Sep 17 00:00:00 2001
From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
Date: Mon, 22 Aug 2022 10:28:37 +0100
Subject: [PATCH 1/3] Cldc 1338 dates validation (#820)
* Change property major repairs date validation from 2 years to 10
* add voiddate_date_in_soft_range? and major_repairs_date_in_soft_range? methods
* update error messages for hard validations
* Add property_major_repairs_value_check to the form
* add void_date_value_check and fix some namings
* Update value_check hidden in check answers to depend on whether the questions is answered
* Remove a schema key
* extract constants for number of days
* change error messages wording
* update schema and csv files
---
app/models/validations/date_validations.rb | 4 +-
app/models/validations/soft_validations.rb | 11 +
.../imports/case_logs_import_service.rb | 4 +-
config/forms/2021_2022.json | 323 +++++++++++++++---
config/forms/2022_2023.json | 323 +++++++++++++++---
config/locales/en.yml | 6 +-
...0330_add_major_repairs_date_value_check.rb | 5 +
...0220808093035_add_void_date_value_check.rb | 5 +
db/schema.rb | 2 +
spec/factories/case_log.rb | 2 +
spec/fixtures/files/case_logs_download.csv | 4 +-
.../files/case_logs_download_non_support.csv | 4 +-
.../validations/date_validations_spec.rb | 10 +-
.../validations/soft_validations_spec.rb | 32 ++
14 files changed, 642 insertions(+), 93 deletions(-)
create mode 100644 db/migrate/20220808090330_add_major_repairs_date_value_check.rb
create mode 100644 db/migrate/20220808093035_add_void_date_value_check.rb
diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb
index 774f9828c..6351a712b 100644
--- a/app/models/validations/date_validations.rb
+++ b/app/models/validations/date_validations.rb
@@ -9,8 +9,8 @@ module Validations::DateValidations
record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.not_first_let")
end
- if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 730
- record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.730_days_before_tenancy_start")
+ if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650
+ record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start")
end
end
diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb
index 686c69174..dd3e94b2e 100644
--- a/app/models/validations/soft_validations.rb
+++ b/app/models/validations/soft_validations.rb
@@ -62,6 +62,17 @@ module Validations::SoftValidations
end
end
+ TWO_YEARS_IN_DAYS = 730
+ TEN_YEARS_IN_DAYS = 3650
+
+ def major_repairs_date_in_soft_range?
+ mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS)
+ end
+
+ def voiddate_in_soft_range?
+ voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS)
+ end
+
private
def details_known_or_lead_tenant?(tenant_number)
diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb
index 96811487f..a0d75c0bb 100644
--- a/app/services/imports/case_logs_import_service.rb
+++ b/app/services/imports/case_logs_import_service.rb
@@ -209,6 +209,8 @@ module Imports
# Soft validations can become required answers, set them to yes by default
attributes["pregnancy_value_check"] = 0
+ attributes["major_repairs_date_value_check"] = 0
+ attributes["void_date_value_check"] = 0
attributes["retirement_value_check"] = 0
attributes["rent_value_check"] = 0
attributes["net_income_value_check"] = 0
@@ -273,7 +275,7 @@ module Imports
end
def fields_not_present_in_softwire_data
- %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check]
+ %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check]
end
def check_status_completed(case_log, previous_status)
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index ffbdc0887..d365a5a8f 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -771,6 +771,38 @@
}
]
},
+ "void_date_value_check": {
+ "depends_on": [{ "voiddate_in_soft_range?": true }],
+ "title_text": {
+ "translation": "soft_validations.void_date.title_text"
+ },
+ "informative_text": {},
+ "questions": {
+ "void_date_value_check": {
+ "check_answer_label": "Void date confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "void_date_value_check": 0
+ },
+ {
+ "void_date_value_check": 1
+ }
+ ]
+ },
+ "header": "Are you sure the time between these dates is correct?",
+ "type": "interruption_screen",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
+ }
+ }
+ }
+ }
+ },
"new_build_handover_date": {
"header": "",
"description": "",
@@ -867,6 +899,38 @@
"rsnvac": 19
}
]
+ },
+ "property_major_repairs_value_check": {
+ "depends_on": [{ "major_repairs_date_in_soft_range?": true }],
+ "title_text": {
+ "translation": "soft_validations.major_repairs_date.title_text"
+ },
+ "informative_text": {},
+ "questions": {
+ "major_repairs_date_value_check": {
+ "check_answer_label": "Major repairs date confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "major_repairs_date_value_check": 0
+ },
+ {
+ "major_repairs_date_value_check": 1
+ }
+ ]
+ },
+ "header": "Are you sure the time between these dates is correct?",
+ "type": "interruption_screen",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
+ }
+ }
+ }
+ }
}
}
},
@@ -1722,8 +1786,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -1768,8 +1841,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2216,8 +2298,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2262,8 +2353,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2707,8 +2807,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2753,8 +2862,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3195,8 +3313,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3241,8 +3368,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3680,8 +3816,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3726,8 +3871,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4162,8 +4316,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4208,8 +4371,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4641,8 +4813,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4687,8 +4868,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -5117,8 +5307,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -5163,8 +5362,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -5381,8 +5589,16 @@
},
"questions": {
"pregnancy_value_check": {
- "check_answer_label": "Pregnancy soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Pregnancy confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [{
+ "pregnancy_value_check": 0
+ },
+ {
+ "pregnancy_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@@ -6875,8 +7091,17 @@
},
"questions": {
"net_income_value_check": {
- "check_answer_label": "Net income soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Net income confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "net_income_value_check": 0
+ },
+ {
+ "net_income_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@@ -7779,8 +8004,17 @@
},
"questions": {
"rent_value_check": {
- "check_answer_label": "Rent soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Total rent confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "rent_value_check": 0
+ },
+ {
+ "rent_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@@ -7823,8 +8057,17 @@
},
"questions": {
"rent_value_check": {
- "check_answer_label": "Rent soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Total rent confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "rent_value_check": 0
+ },
+ {
+ "rent_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index 7735e5ad9..0e737c43e 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -771,6 +771,38 @@
}
]
},
+ "void_date_value_check": {
+ "depends_on": [{ "voiddate_in_soft_range?": true }],
+ "title_text": {
+ "translation": "soft_validations.void_date.title_text"
+ },
+ "informative_text": {},
+ "questions": {
+ "void_date_value_check": {
+ "check_answer_label": "Void date confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "void_date_value_check": 0
+ },
+ {
+ "void_date_value_check": 1
+ }
+ ]
+ },
+ "header": "Are you sure the time between these dates is correct?",
+ "type": "interruption_screen",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
+ }
+ }
+ }
+ }
+ },
"new_build_handover_date": {
"header": "",
"description": "",
@@ -867,6 +899,38 @@
"rsnvac": 19
}
]
+ },
+ "property_major_repairs_value_check": {
+ "depends_on": [{ "major_repairs_date_in_soft_range?": true }],
+ "title_text": {
+ "translation": "soft_validations.major_repairs_date.title_text"
+ },
+ "informative_text": {},
+ "questions": {
+ "major_repairs_date_value_check": {
+ "check_answer_label": "Major repairs date confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "major_repairs_date_value_check": 0
+ },
+ {
+ "major_repairs_date_value_check": 1
+ }
+ ]
+ },
+ "header": "Are you sure the time between these dates is correct?",
+ "type": "interruption_screen",
+ "answer_options": {
+ "0": {
+ "value": "Yes"
+ },
+ "1": {
+ "value": "No"
+ }
+ }
+ }
+ }
}
}
},
@@ -1709,8 +1773,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -1753,8 +1826,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2201,8 +2283,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2247,8 +2338,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2692,8 +2792,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -2738,8 +2847,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3180,8 +3298,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3226,8 +3353,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3665,8 +3801,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -3711,8 +3856,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4147,8 +4301,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4193,8 +4356,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4626,8 +4798,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -4672,8 +4853,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -5102,8 +5292,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person is retired?",
"type": "interruption_screen",
"answer_options": {
@@ -5148,8 +5347,17 @@
},
"questions": {
"retirement_value_check": {
- "check_answer_label": "Retirement age soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Retirement confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "retirement_value_check": 0
+ },
+ {
+ "retirement_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this person isn’t retired?",
"type": "interruption_screen",
"answer_options": {
@@ -5369,8 +5577,16 @@
},
"questions": {
"pregnancy_value_check": {
- "check_answer_label": "Pregnancy soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Pregnancy confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [{
+ "pregnancy_value_check": 0
+ },
+ {
+ "pregnancy_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@@ -6818,8 +7034,17 @@
},
"questions": {
"net_income_value_check": {
- "check_answer_label": "Net income soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Net income confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "net_income_value_check": 0
+ },
+ {
+ "net_income_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@@ -7719,8 +7944,17 @@
},
"questions": {
"rent_value_check": {
- "check_answer_label": "Rent soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Total rent confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "rent_value_check": 0
+ },
+ {
+ "rent_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
@@ -7763,8 +7997,17 @@
},
"questions": {
"rent_value_check": {
- "check_answer_label": "Rent soft validation",
- "hidden_in_check_answers": true,
+ "check_answer_label": "Total rent confirmation",
+ "hidden_in_check_answers": {
+ "depends_on": [
+ {
+ "rent_value_check": 0
+ },
+ {
+ "rent_value_check": 1
+ }
+ ]
+ },
"header": "Are you sure this is correct?",
"type": "interruption_screen",
"answer_options": {
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 56b70d397..107558f3c 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -122,7 +122,7 @@ en:
mrcdate:
before_tenancy_start: "Enter a major repairs date that is before the tenancy start date"
not_first_let: "Major repairs date must not be completed if the tenancy is a first let"
- 730_days_before_tenancy_start: "Enter a major repairs completion date that is no more than 730 days before the tenancy start date"
+ ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date"
void_date:
ten_years_before_tenancy_start: "Enter a void date must no more than 10 years before the tenancy start date"
before_tenancy_start: "Enter a void date must that is before the tenancy start date"
@@ -319,6 +319,10 @@ en:
title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property."
females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:
"
+ major_repairs_date:
+ title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 2 years"
+ void_date:
+ title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years"
devise:
two_factor_authentication:
diff --git a/db/migrate/20220808090330_add_major_repairs_date_value_check.rb b/db/migrate/20220808090330_add_major_repairs_date_value_check.rb
new file mode 100644
index 000000000..e1e666b65
--- /dev/null
+++ b/db/migrate/20220808090330_add_major_repairs_date_value_check.rb
@@ -0,0 +1,5 @@
+class AddMajorRepairsDateValueCheck < ActiveRecord::Migration[7.0]
+ def change
+ add_column :case_logs, :major_repairs_date_value_check, :integer
+ end
+end
diff --git a/db/migrate/20220808093035_add_void_date_value_check.rb b/db/migrate/20220808093035_add_void_date_value_check.rb
new file mode 100644
index 000000000..c39a4d02b
--- /dev/null
+++ b/db/migrate/20220808093035_add_void_date_value_check.rb
@@ -0,0 +1,5 @@
+class AddVoidDateValueCheck < ActiveRecord::Migration[7.0]
+ def change
+ add_column :case_logs, :void_date_value_check, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 1b65e5482..206fc69b0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -200,6 +200,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_10_152340) do
t.integer "vacdays"
t.bigint "scheme_id"
t.bigint "location_id"
+ t.integer "major_repairs_date_value_check"
+ t.integer "void_date_value_check"
t.index ["created_by_id"], name: "index_case_logs_on_created_by_id"
t.index ["location_id"], name: "index_case_logs_on_location_id"
t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id"
diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb
index ec2d2c522..46c151fd2 100644
--- a/spec/factories/case_log.rb
+++ b/spec/factories/case_log.rb
@@ -110,6 +110,8 @@ FactoryBot.define do
rp_dontknow { 0 }
tenancyother { nil }
net_income_value_check { nil }
+ void_date_value_check { 1 }
+ major_repairs_date_value_check { 1 }
net_income_known { 0 }
previous_la_known { 1 }
property_owner_organisation { "Test" }
diff --git a/spec/fixtures/files/case_logs_download.csv b/spec/fixtures/files/case_logs_download.csv
index 5f5a1c96f..b1d71dfec 100644
--- a/spec/fixtures/files/case_logs_download.csv
+++ b/spec/fixtures/files/case_logs_download.csv
@@ -1,2 +1,2 @@
-id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
-{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,6,DLUHC,DLUHC,Danny Rojas
+id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
+{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas
diff --git a/spec/fixtures/files/case_logs_download_non_support.csv b/spec/fixtures/files/case_logs_download_non_support.csv
index 9bcd0e6aa..0c24699c0 100644
--- a/spec/fixtures/files/case_logs_download_non_support.csv
+++ b/spec/fixtures/files/case_logs_download_non_support.csv
@@ -1,2 +1,2 @@
-id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
-{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,6,DLUHC,DLUHC,Danny Rojas
+id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name
+{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas
diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb
index ca09c28c8..3370f9cc0 100644
--- a/spec/models/validations/date_validations_spec.rb
+++ b/spec/models/validations/date_validations_spec.rb
@@ -85,17 +85,17 @@ RSpec.describe Validations::DateValidations do
expect(record.errors["mrcdate"]).to be_empty
end
- it "cannot be more than 2 years before the tenancy start date" do
+ it "cannot be more than 10 years before the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
- record.mrcdate = Time.zone.local(2020, 1, 1)
+ record.mrcdate = Time.zone.local(2012, 1, 1)
date_validator.validate_property_major_repairs(record)
expect(record.errors["mrcdate"])
- .to include(match I18n.t("validations.property.mrcdate.730_days_before_tenancy_start"))
+ .to include(match I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start"))
end
- it "must be within 2 years of the tenancy start date" do
+ it "must be within 10 years of the tenancy start date" do
record.startdate = Time.zone.local(2022, 2, 1)
- record.mrcdate = Time.zone.local(2020, 3, 1)
+ record.mrcdate = Time.zone.local(2012, 3, 1)
date_validator.validate_property_major_repairs(record)
expect(record.errors["mrcdate"]).to be_empty
end
diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb
index b28a53b9e..64d7ba2ab 100644
--- a/spec/models/validations/soft_validations_spec.rb
+++ b/spec/models/validations/soft_validations_spec.rb
@@ -205,4 +205,36 @@ RSpec.describe Validations::SoftValidations do
end
end
end
+
+ describe "major repairs date soft validations" do
+ context "when the major repairs date is within 10 years of the tenancy start date" do
+ it "shows the interruption screen" do
+ record.update!(startdate: Time.zone.local(2022, 2, 1), mrcdate: Time.zone.local(2013, 2, 1))
+ expect(record.major_repairs_date_in_soft_range?).to be true
+ end
+ end
+
+ context "when the major repairs date is less than 2 years before the tenancy start date" do
+ it "does not show the interruption screen" do
+ record.update!(startdate: Time.zone.local(2022, 2, 1), mrcdate: Time.zone.local(2021, 2, 1))
+ expect(record.major_repairs_date_in_soft_range?).to be false
+ end
+ end
+ end
+
+ describe "void date soft validations" do
+ context "when the void date is within 10 years of the tenancy start date" do
+ it "shows the interruption screen" do
+ record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2013, 2, 1))
+ expect(record.voiddate_in_soft_range?).to be true
+ end
+ end
+
+ context "when the void date is less than 2 years before the tenancy start date" do
+ it "does not show the interruption screen" do
+ record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2021, 2, 1))
+ expect(record.voiddate_in_soft_range?).to be false
+ end
+ end
+ end
end
From e82f8ed88ec8ee9d6fe863ea9823ff816252f6c4 Mon Sep 17 00:00:00 2001
From: Ted-U <92022120+Ted-U@users.noreply.github.com>
Date: Mon, 22 Aug 2022 11:02:26 +0100
Subject: [PATCH 2/3] CLDC-1310-seperate-tenants-fix (#833)
* fix pushing to wrong branch
* Make household characteristics check answers match design
* update test form
* add feature specs
* lint fixes
* make changes to forms
* update spec description
* update check for summary card in check answers
* add specs
* fix specs
* extract helper method
* lint fixes
Co-authored-by: Dushan Despotovic
---
...swers_summary_list_card_component.html.erb | 37 +++++++++
...eck_answers_summary_list_card_component.rb | 18 +++++
app/helpers/check_answers_helper.rb | 4 +
app/models/form/question.rb | 3 +-
app/views/form/check_answers.html.erb | 14 +++-
config/forms/2021_2022.json | 55 +++++++++++++
config/forms/2022_2023.json | 77 ++++++++++++++++++-
...nswers_summary_list_card_component_spec.rb | 27 +++++++
spec/features/form/check_answers_page_spec.rb | 13 ++++
spec/fixtures/forms/2021_2022.json | 33 ++++++++
spec/models/form/subsection_spec.rb | 4 +-
spec/models/form_handler_spec.rb | 2 +-
spec/models/form_spec.rb | 2 +-
13 files changed, 276 insertions(+), 13 deletions(-)
create mode 100644 app/components/check_answers_summary_list_card_component.html.erb
create mode 100644 app/components/check_answers_summary_list_card_component.rb
create mode 100644 spec/components/check_answers_summary_list_card_component_spec.rb
diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb
new file mode 100644
index 000000000..c2e3c8ee5
--- /dev/null
+++ b/app/components/check_answers_summary_list_card_component.html.erb
@@ -0,0 +1,37 @@
+
+ <% if applicable_questions.first.check_answers_card_number != 0 %>
+
+ <% end %>
+
+ <%= govuk_summary_list do |summary_list| %>
+ <% applicable_questions.each do |question| %>
+ <% summary_list.row do |row| %>
+ <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %>
+ <% row.value do %>
+ <%= get_answer_label(question) %>
+ <% extra_value = question.get_extra_check_answer_value(case_log) %>
+ <% if extra_value %>
+ <%= extra_value %>
+ <% end %>
+
+ <% question.get_inferred_answers(case_log).each do |inferred_answer| %>
+ <%= inferred_answer %>
+ <% end %>
+ <% end %>
+ <% row.action(
+ text: question.action_text(case_log),
+ href: question.action_href(case_log, question.page.id),
+ visually_hidden_text: question.check_answer_label.to_s.downcase,
+ ) %>
+ <% end %>
+ <% end %>
+ <% end %>
+
+
diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb
new file mode 100644
index 000000000..0ae6afcac
--- /dev/null
+++ b/app/components/check_answers_summary_list_card_component.rb
@@ -0,0 +1,18 @@
+class CheckAnswersSummaryListCardComponent < ViewComponent::Base
+ attr_reader :questions, :case_log, :user
+
+ def initialize(questions:, case_log:, user:)
+ @questions = questions
+ @case_log = case_log
+ @user = user
+ super
+ end
+
+ def applicable_questions
+ questions.reject { |q| q.hidden_in_check_answers?(case_log, user) }
+ end
+
+ def get_answer_label(question)
+ question.answer_label(case_log).presence || "You didn’t answer this question".html_safe
+ end
+end
diff --git a/app/helpers/check_answers_helper.rb b/app/helpers/check_answers_helper.rb
index 760c08ab0..9c0401f79 100644
--- a/app/helpers/check_answers_helper.rb
+++ b/app/helpers/check_answers_helper.rb
@@ -24,6 +24,10 @@ module CheckAnswersHelper
end
end
+ def any_questions_have_summary_card_number?(subsection, case_log)
+ subsection.applicable_questions(case_log).map(&:check_answers_card_number).compact.length.positive?
+ end
+
private
def answered_questions_count(subsection, case_log, current_user)
diff --git a/app/models/form/question.rb b/app/models/form/question.rb
index c21477bc9..11fa40c0b 100644
--- a/app/models/form/question.rb
+++ b/app/models/form/question.rb
@@ -3,7 +3,7 @@ class Form::Question
:type, :min, :max, :step, :width, :fields_to_add, :result_field,
:conditional_for, :readonly, :answer_options, :page, :check_answer_label,
:inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value,
- :guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived
+ :guidance_partial, :prefix, :suffix, :requires_js, :fields_added, :derived, :check_answers_card_number
module GuidancePosition
TOP = 1
@@ -37,6 +37,7 @@ class Form::Question
@suffix = hsh["suffix"]
@requires_js = hsh["requires_js"]
@fields_added = hsh["fields_added"]
+ @check_answers_card_number = hsh["check_answers_card_number"]
end
end
diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb
index 8db15d81e..44b4f89d4 100644
--- a/app/views/form/check_answers.html.erb
+++ b/app/views/form/check_answers.html.erb
@@ -17,10 +17,16 @@
<% end %>
<%= display_answered_questions_summary(subsection, @case_log, current_user) %>
- <%= render partial: "form/check_answers_summary_list", locals: {
- subsection:,
- case_log: @case_log,
- } %>
+ <% if any_questions_have_summary_card_number?(subsection, @case_log) %>
+ <% subsection.applicable_questions(@case_log).group_by(&:check_answers_card_number).values.each do |question_group| %>
+ <%= render CheckAnswersSummaryListCardComponent.new(questions: question_group, case_log: @case_log, user: current_user) %>
+ <% end %>
+ <% else %>
+ <%= render partial: "form/check_answers_summary_list", locals: {
+ subsection:,
+ case_log: @case_log,
+ } %>
+ <% end %>
<%= form_with model: @case_log, method: "get" do |f| %>
<%= f.govuk_submit "Save and return to log" do %>
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index d365a5a8f..e2e0f0131 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -1127,6 +1127,7 @@
"header": "",
"guidance_partial": "privacy_notice",
"check_answer_label": "Tenant has seen the privacy notice",
+ "check_answers_card_number": 0,
"type": "checkbox",
"answer_options": {
"declaration": {
@@ -1141,6 +1142,7 @@
"description": "",
"questions": {
"hhmemb": {
+ "check_answers_card_number": 0,
"check_answer_label": "Number of household members",
"header": "How many people live in the household for this letting?",
"hint_text": "You can provide details for a maximum of 8 people.",
@@ -1240,6 +1242,7 @@
"description": "",
"questions": {
"age1_known": {
+ "check_answers_card_number": 1,
"header": "Do you know the lead tenant’s age?",
"hint_text": "The ’lead’ or ’main’ 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",
@@ -1266,6 +1269,7 @@
}
},
"age1": {
+ "check_answers_card_number": 1,
"header": "Age",
"check_answer_label": "Lead tenant’s age",
"type": "numeric",
@@ -1371,6 +1375,7 @@
"questions": {
"sex1": {
"check_answer_label": "Lead tenant’s gender identity",
+ "check_answers_card_number": 1,
"header": "Which of these best describes the lead tenant’s gender identity?",
"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",
@@ -1483,6 +1488,7 @@
"questions": {
"ethnic_group": {
"check_answer_label": "Lead tenant’s ethnic group",
+ "check_answers_card_number": 1,
"header": "What is the lead tenant’s ethnic group?",
"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",
@@ -1518,6 +1524,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Arab background?",
"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.",
@@ -1539,6 +1546,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Asian or Asian British background?",
"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.",
@@ -1569,6 +1577,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?",
"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.",
@@ -1593,6 +1602,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?",
"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.",
@@ -1620,6 +1630,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s White background?",
"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.",
@@ -1647,6 +1658,7 @@
"description": "",
"questions": {
"national": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s nationality",
"header": "What is the lead tenant’s nationality?",
"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.",
@@ -1716,6 +1728,7 @@
"ecstat1": {
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s working situation?",
+ "check_answers_card_number": 1,
"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": {
@@ -1871,6 +1884,7 @@
"questions": {
"details_known_2": {
"check_answer_label": "Details known for person 2",
+ "check_answers_card_number": 2,
"header": "Do you know details for person 2?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -1914,6 +1928,7 @@
"questions": {
"relat2": {
"check_answer_label": "Person 2’s relationship to the lead tenant",
+ "check_answers_card_number": 2,
"header": "What is person 2’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -1949,6 +1964,7 @@
"questions": {
"age2_known": {
"header": "Do you know person 2’s age?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -1976,6 +1992,7 @@
"age2": {
"header": "Age",
"check_answer_label": "Person 2’s age",
+ "check_answers_card_number": 2,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2087,6 +2104,7 @@
"sex2": {
"check_answer_label": "Person 2’s gender identity",
"header": "Which of these best describes person 2’s gender identity?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2208,6 +2226,7 @@
"questions": {
"ecstat2": {
"check_answer_label": "Person 2’s working situation",
+ "check_answers_card_number": 2,
"header": "Which of these best describes person 2’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2383,6 +2402,7 @@
"questions": {
"details_known_3": {
"check_answer_label": "Details known for person 3",
+ "check_answers_card_number": 3,
"header": "Do you know details for person 3?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2423,6 +2443,7 @@
"questions": {
"relat3": {
"check_answer_label": "Person 3’s relationship to the lead tenant",
+ "check_answers_card_number": 3,
"header": "What is person 3’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2458,6 +2479,7 @@
"questions": {
"age3_known": {
"header": "Do you know person 3’s age?",
+ "check_answers_card_number": 3,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2485,6 +2507,7 @@
"age3": {
"header": "Age",
"check_answer_label": "Person 3’s age",
+ "check_answers_card_number": 3,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2595,6 +2618,7 @@
"questions": {
"sex3": {
"check_answer_label": "Person 3’s gender identity",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -2717,6 +2741,7 @@
"questions": {
"ecstat3": {
"check_answer_label": "Person 3’s working situation",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2892,6 +2917,7 @@
"questions": {
"details_known_4": {
"check_answer_label": "Details known for person 4",
+ "check_answers_card_number": 4,
"header": "Do you know details for person 4?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2929,6 +2955,7 @@
"questions": {
"relat4": {
"check_answer_label": "Person 4’s relationship to the lead tenant",
+ "check_answers_card_number": 4,
"header": "What is person 4’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2964,6 +2991,7 @@
"questions": {
"age4_known": {
"header": "Do you know person 4’s age?",
+ "check_answers_card_number": 4,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2991,6 +3019,7 @@
"age4": {
"header": "Age",
"check_answer_label": "Person 4’s age",
+ "check_answers_card_number": 4,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3101,6 +3130,7 @@
"questions": {
"sex4": {
"check_answer_label": "Person 4’s gender identity",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3223,6 +3253,7 @@
"questions": {
"ecstat4": {
"check_answer_label": "Person 4’s working situation",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3398,6 +3429,7 @@
"questions": {
"details_known_5": {
"check_answer_label": "Details known for person 5",
+ "check_answers_card_number": 5,
"header": "Do you know details for person 5?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3432,6 +3464,7 @@
"questions": {
"relat5": {
"check_answer_label": "Person 5’s relationship to the lead tenant",
+ "check_answers_card_number": 5,
"header": "What is person 5’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3467,6 +3500,7 @@
"questions": {
"age5_known": {
"header": "Do you know person 5’s age?",
+ "check_answers_card_number": 5,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3494,6 +3528,7 @@
"age5": {
"header": "Age",
"check_answer_label": "Person 5’s age",
+ "check_answers_card_number": 5,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3604,6 +3639,7 @@
"questions": {
"sex5": {
"check_answer_label": "Person 5’s gender identity",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3726,6 +3762,7 @@
"questions": {
"ecstat5": {
"check_answer_label": "Person 5’s working situation",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3901,6 +3938,7 @@
"questions": {
"details_known_6": {
"check_answer_label": "Details known for person 6",
+ "check_answers_card_number": 6,
"header": "Do you know details for person 6?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3932,6 +3970,7 @@
"questions": {
"relat6": {
"check_answer_label": "Person 6’s relationship to the lead tenant",
+ "check_answers_card_number": 6,
"header": "What is person 6’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3967,6 +4006,7 @@
"questions": {
"age6_known": {
"header": "Do you know person 6’s age?",
+ "check_answers_card_number": 6,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3994,6 +4034,7 @@
"age6": {
"header": "Age",
"check_answer_label": "Person 6’s age",
+ "check_answers_card_number": 6,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4104,6 +4145,7 @@
"questions": {
"sex6": {
"check_answer_label": "Person 6’s gender identity",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4226,6 +4268,7 @@
"questions": {
"ecstat6": {
"check_answer_label": "Person 6’s working situation",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4401,6 +4444,7 @@
"questions": {
"details_known_7": {
"check_answer_label": "Details known for person 7",
+ "check_answers_card_number": 7,
"header": "Do you know details for person 7?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4429,6 +4473,7 @@
"questions": {
"relat7": {
"check_answer_label": "Person 7’s relationship to the lead tenant",
+ "check_answers_card_number": 7,
"header": "What is person 7’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4464,6 +4509,7 @@
"questions": {
"age7_known": {
"header": "Do you know person 7’s age?",
+ "check_answers_card_number": 7,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4491,6 +4537,7 @@
"age7": {
"header": "Age",
"check_answer_label": "Person 7’s age",
+ "check_answers_card_number": 7,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4601,6 +4648,7 @@
"questions": {
"sex7": {
"check_answer_label": "Person 7’s gender identity",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4723,6 +4771,7 @@
"questions": {
"ecstat7": {
"check_answer_label": "Person 7’s working situation",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4898,6 +4947,7 @@
"questions": {
"details_known_8": {
"check_answer_label": "Details known for person 8",
+ "check_answers_card_number": 8,
"header": "Do you know details for person 8?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4923,6 +4973,7 @@
"questions": {
"relat8": {
"check_answer_label": "Person 8’s relationship to the lead tenant",
+ "check_answers_card_number": 8,
"header": "What is person 8’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4958,6 +5009,7 @@
"questions": {
"age8_known": {
"header": "Do you know person 8’s age?",
+ "check_answers_card_number": 8,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4985,6 +5037,7 @@
"age8": {
"header": "Age",
"check_answer_label": "Person 8’s age",
+ "check_answers_card_number": 8,
"type": "numeric",
"min": 0,
"max": 120,
@@ -5095,6 +5148,7 @@
"questions": {
"sex8": {
"check_answer_label": "Person 8’s gender identity",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -5217,6 +5271,7 @@
"questions": {
"ecstat8": {
"check_answer_label": "Person 8’s working situation",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s working situation?",
"hint_text": "",
"type": "radio",
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index 0e737c43e..0102d5587 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -1162,6 +1162,7 @@
"header": "",
"guidance_partial": "privacy_notice",
"check_answer_label": "Tenant has seen the privacy notice",
+ "check_answers_card_number": 0,
"type": "checkbox",
"answer_options": {
"declaration": {
@@ -1176,6 +1177,7 @@
"description": "",
"questions": {
"hhmemb": {
+ "check_answers_card_number": 0,
"check_answer_label": "Number of household members",
"header": "How many people live in the household for this letting?",
"hint_text": "You can provide details for a maximum of 8 people.",
@@ -1228,7 +1230,11 @@
}
},
"females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check": {
- "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }],
+ "depends_on": [
+ {
+ "female_in_pregnant_household_in_soft_validation_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1271,6 +1277,7 @@
"description": "",
"questions": {
"age1_known": {
+ "check_answers_card_number": 1,
"header": "Do you know the lead tenant’s age?",
"hint_text": "The ’lead’ or ’main’ 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",
@@ -1297,6 +1304,7 @@
}
},
"age1": {
+ "check_answers_card_number": 1,
"header": "Age",
"check_answer_label": "Lead tenant’s age",
"type": "numeric",
@@ -1354,7 +1362,11 @@
}
},
"females_in_soft_age_range_in_pregnant_household_lead_age_value_check": {
- "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }],
+ "depends_on": [
+ {
+ "female_in_pregnant_household_in_soft_validation_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1398,6 +1410,7 @@
"questions": {
"sex1": {
"check_answer_label": "Lead tenant’s gender identity",
+ "check_answers_card_number": 1,
"header": "Which of these best describes the lead tenant’s gender identity?",
"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",
@@ -1462,7 +1475,11 @@
}
},
"females_in_soft_age_range_in_pregnant_household_lead_value_check": {
- "depends_on": [{ "female_in_pregnant_household_in_soft_validation_range?": true }],
+ "depends_on": [
+ {
+ "female_in_pregnant_household_in_soft_validation_range?": true
+ }
+ ],
"title_text": {
"translation": "soft_validations.pregnancy.title",
"arguments": [
@@ -1506,6 +1523,7 @@
"questions": {
"ethnic_group": {
"check_answer_label": "Lead tenant’s ethnic group",
+ "check_answers_card_number": 1,
"header": "What is the lead tenant’s ethnic group?",
"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",
@@ -1541,6 +1559,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Arab background?",
"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.",
@@ -1562,6 +1581,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Asian or Asian British background?",
"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.",
@@ -1592,6 +1612,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?",
"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.",
@@ -1616,6 +1637,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?",
"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.",
@@ -1643,6 +1665,7 @@
"description": "",
"questions": {
"ethnic": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s ethnic background",
"header": "Which of the following best describes the lead tenant’s White background?",
"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.",
@@ -1670,6 +1693,7 @@
"description": "",
"questions": {
"national": {
+ "check_answers_card_number": 1,
"check_answer_label": "Lead tenant’s nationality",
"header": "What is the lead tenant’s nationality?",
"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.",
@@ -1703,6 +1727,7 @@
"ecstat1": {
"check_answer_label": "Lead tenant’s working situation",
"header": "Which of these best describes the lead tenant’s working situation?",
+ "check_answers_card_number": 1,
"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": {
@@ -1798,7 +1823,9 @@
}
},
"lead_tenant_over_retirement_value_check": {
- "depends_on": [{ "person_1_not_retired_over_soft_max_age?": true }],
+ "depends_on": [
+ { "person_1_not_retired_over_soft_max_age?": true }
+ ],
"title_text": {
"translation": "soft_validations.retirement.max.title",
"arguments": [
@@ -1856,6 +1883,7 @@
"questions": {
"details_known_2": {
"check_answer_label": "Details known for person 2",
+ "check_answers_card_number": 2,
"header": "Do you know details for person 2?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -1899,6 +1927,7 @@
"questions": {
"relat2": {
"check_answer_label": "Person 2’s relationship to the lead tenant",
+ "check_answers_card_number": 2,
"header": "What is person 2’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -1934,6 +1963,7 @@
"questions": {
"age2_known": {
"header": "Do you know person 2’s age?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -1961,6 +1991,7 @@
"age2": {
"header": "Age",
"check_answer_label": "Person 2’s age",
+ "check_answers_card_number": 2,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2072,6 +2103,7 @@
"sex2": {
"check_answer_label": "Person 2’s gender identity",
"header": "Which of these best describes person 2’s gender identity?",
+ "check_answers_card_number": 2,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2193,6 +2225,7 @@
"questions": {
"ecstat2": {
"check_answer_label": "Person 2’s working situation",
+ "check_answers_card_number": 2,
"header": "Which of these best describes person 2’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2368,6 +2401,7 @@
"questions": {
"details_known_3": {
"check_answer_label": "Details known for person 3",
+ "check_answers_card_number": 3,
"header": "Do you know details for person 3?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2408,6 +2442,7 @@
"questions": {
"relat3": {
"check_answer_label": "Person 3’s relationship to the lead tenant",
+ "check_answers_card_number": 3,
"header": "What is person 3’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2443,6 +2478,7 @@
"questions": {
"age3_known": {
"header": "Do you know person 3’s age?",
+ "check_answers_card_number": 3,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2470,6 +2506,7 @@
"age3": {
"header": "Age",
"check_answer_label": "Person 3’s age",
+ "check_answers_card_number": 3,
"type": "numeric",
"min": 0,
"max": 120,
@@ -2580,6 +2617,7 @@
"questions": {
"sex3": {
"check_answer_label": "Person 3’s gender identity",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -2702,6 +2740,7 @@
"questions": {
"ecstat3": {
"check_answer_label": "Person 3’s working situation",
+ "check_answers_card_number": 3,
"header": "Which of these best describes person 3’s working situation?",
"hint_text": "",
"type": "radio",
@@ -2877,6 +2916,7 @@
"questions": {
"details_known_4": {
"check_answer_label": "Details known for person 4",
+ "check_answers_card_number": 4,
"header": "Do you know details for person 4?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -2914,6 +2954,7 @@
"questions": {
"relat4": {
"check_answer_label": "Person 4’s relationship to the lead tenant",
+ "check_answers_card_number": 4,
"header": "What is person 4’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -2949,6 +2990,7 @@
"questions": {
"age4_known": {
"header": "Do you know person 4’s age?",
+ "check_answers_card_number": 4,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -2976,6 +3018,7 @@
"age4": {
"header": "Age",
"check_answer_label": "Person 4’s age",
+ "check_answers_card_number": 4,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3086,6 +3129,7 @@
"questions": {
"sex4": {
"check_answer_label": "Person 4’s gender identity",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3208,6 +3252,7 @@
"questions": {
"ecstat4": {
"check_answer_label": "Person 4’s working situation",
+ "check_answers_card_number": 4,
"header": "Which of these best describes person 4’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3383,6 +3428,7 @@
"questions": {
"details_known_5": {
"check_answer_label": "Details known for person 5",
+ "check_answers_card_number": 5,
"header": "Do you know details for person 5?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3417,6 +3463,7 @@
"questions": {
"relat5": {
"check_answer_label": "Person 5’s relationship to the lead tenant",
+ "check_answers_card_number": 5,
"header": "What is person 5’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3452,6 +3499,7 @@
"questions": {
"age5_known": {
"header": "Do you know person 5’s age?",
+ "check_answers_card_number": 5,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3479,6 +3527,7 @@
"age5": {
"header": "Age",
"check_answer_label": "Person 5’s age",
+ "check_answers_card_number": 5,
"type": "numeric",
"min": 0,
"max": 120,
@@ -3589,6 +3638,7 @@
"questions": {
"sex5": {
"check_answer_label": "Person 5’s gender identity",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -3711,6 +3761,7 @@
"questions": {
"ecstat5": {
"check_answer_label": "Person 5’s working situation",
+ "check_answers_card_number": 5,
"header": "Which of these best describes person 5’s working situation?",
"hint_text": "",
"type": "radio",
@@ -3886,6 +3937,7 @@
"questions": {
"details_known_6": {
"check_answer_label": "Details known for person 6",
+ "check_answers_card_number": 6,
"header": "Do you know details for person 6?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -3917,6 +3969,7 @@
"questions": {
"relat6": {
"check_answer_label": "Person 6’s relationship to the lead tenant",
+ "check_answers_card_number": 6,
"header": "What is person 6’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -3952,6 +4005,7 @@
"questions": {
"age6_known": {
"header": "Do you know person 6’s age?",
+ "check_answers_card_number": 6,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -3979,6 +4033,7 @@
"age6": {
"header": "Age",
"check_answer_label": "Person 6’s age",
+ "check_answers_card_number": 6,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4089,6 +4144,7 @@
"questions": {
"sex6": {
"check_answer_label": "Person 6’s gender identity",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4211,6 +4267,7 @@
"questions": {
"ecstat6": {
"check_answer_label": "Person 6’s working situation",
+ "check_answers_card_number": 6,
"header": "Which of these best describes person 6’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4386,6 +4443,7 @@
"questions": {
"details_known_7": {
"check_answer_label": "Details known for person 7",
+ "check_answers_card_number": 7,
"header": "Do you know details for person 7?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4414,6 +4472,7 @@
"questions": {
"relat7": {
"check_answer_label": "Person 7’s relationship to the lead tenant",
+ "check_answers_card_number": 7,
"header": "What is person 7’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4449,6 +4508,7 @@
"questions": {
"age7_known": {
"header": "Do you know person 7’s age?",
+ "check_answers_card_number": 7,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4476,6 +4536,7 @@
"age7": {
"header": "Age",
"check_answer_label": "Person 7’s age",
+ "check_answers_card_number": 7,
"type": "numeric",
"min": 0,
"max": 120,
@@ -4586,6 +4647,7 @@
"questions": {
"sex7": {
"check_answer_label": "Person 7’s gender identity",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -4708,6 +4770,7 @@
"questions": {
"ecstat7": {
"check_answer_label": "Person 7’s working situation",
+ "check_answers_card_number": 7,
"header": "Which of these best describes person 7’s working situation?",
"hint_text": "",
"type": "radio",
@@ -4883,6 +4946,7 @@
"questions": {
"details_known_8": {
"check_answer_label": "Details known for person 8",
+ "check_answers_card_number": 8,
"header": "Do you know details for person 8?",
"hint_text": "You must provide details for everyone in the household if you know them.",
"type": "radio",
@@ -4908,6 +4972,7 @@
"questions": {
"relat8": {
"check_answer_label": "Person 8’s relationship to the lead tenant",
+ "check_answers_card_number": 8,
"header": "What is person 8’s relationship to the lead tenant?",
"hint_text": "",
"type": "radio",
@@ -4943,6 +5008,7 @@
"questions": {
"age8_known": {
"header": "Do you know person 8’s age?",
+ "check_answers_card_number": 8,
"hint_text": "",
"type": "radio",
"answer_options": {
@@ -4970,6 +5036,7 @@
"age8": {
"header": "Age",
"check_answer_label": "Person 8’s age",
+ "check_answers_card_number": 8,
"type": "numeric",
"min": 0,
"max": 120,
@@ -5080,6 +5147,7 @@
"questions": {
"sex8": {
"check_answer_label": "Person 8’s gender identity",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s gender identity?",
"hint_text": "",
"type": "radio",
@@ -5202,6 +5270,7 @@
"questions": {
"ecstat8": {
"check_answer_label": "Person 8’s working situation",
+ "check_answers_card_number": 8,
"header": "Which of these best describes person 8’s working situation?",
"hint_text": "",
"type": "radio",
diff --git a/spec/components/check_answers_summary_list_card_component_spec.rb b/spec/components/check_answers_summary_list_card_component_spec.rb
new file mode 100644
index 000000000..9ccfebe51
--- /dev/null
+++ b/spec/components/check_answers_summary_list_card_component_spec.rb
@@ -0,0 +1,27 @@
+require "rails_helper"
+
+RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do
+ context "when given a set of questions" do
+ let(:user) { FactoryBot.build(:user) }
+ let(:case_log) { FactoryBot.build(:case_log, :completed, age2: 99) }
+ let(:subsection_id) { "household_characteristics" }
+ let(:subsection) { case_log.form.get_subsection(subsection_id) }
+ let(:questions) { subsection.applicable_questions(case_log) }
+
+ it "renders a summary list card for the answers to those questions" do
+ result = render_inline(described_class.new(questions:, case_log:, user:))
+ expect(result).to have_content(questions.first.answer_label(case_log))
+ end
+
+ it "applicable questions doesn't return questions that are hidden in check answers" do
+ summary_list = described_class.new(questions:, case_log:, user:)
+ expect(summary_list.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false)
+ end
+
+ it "has the correct answer label for a question" do
+ summary_list = described_class.new(questions:, case_log:, user:)
+ sex1_question = questions[2]
+ expect(summary_list.get_answer_label(sex1_question)).to eq("Female")
+ end
+ end
+end
diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb
index 4e4253470..3ba4e28ab 100644
--- a/spec/features/form/check_answers_page_spec.rb
+++ b/spec/features/form/check_answers_page_spec.rb
@@ -133,6 +133,19 @@ RSpec.describe "Form Check Answers Page" do
end
end
+ it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
+ visit("/logs/#{completed_case_log.id}/household-needs/check-answers")
+ assert_selector ".x-govuk-summary-card__title", count: 0
+ end
+
+ context "when the user is checking their answers for the household characteristics subsection" do
+ it "they see a seperate summary card for each member of the household" do
+ visit("/logs/#{completed_case_log.id}/#{subsection}/check-answers")
+ assert_selector ".x-govuk-summary-card__title", text: "Lead tenant", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 1
+ end
+ end
+
context "when viewing setup section answers" do
before do
FactoryBot.create(:location, scheme:)
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 9a24381e9..ea8b3ce40 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -13,6 +13,7 @@
"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.",
@@ -31,6 +32,7 @@
"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",
@@ -52,6 +54,7 @@
"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",
@@ -77,6 +80,7 @@
"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.",
@@ -125,6 +129,7 @@
"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",
@@ -140,6 +145,7 @@
}
},
"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",
@@ -153,6 +159,7 @@
}
},
"age2": {
+ "check_answers_card_number": 2,
"check_answer_label": "Person 2’s age",
"header": "Do you know person 2’s age?",
"type": "numeric",
@@ -162,6 +169,7 @@
"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",
@@ -182,11 +190,35 @@
}
}
},
+ "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",
@@ -216,6 +248,7 @@
"propcode": {
"questions": {
"propcode": {
+ "check_answers_card_number": 0,
"check_answer_label": "",
"header": "property reference?",
"type": "text"
diff --git a/spec/models/form/subsection_spec.rb b/spec/models/form/subsection_spec.rb
index 1b876520a..95208b8e5 100644
--- a/spec/models/form/subsection_spec.rb
+++ b/spec/models/form/subsection_spec.rb
@@ -25,12 +25,12 @@ RSpec.describe Form::Subsection, type: :model do
end
it "has pages" do
- expected_pages = %w[tenant_code_test person_1_age person_1_gender person_1_working_situation household_number_of_members person_2_working_situation propcode]
+ expected_pages = %w[tenant_code_test person_1_age person_1_gender person_1_working_situation household_number_of_members retirement_value_check person_2_working_situation propcode]
expect(subsection.pages.map(&:id)).to eq(expected_pages)
end
it "has questions" do
- expected_questions = %w[tenancycode age1 sex1 ecstat1 hhmemb relat2 age2 sex2 ecstat2 propcode]
+ expected_questions = %w[tenancycode age1 sex1 ecstat1 hhmemb relat2 age2 sex2 retirement_value_check ecstat2 propcode]
expect(subsection.questions.map(&:id)).to eq(expected_questions)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 2222d737e..94a3af2fe 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe FormHandler do
form_handler = described_class.instance
form = form_handler.get_form(test_form_name)
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(44)
+ expect(form.pages.count).to eq(45)
end
end
diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb
index 291343cd9..4b6b66672 100644
--- a/spec/models/form_spec.rb
+++ b/spec/models/form_spec.rb
@@ -178,7 +178,7 @@ RSpec.describe Form, type: :model do
describe "invalidated_page_questions" do
let(:case_log) { FactoryBot.create(:case_log, :in_progress, needstype: 1) }
- let(:expected_invalid) { %w[scheme_id condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] }
+ let(:expected_invalid) { %w[scheme_id retirement_value_check condition_effects cbl conditional_question_no_second_question net_income_value_check dependent_question offered layear declaration] }
context "when dependencies are not met" do
it "returns an array of question keys whose pages conditions are not met" do
From 3d9fb63707ec18d0e5633c38a8b3a7fbc402f0fa Mon Sep 17 00:00:00 2001
From: natdeanlewissoftwire
<94526761+natdeanlewissoftwire@users.noreply.github.com>
Date: Mon, 22 Aug 2022 14:04:16 +0100
Subject: [PATCH 3/3] Cldc 1433 csv output symbols correctly (#837)
* Add BOMs before CSV info
* add BOM to tests
* DRYing
* remove added blank line
---
app/controllers/application_controller.rb | 4 ++++
app/controllers/case_logs_controller.rb | 2 +-
app/controllers/organisations_controller.rb | 4 ++--
app/controllers/users_controller.rb | 2 +-
spec/requests/case_logs_controller_spec.rb | 2 +-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 78b367d80..5685796af 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,4 +14,8 @@ protected
def user_for_paper_trail
current_user
end
+
+ def byte_order_mark
+ "\uFEFF"
+ end
end
diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb
index 17bae5ee8..a9b927725 100644
--- a/app/controllers/case_logs_controller.rb
+++ b/app/controllers/case_logs_controller.rb
@@ -22,7 +22,7 @@ class CaseLogsController < ApplicationController
end
format.csv do
- send_data unpaginated_filtered_logs.to_csv(current_user), filename: "logs-#{Time.zone.now}.csv"
+ send_data byte_order_mark + unpaginated_filtered_logs.to_csv(current_user), filename: "logs-#{Time.zone.now}.csv"
end
end
end
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index cb600b004..81ba4f737 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -45,7 +45,7 @@ class OrganisationsController < ApplicationController
end
end
format.csv do
- send_data unpaginated_filtered_users.to_csv, filename: "users-#{@organisation.name}-#{Time.zone.now}.csv"
+ send_data byte_order_mark + unpaginated_filtered_users.to_csv, filename: "users-#{@organisation.name}-#{Time.zone.now}.csv"
end
end
end
@@ -103,7 +103,7 @@ class OrganisationsController < ApplicationController
end
format.csv do
- send_data unpaginated_filtered_logs.to_csv, filename: "logs-#{@organisation.name}-#{Time.zone.now}.csv"
+ send_data byte_order_mark + unpaginated_filtered_logs.to_csv, filename: "logs-#{@organisation.name}-#{Time.zone.now}.csv"
end
end
else
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index cd82742b6..9ab691a53 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -20,7 +20,7 @@ class UsersController < ApplicationController
format.html
format.csv do
if current_user.support?
- send_data filtered_users.to_csv, filename: "users-#{Time.zone.now}.csv"
+ send_data byte_order_mark + filtered_users.to_csv, filename: "users-#{Time.zone.now}.csv"
else
head :unauthorized
end
diff --git a/spec/requests/case_logs_controller_spec.rb b/spec/requests/case_logs_controller_spec.rb
index 4ca219c67..5c4ce4dca 100644
--- a/spec/requests/case_logs_controller_spec.rb
+++ b/spec/requests/case_logs_controller_spec.rb
@@ -755,7 +755,7 @@ RSpec.describe CaseLogsController, type: :request do
it "downloads a CSV file with headers" do
csv = CSV.parse(response.body)
- expect(csv.first.first).to eq("id")
+ expect(csv.first.first).to eq("\uFEFFid")
expect(csv.second.first).to eq(case_log.id.to_s)
end