From 912e099c2de7af09ed1060d4b356b7e585104339 Mon Sep 17 00:00:00 2001 From: samyou-softwire Date: Tue, 24 Feb 2026 14:28:13 +0000 Subject: [PATCH] CLDC-4168: Add mortgage length known to question page --- .../form/sales/pages/mortgage_length.rb | 3 ++- .../form/sales/questions/mortgage_length.rb | 1 + .../sales/questions/mortgage_length_known.rb | 24 +++++++++++++++++++ .../forms/2026/sales/sale_information.en.yml | 7 ++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 app/models/form/sales/questions/mortgage_length_known.rb diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb index dbc01a695..e80d68cff 100644 --- a/app/models/form/sales/pages/mortgage_length.rb +++ b/app/models/form/sales/pages/mortgage_length.rb @@ -9,7 +9,8 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page def questions @questions ||= [ + (Form::Sales::Questions::MortgageLengthKnown.new(nil, nil, self, ownershipsch: @ownershipsch) if form.start_year_2026_or_later?), Form::Sales::Questions::MortgageLength.new(nil, nil, self, ownershipsch: @ownershipsch), - ] + ].compact end end diff --git a/app/models/form/sales/questions/mortgage_length.rb b/app/models/form/sales/questions/mortgage_length.rb index 552b86f56..493deb11d 100644 --- a/app/models/form/sales/questions/mortgage_length.rb +++ b/app/models/form/sales/questions/mortgage_length.rb @@ -19,5 +19,6 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question 2023 => { 1 => 93, 2 => 106, 3 => 114 }, 2024 => { 1 => 94, 2 => 107, 3 => 114 }, 2025 => { 1 => 84, 2 => 108 }, + 2026 => { 1 => 84, 2 => 108 }, }.freeze end diff --git a/app/models/form/sales/questions/mortgage_length_known.rb b/app/models/form/sales/questions/mortgage_length_known.rb new file mode 100644 index 000000000..d2f7e1d0c --- /dev/null +++ b/app/models/form/sales/questions/mortgage_length_known.rb @@ -0,0 +1,24 @@ +class Form::Sales::Questions::MortgageLengthKnown < ::Form::Question + def initialize(id, hsh, page, ownershipsch:) + super(id, hsh, page) + @id = "mortgage_length_known" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @conditional_for = { "mortlen" => [0] } + @hidden_in_check_answers = { + "depends_on" => [ + { "mortgage_length_known" => 0 }, + ], + } + @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze + + QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = { + 2023 => { 1 => 93, 2 => 106, 3 => 114 }, + 2024 => { 1 => 94, 2 => 107, 3 => 114 }, + 2025 => { 1 => 84, 2 => 108 }, + 2026 => { 1 => 84, 2 => 108 }, + }.freeze +end diff --git a/config/locales/forms/2026/sales/sale_information.en.yml b/config/locales/forms/2026/sales/sale_information.en.yml index 1d71145e6..c74388ff0 100644 --- a/config/locales/forms/2026/sales/sale_information.en.yml +++ b/config/locales/forms/2026/sales/sale_information.en.yml @@ -204,6 +204,13 @@ en: hint_text: "You should round up to the nearest year. Value should not exceed 60 years." question_text: "What is the length of the mortgage?" + mortgage_length_known: + page_header: "" + check_answer_label: "Length of mortgage known" + check_answer_prompt: "" + hint_text: "" + question_text: "Do you know the length of the mortgage?" + extrabor: page_header: "" check_answer_label: "Any other borrowing"