diff --git a/app/models/form/lettings/pages/tenancyother_value_check.rb b/app/models/form/lettings/pages/tenancyother_value_check.rb new file mode 100644 index 000000000..e350da85c --- /dev/null +++ b/app/models/form/lettings/pages/tenancyother_value_check.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Pages::TenancyotherValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "tenancyother_value_check" + @copy_key = "lettings.soft_validations.tenancyother_value_check" + @depends_on = [{ "tenancyother_might_be_introductory_or_starter_period?" => true }] + @title_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [{ "key" => "tenancyother", "i18n_template" => "tenancyother" }], + } + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::TenancyotherValueCheck.new(nil, nil, self)] + end + + def interruption_screen_question_ids + %w[tenancy tenancyother] + end +end diff --git a/app/models/form/lettings/questions/tenancyother_value_check.rb b/app/models/form/lettings/questions/tenancyother_value_check.rb new file mode 100644 index 000000000..309de7169 --- /dev/null +++ b/app/models/form/lettings/questions/tenancyother_value_check.rb @@ -0,0 +1,13 @@ +class Form::Lettings::Questions::TenancyotherValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancyother_value_check" + @copy_key = "lettings.soft_validations.tenancyother_value_check" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "tenancyother_value_check" => 0 }, { "tenancyother_value_check" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/subsections/tenancy_information.rb b/app/models/form/lettings/subsections/tenancy_information.rb index b65039b8d..51c58fec5 100644 --- a/app/models/form/lettings/subsections/tenancy_information.rb +++ b/app/models/form/lettings/subsections/tenancy_information.rb @@ -13,6 +13,7 @@ class Form::Lettings::Subsections::TenancyInformation < ::Form::Subsection Form::Lettings::Pages::TenancyType.new(nil, nil, self), Form::Lettings::Pages::StarterTenancyType.new(nil, nil, self), Form::Lettings::Pages::TenancyLength.new(nil, nil, self), + (Form::Lettings::Pages::TenancyotherValueCheck.new(nil, nil, self) if form.start_year_2026_or_later?), Form::Lettings::Pages::TenancyLengthAffordableRent.new(nil, nil, self), Form::Lettings::Pages::TenancyLengthIntermediateRent.new(nil, nil, self), (Form::Lettings::Pages::TenancyLengthPeriodic.new(nil, nil, self) if form.start_year_2024_or_later?), diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 35436dc32..536101062 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -208,6 +208,16 @@ module Validations::SoftValidations PHRASES_LIKELY_TO_INDICATE_EXISTING_REASON_CATEGORY_REGEX.match?(reasonother) end + PHRASES_LIKELY_TO_INDICATE_INTRODUCTORY_OR_STARTER_PERIOD = %w[introductory intro starter].freeze + + PHRASES_LIKELY_TO_INDICATE_INTRODUCTORY_OR_STARTER_PERIOD_REGEX = Regexp.union( + PHRASES_LIKELY_TO_INDICATE_INTRODUCTORY_OR_STARTER_PERIOD.map { |phrase| Regexp.new("\\b[^[:alpha]]*#{phrase}[^[:alpha:]]*\\b", Regexp::IGNORECASE) }, + ) + + def tenancyother_might_be_introductory_or_starter_period? + PHRASES_LIKELY_TO_INDICATE_INTRODUCTORY_OR_STARTER_PERIOD_REGEX.match?(tenancyother) + end + def multiple_partners? return unless hhmemb diff --git a/config/locales/forms/2026/lettings/soft_validations.en.yml b/config/locales/forms/2026/lettings/soft_validations.en.yml index 5a1d7d1a3..9007360ac 100644 --- a/config/locales/forms/2026/lettings/soft_validations.en.yml +++ b/config/locales/forms/2026/lettings/soft_validations.en.yml @@ -57,6 +57,25 @@ en: title_text: "You told us that the tenant’s main reason for leaving their last settled home was %{reasonother}." informative_text: "The reason you have entered looks very similar to one of the existing response categories. Please check the categories and select the appropriate one. If the existing categories are not suitable, please confirm here to move onto the next question." + tenancyother_value_check: + page_header: "" + check_answer_label: "Tenancy other confirmation" + check_answer_prompt: "Confirm tenancy type" + hint_text: "" + question_text: "" + title_text: "You told us that the type of tenancy was %{tenancyother}." + informative_text: "Give the type of tenancy that the tenants rolls onto after any introductory or starter period." + + + referral_value_check: + page_header: "" + check_answer_label: "Referral confirmation" + check_answer_prompt: "Confirm referral type" + hint_text: "" + question_text: "Are you sure?" + title_text: "Are you sure?" + informative_text: "This is a general needs log, and this referral type is for supported housing." + net_income_value_check: page_header: "" check_answer_label: "Net income confirmation" diff --git a/db/migrate/20260212091506_add_tenancyother_value_check_to_lettings_logs.rb b/db/migrate/20260212091506_add_tenancyother_value_check_to_lettings_logs.rb new file mode 100644 index 000000000..339dc7a07 --- /dev/null +++ b/db/migrate/20260212091506_add_tenancyother_value_check_to_lettings_logs.rb @@ -0,0 +1,5 @@ +class AddTenancyotherValueCheckToLettingsLogs < ActiveRecord::Migration[7.0] + def change + add_column :lettings_logs, :tenancyother_value_check, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 19faeed2a..62d32713f 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.2].define(version: 2026_02_04_100051) do +ActiveRecord::Schema[7.2].define(version: 2026_02_12_091506) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -403,6 +403,7 @@ ActiveRecord::Schema[7.2].define(version: 2026_02_04_100051) do t.integer "referral_register" t.integer "referral_noms" t.integer "referral_org" + t.integer "tenancyother_value_check" t.index ["assigned_to_id"], name: "index_lettings_logs_on_assigned_to_id" 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"