From 46459c4bfa6028acbe0608f1c8c4a8140ec60c2e Mon Sep 17 00:00:00 2001 From: Samuel Young Date: Wed, 7 Jan 2026 18:23:16 +0000 Subject: [PATCH] CLDC-4105: Add soft validation to main flow --- .../pages/working_situation_illness_check.rb | 24 +++++++++++++++++++ .../working_situation_illness_check_lead.rb | 23 ++++++++++++++++++ .../working_situation_illness_check_person.rb | 24 +++++++++++++++++++ .../working_situation_illness_check.rb | 13 ++++++++++ .../subsections/household_characteristics.rb | 8 +++++++ .../lettings/subsections/household_needs.rb | 1 + app/models/validations/soft_validations.rb | 21 ++++++++++++++++ .../2026/lettings/soft_validations.en.yml | 9 +++++++ 8 files changed, 123 insertions(+) create mode 100644 app/models/form/lettings/pages/working_situation_illness_check.rb create mode 100644 app/models/form/lettings/pages/working_situation_illness_check_lead.rb create mode 100644 app/models/form/lettings/pages/working_situation_illness_check_person.rb create mode 100644 app/models/form/lettings/questions/working_situation_illness_check.rb diff --git a/app/models/form/lettings/pages/working_situation_illness_check.rb b/app/models/form/lettings/pages/working_situation_illness_check.rb new file mode 100644 index 000000000..56f48a725 --- /dev/null +++ b/app/models/form/lettings/pages/working_situation_illness_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Pages::WorkingSituationIllnessCheck < ::Form::Page + def initialize(id, hsh, subsection) + super(id, hsh, subsection) + @id = "working_situation_long_term_illness_check" + @copy_key = "lettings.soft_validations.working_situation_illness_check" + @depends_on = [{ "at_least_one_working_situation_is_sickness_and_household_sickness_is_no?" => true }] + @title_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], + } + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::WorkingSituationIllnessCheck.new(nil, nil, self, person_index: 0)] + end + + def interruption_screen_question_ids + %w[illness ecstat1 ecstat2 ecstat3 ecstat4 ecstat5 ecstat6 ecstat7 ecstat8] + end +end diff --git a/app/models/form/lettings/pages/working_situation_illness_check_lead.rb b/app/models/form/lettings/pages/working_situation_illness_check_lead.rb new file mode 100644 index 000000000..a31c58d4d --- /dev/null +++ b/app/models/form/lettings/pages/working_situation_illness_check_lead.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Pages::WorkingSituationIllnessCheckLead < ::Form::Page + def initialize(id, hsh, subsection) + super(id, hsh, subsection) + @copy_key = "lettings.soft_validations.working_situation_illness_check" + @depends_on = [{ "at_least_one_working_situation_is_sickness_and_household_sickness_is_no?" => true }] + @title_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], + } + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::WorkingSituationIllnessCheck.new(nil, nil, self, person_index: 1)] + end + + def interruption_screen_question_ids + %w[illness ecstat1 ecstat2 ecstat3 ecstat4 ecstat5 ecstat6 ecstat7 ecstat8] + end +end diff --git a/app/models/form/lettings/pages/working_situation_illness_check_person.rb b/app/models/form/lettings/pages/working_situation_illness_check_person.rb new file mode 100644 index 000000000..1175902cb --- /dev/null +++ b/app/models/form/lettings/pages/working_situation_illness_check_person.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Pages::WorkingSituationIllnessCheckPerson < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @copy_key = "lettings.soft_validations.working_situation_illness_check" + @depends_on = [{ "at_least_one_working_situation_is_sickness_and_household_sickness_is_no?" => true, "details_known_#{person_index}" => 0 }] + @title_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], + } + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } + @person_index = person_index + end + + def questions + @questions ||= [Form::Lettings::Questions::WorkingSituationIllnessCheck.new(nil, nil, self, person_index: @person_index)] + end + + def interruption_screen_question_ids + %w[illness ecstat1 ecstat2 ecstat3 ecstat4 ecstat5 ecstat6 ecstat7 ecstat8] + end +end diff --git a/app/models/form/lettings/questions/working_situation_illness_check.rb b/app/models/form/lettings/questions/working_situation_illness_check.rb new file mode 100644 index 000000000..c314c8aa2 --- /dev/null +++ b/app/models/form/lettings/questions/working_situation_illness_check.rb @@ -0,0 +1,13 @@ +class Form::Lettings::Questions::WorkingSituationIllnessCheck < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "working_situation_illness_check" + @copy_key = page.copy_key + @type = "interruption_screen" + @check_answers_card_number = person_index + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "working_situation_illness_check" => 0 }, { "working_situation_illness_check" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb index a454ffed5..91c7adaee 100644 --- a/app/models/form/lettings/subsections/household_characteristics.rb +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -31,6 +31,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::LeadTenantWorkingSituation.new(nil, nil, self), Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck.new("working_situation_lead_tenant_under_retirement_value_check", nil, self), Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new("working_situation_lead_tenant_over_retirement_value_check", nil, self), + (Form::Lettings::Pages::WorkingSituationIllnessCheckLead.new("working_situation_lead_tenant_long_term_illness_check", nil, self) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 2), relationship_question(person_index: 2), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), @@ -51,6 +52,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_2_under_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_2_over_retirement_value_check", nil, self, person_index: 2), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_2_long_term_illness_check", nil, self, person_index: 2) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3), relationship_question(person_index: 3), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), @@ -71,6 +73,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_3_under_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_3_over_retirement_value_check", nil, self, person_index: 3), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_3_long_term_illness_check", nil, self, person_index: 3) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4), relationship_question(person_index: 4), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), @@ -91,6 +94,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_4_under_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_4_over_retirement_value_check", nil, self, person_index: 4), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_4_long_term_illness_check", nil, self, person_index: 4) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5), relationship_question(person_index: 5), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), @@ -111,6 +115,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_5_under_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_5_over_retirement_value_check", nil, self, person_index: 5), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_5_long_term_illness_check", nil, self, person_index: 5) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6), relationship_question(person_index: 6), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), @@ -131,6 +136,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_6_under_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_6_over_retirement_value_check", nil, self, person_index: 6), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_6_long_term_illness_check", nil, self, person_index: 6) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7), relationship_question(person_index: 7), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_2024_or_later?), @@ -151,6 +157,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_7_under_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_7_over_retirement_value_check", nil, self, person_index: 7), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_7_long_term_illness_check", nil, self, person_index: 7) if form.start_year_2026_or_later?), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8), relationship_question(person_index: 8), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_2024_or_later?), @@ -171,6 +178,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("working_situation_8_under_retirement_value_check", nil, self, person_index: 8), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_8_over_retirement_value_check", nil, self, person_index: 8), + (Form::Lettings::Pages::WorkingSituationIllnessCheckPerson.new("working_situation_8_long_term_illness_check", nil, self, person_index: 8) if form.start_year_2026_or_later?), ].compact end diff --git a/app/models/form/lettings/subsections/household_needs.rb b/app/models/form/lettings/subsections/household_needs.rb index 2f6900f4f..e0502386b 100644 --- a/app/models/form/lettings/subsections/household_needs.rb +++ b/app/models/form/lettings/subsections/household_needs.rb @@ -17,6 +17,7 @@ class Form::Lettings::Subsections::HouseholdNeeds < ::Form::Subsection Form::Lettings::Pages::AccessNeedsExist.new("access_needs_exist", nil, self), Form::Lettings::Pages::TypeOfAccessNeeds.new(nil, nil, self), Form::Lettings::Pages::HealthConditions.new("health_conditions", nil, self), + (Form::Lettings::Pages::WorkingSituationIllnessCheck.new(nil, nil, self) if form.start_year_2026_or_later?), Form::Lettings::Pages::HealthConditionEffects.new(nil, nil, self), ].compact end diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 58e74325d..1d37befeb 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -215,6 +215,10 @@ module Validations::SoftValidations (2..max_person_with_details).many? { |n| public_send("relat#{n}") == "P" } end + def at_least_one_working_situation_is_sickness_and_household_sickness_is_no? + at_least_one_person_working_situation_is_illness? && no_one_in_household_with_illness? + end + private def details_known_or_lead_tenant?(tenant_number) @@ -282,4 +286,21 @@ private age < 16 && relationship == "P" end + + def at_least_one_person_working_situation_is_illness? + return unless hhmemb + + person_count = hhmemb || 8 + + (1..person_count).any? do |n| + ecstat = public_send("ecstat#{n}") + ecstat == 8 + end + end + + def no_one_in_household_with_illness? + return unless illness + + illness == 2 + end end diff --git a/config/locales/forms/2026/lettings/soft_validations.en.yml b/config/locales/forms/2026/lettings/soft_validations.en.yml index 2d657cf11..50e6f42f9 100644 --- a/config/locales/forms/2026/lettings/soft_validations.en.yml +++ b/config/locales/forms/2026/lettings/soft_validations.en.yml @@ -155,3 +155,12 @@ en: question_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." title_text: "No address found" informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." + + working_situation_illness_check: + page_header: "" + check_answer_label: "Working situation illness confirmation" + check_answer_prompt: "Confirm 'unable to work due to illness' working situation and long-term illness warning" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You have said that at least one person's situation is 'Unable to work because of long-term sickness or disability'." + informative_text: "You also told us there is no-one in the household with a long-lasting health condition."