diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb index 774f9828c..6351a712b 100644 --- a/app/models/validations/date_validations.rb +++ b/app/models/validations/date_validations.rb @@ -9,8 +9,8 @@ module Validations::DateValidations record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.not_first_let") end - if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 730 - record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.730_days_before_tenancy_start") + if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650 + record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start") end end diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 686c69174..dd3e94b2e 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -62,6 +62,17 @@ module Validations::SoftValidations end end + TWO_YEARS_IN_DAYS = 730 + TEN_YEARS_IN_DAYS = 3650 + + def major_repairs_date_in_soft_range? + mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS) + end + + def voiddate_in_soft_range? + voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS) + end + private def details_known_or_lead_tenant?(tenant_number) diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 96811487f..a0d75c0bb 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -209,6 +209,8 @@ module Imports # Soft validations can become required answers, set them to yes by default attributes["pregnancy_value_check"] = 0 + attributes["major_repairs_date_value_check"] = 0 + attributes["void_date_value_check"] = 0 attributes["retirement_value_check"] = 0 attributes["rent_value_check"] = 0 attributes["net_income_value_check"] = 0 @@ -273,7 +275,7 @@ module Imports end def fields_not_present_in_softwire_data - %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check] + %w[majorrepairs illness_type_0 tshortfall_known pregnancy_value_check retirement_value_check rent_value_check net_income_value_check major_repairs_date_value_check void_date_value_check] end def check_status_completed(case_log, previous_status) diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index ffbdc0887..d365a5a8f 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -771,6 +771,38 @@ } ] }, + "void_date_value_check": { + "depends_on": [{ "voiddate_in_soft_range?": true }], + "title_text": { + "translation": "soft_validations.void_date.title_text" + }, + "informative_text": {}, + "questions": { + "void_date_value_check": { + "check_answer_label": "Void date confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "void_date_value_check": 0 + }, + { + "void_date_value_check": 1 + } + ] + }, + "header": "Are you sure the time between these dates is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + } + }, "new_build_handover_date": { "header": "", "description": "", @@ -867,6 +899,38 @@ "rsnvac": 19 } ] + }, + "property_major_repairs_value_check": { + "depends_on": [{ "major_repairs_date_in_soft_range?": true }], + "title_text": { + "translation": "soft_validations.major_repairs_date.title_text" + }, + "informative_text": {}, + "questions": { + "major_repairs_date_value_check": { + "check_answer_label": "Major repairs date confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "major_repairs_date_value_check": 0 + }, + { + "major_repairs_date_value_check": 1 + } + ] + }, + "header": "Are you sure the time between these dates is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + } } } }, @@ -1722,8 +1786,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -1768,8 +1841,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -2216,8 +2298,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -2262,8 +2353,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -2707,8 +2807,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -2753,8 +2862,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -3195,8 +3313,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -3241,8 +3368,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -3680,8 +3816,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -3726,8 +3871,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -4162,8 +4316,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -4208,8 +4371,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -4641,8 +4813,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -4687,8 +4868,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -5117,8 +5307,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -5163,8 +5362,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -5381,8 +5589,16 @@ }, "questions": { "pregnancy_value_check": { - "check_answer_label": "Pregnancy soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Pregnancy confirmation", + "hidden_in_check_answers": { + "depends_on": [{ + "pregnancy_value_check": 0 + }, + { + "pregnancy_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { @@ -6875,8 +7091,17 @@ }, "questions": { "net_income_value_check": { - "check_answer_label": "Net income soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Net income confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "net_income_value_check": 0 + }, + { + "net_income_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { @@ -7779,8 +8004,17 @@ }, "questions": { "rent_value_check": { - "check_answer_label": "Rent soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Total rent confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "rent_value_check": 0 + }, + { + "rent_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { @@ -7823,8 +8057,17 @@ }, "questions": { "rent_value_check": { - "check_answer_label": "Rent soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Total rent confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "rent_value_check": 0 + }, + { + "rent_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index 7735e5ad9..0e737c43e 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -771,6 +771,38 @@ } ] }, + "void_date_value_check": { + "depends_on": [{ "voiddate_in_soft_range?": true }], + "title_text": { + "translation": "soft_validations.void_date.title_text" + }, + "informative_text": {}, + "questions": { + "void_date_value_check": { + "check_answer_label": "Void date confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "void_date_value_check": 0 + }, + { + "void_date_value_check": 1 + } + ] + }, + "header": "Are you sure the time between these dates is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + } + }, "new_build_handover_date": { "header": "", "description": "", @@ -867,6 +899,38 @@ "rsnvac": 19 } ] + }, + "property_major_repairs_value_check": { + "depends_on": [{ "major_repairs_date_in_soft_range?": true }], + "title_text": { + "translation": "soft_validations.major_repairs_date.title_text" + }, + "informative_text": {}, + "questions": { + "major_repairs_date_value_check": { + "check_answer_label": "Major repairs date confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "major_repairs_date_value_check": 0 + }, + { + "major_repairs_date_value_check": 1 + } + ] + }, + "header": "Are you sure the time between these dates is correct?", + "type": "interruption_screen", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + } } } }, @@ -1709,8 +1773,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -1753,8 +1826,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -2201,8 +2283,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -2247,8 +2338,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -2692,8 +2792,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -2738,8 +2847,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -3180,8 +3298,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -3226,8 +3353,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -3665,8 +3801,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -3711,8 +3856,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -4147,8 +4301,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -4193,8 +4356,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -4626,8 +4798,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -4672,8 +4853,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -5102,8 +5292,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person is retired?", "type": "interruption_screen", "answer_options": { @@ -5148,8 +5347,17 @@ }, "questions": { "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Retirement confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "retirement_value_check": 0 + }, + { + "retirement_value_check": 1 + } + ] + }, "header": "Are you sure this person isn’t retired?", "type": "interruption_screen", "answer_options": { @@ -5369,8 +5577,16 @@ }, "questions": { "pregnancy_value_check": { - "check_answer_label": "Pregnancy soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Pregnancy confirmation", + "hidden_in_check_answers": { + "depends_on": [{ + "pregnancy_value_check": 0 + }, + { + "pregnancy_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { @@ -6818,8 +7034,17 @@ }, "questions": { "net_income_value_check": { - "check_answer_label": "Net income soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Net income confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "net_income_value_check": 0 + }, + { + "net_income_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { @@ -7719,8 +7944,17 @@ }, "questions": { "rent_value_check": { - "check_answer_label": "Rent soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Total rent confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "rent_value_check": 0 + }, + { + "rent_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { @@ -7763,8 +7997,17 @@ }, "questions": { "rent_value_check": { - "check_answer_label": "Rent soft validation", - "hidden_in_check_answers": true, + "check_answer_label": "Total rent confirmation", + "hidden_in_check_answers": { + "depends_on": [ + { + "rent_value_check": 0 + }, + { + "rent_value_check": 1 + } + ] + }, "header": "Are you sure this is correct?", "type": "interruption_screen", "answer_options": { diff --git a/config/locales/en.yml b/config/locales/en.yml index 56b70d397..107558f3c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -122,7 +122,7 @@ en: mrcdate: before_tenancy_start: "Enter a major repairs date that is before the tenancy start date" not_first_let: "Major repairs date must not be completed if the tenancy is a first let" - 730_days_before_tenancy_start: "Enter a major repairs completion date that is no more than 730 days before the tenancy start date" + ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date" void_date: ten_years_before_tenancy_start: "Enter a void date must no more than 10 years before the tenancy start date" before_tenancy_start: "Enter a void date must that is before the tenancy start date" @@ -319,6 +319,10 @@ en: title: "You told us somebody in the household is pregnant" no_females: "You also told us there are no female tenants living at the property." females_not_in_soft_age_range: "You also told us that any female tenants living at the property are in the following age ranges:" + major_repairs_date: + title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 2 years" + void_date: + title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years" devise: two_factor_authentication: diff --git a/db/migrate/20220808090330_add_major_repairs_date_value_check.rb b/db/migrate/20220808090330_add_major_repairs_date_value_check.rb new file mode 100644 index 000000000..e1e666b65 --- /dev/null +++ b/db/migrate/20220808090330_add_major_repairs_date_value_check.rb @@ -0,0 +1,5 @@ +class AddMajorRepairsDateValueCheck < ActiveRecord::Migration[7.0] + def change + add_column :case_logs, :major_repairs_date_value_check, :integer + end +end diff --git a/db/migrate/20220808093035_add_void_date_value_check.rb b/db/migrate/20220808093035_add_void_date_value_check.rb new file mode 100644 index 000000000..c39a4d02b --- /dev/null +++ b/db/migrate/20220808093035_add_void_date_value_check.rb @@ -0,0 +1,5 @@ +class AddVoidDateValueCheck < ActiveRecord::Migration[7.0] + def change + add_column :case_logs, :void_date_value_check, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 1b65e5482..206fc69b0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -200,6 +200,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_10_152340) do t.integer "vacdays" t.bigint "scheme_id" t.bigint "location_id" + t.integer "major_repairs_date_value_check" + t.integer "void_date_value_check" t.index ["created_by_id"], name: "index_case_logs_on_created_by_id" t.index ["location_id"], name: "index_case_logs_on_location_id" t.index ["managing_organisation_id"], name: "index_case_logs_on_managing_organisation_id" diff --git a/spec/factories/case_log.rb b/spec/factories/case_log.rb index ec2d2c522..46c151fd2 100644 --- a/spec/factories/case_log.rb +++ b/spec/factories/case_log.rb @@ -110,6 +110,8 @@ FactoryBot.define do rp_dontknow { 0 } tenancyother { nil } net_income_value_check { nil } + void_date_value_check { 1 } + major_repairs_date_value_check { 1 } net_income_known { 0 } previous_la_known { 1 } property_owner_organisation { "Test" } diff --git a/spec/fixtures/files/case_logs_download.csv b/spec/fixtures/files/case_logs_download.csv index 5f5a1c96f..b1d71dfec 100644 --- a/spec/fixtures/files/case_logs_download.csv +++ b/spec/fixtures/files/case_logs_download.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,6,DLUHC,DLUHC,Danny Rojas +id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,net_income_value_check,property_owner_organisation,property_manager_organisation,sale_or_letting,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,needstype,lettype,postcode_known,is_la_inferred,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,previous_la_known,is_previous_la_inferred,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,ethnic_other,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,rent_type,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,retirement_value_check,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,,Supported housing,,,No,0,0,0,,0,,,,,,,,,,,,,,No,,,,,,,,,,,,,,,,,,,,0,,,,,,,,0,,,,,,,,,,,,,,,,,,,,,,9,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas diff --git a/spec/fixtures/files/case_logs_download_non_support.csv b/spec/fixtures/files/case_logs_download_non_support.csv index 9bcd0e6aa..0c24699c0 100644 --- a/spec/fixtures/files/case_logs_download_non_support.csv +++ b/spec/fixtures/files/case_logs_download_non_support.csv @@ -1,2 +1,2 @@ -id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name -{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,6,DLUHC,DLUHC,Danny Rojas +id,status,created_at,updated_at,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,irproduct_other,purchaser_code,reason,propcode,majorrepairs,la,prevloc,hb,hbrentshortfall,property_relet,mrcdate,incref,sale_completion_date,startdate,armedforces,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,declaration,ppcodenk,ethnic_group,ethnic_other,has_benefits,renewal,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,scheme_id,location_id,major_repairs_date_value_check,void_date_value_check,unittype_sh,owning_organisation_name,managing_organisation_name,created_by_name +{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,,,,,,,SE1 1TE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Westminster,,,,,,,,,,,,,,0,,,,,,,,,,,,,,0,,0,,,,,,,,,,,,,,,,{scheme_id},SE1 1TE,,,6,DLUHC,DLUHC,Danny Rojas diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb index ca09c28c8..3370f9cc0 100644 --- a/spec/models/validations/date_validations_spec.rb +++ b/spec/models/validations/date_validations_spec.rb @@ -85,17 +85,17 @@ RSpec.describe Validations::DateValidations do expect(record.errors["mrcdate"]).to be_empty end - it "cannot be more than 2 years before the tenancy start date" do + it "cannot be more than 10 years before the tenancy start date" do record.startdate = Time.zone.local(2022, 2, 1) - record.mrcdate = Time.zone.local(2020, 1, 1) + record.mrcdate = Time.zone.local(2012, 1, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.730_days_before_tenancy_start")) + .to include(match I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start")) end - it "must be within 2 years of the tenancy start date" do + it "must be within 10 years of the tenancy start date" do record.startdate = Time.zone.local(2022, 2, 1) - record.mrcdate = Time.zone.local(2020, 3, 1) + record.mrcdate = Time.zone.local(2012, 3, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]).to be_empty end diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index b28a53b9e..64d7ba2ab 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -205,4 +205,36 @@ RSpec.describe Validations::SoftValidations do end end end + + describe "major repairs date soft validations" do + context "when the major repairs date is within 10 years of the tenancy start date" do + it "shows the interruption screen" do + record.update!(startdate: Time.zone.local(2022, 2, 1), mrcdate: Time.zone.local(2013, 2, 1)) + expect(record.major_repairs_date_in_soft_range?).to be true + end + end + + context "when the major repairs date is less than 2 years before the tenancy start date" do + it "does not show the interruption screen" do + record.update!(startdate: Time.zone.local(2022, 2, 1), mrcdate: Time.zone.local(2021, 2, 1)) + expect(record.major_repairs_date_in_soft_range?).to be false + end + end + end + + describe "void date soft validations" do + context "when the void date is within 10 years of the tenancy start date" do + it "shows the interruption screen" do + record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2013, 2, 1)) + expect(record.voiddate_in_soft_range?).to be true + end + end + + context "when the void date is less than 2 years before the tenancy start date" do + it "does not show the interruption screen" do + record.update!(startdate: Time.zone.local(2022, 2, 1), voiddate: Time.zone.local(2021, 2, 1)) + expect(record.voiddate_in_soft_range?).to be false + end + end + end end