Browse Source

CLDC-4168: Add mortgage length known to question page

pull/3195/head
samyou-softwire 3 weeks ago
parent
commit
912e099c2d
  1. 3
      app/models/form/sales/pages/mortgage_length.rb
  2. 1
      app/models/form/sales/questions/mortgage_length.rb
  3. 24
      app/models/form/sales/questions/mortgage_length_known.rb
  4. 7
      config/locales/forms/2026/sales/sale_information.en.yml

3
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

1
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

24
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

7
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"

Loading…
Cancel
Save