From 5907502f213525ccfe7024f84da6c46c3de33e9e Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 20 Mar 2024 11:39:19 +0000 Subject: [PATCH] CLDC-3146 Update household validations (#2256) * Separate the validations, remove irrelevant tests * Remove relevant lettings 2023 validations from 24 * Update validations for 2024 lettings * Separate sales validations * Infer child uner 16 for sales * Update sales validations * Update tests * Add validations to all relevant fields * Add a 2023 context * Undo some 2024 validations * Remove another validation, update test names * Remove child option hint * Update person age hint * Add ecstat buyer validation * Add custom ecstat BU errors * Skip working situation for child in sales * Add child under 16 validation to 2024, do not reset ecstat * Add soft validation columns * Add partner under 16 soft validation * Add multiple partners soft validations * Remove child option for buyer 2 * Update CSVs * Check hhmemb exists * refactor * Display child option for lettings * Remove wrong tests * More tests --- .../lettings_log_variables.rb | 2 - .../derived_variables/sales_log_variables.rb | 10 + .../pages/multiple_partners_value_check.rb | 26 ++ .../pages/partner_under_16_value_check.rb | 32 ++ app/models/form/lettings/questions/age.rb | 11 +- .../multiple_partners_value_check.rb | 24 ++ .../questions/partner_under_16_value_check.rb | 24 ++ .../lettings/questions/person_relationship.rb | 34 +- .../questions/person_working_situation.rb | 43 +-- .../subsections/household_characteristics.rb | 21 ++ .../pages/multiple_partners_value_check.rb | 26 ++ .../pages/partner_under_16_value_check.rb | 32 ++ .../sales/pages/person_working_situation.rb | 11 +- app/models/form/sales/questions/age2.rb | 2 +- .../buyer2_relationship_to_buyer1.rb | 26 +- .../questions/buyer2_working_situation.rb | 1 - .../multiple_partners_value_check.rb | 24 ++ .../questions/partner_under_16_value_check.rb | 24 ++ app/models/form/sales/questions/person_age.rb | 6 + .../person_relationship_to_buyer_1.rb | 25 +- .../questions/person_working_situation.rb | 38 +- .../subsections/household_characteristics.rb | 15 + app/models/lettings_log.rb | 10 - app/models/log.rb | 10 + .../validations/household_validations.rb | 128 ++++--- .../sales/household_validations.rb | 125 ++++--- app/models/validations/shared_validations.rb | 2 + app/models/validations/soft_validations.rb | 17 + .../bulk_upload/sales/year2024/row_parser.rb | 19 +- config/locales/en.yml | 15 + ...706_add_relationship_value_check_fields.rb | 13 + db/schema.rb | 6 +- spec/factories/sales_log.rb | 2 +- .../lettings_log_csv_export_codes_23.csv | 4 +- .../lettings_log_csv_export_codes_24.csv | 4 +- .../lettings_log_csv_export_labels_23.csv | 4 +- .../lettings_log_csv_export_labels_24.csv | 4 +- ...gs_log_csv_export_non_support_codes_23.csv | 4 +- ...gs_log_csv_export_non_support_codes_24.csv | 4 +- ...s_log_csv_export_non_support_labels_23.csv | 4 +- ...s_log_csv_export_non_support_labels_24.csv | 4 +- .../files/sales_logs_csv_export_codes_23.csv | 2 +- .../files/sales_logs_csv_export_codes_24.csv | 2 +- .../files/sales_logs_csv_export_labels_23.csv | 2 +- .../files/sales_logs_csv_export_labels_24.csv | 2 +- .../multiple_partners_value_check_spec.rb | 91 +++++ .../pages/partner_under16_value_check_spec.rb | 255 +++++++++++++ .../form/lettings/pages/person_age_spec.rb | 2 +- .../pages/person_relationship_to_lead_spec.rb | 2 +- .../form/lettings/questions/age_spec.rb | 2 +- .../multiple_partners_value_check_spec.rb | 61 +++ .../partner_under16_value_check_spec.rb | 61 +++ .../questions/person_relationship_spec.rb | 2 +- .../person_working_situation_spec.rb | 1 + .../household_characteristics_spec.rb | 21 ++ .../buyer2_relationship_to_buyer1_spec.rb | 2 +- .../multiple_partners_value_check_spec.rb | 91 +++++ .../pages/partner_under16_value_check_spec.rb | 255 +++++++++++++ .../person_relationship_to_buyer1_spec.rb | 2 +- .../pages/person_working_situation_spec.rb | 8 +- spec/models/form/sales/questions/age2_spec.rb | 2 +- .../buyer2_relationship_to_buyer1_spec.rb | 2 +- .../buyer2_working_situation_spec.rb | 1 - .../multiple_partners_value_check_spec.rb | 61 +++ .../partner_under16_value_check_spec.rb | 61 +++ .../form/sales/questions/person_age_spec.rb | 2 +- .../person_relationship_to_buyer1_spec.rb | 2 +- .../person_working_situation_spec.rb | 7 +- .../household_characteristics_spec.rb | 15 + spec/models/lettings_log_spec.rb | 22 +- spec/models/sales_log_spec.rb | 47 ++- .../validations/household_validations_spec.rb | 354 ++++++++++++------ .../sales/household_validations_spec.rb | 348 +++++++++++++---- .../validations/shared_validations_spec.rb | 2 +- .../lettings/year2024/row_parser_spec.rb | 6 +- .../sales/year2024/row_parser_spec.rb | 55 ++- 76 files changed, 2255 insertions(+), 432 deletions(-) create mode 100644 app/models/form/lettings/pages/multiple_partners_value_check.rb create mode 100644 app/models/form/lettings/pages/partner_under_16_value_check.rb create mode 100644 app/models/form/lettings/questions/multiple_partners_value_check.rb create mode 100644 app/models/form/lettings/questions/partner_under_16_value_check.rb create mode 100644 app/models/form/sales/pages/multiple_partners_value_check.rb create mode 100644 app/models/form/sales/pages/partner_under_16_value_check.rb create mode 100644 app/models/form/sales/questions/multiple_partners_value_check.rb create mode 100644 app/models/form/sales/questions/partner_under_16_value_check.rb create mode 100644 db/migrate/20240319122706_add_relationship_value_check_fields.rb create mode 100644 spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb create mode 100644 spec/models/form/lettings/pages/partner_under16_value_check_spec.rb create mode 100644 spec/models/form/lettings/questions/multiple_partners_value_check_spec.rb create mode 100644 spec/models/form/lettings/questions/partner_under16_value_check_spec.rb create mode 100644 spec/models/form/sales/pages/multiple_partners_value_check_spec.rb create mode 100644 spec/models/form/sales/pages/partner_under16_value_check_spec.rb create mode 100644 spec/models/form/sales/questions/multiple_partners_value_check_spec.rb create mode 100644 spec/models/form/sales/questions/partner_under16_value_check_spec.rb diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index ac17e0219..56b47e9ad 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -216,8 +216,6 @@ private (2..8).each do |idx| if age_under_16?(idx) self["ecstat#{idx}"] = 9 - elsif public_send("ecstat#{idx}") == 9 && age_known?(idx) - self["ecstat#{idx}"] = nil end end end diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index a4817a230..cb49b6cc2 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -36,6 +36,7 @@ module DerivedVariables::SalesLogVariables if saledate && form.start_year_after_2024? self.soctenant = soctenant_from_prevten_values + child_under_16_constraints! end self.uprn_known = 0 if address_answered_without_uprn? @@ -124,6 +125,15 @@ private end end + def child_under_16_constraints! + start_index = joint_purchase? ? 3 : 2 + (start_index..6).each do |idx| + if age_under_16?(idx) + self["ecstat#{idx}"] = 9 + end + end + end + def household_type return unless total_elder && total_adult && totchild diff --git a/app/models/form/lettings/pages/multiple_partners_value_check.rb b/app/models/form/lettings/pages/multiple_partners_value_check.rb new file mode 100644 index 000000000..3f9cdb3ae --- /dev/null +++ b/app/models/form/lettings/pages/multiple_partners_value_check.rb @@ -0,0 +1,26 @@ +class Form::Lettings::Pages::MultiplePartnersValueCheck < Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @depends_on = [ + { + "multiple_partners?" => true, + }, + ] + @person_index = person_index + @title_text = { + "translation" => "soft_validations.multiple_partners_lettings.title", + "arguments" => [], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Lettings::Questions::MultiplePartnersValueCheck.new(nil, nil, self, person_index: @person_index), + ] + end + + def interruption_screen_question_ids + %w[relat2 relat3 relat4 relat5 relat6 relat7 relat8] + end +end diff --git a/app/models/form/lettings/pages/partner_under_16_value_check.rb b/app/models/form/lettings/pages/partner_under_16_value_check.rb new file mode 100644 index 000000000..87d5865c4 --- /dev/null +++ b/app/models/form/lettings/pages/partner_under_16_value_check.rb @@ -0,0 +1,32 @@ +class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @depends_on = [ + { + "person_#{person_index}_partner_under_16?" => true, + }, + ] + @person_index = person_index + @title_text = { + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age#{person_index}", + "label" => true, + "i18n_template" => "age", + }, + ], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Lettings::Questions::PartnerUnder16ValueCheck.new(nil, nil, self, person_index: @person_index), + ] + end + + def interruption_screen_question_ids + ["age#{@person_index}", "relat#{@person_index}"] + end +end diff --git a/app/models/form/lettings/questions/age.rb b/app/models/form/lettings/questions/age.rb index 26f7527d6..0a457203c 100644 --- a/app/models/form/lettings/questions/age.rb +++ b/app/models/form/lettings/questions/age.rb @@ -11,9 +11,10 @@ class Form::Lettings::Questions::Age < ::Form::Question @max = 120 @min = 1 @step = 1 - @hint_text = "For a child under 1, enter 1" if person_type == "child" @person_index = person_index @question_number = question_number + @person_type = person_type + @hint_text = hint_text end def question_number @@ -26,4 +27,12 @@ class Form::Lettings::Questions::Age < ::Form::Question base_question_number + (4 * @person_index) end + + def hint_text + if form.start_year_after_2024? + "Answer 1 for children aged under 1 year old" + elsif @person_type == "child" + "For a child under 1, enter 1" + end + end end diff --git a/app/models/form/lettings/questions/multiple_partners_value_check.rb b/app/models/form/lettings/questions/multiple_partners_value_check.rb new file mode 100644 index 000000000..65320ffdf --- /dev/null +++ b/app/models/form/lettings/questions/multiple_partners_value_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Questions::MultiplePartnersValueCheck < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "multiple_partners_value_check" + @check_answer_label = "Multiple partners confirmation" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "multiple_partners_value_check" => 0, + }, + { + "multiple_partners_value_check" => 1, + }, + ], + } + @check_answers_card_number = person_index + @header = "Are you sure this is correct?" + end +end diff --git a/app/models/form/lettings/questions/partner_under_16_value_check.rb b/app/models/form/lettings/questions/partner_under_16_value_check.rb new file mode 100644 index 000000000..7cda45cb5 --- /dev/null +++ b/app/models/form/lettings/questions/partner_under_16_value_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Questions::PartnerUnder16ValueCheck < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "partner_under_16_value_check" + @check_answer_label = "Partner under 16 confirmation" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "partner_under_16_value_check" => 0, + }, + { + "partner_under_16_value_check" => 1, + }, + ], + } + @check_answers_card_number = person_index + @header = "Are you sure this is correct?" + end +end diff --git a/app/models/form/lettings/questions/person_relationship.rb b/app/models/form/lettings/questions/person_relationship.rb index 118211c9d..c20ec9f2c 100644 --- a/app/models/form/lettings/questions/person_relationship.rb +++ b/app/models/form/lettings/questions/person_relationship.rb @@ -7,21 +7,33 @@ class Form::Lettings::Questions::PersonRelationship < ::Form::Question @type = "radio" @check_answers_card_number = person_index @hint_text = "" - @answer_options = ANSWER_OPTIONS + @answer_options = answer_options @person_index = person_index @question_number = question_number end - ANSWER_OPTIONS = { - "P" => { "value" => "Partner" }, - "C" => { - "value" => "Child", - "hint" => "Must be eligible for child benefit: under age 16 or under 20 if still in full-time education.", - }, - "X" => { "value" => "Other" }, - "divider" => { "value" => true }, - "R" => { "value" => "Person prefers not to say" }, - }.freeze + def answer_options + if form.start_year_after_2024? + { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child" }, + "X" => { "value" => "Other" }, + "divider" => { "value" => true }, + "R" => { "value" => "Person prefers not to say" }, + } + else + { + "P" => { "value" => "Partner" }, + "C" => { + "value" => "Child", + "hint" => "Must be eligible for child benefit: under age 16 or under 20 if still in full-time education.", + }, + "X" => { "value" => "Other" }, + "divider" => { "value" => true }, + "R" => { "value" => "Person prefers not to say" }, + } + end + end def question_number base_question_number = case form.start_date.year diff --git a/app/models/form/lettings/questions/person_working_situation.rb b/app/models/form/lettings/questions/person_working_situation.rb index 8541d096a..974bb01b8 100644 --- a/app/models/form/lettings/questions/person_working_situation.rb +++ b/app/models/form/lettings/questions/person_working_situation.rb @@ -7,31 +7,32 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question @type = "radio" @check_answers_card_number = person_index @hint_text = "" - @answer_options = ANSWER_OPTIONS @person_index = person_index @question_number = question_number + @answer_options = answer_options end - ANSWER_OPTIONS = { - "1" => { "value" => "Full-time – 30 hours or more" }, - "2" => { "value" => "Part-time – Less than 30 hours" }, - "7" => { "value" => "Full-time student" }, - "3" => { "value" => "In government training into work, such as New Deal" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work because of long term sick or disability" }, - "5" => { "value" => "Retired" }, - "9" => { - "value" => "Child under 16", - "depends_on" => [ - { "age2_known" => 1 }, - { "age2" => { "operator" => "<", "operand" => 16 } }, - ], - }, - "0" => { "value" => "Other" }, - "divider" => { "value" => true }, - "10" => { "value" => "Person prefers not to say" }, - }.freeze + def answer_options + { "1" => { "value" => "Full-time – 30 hours or more" }, + "2" => { "value" => "Part-time – Less than 30 hours" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long term sick or disability" }, + "5" => { "value" => "Retired" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "age#{@person_index}_known" => 1 }, + { "age#{@person_index}_known" => nil }, + { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, + ], + }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Person prefers not to say" } } + end def question_number base_question_number = case form.start_date.year diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb index 1e442cb18..b74cc3792 100644 --- a/app/models/form/lettings/subsections/household_characteristics.rb +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -33,6 +33,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new("working_situation_lead_tenant_over_retirement_value_check", nil, self), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 2), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -41,6 +43,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 2), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_2_under_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_2_over_retirement_value_check", nil, self, person_index: 2), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -51,6 +54,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_2_over_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 3), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -59,6 +64,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 3), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_3_under_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_3_over_retirement_value_check", nil, self, person_index: 3), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -69,6 +75,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_3_over_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 4), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -77,6 +85,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 4), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_4_under_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_4_over_retirement_value_check", nil, self, person_index: 4), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -87,6 +96,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_4_over_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 5), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -95,6 +106,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 5), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_5_under_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_5_over_retirement_value_check", nil, self, person_index: 5), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -105,6 +117,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_5_over_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 6), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -113,6 +127,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 6), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_6_under_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_6_over_retirement_value_check", nil, self, person_index: 6), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -123,6 +138,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_6_over_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 7), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_7_multiple_partners_value_check", nil, self, person_index: 7) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -131,6 +148,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 7), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_7_under_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_7_over_retirement_value_check", nil, self, person_index: 7), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -141,6 +159,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_7_over_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 8), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_8_multiple_partners_value_check", nil, self, person_index: 8) if form.start_year_after_2024?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, @@ -149,6 +169,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 8), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_8_under_retirement_value_check", nil, self, person_index: 8), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_8_over_retirement_value_check", nil, self, person_index: 8), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, diff --git a/app/models/form/sales/pages/multiple_partners_value_check.rb b/app/models/form/sales/pages/multiple_partners_value_check.rb new file mode 100644 index 000000000..db409f148 --- /dev/null +++ b/app/models/form/sales/pages/multiple_partners_value_check.rb @@ -0,0 +1,26 @@ +class Form::Sales::Pages::MultiplePartnersValueCheck < Form::Sales::Pages::Person + def initialize(id, hsh, subsection, person_index:) + super + @depends_on = [ + { + "multiple_partners?" => true, + }, + ] + @person_index = person_index + @title_text = { + "translation" => "soft_validations.multiple_partners_sales.title", + "arguments" => [], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::MultiplePartnersValueCheck.new(nil, nil, self, person_index: @person_index), + ] + end + + def interruption_screen_question_ids + %w[relat2 relat3 relat4 relat5 relat6] + end +end diff --git a/app/models/form/sales/pages/partner_under_16_value_check.rb b/app/models/form/sales/pages/partner_under_16_value_check.rb new file mode 100644 index 000000000..5113e1677 --- /dev/null +++ b/app/models/form/sales/pages/partner_under_16_value_check.rb @@ -0,0 +1,32 @@ +class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person + def initialize(id, hsh, subsection, person_index:) + super + @depends_on = [ + { + "person_#{person_index}_partner_under_16?" => true, + }, + ] + @person_index = person_index + @title_text = { + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age#{person_index}", + "label" => true, + "i18n_template" => "age", + }, + ], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::PartnerUnder16ValueCheck.new(nil, nil, self, person_index: @person_index), + ] + end + + def interruption_screen_question_ids + ["age#{@person_index}", "relat#{@person_index}"] + end +end diff --git a/app/models/form/sales/pages/person_working_situation.rb b/app/models/form/sales/pages/person_working_situation.rb index 91cda5b85..488141ccf 100644 --- a/app/models/form/sales/pages/person_working_situation.rb +++ b/app/models/form/sales/pages/person_working_situation.rb @@ -1,7 +1,16 @@ class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person def initialize(id, hsh, subsection, person_index:) super - @depends_on = [{ "details_known_#{person_index}" => 1 }] + @depends_on = [ + { + "details_known_#{person_index}" => 1, + "age#{person_index}" => { + "operator" => ">", + "operand" => 15, + }, + }, + { "details_known_#{person_index}" => 1, "age#{person_index}" => nil }, + ] end def questions diff --git a/app/models/form/sales/questions/age2.rb b/app/models/form/sales/questions/age2.rb index 622cbcbb3..82deecbed 100644 --- a/app/models/form/sales/questions/age2.rb +++ b/app/models/form/sales/questions/age2.rb @@ -12,7 +12,7 @@ class Form::Sales::Questions::Age2 < ::Form::Question }] @check_answers_card_number = 2 @max = 110 - @min = 0 + @min = 16 @step = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb index b6906e845..f8acf75aa 100644 --- a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb @@ -5,7 +5,7 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question @check_answer_label = "Buyer 2's relationship to buyer 1" @header = "What is buyer 2's relationship to buyer 1?" @type = "radio" - @answer_options = ANSWER_OPTIONS + @answer_options = answer_options @check_answers_card_number = 2 @inferred_check_answers_value = [{ "condition" => { @@ -16,12 +16,24 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end - ANSWER_OPTIONS = { - "P" => { "value" => "Partner" }, - "C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." }, - "X" => { "value" => "Other" }, - "R" => { "value" => "Buyer prefers not to say" }, - }.freeze + def answer_options + if form.start_year_after_2024? + + { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child" }, + "X" => { "value" => "Other" }, + "R" => { "value" => "Buyer prefers not to say" }, + } + else + { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." }, + "X" => { "value" => "Other" }, + "R" => { "value" => "Buyer prefers not to say" }, + } + end + end QUESTION_NUMBER_FROM_YEAR = { 2023 => 27, 2024 => 29 }.freeze end diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb index 520f75c65..e5eed38de 100644 --- a/app/models/form/sales/questions/buyer2_working_situation.rb +++ b/app/models/form/sales/questions/buyer2_working_situation.rb @@ -27,7 +27,6 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question "0" => { "value" => "Other" }, "10" => { "value" => "Buyer prefers not to say" }, "7" => { "value" => "Full-time student" }, - "9" => { "value" => "Child under 16" }, }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 33, 2024 => 35 }.freeze diff --git a/app/models/form/sales/questions/multiple_partners_value_check.rb b/app/models/form/sales/questions/multiple_partners_value_check.rb new file mode 100644 index 000000000..ce99438d0 --- /dev/null +++ b/app/models/form/sales/questions/multiple_partners_value_check.rb @@ -0,0 +1,24 @@ +class Form::Sales::Questions::MultiplePartnersValueCheck < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "multiple_partners_value_check" + @check_answer_label = "Multiple partners confirmation" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "multiple_partners_value_check" => 0, + }, + { + "multiple_partners_value_check" => 1, + }, + ], + } + @check_answers_card_number = person_index + @header = "Are you sure this is correct?" + end +end diff --git a/app/models/form/sales/questions/partner_under_16_value_check.rb b/app/models/form/sales/questions/partner_under_16_value_check.rb new file mode 100644 index 000000000..4c147b7e5 --- /dev/null +++ b/app/models/form/sales/questions/partner_under_16_value_check.rb @@ -0,0 +1,24 @@ +class Form::Sales::Questions::PartnerUnder16ValueCheck < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "partner_under_16_value_check" + @check_answer_label = "Partner under 16 confirmation" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "partner_under_16_value_check" => 0, + }, + { + "partner_under_16_value_check" => 1, + }, + ], + } + @check_answers_card_number = person_index + @header = "Are you sure this is correct?" + end +end diff --git a/app/models/form/sales/questions/person_age.rb b/app/models/form/sales/questions/person_age.rb index 34944c8f1..9f3d9378f 100644 --- a/app/models/form/sales/questions/person_age.rb +++ b/app/models/form/sales/questions/person_age.rb @@ -27,4 +27,10 @@ class Form::Sales::Questions::PersonAge < ::Form::Question base_question_number + (4 * @person_index) end + + def hint_text + if form.start_year_after_2024? + "Answer 1 for children aged under 1 year old" + end + end end diff --git a/app/models/form/sales/questions/person_relationship_to_buyer_1.rb b/app/models/form/sales/questions/person_relationship_to_buyer_1.rb index 872b46d4f..3fe33cef0 100644 --- a/app/models/form/sales/questions/person_relationship_to_buyer_1.rb +++ b/app/models/form/sales/questions/person_relationship_to_buyer_1.rb @@ -4,7 +4,7 @@ class Form::Sales::Questions::PersonRelationshipToBuyer1 < ::Form::Question @check_answer_label = "Person #{person_index}’s relationship to Buyer 1" @header = "What is Person #{person_index}’s relationship to Buyer 1?" @type = "radio" - @answer_options = ANSWER_OPTIONS + @answer_options = answer_options @check_answers_card_number = person_index @inferred_check_answers_value = [{ "condition" => { @@ -16,12 +16,23 @@ class Form::Sales::Questions::PersonRelationshipToBuyer1 < ::Form::Question @question_number = question_number end - ANSWER_OPTIONS = { - "P" => { "value" => "Partner" }, - "C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." }, - "X" => { "value" => "Other" }, - "R" => { "value" => "Person prefers not to say" }, - }.freeze + def answer_options + if form.start_year_after_2024? + { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child" }, + "X" => { "value" => "Other" }, + "R" => { "value" => "Person prefers not to say" }, + } + else + { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." }, + "X" => { "value" => "Other" }, + "R" => { "value" => "Person prefers not to say" }, + } + end + end def question_number base_question_number = case form.start_date.year diff --git a/app/models/form/sales/questions/person_working_situation.rb b/app/models/form/sales/questions/person_working_situation.rb index e73f7debd..2e9ae1edb 100644 --- a/app/models/form/sales/questions/person_working_situation.rb +++ b/app/models/form/sales/questions/person_working_situation.rb @@ -4,7 +4,6 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question @check_answer_label = "Person #{person_index}’s working situation" @header = "Which of these best describes Person #{person_index}’s working situation?" @type = "radio" - @answer_options = ANSWER_OPTIONS @check_answers_card_number = person_index @inferred_check_answers_value = [{ "condition" => { @@ -14,21 +13,32 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question }] @person_index = person_index @question_number = question_number + @answer_options = answer_options end - ANSWER_OPTIONS = { - "1" => { "value" => "Full-time - 30 hours or more" }, - "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work, such as New Deal" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work due to long term sick or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Person prefers not to say" }, - "7" => { "value" => "Full-time student" }, - "9" => { "value" => "Child under 16" }, - }.freeze + def answer_options + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Person prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, + { "age#{@person_index}_known" => 1 }, + { "age#{@person_index}_known" => nil }, + { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, + ], + }, + } + end def question_number base_question_number = case form.start_date.year diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index eeb8dbea3..40e41201b 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -50,10 +50,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("age_2_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_2_student_not_child_value_check", nil, self, person_index: 2), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("gender_2_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 2), @@ -61,10 +64,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("age_3_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_3_student_not_child_value_check", nil, self, person_index: 3), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("gender_3_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 3), @@ -72,10 +78,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("age_4_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_4_student_not_child_value_check", nil, self, person_index: 4), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("gender_4_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 4), @@ -83,10 +92,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_5_known", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_5_age", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("age_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_5_student_not_child_value_check", nil, self, person_index: 5), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), Form::Sales::Pages::PersonGenderIdentity.new("person_5_gender_identity", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("gender_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5), @@ -94,10 +106,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonKnown.new("person_6_known", nil, self, person_index: 6), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_6_student_not_child_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonAge.new("person_6_age", nil, self, person_index: 6), Form::Sales::Pages::RetirementValueCheck.new("age_6_retirement_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_6_student_not_child_value_check", nil, self, person_index: 6), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), Form::Sales::Pages::PersonGenderIdentity.new("person_6_gender_identity", nil, self, person_index: 6), Form::Sales::Pages::RetirementValueCheck.new("gender_6_retirement_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonWorkingSituation.new("person_6_working_situation", nil, self, person_index: 6), diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 5d56e53c7..7dcebd226 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -556,12 +556,6 @@ class LettingsLog < Log RETIREMENT_AGES[gender] end - def age_known?(person_num) - return false unless person_num.is_a?(Integer) - - !!public_send("age#{person_num}_known")&.zero? - end - def age_unknown?(person_num) return false unless person_num.is_a?(Integer) @@ -752,10 +746,6 @@ private collection_start_year >= 2022 && !is_fixed_term_tenancy? end - def age_under_16?(person_num) - public_send("age#{person_num}") && public_send("age#{person_num}") < 16 - end - def process_postcode_changes! self.postcode_full = upcase_and_remove_whitespace(postcode_full) return if postcode_full.blank? diff --git a/app/models/log.rb b/app/models/log.rb index 8847812d3..0d898827a 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -277,6 +277,16 @@ class Log < ApplicationRecord nationality_all_group&.zero? || nationality_all_group == 826 end + def age_under_16?(person_num) + public_send("age#{person_num}") && public_send("age#{person_num}") < 16 + end + + def age_known?(person_num) + return false unless person_num.is_a?(Integer) + + !!public_send("age#{person_num}_known")&.zero? + end + private # Handle logs that are older than previous collection start date diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index c7e034e94..52c1de668 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -51,17 +51,81 @@ module Validations::HouseholdValidations end end - def validate_household_number_of_other_members(record) - (2..8).each do |n| - validate_person_age_matches_economic_status(record, n) - validate_person_age_matches_relationship(record, n) - validate_person_age_and_relationship_matches_economic_status(record, n) - end + def validate_partner_count(record) shared_validate_partner_count(record, 8) end def validate_person_1_economic(record) - validate_person_age_matches_economic_status(record, 1) + return unless record.age1 && record.ecstat1 && !record.form.start_year_after_2024? + + if record.age1 < 16 && !economic_status_is_child_other_or_refused?(record.ecstat1) + record.errors.add "ecstat1", I18n.t("validations.household.ecstat.child_under_16", person_num: 1) + record.errors.add "age1", I18n.t("validations.household.age.child_under_16_ecstat", person_num: 1) + end + if tenant_is_economic_child?(record.ecstat1) && record.age1 > 16 + record.errors.add "ecstat1", I18n.t("validations.household.ecstat.child_over_16", person_num: 1) + record.errors.add "age1", I18n.t("validations.household.age.child_over_16", person_num: 1) + end + end + + def validate_person_age_matches_economic_status(record) + (2..8).each do |person_num| + age = record.public_send("age#{person_num}") + economic_status = record.public_send("ecstat#{person_num}") + next unless age && economic_status + + if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_after_2024? + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_under_16", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_ecstat", person_num:) + end + if tenant_is_economic_child?(economic_status) && age > 16 + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_over_16", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_16", person_num:) + end + end + end + + def validate_person_age_matches_relationship(record) + return unless record.startdate && !record.form.start_year_after_2024? + + (2..8).each do |person_num| + age = record.public_send("age#{person_num}") + relationship = record.public_send("relat#{person_num}") + next unless age && relationship + + if age < 16 && !relationship_is_child_other_or_refused?(relationship) + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_lettings", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_lettings", person_num:) + end + end + end + + def validate_person_age_and_relationship_matches_economic_status(record) + return unless record.startdate && !record.form.start_year_after_2024? + + (2..8).each do |person_num| + age = record.public_send("age#{person_num}") + economic_status = record.public_send("ecstat#{person_num}") + relationship = record.public_send("relat#{person_num}") + next unless age && economic_status && relationship + + age_between_16_19 = age.between?(16, 19) + student = tenant_is_fulltime_student?(economic_status) + economic_status_refused = tenant_economic_status_refused?(economic_status) + child = tenant_is_child?(relationship) + + if age_between_16_19 && !(student || economic_status_refused) && child + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") + record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") + end + + next unless !age_between_16_19 && student && child + + record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") + end end def validate_condition_effects(record) @@ -182,56 +246,6 @@ private end end - def validate_person_age_matches_economic_status(record, person_num) - age = record.public_send("age#{person_num}") - economic_status = record.public_send("ecstat#{person_num}") - return unless age && economic_status - - if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_under_16", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_ecstat", person_num:) - end - if tenant_is_economic_child?(economic_status) && age > 16 - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_over_16", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_16", person_num:) - end - end - - def validate_person_age_matches_relationship(record, person_num) - age = record.public_send("age#{person_num}") - relationship = record.public_send("relat#{person_num}") - return unless age && relationship - - if age < 16 && !relationship_is_child_other_or_refused?(relationship) - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_lettings", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_lettings", person_num:) - end - end - - def validate_person_age_and_relationship_matches_economic_status(record, person_num) - age = record.public_send("age#{person_num}") - economic_status = record.public_send("ecstat#{person_num}") - relationship = record.public_send("relat#{person_num}") - return unless age && economic_status && relationship - - age_between_16_19 = age.between?(16, 19) - student = tenant_is_fulltime_student?(economic_status) - economic_status_refused = tenant_economic_status_refused?(economic_status) - child = tenant_is_child?(relationship) - - if age_between_16_19 && !(student || economic_status_refused) && child - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") - end - - if !age_between_16_19 && student && child - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") - end - end - def tenant_is_economic_child?(economic_status) economic_status == 9 end diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index c23a72609..e006374aa 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -1,13 +1,7 @@ module Validations::Sales::HouseholdValidations include Validations::SharedValidations - def validate_household_number_of_other_members(record) - (2..6).each do |n| - validate_person_age_matches_relationship(record, n) - validate_person_age_and_relationship_matches_economic_status(record, n) - validate_person_age_matches_economic_status(record, n) - validate_child_12_years_younger(record, n) - end + def validate_partner_count(record) shared_validate_partner_count(record, 6) end @@ -31,74 +25,95 @@ module Validations::Sales::HouseholdValidations end end -private - - def validate_person_age_matches_relationship(record, person_num) - age = record.public_send("age#{person_num}") - relationship = record.public_send("relat#{person_num}") - return unless age && relationship - - if age < 16 && !relationship_is_child_other_or_refused?(relationship) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_sales", person_num:) - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_sales", person_num:) - elsif age >= 20 && person_is_child?(relationship) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20") + def validate_person_age_matches_relationship(record) + return unless record.saledate && !record.form.start_year_after_2024? + + (2..6).each do |person_num| + age = record.public_send("age#{person_num}") + relationship = record.public_send("relat#{person_num}") + next unless age && relationship + + if age < 16 && !relationship_is_child_other_or_refused?(relationship) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_sales", person_num:) + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_sales", person_num:) + elsif age >= 20 && person_is_child?(relationship) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20") + end end end - def validate_person_age_and_relationship_matches_economic_status(record, person_num) - age = record.public_send("age#{person_num}") - economic_status = record.public_send("ecstat#{person_num}") - relationship = record.public_send("relat#{person_num}") - return unless age && economic_status && relationship - - age_between_16_19 = age.between?(16, 19) - student = person_is_fulltime_student?(economic_status) - economic_status_refused = person_economic_status_refused?(economic_status) - child = person_is_child?(relationship) - - if age_between_16_19 && !(student || economic_status_refused) && child - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") - end + def validate_person_age_and_relationship_matches_economic_status(record) + return unless record.saledate && !record.form.start_year_after_2024? + + (2..6).each do |person_num| + age = record.public_send("age#{person_num}") + economic_status = record.public_send("ecstat#{person_num}") + relationship = record.public_send("relat#{person_num}") + next unless age && economic_status && relationship + + age_between_16_19 = age.between?(16, 19) + student = person_is_fulltime_student?(economic_status) + economic_status_refused = person_economic_status_refused?(economic_status) + child = person_is_child?(relationship) + + if age_between_16_19 && !(student || economic_status_refused) && child + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") + record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") + record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") + end + + next unless !age_between_16_19 && student && child - if !age_between_16_19 && student && child record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") end end - def validate_person_age_matches_economic_status(record, person_num) - age = record.public_send("age#{person_num}") - economic_status = record.public_send("ecstat#{person_num}") - return unless age && economic_status - - if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_under_16", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_ecstat", person_num:) - end - if person_is_economic_child?(economic_status) && age > 16 - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_over_16", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_16", person_num:) + def validate_person_age_matches_economic_status(record) + (2..6).each do |person_num| + age = record.public_send("age#{person_num}") + economic_status = record.public_send("ecstat#{person_num}") + next unless age && economic_status + + if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_after_2024? + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_under_16", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_ecstat", person_num:) + end + if person_is_economic_child?(economic_status) && age > 16 + record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_over_16", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_16", person_num:) + end end end - def validate_child_12_years_younger(record, person_num) - buyer_1_age = record.public_send("age1") - person_age = record.public_send("age#{person_num}") - relationship = record.public_send("relat#{person_num}") - return unless buyer_1_age && person_age && relationship + def validate_child_12_years_younger(record) + return unless record.saledate && !record.form.start_year_after_2024? + + (2..6).each do |person_num| + buyer_1_age = record.public_send("age1") + person_age = record.public_send("age#{person_num}") + relationship = record.public_send("relat#{person_num}") + next unless buyer_1_age && person_age && relationship + + next unless person_age > buyer_1_age - 12 && person_is_child?(relationship) - if person_age > buyer_1_age - 12 && person_is_child?(relationship) record.errors.add "age1", I18n.t("validations.household.age.child_12_years_younger") record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_12_years_younger") record.errors.add "relat#{person_num}", I18n.t("validations.household.age.child_12_years_younger") end end + def validate_buyer_not_child(record) + return unless record.saledate && record.form.start_year_after_2024? + + record.errors.add "ecstat1", I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "1") if person_is_economic_child?(record.ecstat1) + record.errors.add "ecstat2", I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "2") if person_is_economic_child?(record.ecstat2) && record.joint_purchase? + end + +private + def person_is_fulltime_student?(economic_status) economic_status == 7 end diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index 3fd621972..79fc95158 100644 --- a/app/models/validations/shared_validations.rb +++ b/app/models/validations/shared_validations.rb @@ -103,6 +103,8 @@ module Validations::SharedValidations end def shared_validate_partner_count(record, max_people) + return if record.form.start_year_after_2024? + partner_numbers = (2..max_people).select { |n| person_is_partner?(record["relat#{n}"]) } if partner_numbers.count > 1 partner_numbers.each do |n| diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index da3e050c5..d5c301066 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -62,6 +62,9 @@ module Validations::SoftValidations define_method("person_#{person_num}_not_retired_over_soft_max_age?") do not_retired_over_soft_max_age?(person_num) end + define_method("person_#{person_num}_partner_under_16?") do + partner_under_16?(person_num) + end end def no_females_in_a_pregnant_household? @@ -188,6 +191,12 @@ module Validations::SoftValidations PHRASES_LIKELY_TO_INDICATE_EXISTING_REASON_CATEGORY_REGEX.match?(reasonother) end + def multiple_partners? + return unless hhmemb + + (2..hhmemb).many? { |n| public_send("relat#{n}") == "P" } + end + private def details_known_or_lead_tenant?(tenant_number) @@ -234,4 +243,12 @@ private %w[M X].include?(gender) && !tenant_retired_or_prefers_not_say && age > retirement_age_for_person(person_num) || gender == "F" && !tenant_retired_or_prefers_not_say && age > 60 end + + def partner_under_16?(person_num) + age = public_send("age#{person_num}") + relationship = public_send("relat#{person_num}") + return unless age && relationship + + age < 16 && relationship == "P" + end end diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 488dea386..f1124f79d 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -452,6 +452,7 @@ class BulkUpload::Sales::Year2024::RowParser validate :validate_buyer1_economic_status, on: :before_log validate :validate_address_option_found, on: :after_log + validate :validate_buyer2_economic_status, on: :before_log validate :validate_nulls, on: :after_log validate :validate_valid_radio_option, on: :before_log @@ -1359,7 +1360,23 @@ private def validate_buyer1_economic_status if field_35 == 9 - errors.add(:field_35, "Buyer 1 cannot be a child under 16") + if field_31.present? && field_31.to_i >= 16 + errors.add(:field_35, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1")) + errors.add(:field_31, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1")) + else + errors.add(:field_35, I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "1")) + end + end + end + + def validate_buyer2_economic_status + if field_42 == 9 + if field_38.present? && field_38.to_i >= 16 + errors.add(:field_42, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2")) + errors.add(:field_38, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2")) + else + errors.add(:field_42, I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "2")) + end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 487ceed1a..afbba3e2c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -470,6 +470,8 @@ en: must_be_16_19: "Person must be aged 16-19 if they are a student and have relationship ‘child’" lead: over_25: "The lead tenant must be under 26 as you told us their housing situation immediately before this letting was a children’s home or foster care" + student_not_child: + cannot_be_16_19: "Person cannot be aged 16-19 if they are a student but not a child" ecstat: retired_over_70: "Person %{person_num} must be retired if over 70" child_under_16: "Person %{person_num}’s working situation must be ‘child under 16’, ‘other’ or ‘prefers not to say’ as you told us they’re under 16" @@ -481,6 +483,10 @@ en: must_be_student: "Person must be a student if they are aged 16-19 and have relationship ‘child’" retired_male: "Answer cannot be ‘retired’ as the male tenant is under 65" retired_female: "Answer cannot be ‘retired’ as the female tenant is under 60" + not_child_16_19: + cannot_be_student: "Person cannot be a student if they are aged 16-19 but are not a child" + buyer_cannot_be_child: "Buyer %{buyer_index} cannot have a working situation of child under 16" + buyer_cannot_be_over_16_and_child: "Buyer %{buyer_index}'s age cannot be 16 or over if their working situation is child under 16" relat: child_under_16_sales: "Answer cannot be ‘partner’ as you told us person %{person_num}'s age is under 16" child_under_16_lettings: "Answer cannot be ‘partner’ as you told us person %{person_num}'s age is under 16" @@ -491,6 +497,7 @@ en: cannot_be_child: student_not_16_19: "Answer cannot be ‘child’ if the person is a student but not aged 16-19" 16_19_not_student: "Answer cannot be ‘child’ if the person is aged 16-19 but not a student" + child_over_19: "Answer cannot be child as you told us person %{person_num} is over 19" housingneeds_a: one_or_two_choices: "You can only select one option or ‘other disabled access needs’ plus ‘wheelchair-accessible housing’, ‘wheelchair access to essential rooms’ or ‘level access housing’" housingneeds_type: @@ -767,6 +774,14 @@ Make sure these answers are correct." no_address_found: 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." + partner_under_16_lettings: + title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant." + partner_under_16_sales: + title: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1." + multiple_partners_lettings: + title: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant." + multiple_partners_sales: + title: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1." devise: email: diff --git a/db/migrate/20240319122706_add_relationship_value_check_fields.rb b/db/migrate/20240319122706_add_relationship_value_check_fields.rb new file mode 100644 index 000000000..e7ad9339e --- /dev/null +++ b/db/migrate/20240319122706_add_relationship_value_check_fields.rb @@ -0,0 +1,13 @@ +class AddRelationshipValueCheckFields < ActiveRecord::Migration[7.0] + def change + change_table :lettings_logs, bulk: true do |t| + t.column :partner_under_16_value_check, :integer + t.column :multiple_partners_value_check, :integer + end + + change_table :sales_logs, bulk: true do |t| + t.column :partner_under_16_value_check, :integer + t.column :multiple_partners_value_check, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6f17b99c4..b62055ade 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_03_11_102706) do +ActiveRecord::Schema[7.0].define(version: 2024_03_19_122706) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -312,6 +312,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_11_102706) do t.string "postcode_full_input" t.integer "address_search_value_check" t.string "uprn_selection" + t.integer "partner_under_16_value_check" + t.integer "multiple_partners_value_check" t.index ["bulk_upload_id"], name: "index_lettings_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_lettings_logs_on_created_by_id" t.index ["location_id"], name: "index_lettings_logs_on_location_id" @@ -669,6 +671,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_11_102706) do t.string "postcode_full_input" t.integer "address_search_value_check" t.string "uprn_selection" + t.integer "partner_under_16_value_check" + t.integer "multiple_partners_value_check" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb index 29f32346f..78916e0e4 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -76,7 +76,7 @@ FactoryBot.define do buy2livein { "1" } ecstat1 { "1" } ecstat2 { "1" } - hholdcount { "6" } + hholdcount { "4" } wheel { 1 } details_known_3 { 1 } age3_known { 0 } diff --git a/spec/fixtures/files/lettings_log_csv_export_codes_23.csv b/spec/fixtures/files/lettings_log_csv_export_codes_23.csv index 6ef3a8c41..5071b4a09 100644 --- a/spec/fixtures/files/lettings_log_csv_export_codes_23.csv +++ b/spec/fixtures/files/lettings_log_csv_export_codes_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,,,,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,,13,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,,,,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,1,4,,1,4,0,0,2,35,,F,0,2,,13,0,0,P,,,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_codes_24.csv b/spec/fixtures/files/lettings_log_csv_export_codes_24.csv index acc80f3ae..c73ad3ab7 100644 --- a/spec/fixtures/files/lettings_log_csv_export_codes_24.csv +++ b/spec/fixtures/files/lettings_log_csv_export_codes_24.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,1,0,,,,,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,4,,1,4,0,0,2,35,,F,0,2,13,,0,0,P,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,0,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,,,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,1,0,,,,,,,fake address,,London,,NW9 5LL,false,Barnet,E09000003,0,2,6,2,2,7,1,1,3,2023-11-24,,,1,2023-11-25,,3,1,4,,2,,4,,1,4,0,0,2,35,,F,0,2,13,,0,0,P,,,32,M,6,1,R,-9,R,10,0,R,-9,R,10,,,,,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,,6,2,1,0,TN23 6LZ,1,false,Ashford,E07000105,1,0,1,0,0,0,0,0,1,0,,2,,0,0,1,268,,6,1,1,,0,2,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,1,0,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_labels_23.csv b/spec/fixtures/files/lettings_log_csv_export_labels_23.csv index ea012876b..638212806 100644 --- a/spec/fixtures/files/lettings_log_csv_export_labels_23.csv +++ b/spec/fixtures/files/lettings_log_csv_export_labels_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,,,,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,,Tenant prefers not to say,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,,,,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,,Yes,4,0,0,2,35,,Female,White,Irish,,Tenant prefers not to say,Other,Yes,Partner,,,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_labels_24.csv b/spec/fixtures/files/lettings_log_csv_export_labels_24.csv index f196c1045..bbe790ef1 100644 --- a/spec/fixtures/files/lettings_log_csv_export_labels_24.csv +++ b/spec/fixtures/files/lettings_log_csv_export_labels_24.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,Yes,No,,,,,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,,Other,Yes,Partner,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,old_id,old_form_id,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,postcode_known,uprn_known,uprn,uprn_confirmed,address_line1_input,postcode_full_input,address_search_value_check,uprn_selection,address_line1,address_line2,town_or_city,county,postcode_full,is_la_inferred,la_label,la,first_time_property_let_as_social_housing,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,pregnancy_value_check,refused,hhtype,totchild,totelder,totadult,age1,retirement_value_check,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,details_known_2,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,details_known_3,relat3,age3,sex3,ecstat3,details_known_4,relat4,age4,sex4,ecstat4,details_known_5,relat5,age5,sex5,ecstat5,details_known_6,relat6,age6,sex6,ecstat6,details_known_7,relat7,age7,sex7,ecstat7,details_known_8,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,reasonother_value_check,prevten,new_old,homeless,ppcodenk,ppostcode_full,previous_la_known,is_previous_la_inferred,prevloc_label,prevloc,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,net_income_known,incref,incfreq,earnings,net_income_value_check,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,wrent,rent_value_check,scharge,wscharge,pscharge,wpschrge,supcharg,wsupchrg,tcharge,wtcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall_known,tshortfall,wtshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,s.port@jeemayle.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,single log,,,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,Yes,No,,,,,,,fake address,,London,,NW9 5LL,No,Barnet,E09000003,No,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,,Yes,4,0,0,2,35,,Female,White,Irish,Tenant prefers not to say,,Other,Yes,Partner,,,32,Male,Not seeking work,No,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Yes,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,,Other supported housing,2,No,Yes,TN23 6LZ,Yes,No,Ashford,E07000105,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,Yes,No,Weekly,268,,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,100.0,,50.0,25.0,40.0,20.0,35.0,17.5,325.0,162.5,,,,Yes,Yes,12.0,6.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv index 2fcf96476..e843712ea 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,1,4,1,35,F,0,2,,13,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,,0,1,268,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,1,4,1,35,F,0,2,,13,0,P,,,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,,2,,0,1,268,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv index 9ba4f78eb..724d2de7d 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_codes_24.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,4,1,35,F,0,2,13,,0,P,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,0,,2,,0,1,268,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,1,2023,DLUHC,DLUHC,1,7,0,2023-11-26,2,2,1,,2,HIJKLMN,ABCDEFG,1,0,,fake address,,London,,NW9 5LL,Barnet,2,6,2,2,7,1,1,3,2023-11-24,1,,1,2023-11-25,,3,1,4,,2,,4,1,35,F,0,2,13,,0,P,,,32,M,6,R,-9,R,10,R,-9,R,10,,,,,,,,,,,,,,,,,1,4,1,2,1,0,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,2,7,4,,6,1,0,TN23 6LZ,Ashford,1,0,1,0,0,0,0,0,1,0,,2,,0,1,268,6,1,1,,0,2,,,,,200.0,50.0,40.0,35.0,325.0,,,,1,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv index 305a0d000..278228f0d 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_23.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,,Tenant prefers not to say,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,declaration,hhmemb,refused,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2023-11-26T00:00:00+00:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,Yes,4,Yes,35,Female,White,Irish,,Tenant prefers not to say,Other,Partner,,,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,,Tenant applied directly (no referral or nomination),,No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv index fd6fd06e7..e6f534033 100644 --- a/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv +++ b/spec/fixtures/files/lettings_log_csv_export_non_support_labels_24.csv @@ -1,2 +1,2 @@ -id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate -,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,Yes,35,Female,White,Irish,Tenant prefers not to say,,Other,Partner,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, +id,status,duplicate_set_id,created_by,is_dpo,created_at,updated_by,updated_at,creation_method,collection_start_year,owning_organisation_name,managing_organisation_name,needstype,lettype,renewal,startdate,renttype,renttype_detail,irproduct,irproduct_other,lar,tenancycode,propcode,declaration,uprn_known,uprn,address_line1,address_line2,town_or_city,county,postcode_full,la_label,unitletas,rsnvac,newprop,offered,unittype_gn,builtype,wchair,beds,voiddate,vacdays,void_date_value_check,majorrepairs,mrcdate,major_repairs_date_value_check,joint,startertenancy,tenancy,tenancyother,tenancylength,sheltered,hhmemb,refused,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,relat2,partner_under_16_value_check,multiple_partners_value_check,age2,sex2,ecstat2,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,relat7,age7,sex7,ecstat7,relat8,age8,sex8,ecstat8,armedforces,leftreg,reservist,preg_occ,housingneeds,housingneeds_type,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,housingneeds_other,illness,illness_type_4,illness_type_5,illness_type_2,illness_type_6,illness_type_7,illness_type_3,illness_type_9,illness_type_8,illness_type_1,illness_type_10,layear,waityear,reason,reasonother,prevten,homeless,ppcodenk,ppostcode_full,prevloc_label,reasonpref,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,cbl,cap,chr,accessible_register,letting_allocation_none,referral,referral_value_check,incref,incfreq,earnings,hb,has_benefits,benefits,household_charge,nocharge,period,is_carehome,chcharge,wchchrg,carehome_charges_value_check,brent,scharge,pscharge,supcharg,tcharge,scharge_value_check,pscharge_value_check,supcharg_value_check,hbrentshortfall,tshortfall,scheme_code,scheme_service_name,scheme_sensitive,SCHTYPE,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_local_authority,location_startdate +,completed,,choreographer@owtluk.com,false,2023-11-26T00:00:00+00:00,,2024-04-01T00:00:00+01:00,single log,2023,DLUHC,DLUHC,General needs,Affordable rent general needs local authority,No,2023-11-26,Affordable Rent,Affordable Rent,Rent to Buy,,No,HIJKLMN,ABCDEFG,Yes,No,,fake address,,London,,NW9 5LL,Barnet,Affordable rent basis,Tenant abandoned property,No,2,House,Purpose built,Yes,3,2023-11-24,1,,Yes,2023-11-25,,Don’t know,Yes,Assured Shorthold Tenancy (AST) – Fixed term,,2,,4,Yes,35,Female,White,Irish,Tenant prefers not to say,,Other,Partner,,,32,Male,Not seeking work,Prefers not to say,Not known,Prefers not to say,Prefers not to say,Person prefers not to say,Not known,Person prefers not to say,Person prefers not to say,,,,,,,,,,,,,,,,,Yes – the person is a current or former regular,No – they left up to and including 5 years ago,Yes,No,Yes,Fully wheelchair accessible housing,Yes,No,No,No,No,No,No,Yes,No,No,Yes,No,No,No,No,No,No,No,Less than 1 year,1 year but under 2 years,Loss of tied accommodation,,Other supported housing,No,Yes,TN23 6LZ,Ashford,Yes,,Yes,,,,No,No,Yes,No,,Tenant applied directly (no referral or nomination),,No,Weekly,268,Universal Credit housing element,Yes,All,,No,Every 2 weeks,,,,,200.0,50.0,40.0,35.0,325.0,,,,Yes,12.0,,,,,,,,,,,,,,,,,,,, diff --git a/spec/fixtures/files/sales_logs_csv_export_codes_23.csv b/spec/fixtures/files/sales_logs_csv_export_codes_23.csv index bd2b7b305..0ecac1947 100644 --- a/spec/fixtures/files/sales_logs_csv_export_codes_23.csv +++ b/spec/fixtures/files/sales_logs_csv_export_codes_23.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,wchair,noint,privacynotice,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,nationalbuy2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,1,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,1,2,1,30,X,17,17,,18,1,1,P,35,X,17,,,13,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 +,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,1,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,1,2,1,30,X,17,17,,18,1,1,P,35,X,17,,,13,1,1,3,C,14,X,,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_codes_24.csv b/spec/fixtures/files/sales_logs_csv_export_codes_24.csv index a66f03826..4182589ff 100644 --- a/spec/fixtures/files/sales_logs_csv_export_codes_24.csv +++ b/spec/fixtures/files/sales_logs_csv_export_codes_24.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2024-05-01T00:00:00+01:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,1,1,0,1,30,X,17,17,18,,1,1,P,35,X,17,,13,,1,1,3,C,14,X,9,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 +,completed,,2023-12-08T00:00:00+00:00,2024-05-01T00:00:00+01:00,,2023,1,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,2,8,,,,1,1,2,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,1,1,0,1,30,X,17,17,18,,1,1,P,35,X,17,,13,,1,1,3,C,14,X,,X,-9,X,3,R,-9,R,10,,,,,1,1,,,0,,,1,1,1,1,,3,,1,4,5,1,1,0,10000,1,0,10000,1,4,1,,1,2,10,,,,,,,,,,,,,,,,,110000.0,,1,20000.0,5,,10,1,80000.0,,,1,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_23.csv b/spec/fixtures/files/sales_logs_csv_export_labels_23.csv index 44c484d83..ca7b4b1b7 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels_23.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels_23.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,beds,proptype,builtype,pcodenk,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,wchair,noint,privacynotice,age1,sex1,ethnic_group,ethnic,nationality_all,national,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationality_all_buyer2,nationalbuy2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 +,completed,,2023-12-08T00:00:00+00:00,2024-01-01T00:00:00+00:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,2,Flat or maisonette,Purpose built,0,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,Yes,Yes,1,30,Non-binary,Buyer prefers not to say,17,,United Kingdom,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,,Buyer prefers not to say,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/fixtures/files/sales_logs_csv_export_labels_24.csv b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv index 508b40dac..44c97dd06 100644 --- a/spec/fixtures/files/sales_logs_csv_export_labels_24.csv +++ b/spec/fixtures/files/sales_logs_csv_export_labels_24.csv @@ -1,2 +1,2 @@ id,status,duplicate_set_id,created_at,updated_at,old_form_id,collection_start_year,creation_method,is_dpo,owning_organisation_name,managing_organisation_name,created_by,day,month,year,purchid,ownershipsch,type,othtype,companybuy,buylivein,jointpur,jointmore,noint,privacynotice,uprn,uprn_confirmed,address_line1_input,postcode_full_input,uprn_selection,address_line1,address_line2,town_or_city,county,pcode1,pcode2,la_known,la,la_label,beds,proptype,builtype,pcodenk,wchair,age1,sex1,ethnic_group,ethnic,national,nationality_all,ecstat1,buy1livein,relat2,age2,sex2,ethnic_group2,ethnicbuy2,nationalbuy2,nationality_all_buyer2,ecstat2,buy2livein,hholdcount,relat3,age3,sex3,ecstat3,relat4,age4,sex4,ecstat4,relat5,age5,sex5,ecstat5,relat6,age6,sex6,ecstat6,prevten,ppcodenk,ppostc1,ppostc2,previous_la_known,prevloc,prevloc_label,pregyrha,pregother,pregla,pregghb,pregblank,buy2living,prevtenbuy2,hhregres,hhregresstill,armedforcesspouse,disabled,wheel,income1nk,income1,inc1mort,income2nk,income2,inc2mort,hb,savingsnk,savings,prevown,prevshared,proplen,staircase,stairbought,stairowned,staircasesale,resale,exday,exmonth,exyear,hoday,homonth,hoyear,lanomagr,soctenant,frombeds,fromprop,socprevten,value,equity,mortgageused,mortgage,mortgagelender,mortgagelenderother,mortlen,extrabor,deposit,cashdis,mrent,has_mscharge,mscharge,discount,grant -,completed,,2023-12-08T00:00:00+00:00,2024-05-01T00:00:00+01:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,Child under 16,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 +,completed,,2023-12-08T00:00:00+00:00,2024-05-01T00:00:00+01:00,,2023,single log,false,DLUHC,DLUHC,billyboy@eyeklaud.com,8,12,2023,,Yes - a discounted ownership scheme,Right to Acquire (RTA),,,,Yes,Yes,Yes,1,,,,,,Address line 1,,Town or city,,SW1A,1AA,1,E09000003,Barnet,2,Flat or maisonette,Purpose built,0,Yes,30,Non-binary,Buyer prefers not to say,17,United Kingdom,,Full-time - 30 hours or more,Yes,Partner,35,Non-binary,Buyer prefers not to say,,Buyer prefers not to say,,Full-time - 30 hours or more,Yes,3,Child,14,Non-binary,,Other,Not known,Non-binary,"In government training into work, such as New Deal",Prefers not to say,Not known,Prefers not to say,Prefers not to say,,,,,Local authority tenant,No,,,No,,,1,1,1,1,,Don't know,,Yes,Yes,No,Yes,Yes,Yes,10000,Yes,Yes,10000,Yes,"Don’t know ",No,,Yes,No,10,,,,,,,,,,,,,,,,,110000.0,,Yes,20000.0,Cambridge Building Society,,10,Yes,80000.0,,,Yes,100.0,,10000.0 diff --git a/spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb b/spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb new file mode 100644 index 000000000..2df5e394b --- /dev/null +++ b/spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb @@ -0,0 +1,91 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 1 } + + let(:page_id) { "multiple_partners_value_check" } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "is interruption screen page" do + expect(page.interruption_screen?).to eq(true) + end + + context "with person 1" do + let(:person_index) { 1 } + let(:page_id) { "multiple_partners_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("multiple_partners_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.multiple_partners_lettings.title", + "arguments" => [], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6 relat7 relat8]) + end + end + + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_multiple_partners_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_multiple_partners_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.multiple_partners_lettings.title", + "arguments" => [], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6 relat7 relat8]) + end + end +end diff --git a/spec/models/form/lettings/pages/partner_under16_value_check_spec.rb b/spec/models/form/lettings/pages/partner_under16_value_check_spec.rb new file mode 100644 index 000000000..9ad520451 --- /dev/null +++ b/spec/models/form/lettings/pages/partner_under16_value_check_spec.rb @@ -0,0 +1,255 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 1 } + + let(:page_id) { "partner_under_16_value_check" } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "is interruption screen page" do + expect(page.interruption_screen?).to eq(true) + end + + context "with person 1" do + let(:person_index) { 1 } + let(:page_id) { "partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_1_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age1", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age1 relat1]) + end + end + + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_2_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age2", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age2 relat2]) + end + end + + context "with person 3" do + let(:person_index) { 3 } + let(:page_id) { "person_3_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_3_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age3", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age3 relat3]) + end + end + + context "with person 4" do + let(:person_index) { 4 } + let(:page_id) { "person_4_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_4_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_4_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age4", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age4 relat4]) + end + end + + context "with person 5" do + let(:person_index) { 5 } + let(:page_id) { "person_5_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_5_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_5_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age5", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age5 relat5]) + end + end + + context "with person 6" do + let(:person_index) { 6 } + let(:page_id) { "person_6_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_6_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_6_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_lettings.title", + "arguments" => [ + { + "key" => "age6", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age6 relat6]) + end + end +end diff --git a/spec/models/form/lettings/pages/person_age_spec.rb b/spec/models/form/lettings/pages/person_age_spec.rb index 483784e5c..562d91cfa 100644 --- a/spec/models/form/lettings/pages/person_age_spec.rb +++ b/spec/models/form/lettings/pages/person_age_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do subject(:page) { described_class.new(nil, page_definition, subsection, person_index:, person_type:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: false)) } let(:person_index) { 2 } let(:person_type) { "non_child" } diff --git a/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb b/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb index 6bf4558af..a73e94482 100644 --- a/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb +++ b/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Form::Lettings::Pages::PersonRelationshipToLead, type: :model do subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: false)) } let(:person_index) { 2 } it "has correct subsection" do diff --git a/spec/models/form/lettings/questions/age_spec.rb b/spec/models/form/lettings/questions/age_spec.rb index bdd2f0a21..85659fc8f 100644 --- a/spec/models/form/lettings/questions/age_spec.rb +++ b/spec/models/form/lettings/questions/age_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Form::Lettings::Questions::Age, type: :model do subject(:question) { described_class.new(nil, question_definition, page, person_index:, person_type:) } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4), start_year_after_2024?: false))) } let(:person_index) { 2 } let(:person_type) { "non_child" } diff --git a/spec/models/form/lettings/questions/multiple_partners_value_check_spec.rb b/spec/models/form/lettings/questions/multiple_partners_value_check_spec.rb new file mode 100644 index 000000000..04cd6aee3 --- /dev/null +++ b/spec/models/form/lettings/questions/multiple_partners_value_check_spec.rb @@ -0,0 +1,61 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::MultiplePartnersValueCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("multiple_partners_value_check") + end + + it "has the correct header" do + expect(question.header).to eq("Are you sure this is correct?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Multiple partners confirmation") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has a correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(1) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "multiple_partners_value_check" => 0, + }, + { + "multiple_partners_value_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/lettings/questions/partner_under16_value_check_spec.rb b/spec/models/form/lettings/questions/partner_under16_value_check_spec.rb new file mode 100644 index 000000000..87206a0df --- /dev/null +++ b/spec/models/form/lettings/questions/partner_under16_value_check_spec.rb @@ -0,0 +1,61 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::PartnerUnder16ValueCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("partner_under_16_value_check") + end + + it "has the correct header" do + expect(question.header).to eq("Are you sure this is correct?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Partner under 16 confirmation") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has a correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(1) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "partner_under_16_value_check" => 0, + }, + { + "partner_under_16_value_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/lettings/questions/person_relationship_spec.rb b/spec/models/form/lettings/questions/person_relationship_spec.rb index 31b2c402e..51975e719 100644 --- a/spec/models/form/lettings/questions/person_relationship_spec.rb +++ b/spec/models/form/lettings/questions/person_relationship_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do subject(:question) { described_class.new(nil, question_definition, page, person_index:) } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4), start_year_after_2024?: false))) } let(:person_index) { 2 } it "has correct page" do diff --git a/spec/models/form/lettings/questions/person_working_situation_spec.rb b/spec/models/form/lettings/questions/person_working_situation_spec.rb index 5f4c513f4..b4af7eb62 100644 --- a/spec/models/form/lettings/questions/person_working_situation_spec.rb +++ b/spec/models/form/lettings/questions/person_working_situation_spec.rb @@ -33,6 +33,7 @@ RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model d "9" => { "depends_on" => [ { "age2_known" => 1 }, + { "age2_known" => nil }, { "age2" => { "operand" => 16, "operator" => "<" } }, ], "value" => "Child under 16", diff --git a/spec/models/form/lettings/subsections/household_characteristics_spec.rb b/spec/models/form/lettings/subsections/household_characteristics_spec.rb index 34738ed7a..c71ee165c 100644 --- a/spec/models/form/lettings/subsections/household_characteristics_spec.rb +++ b/spec/models/form/lettings/subsections/household_characteristics_spec.rb @@ -189,12 +189,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_lead_tenant_over_retirement_value_check person_2_known person_2_relationship_to_lead + relationship_2_partner_under_16_value_check + relationship_2_multiple_partners_value_check person_2_age_child person_2_age_non_child no_females_pregnant_household_person_2_age_value_check females_in_soft_age_range_in_pregnant_household_person_2_age_value_check age_2_under_retirement_value_check age_2_over_retirement_value_check + age_2_partner_under_16_value_check person_2_gender_identity no_females_pregnant_household_person_2_value_check females_in_soft_age_range_in_pregnant_household_person_2_value_check @@ -204,12 +207,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_2_over_retirement_value_check person_3_known person_3_relationship_to_lead + relationship_3_partner_under_16_value_check + relationship_3_multiple_partners_value_check person_3_age_child person_3_age_non_child no_females_pregnant_household_person_3_age_value_check females_in_soft_age_range_in_pregnant_household_person_3_age_value_check age_3_under_retirement_value_check age_3_over_retirement_value_check + age_3_partner_under_16_value_check person_3_gender_identity no_females_pregnant_household_person_3_value_check females_in_soft_age_range_in_pregnant_household_person_3_value_check @@ -219,12 +225,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_3_over_retirement_value_check person_4_known person_4_relationship_to_lead + relationship_4_partner_under_16_value_check + relationship_4_multiple_partners_value_check person_4_age_child person_4_age_non_child no_females_pregnant_household_person_4_age_value_check females_in_soft_age_range_in_pregnant_household_person_4_age_value_check age_4_under_retirement_value_check age_4_over_retirement_value_check + age_4_partner_under_16_value_check person_4_gender_identity no_females_pregnant_household_person_4_value_check females_in_soft_age_range_in_pregnant_household_person_4_value_check @@ -234,12 +243,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_4_over_retirement_value_check person_5_known person_5_relationship_to_lead + relationship_5_partner_under_16_value_check + relationship_5_multiple_partners_value_check person_5_age_child person_5_age_non_child no_females_pregnant_household_person_5_age_value_check females_in_soft_age_range_in_pregnant_household_person_5_age_value_check age_5_under_retirement_value_check age_5_over_retirement_value_check + age_5_partner_under_16_value_check person_5_gender_identity no_females_pregnant_household_person_5_value_check females_in_soft_age_range_in_pregnant_household_person_5_value_check @@ -249,12 +261,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_5_over_retirement_value_check person_6_known person_6_relationship_to_lead + relationship_6_partner_under_16_value_check + relationship_6_multiple_partners_value_check person_6_age_child person_6_age_non_child no_females_pregnant_household_person_6_age_value_check females_in_soft_age_range_in_pregnant_household_person_6_age_value_check age_6_under_retirement_value_check age_6_over_retirement_value_check + age_6_partner_under_16_value_check person_6_gender_identity no_females_pregnant_household_person_6_value_check females_in_soft_age_range_in_pregnant_household_person_6_value_check @@ -264,12 +279,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_6_over_retirement_value_check person_7_known person_7_relationship_to_lead + relationship_7_partner_under_16_value_check + relationship_7_multiple_partners_value_check person_7_age_child person_7_age_non_child no_females_pregnant_household_person_7_age_value_check females_in_soft_age_range_in_pregnant_household_person_7_age_value_check age_7_under_retirement_value_check age_7_over_retirement_value_check + age_7_partner_under_16_value_check person_7_gender_identity no_females_pregnant_household_person_7_value_check females_in_soft_age_range_in_pregnant_household_person_7_value_check @@ -279,12 +297,15 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_7_over_retirement_value_check person_8_known person_8_relationship_to_lead + relationship_8_partner_under_16_value_check + relationship_8_multiple_partners_value_check person_8_age_child person_8_age_non_child no_females_pregnant_household_person_8_age_value_check females_in_soft_age_range_in_pregnant_household_person_8_age_value_check age_8_under_retirement_value_check age_8_over_retirement_value_check + age_8_partner_under_16_value_check person_8_gender_identity no_females_pregnant_household_person_8_value_check females_in_soft_age_range_in_pregnant_household_person_8_value_check diff --git a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb index d7fd457d9..4a7745bb0 100644 --- a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb +++ b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb b/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb new file mode 100644 index 000000000..57d8c2771 --- /dev/null +++ b/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb @@ -0,0 +1,91 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::MultiplePartnersValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 1 } + + let(:page_id) { "multiple_partners_value_check" } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "is interruption screen page" do + expect(page.interruption_screen?).to eq(true) + end + + context "with person 1" do + let(:person_index) { 1 } + let(:page_id) { "multiple_partners_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("multiple_partners_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.multiple_partners_sales.title", + "arguments" => [], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6]) + end + end + + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_multiple_partners_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_multiple_partners_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "multiple_partners?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.multiple_partners_sales.title", + "arguments" => [], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[relat2 relat3 relat4 relat5 relat6]) + end + end +end diff --git a/spec/models/form/sales/pages/partner_under16_value_check_spec.rb b/spec/models/form/sales/pages/partner_under16_value_check_spec.rb new file mode 100644 index 000000000..7535d89ca --- /dev/null +++ b/spec/models/form/sales/pages/partner_under16_value_check_spec.rb @@ -0,0 +1,255 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 1 } + + let(:page_id) { "partner_under_16_value_check" } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "is interruption screen page" do + expect(page.interruption_screen?).to eq(true) + end + + context "with person 1" do + let(:person_index) { 1 } + let(:page_id) { "partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_1_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age1", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age1 relat1]) + end + end + + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_2_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age2", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age2 relat2]) + end + end + + context "with person 3" do + let(:person_index) { 3 } + let(:page_id) { "person_3_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_3_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age3", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age3 relat3]) + end + end + + context "with person 4" do + let(:person_index) { 4 } + let(:page_id) { "person_4_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_4_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_4_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age4", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age4 relat4]) + end + end + + context "with person 5" do + let(:person_index) { 5 } + let(:page_id) { "person_5_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_5_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_5_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age5", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age5 relat5]) + end + end + + context "with person 6" do + let(:person_index) { 6 } + let(:page_id) { "person_6_partner_under_16_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_6_partner_under_16_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_6_partner_under_16?" => true }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.partner_under_16_sales.title", + "arguments" => [ + { + "key" => "age6", + "label" => true, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + end + + it "has correct interruption_screen_question_ids" do + expect(page.interruption_screen_question_ids).to eq(%w[age6 relat6]) + end + end +end diff --git a/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb index 2efad476a..0fb5503ce 100644 --- a/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb +++ b/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Form::Sales::Pages::PersonRelationshipToBuyer1, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false)) } let(:person_index) { 1 } let(:page_id) { "person_1_relationship_to_buyer_1" } diff --git a/spec/models/form/sales/pages/person_working_situation_spec.rb b/spec/models/form/sales/pages/person_working_situation_spec.rb index aeee1aaec..9400274f7 100644 --- a/spec/models/form/sales/pages/person_working_situation_spec.rb +++ b/spec/models/form/sales/pages/person_working_situation_spec.rb @@ -34,7 +34,7 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "details_known_2" => 1 }]) + expect(page.depends_on).to eq([{ "age2" => { "operand" => 15, "operator" => ">" }, "details_known_2" => 1 }, { "age2" => nil, "details_known_2" => 1 }]) end end @@ -51,7 +51,7 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "details_known_3" => 1 }]) + expect(page.depends_on).to eq([{ "age3" => { "operand" => 15, "operator" => ">" }, "details_known_3" => 1 }, { "age3" => nil, "details_known_3" => 1 }]) end end @@ -68,7 +68,7 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "details_known_4" => 1 }]) + expect(page.depends_on).to eq([{ "age4" => { "operand" => 15, "operator" => ">" }, "details_known_4" => 1 }, { "age4" => nil, "details_known_4" => 1 }]) end end @@ -85,7 +85,7 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "details_known_5" => 1 }]) + expect(page.depends_on).to eq([{ "age5" => { "operand" => 15, "operator" => ">" }, "details_known_5" => 1 }, { "age5" => nil, "details_known_5" => 1 }]) end end end diff --git a/spec/models/form/sales/questions/age2_spec.rb b/spec/models/form/sales/questions/age2_spec.rb index f09148869..c5aa815f7 100644 --- a/spec/models/form/sales/questions/age2_spec.rb +++ b/spec/models/form/sales/questions/age2_spec.rb @@ -53,7 +53,7 @@ RSpec.describe Form::Sales::Questions::Age2, type: :model do end it "has the correct min" do - expect(question.min).to eq(0) + expect(question.min).to eq(16) end it "has the correct max" do diff --git a/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb index b37ce0e0e..e4cc4af11 100644 --- a/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb +++ b/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb index eb6588416..a89f10194 100644 --- a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb +++ b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb @@ -47,7 +47,6 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do "0" => { "value" => "Other" }, "10" => { "value" => "Buyer prefers not to say" }, "7" => { "value" => "Full-time student" }, - "9" => { "value" => "Child under 16" }, }) end diff --git a/spec/models/form/sales/questions/multiple_partners_value_check_spec.rb b/spec/models/form/sales/questions/multiple_partners_value_check_spec.rb new file mode 100644 index 000000000..7afda39bb --- /dev/null +++ b/spec/models/form/sales/questions/multiple_partners_value_check_spec.rb @@ -0,0 +1,61 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::MultiplePartnersValueCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("multiple_partners_value_check") + end + + it "has the correct header" do + expect(question.header).to eq("Are you sure this is correct?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Multiple partners confirmation") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has a correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(1) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "multiple_partners_value_check" => 0, + }, + { + "multiple_partners_value_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/sales/questions/partner_under16_value_check_spec.rb b/spec/models/form/sales/questions/partner_under16_value_check_spec.rb new file mode 100644 index 000000000..5be3aa9c7 --- /dev/null +++ b/spec/models/form/sales/questions/partner_under16_value_check_spec.rb @@ -0,0 +1,61 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::PartnerUnder16ValueCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("partner_under_16_value_check") + end + + it "has the correct header" do + expect(question.header).to eq("Are you sure this is correct?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Partner under 16 confirmation") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has a correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(1) + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "partner_under_16_value_check" => 0, + }, + { + "partner_under_16_value_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/sales/questions/person_age_spec.rb b/spec/models/form/sales/questions/person_age_spec.rb index 983d5667e..55a2dc020 100644 --- a/spec/models/form/sales/questions/person_age_spec.rb +++ b/spec/models/form/sales/questions/person_age_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::PersonAge, type: :model do let(:question_id) { "age3" } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } let(:person_index) { 2 } it "has correct page" do diff --git a/spec/models/form/sales/questions/person_relationship_to_buyer1_spec.rb b/spec/models/form/sales/questions/person_relationship_to_buyer1_spec.rb index ad0d17034..57914d70d 100644 --- a/spec/models/form/sales/questions/person_relationship_to_buyer1_spec.rb +++ b/spec/models/form/sales/questions/person_relationship_to_buyer1_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Questions::PersonRelationshipToBuyer1, type: :model let(:question_id) { "relat2" } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false))) } let(:person_index) { 2 } it "has correct page" do diff --git a/spec/models/form/sales/questions/person_working_situation_spec.rb b/spec/models/form/sales/questions/person_working_situation_spec.rb index 77ec1267b..97f438460 100644 --- a/spec/models/form/sales/questions/person_working_situation_spec.rb +++ b/spec/models/form/sales/questions/person_working_situation_spec.rb @@ -32,7 +32,12 @@ RSpec.describe Form::Sales::Questions::PersonWorkingSituation, type: :model do "0" => { "value" => "Other" }, "10" => { "value" => "Person prefers not to say" }, "7" => { "value" => "Full-time student" }, - "9" => { "value" => "Child under 16" }, + "9" => { "value" => "Child under 16", + "depends_on" => + [{ "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, + { "age2_known" => 1 }, + { "age2_known" => nil }, + { "age2" => { "operator" => "<", "operand" => 16 } }] }, }) end diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 3deddf001..2557f33c6 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -292,10 +292,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model number_of_others_in_property_joint_purchase person_2_known person_2_relationship_to_buyer_1 + relationship_2_partner_under_16_value_check + relationship_2_multiple_partners_value_check relationship_2_student_not_child_value_check person_2_age age_2_retirement_value_check age_2_student_not_child_value_check + age_2_partner_under_16_value_check person_2_gender_identity gender_2_retirement_value_check person_2_working_situation @@ -303,10 +306,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model working_situation_2_student_not_child_value_check person_3_known person_3_relationship_to_buyer_1 + relationship_3_partner_under_16_value_check + relationship_3_multiple_partners_value_check relationship_3_student_not_child_value_check person_3_age age_3_retirement_value_check age_3_student_not_child_value_check + age_3_partner_under_16_value_check person_3_gender_identity gender_3_retirement_value_check person_3_working_situation @@ -314,10 +320,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model working_situation_3_student_not_child_value_check person_4_known person_4_relationship_to_buyer_1 + relationship_4_partner_under_16_value_check + relationship_4_multiple_partners_value_check relationship_4_student_not_child_value_check person_4_age age_4_retirement_value_check age_4_student_not_child_value_check + age_4_partner_under_16_value_check person_4_gender_identity gender_4_retirement_value_check person_4_working_situation @@ -325,10 +334,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model working_situation_4_student_not_child_value_check person_5_known person_5_relationship_to_buyer_1 + relationship_5_partner_under_16_value_check + relationship_5_multiple_partners_value_check relationship_5_student_not_child_value_check person_5_age age_5_retirement_value_check age_5_student_not_child_value_check + age_5_partner_under_16_value_check person_5_gender_identity gender_5_retirement_value_check person_5_working_situation @@ -336,10 +348,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model working_situation_5_student_not_child_value_check person_6_known person_6_relationship_to_buyer_1 + relationship_6_partner_under_16_value_check + relationship_6_multiple_partners_value_check relationship_6_student_not_child_value_check person_6_age age_6_retirement_value_check age_6_student_not_child_value_check + age_6_partner_under_16_value_check person_6_gender_identity gender_6_retirement_value_check person_6_working_situation diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 41d9f0646..0c2bd790c 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -103,8 +103,20 @@ RSpec.describe LettingsLog do expect(validator).to receive(:validate_irproduct_other) end - it "validates other household member details" do - expect(validator).to receive(:validate_household_number_of_other_members) + it "validates partner count" do + expect(validator).to receive(:validate_partner_count) + end + + it "validates person age matches economic status" do + expect(validator).to receive(:validate_person_age_matches_economic_status) + end + + it "validates person age matches relationship" do + expect(validator).to receive(:validate_person_age_matches_relationship) + end + + it "validates person age and relationship matches economic status" do + expect(validator).to receive(:validate_person_age_and_relationship_matches_economic_status) end it "validates bedroom number" do @@ -1475,12 +1487,6 @@ RSpec.describe LettingsLog do record_from_db = described_class.find(household_lettings_log.id) expect(record_from_db["ecstat7"]).to eq(9) end - - it "correctly resets economic status when age changes from under 16" do - household_lettings_log.update!(age7_known: 0, age7: 17) - record_from_db = described_class.find(household_lettings_log.id) - expect(record_from_db["ecstat7"]).to eq(nil) - end end it "correctly derives and saves has_benefits" do diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 18b5dc5e8..5685ac58c 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -44,8 +44,24 @@ RSpec.describe SalesLog, type: :model do sales_log.update(age1: 25) end - it "validates other household member details" do - expect(validator).to receive(:validate_household_number_of_other_members) + it "validates partner count" do + expect(validator).to receive(:validate_partner_count) + end + + it "validates person age matches economic status" do + expect(validator).to receive(:validate_person_age_matches_economic_status) + end + + it "validates person age matches relationship" do + expect(validator).to receive(:validate_person_age_matches_relationship) + end + + it "validates person age and relationship matches economic status" do + expect(validator).to receive(:validate_person_age_and_relationship_matches_economic_status) + end + + it "validates child is over 12 years younger than lead tenant" do + expect(validator).to receive(:validate_child_12_years_younger) end it "calls the form to clear any invalid answers" do @@ -816,6 +832,25 @@ RSpec.describe SalesLog, type: :model do expect(record_from_db["ppostcode_full"]).to eq(nil) expect(record_from_db["prevloc"]).to eq(nil) end + + context "when validating household members derived vars" do + let!(:household_sales_log) do + create( + :sales_log, + :completed, + managing_organisation: owning_organisation, + owning_organisation:, + created_by: created_by_user, + age6: 14, + saledate: Time.zone.local(2024, 5, 2), + ) + end + + it "correctly derives economic status for tenants under 16" do + record_from_db = described_class.find(household_sales_log.id) + expect(record_from_db["ecstat6"]).to eq(9) + end + end end it "errors if the property postcode is emptied" do @@ -883,11 +918,11 @@ RSpec.describe SalesLog, type: :model do relat5: "X", relat6: "P", income2: 0, - ecstat2: 9, - ecstat3: 7, + ecstat2: 7, + ecstat3: 9, age1: 47, - age2: 14, - age3: 17, + age2: 17, + age3: 14, age4: 88, age5: 19, age6: 46, diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 5a48d4b3f..c31cee46d 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -272,7 +272,7 @@ RSpec.describe Validations::HouseholdValidations do end end - describe "household member validations" do + describe "#validate_numeric_min_max" do it "validates that the number of household members cannot be less than 1" do record.hhmemb = 0 household_validator.validate_numeric_min_max(record) @@ -292,11 +292,13 @@ RSpec.describe Validations::HouseholdValidations do household_validator.validate_numeric_min_max(record) expect(record.errors["hhmemb"]).to be_empty end + end + describe "#validate_partner_count" do it "validates that only 1 partner exists" do record.relat2 = "P" record.relat3 = "P" - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_partner_count(record) expect(record.errors["relat2"]) .to include(match I18n.t("validations.household.relat.one_partner")) expect(record.errors["relat3"]) @@ -307,165 +309,285 @@ RSpec.describe Validations::HouseholdValidations do it "expects that a tenant can have a partner" do record.relat3 = "P" - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_partner_count(record) expect(record.errors["base"]).to be_empty end + end + + describe "#validate_person_age_matches_relationship" do + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "when the household contains a person under 16" do + it "validates that person must be a child of the tenant" do + record.age2 = 14 + record.relat2 = "P" + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.child_under_16_lettings", person_num: 2)) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.child_under_16_relat_lettings", person_num: 2)) + end + + it "expects that person is a child of the tenant" do + record.age2 = 14 + record.relat2 = "C" + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + end + end + + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end - context "when the household contains a person under 16" do - it "validates that person must be a child of the tenant" do + it "does not add an error is person under 16 is a partner" do record.age2 = 14 record.relat2 = "P" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.child_under_16_lettings", person_num: 2)) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_under_16_relat_lettings", person_num: 2)) + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end - it "expects that person is a child of the tenant" do - record.age2 = 14 + it "does not add an error if person over 19 is child" do + record.age2 = 20 record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]).to be_empty + household_validator.validate_person_age_matches_relationship(record) expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty end + end + end - it "validates that person's economic status must be Child" do - record.age2 = 14 - record.ecstat2 = 1 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_under_16_ecstat", person_num: 2)) + describe "#validate_person_age_matches_economic_status" do + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) end - it "expects that person's economic status is Child" do - record.age2 = 14 - record.ecstat2 = 9 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty + after do + Timecop.return + Singleton.__init__(FormHandler) end - it "validates that a person with economic status 'child' must be under 16" do - record.age2 = 21 - record.relat2 = "C" - record.ecstat2 = 9 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.child_over_16", person_num: 2)) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_over_16", person_num: 2)) + context "when the household contains a person under 16" do + it "validates that person's economic status must be Child" do + record.age2 = 14 + record.ecstat2 = 1 + household_validator.validate_person_age_matches_economic_status(record) + expect(record.errors["ecstat2"]) + .to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.child_under_16_ecstat", person_num: 2)) + end + + it "expects that person's economic status is Child" do + record.age2 = 14 + record.ecstat2 = 9 + household_validator.validate_person_age_matches_economic_status(record) + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "validates that a person with economic status 'child' must be under 16" do + record.age2 = 21 + record.relat2 = "C" + record.ecstat2 = 9 + household_validator.validate_person_age_matches_economic_status(record) + expect(record.errors["ecstat2"]) + .to include(match I18n.t("validations.household.ecstat.child_over_16", person_num: 2)) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.child_over_16", person_num: 2)) + end end end - context "when the household contains a tenant’s child between the ages of 16 and 19" do - it "validates that person's economic status must be full time student or refused" do - record.age2 = 17 - record.relat2 = "C" + context "with 2024 logs" do + before do + Timecop.freeze(Time.zone.local(2024, 4, 1)) + Singleton.__init__(FormHandler) + record.update!(startdate: Time.zone.local(2024, 4, 1)) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + it "does not run the validation" do + record.age2 = 14 record.ecstat2 = 1 - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.student_16_19.must_be_student", person_num: 2)) + .not_to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student", person_num: 2)) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student", person_num: 2)) + .not_to include(match I18n.t("validations.household.age.child_under_16_ecstat", person_num: 2)) end + end + end - it "expects that person can be a full time student" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 7 - household_validator.validate_household_number_of_other_members(record) + describe "#validate_person_age_and_relationship_matches_economic_status" do + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "when the household contains a tenant’s child between the ages of 16 and 19" do + it "validates that person's economic status must be full time student or refused" do + record.age2 = 17 + record.relat2 = "C" + record.ecstat2 = 1 + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["ecstat2"]) + .to include(match I18n.t("validations.household.ecstat.student_16_19.must_be_student", person_num: 2)) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student", person_num: 2)) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student", person_num: 2)) + end + + it "expects that person can be a full time student" do + record.age2 = 17 + record.relat2 = "C" + record.ecstat2 = 7 + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty + end + + it "expects that person can refuse to share their work status" do + record.age2 = 17 + record.relat2 = "C" + record.ecstat2 = 10 + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty + end + end + + it "does not add an error for a person aged 16-19 who is a student but not a child of the lead tenant" do + record.age2 = 18 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty expect(record.errors["ecstat2"]).to be_empty expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty end - it "expects that person can refuse to share their work status" do - record.age2 = 17 - record.relat2 = "C" - record.ecstat2 = 10 - household_validator.validate_household_number_of_other_members(record) + it "does not add an error for a person not aged 16-19 who is a student but not a child of the lead tenant" do + record.age2 = 20 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty expect(record.errors["ecstat2"]).to be_empty expect(record.errors["age2"]).to be_empty - expect(record.errors["relat2"]).to be_empty end - end - it "does not add an error for a person aged 16-19 who is a student but not a child of the lead tenant" do - record.age2 = 18 - record.ecstat2 = "7" - record.relat2 = "P" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]).to be_empty - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty - end - - it "does not add an error for a person not aged 16-19 who is a student but not a child of the lead tenant" do - record.age2 = 20 - record.ecstat2 = "7" - record.relat2 = "P" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]).to be_empty - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty + it "adds errors for a person who is a child of the lead tenant and a student but not aged 16-19" do + record.age2 = 14 + record.ecstat2 = "7" + record.relat2 = "C" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19")) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.student_16_19.must_be_16_19")) + expect(record.errors["ecstat2"]) + .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) + end end - it "adds errors for a person who is a child of the lead tenant and a student but not aged 16-19" do - record.age2 = 14 - record.ecstat2 = "7" - record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.student_16_19.must_be_16_19")) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) - end + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } - context "when the household contains a person over 70" do - it "expects that person under 70 does not need to be retired" do - record.age2 = 50 - record.ecstat2 = 1 - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "when the household contains a tenant’s child between the ages of 16 and 19" do + it "does not add an error" do + record.age2 = 17 + record.relat2 = "C" + record.ecstat2 = 1 + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["ecstat2"]) + .to be_empty + expect(record.errors["age2"]) + .to be_empty + expect(record.errors["relat2"]) + .to be_empty + end end - it "expects that person over 70 is retired" do - record.age2 = 71 - record.ecstat2 = 5 - household_validator.validate_household_number_of_other_members(record) + it "does not add an error for a person not aged 16-19 who is a student but not a child of the lead tenant" do + record.age2 = 20 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty expect(record.errors["ecstat2"]).to be_empty expect(record.errors["age2"]).to be_empty end - end - context "when the household contains a retired male" do - it "expects that person is over 65" do - record.age2 = 66 - record.sex2 = "M" - record.ecstat2 = 5 - household_validator.validate_household_number_of_other_members(record) + it "does not add errors for a person who is a child of the lead tenant and a student but not aged 16-19" do + record.age2 = 14 + record.ecstat2 = "7" + record.relat2 = "C" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["sex2"]).to be_empty expect(record.errors["age2"]).to be_empty end - end - context "when the household contains a retired female" do - it "expects that person is over 60" do - record.age2 = 61 - record.sex2 = "F" - record.ecstat2 = 5 - household_validator.validate_household_number_of_other_members(record) + it "does not add for a person who is a student and aged 16-19 but not child" do + record.age2 = 17 + record.ecstat2 = "7" + record.relat2 = "X" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["sex2"]).to be_empty expect(record.errors["age2"]).to be_empty end end diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index deddfa8ef..86ce01fb0 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -4,14 +4,14 @@ RSpec.describe Validations::Sales::HouseholdValidations do subject(:household_validator) { validator_class.new } let(:validator_class) { Class.new { include Validations::Sales::HouseholdValidations } } + let(:record) { build(:sales_log, saledate: log_date) } + let(:log_date) { Time.zone.local(2023, 4, 1) } - describe "household member validations" do - let(:record) { build(:sales_log) } - + describe "#validate_partner_count" do it "validates that only 1 partner exists" do record.relat2 = "P" record.relat3 = "P" - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_partner_count(record) expect(record.errors["relat2"]) .to include(match I18n.t("validations.household.relat.one_partner")) expect(record.errors["relat3"]) @@ -22,33 +22,95 @@ RSpec.describe Validations::Sales::HouseholdValidations do it "expects that a tenant can have a partner" do record.relat3 = "P" - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_partner_count(record) expect(record.errors["base"]).to be_empty end + end - context "when the household contains a person under 16" do - it "expects that person is a child of the tenant" do - record.age2 = 14 + describe "#validate_person_age_matches_relationship" do + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + + context "when the household contains a person under 16" do + it "expects that person is a child of the tenant" do + record.age2 = 14 + record.relat2 = "C" + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "validates that a person under 16 must not be a partner of the buyer" do + record.age2 = 14 + record.relat2 = "P" + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.child_under_16_sales", person_num: 2)) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.child_under_16_relat_sales", person_num: 2)) + end + end + + it "validates that a person over 20 must not be a child of the buyer" do + record.age2 = 21 record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]).to be_empty - expect(record.errors["age2"]).to be_empty + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.child_over_20")) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.child_over_20")) end + end - it "validates that a person under 16 must not be a partner of the buyer" do + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + + it "does not add error if person under 16 is a partner" do record.age2 = 14 record.relat2 = "P" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.child_under_16_sales", person_num: 2)) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_under_16_relat_sales", person_num: 2)) + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["age2"]).to be_empty end + it "does not add error if person over 19 is a child" do + record.age2 = 20 + record.relat2 = "C" + household_validator.validate_person_age_matches_relationship(record) + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty + end + end + end + + describe "#validate_person_age_matches_economic_status" do + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + it "validates that person's economic status must be Child" do record.age2 = 14 record.ecstat2 = 1 - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]) .to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) expect(record.errors["age2"]) @@ -58,7 +120,7 @@ RSpec.describe Validations::Sales::HouseholdValidations do it "expects that person's economic status is Child" do record.age2 = 14 record.ecstat2 = 9 - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]).to be_empty expect(record.errors["age2"]).to be_empty end @@ -66,18 +128,48 @@ RSpec.describe Validations::Sales::HouseholdValidations do it "validates that a person with economic status 'child' must be under 16" do record.age2 = 21 record.ecstat2 = 9 - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]) .to include(match I18n.t("validations.household.ecstat.child_over_16", person_num: 2)) expect(record.errors["age2"]) .to include(match I18n.t("validations.household.age.child_over_16", person_num: 2)) end + end + + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + + it "does not run the validation" do + record.age2 = 14 + record.ecstat2 = 1 + household_validator.validate_person_age_matches_economic_status(record) + expect(record.errors["ecstat2"]) + .not_to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) + expect(record.errors["age2"]) + .not_to include(match I18n.t("validations.household.age.child_under_16_ecstat", person_num: 2)) + end + end + end + + describe "#validate_child_12_years_younger" do + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } it "validates the child is at least 12 years younger than buyer 1" do record.age1 = 30 record.age2 = record.age1 - 11 record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_child_12_years_younger(record) expect(record.errors["age1"]) .to include(match I18n.t("validations.household.age.child_12_years_younger", person_num: 2)) expect(record.errors["age2"]) @@ -90,67 +182,136 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.age1 = 30 record.age2 = record.age1 - 12 record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) + household_validator.validate_child_12_years_younger(record) expect(record.errors["age1"]).to be_empty expect(record.errors["age2"]).to be_empty expect(record.errors["relate2"]).to be_empty end end - it "validates that a person over 20 must not be a child of the buyer" do - record.age2 = 21 - record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.child_over_20")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_over_20")) + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + + it "does not validate that child is at least 12 year younger than buyer" do + record.age1 = 20 + record.age2 = 17 + record.relat2 = "C" + household_validator.validate_child_12_years_younger(record) + expect(record.errors["age1"]).to be_empty + expect(record.errors["age2"]).to be_empty + expect(record.errors["relat2"]).to be_empty + end end + end - it "does not add an error for a person aged 16-19 who is a student but not a child of the buyer" do - record.age2 = 18 - record.ecstat2 = "7" - record.relat2 = "P" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]).to be_empty - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty + describe "#validate_person_age_and_relationship_matches_economic_status" do + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) end - it "does not add an error for a person not aged 16-19 who is a student but not a child of the buyer" do - record.age2 = 20 - record.ecstat2 = "7" - record.relat2 = "P" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]).to be_empty - expect(record.errors["ecstat2"]).to be_empty - expect(record.errors["age2"]).to be_empty + after do + Timecop.return + Singleton.__init__(FormHandler) end - it "adds errors for a person aged 16-19 who is a child of the buyer but not a student" do - record.age2 = 17 - record.ecstat2 = "1" - record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student")) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.student_16_19.must_be_student")) + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + + it "does not add an error for a person aged 16-19 who is a student but not a child of the buyer" do + record.age2 = 18 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "does not add an error for a person not aged 16-19 who is a student but not a child of the buyer" do + record.age2 = 20 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "adds errors for a person aged 16-19 who is a child of the buyer but not a student" do + record.age2 = 17 + record.ecstat2 = "1" + record.relat2 = "C" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student")) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student")) + expect(record.errors["ecstat2"]) + .to include(match I18n.t("validations.household.ecstat.student_16_19.must_be_student")) + end + + it "adds errors for a person who is a child of the buyer and a student but not aged 16-19" do + record.age2 = 14 + record.ecstat2 = "7" + record.relat2 = "C" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]) + .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19")) + expect(record.errors["age2"]) + .to include(match I18n.t("validations.household.age.student_16_19.must_be_16_19")) + expect(record.errors["ecstat2"]) + .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) + end end - it "adds errors for a person who is a child of the buyer and a student but not aged 16-19" do - record.age2 = 14 - record.ecstat2 = "7" - record.relat2 = "C" - household_validator.validate_household_number_of_other_members(record) - expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.student_16_19.must_be_16_19")) - expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + + context "when the household contains a tenant’s child between the ages of 16 and 19" do + it "does not add an error" do + record.age2 = 17 + record.relat2 = "C" + record.ecstat2 = 1 + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["ecstat2"]) + .to be_empty + expect(record.errors["age2"]) + .to be_empty + expect(record.errors["relat2"]) + .to be_empty + end + end + + it "does not add an error for a person not aged 16-19 who is a student but not a child of the buyer" do + record.age2 = 20 + record.ecstat2 = "7" + record.relat2 = "P" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "does not add errors" do + record.age2 = 14 + record.ecstat2 = "7" + record.relat2 = "C" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end + + it "does not add errors for a person who is a student and aged 16-19 but not child" do + record.age2 = 17 + record.ecstat2 = "7" + record.relat2 = "X" + household_validator.validate_person_age_and_relationship_matches_economic_status(record) + expect(record.errors["relat2"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + expect(record.errors["age2"]).to be_empty + end end end @@ -285,4 +446,55 @@ RSpec.describe Validations::Sales::HouseholdValidations do end end end + + describe "#validate_buyer_not_child" do + before do + Timecop.freeze(log_date) + Singleton.__init__(FormHandler) + end + + after do + Timecop.return + Singleton.__init__(FormHandler) + end + + context "with 2023 logs" do + let(:log_date) { Time.zone.local(2023, 4, 1) } + + it "does not add an error if either buyer is a child" do + record.jointpur = 1 + record.ecstat1 = 9 + record.ecstat2 = 9 + household_validator.validate_buyer_not_child(record) + expect(record.errors["ecstat1"]).to be_empty + expect(record.errors["ecstat2"]).to be_empty + end + end + + context "with 2024 logs" do + let(:log_date) { Time.zone.local(2024, 4, 1) } + + it "validates buyer 1 isn't a child" do + record.ecstat1 = 9 + household_validator.validate_buyer_not_child(record) + expect(record.errors["ecstat1"]) + .to include("Buyer 1 cannot have a working situation of child under 16") + end + + it "validates buyer 2 isn't a child" do + record.jointpur = 1 + record.ecstat2 = 9 + household_validator.validate_buyer_not_child(record) + expect(record.errors["ecstat2"]) + .to include("Buyer 2 cannot have a working situation of child under 16") + end + + it "allows person 2 to be a child" do + record.jointpur = 2 + record.ecstat2 = 9 + household_validator.validate_buyer_not_child(record) + expect(record.errors["ecstat2"]).to be_empty + end + end + end end diff --git a/spec/models/validations/shared_validations_spec.rb b/spec/models/validations/shared_validations_spec.rb index 2a154761b..97cb621cb 100644 --- a/spec/models/validations/shared_validations_spec.rb +++ b/spec/models/validations/shared_validations_spec.rb @@ -82,7 +82,7 @@ RSpec.describe Validations::SharedValidations do sales_log.jointpur = 1 sales_log.age2 = 130 shared_validator.validate_numeric_min_max(sales_log) - expect(sales_log.errors["age2"].first).to eq("Buyer 2’s age must be between 0 and 110") + expect(sales_log.errors["age2"].first).to eq("Buyer 2’s age must be between 16 and 110") end end end diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index f99052d99..939d90297 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -150,7 +150,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do field_42: "42", field_48: "41", - field_52: "20", + field_52: "17", field_56: "18", field_60: "16", field_64: "14", @@ -171,7 +171,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do field_47: "P", field_51: "C", - field_55: "X", + field_55: "C", field_59: "R", field_63: "C", field_67: "C", @@ -179,7 +179,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do field_46: "1", field_50: "2", - field_54: "6", + field_54: "7", field_58: "7", field_62: "8", field_66: "9", diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index c1014ecc3..93ab6d9da 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -974,13 +974,62 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do end end + describe "field_42" do # ecstat1 + context "when buyer 2 has no age but has ecstat as child" do + let(:attributes) { valid_attributes.merge({ field_38: nil, field_42: "9" }) } + + it "a custom validation is applied" do + validation_message = "Buyer 2 cannot have a working situation of child under 16" + expect(parser.errors[:field_42]).to include validation_message + end + end + + context "when buyer 2 is under 16" do + let(:attributes) { valid_attributes.merge({ field_38: "9" }) } + + it "a custom validation is applied" do + validation_message = "Buyer 2’s age must be between 16 and 110" + expect(parser.errors[:field_38]).to include validation_message + end + end + + context "when buyer 2 is over 16 but has ecstat as child" do + let(:attributes) { valid_attributes.merge({ field_38: "17", field_42: "9" }) } + + it "a custom validation is applied" do + validation_message = "Buyer 2's age cannot be 16 or over if their working situation is child under 16" + expect(parser.errors[:field_42]).to include validation_message + expect(parser.errors[:field_38]).to include validation_message + end + end + end + describe "field_35" do # ecstat1 - context "when buyer 1 is marked as a child" do - let(:attributes) { valid_attributes.merge({ field_35: "9" }) } + context "when buyer 1 has no age but has ecstat as child" do + let(:attributes) { valid_attributes.merge({ field_31: nil, field_35: "9" }) } + + it "a custom validation is applied" do + validation_message = "Buyer 1 cannot have a working situation of child under 16" + expect(parser.errors[:field_35]).to include validation_message + end + end + + context "when buyer 1 is under 16" do + let(:attributes) { valid_attributes.merge({ field_31: "9" }) } + + it "a custom validation is applied" do + validation_message = "Buyer 1’s age must be between 16 and 110" + expect(parser.errors[:field_31]).to include validation_message + end + end + + context "when buyer 1 is over 16 but has ecstat as child" do + let(:attributes) { valid_attributes.merge({ field_31: "17", field_35: "9" }) } it "a custom validation is applied" do - validation_message = "Buyer 1 cannot be a child under 16" + validation_message = "Buyer 1's age cannot be 16 or over if their working situation is child under 16" expect(parser.errors[:field_35]).to include validation_message + expect(parser.errors[:field_31]).to include validation_message end end end