diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index ed90cbcd9..d1d3ff831 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -66,7 +66,7 @@ module Validations::SoftValidations mrcdate.present? && startdate.present? && mrcdate.between?(startdate.to_date - 3650, startdate.to_date - 730) end - def voiddate_date_in_soft_range? + def voiddate_in_soft_range? voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - 3650, startdate.to_date - 730) end diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 7170b5c39..a0d75c0bb 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -210,6 +210,7 @@ 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 @@ -274,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 4e1935d9f..2d1b8929b 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -771,6 +771,29 @@ } ] }, + "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 soft validation", + "hidden_in_check_answers": true, + "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": "", diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index edc7ce564..a9173462a 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -771,6 +771,29 @@ } ] }, + "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 soft validation", + "hidden_in_check_answers": true, + "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": "", diff --git a/config/locales/en.yml b/config/locales/en.yml index fdb243b5f..1ca470323 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -321,7 +321,8 @@ en: 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 730 days" - hint_text: "Are you sure the time between these dates is correct?" + void_date: + title_text: "You told us the time between the start of the tenancy and the void date is more than 730 days" devise: two_factor_authentication: 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 917b3f215..206fc69b0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -201,6 +201,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_08_10_152340) do 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/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index b38a34888..64d7ba2ab 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -226,14 +226,14 @@ RSpec.describe Validations::SoftValidations 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_date_in_soft_range?).to be true + 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_date_in_soft_range?).to be false + expect(record.voiddate_in_soft_range?).to be false end end end