From b4ecb2232fb367b076aab9e1bea2f1cf34b7ff59 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 16 Oct 2024 11:21:27 +0100 Subject: [PATCH] Extract income confirmation questions --- .../pages/buyer1_income_min_value_check.rb | 5 +++-- .../pages/buyer2_income_min_value_check.rb | 5 +++-- .../questions/buyer1_income_value_check.rb | 3 +-- .../questions/buyer2_income_value_check.rb | 3 +-- config/locales/en.yml | 4 ---- .../forms/2023/sales/soft_validations.en.yml | 17 +++++++++++++++-- .../forms/2024/sales/soft_validations.en.yml | 17 +++++++++++++++-- .../pages/buyer1_income_min_value_check_spec.rb | 3 ++- .../pages/buyer2_income_min_value_check_spec.rb | 3 ++- 9 files changed, 42 insertions(+), 18 deletions(-) diff --git a/app/models/form/sales/pages/buyer1_income_min_value_check.rb b/app/models/form/sales/pages/buyer1_income_min_value_check.rb index 2feb4f887..c7849d85c 100644 --- a/app/models/form/sales/pages/buyer1_income_min_value_check.rb +++ b/app/models/form/sales/pages/buyer1_income_min_value_check.rb @@ -6,8 +6,9 @@ class Form::Sales::Pages::Buyer1IncomeMinValueCheck < ::Form::Page "income1_under_soft_min?" => true, }, ] + @copy_key = "sales.soft_validations.income1_value_check" @title_text = { - "translation" => "soft_validations.income.under_soft_min_for_economic_status.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "field_formatted_as_currency", @@ -22,7 +23,7 @@ class Form::Sales::Pages::Buyer1IncomeMinValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.income.under_soft_min_for_economic_status.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/buyer2_income_min_value_check.rb b/app/models/form/sales/pages/buyer2_income_min_value_check.rb index adef17843..21b96482f 100644 --- a/app/models/form/sales/pages/buyer2_income_min_value_check.rb +++ b/app/models/form/sales/pages/buyer2_income_min_value_check.rb @@ -6,8 +6,9 @@ class Form::Sales::Pages::Buyer2IncomeMinValueCheck < ::Form::Page "income2_under_soft_min?" => true, }, ] + @copy_key = "sales.soft_validations.income2_value_check" @title_text = { - "translation" => "soft_validations.income.under_soft_min_for_economic_status.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "field_formatted_as_currency", @@ -22,7 +23,7 @@ class Form::Sales::Pages::Buyer2IncomeMinValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.income.under_soft_min_for_economic_status.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/questions/buyer1_income_value_check.rb b/app/models/form/sales/questions/buyer1_income_value_check.rb index 63e3b6478..410bd53d5 100644 --- a/app/models/form/sales/questions/buyer1_income_value_check.rb +++ b/app/models/form/sales/questions/buyer1_income_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question def initialize(id, hsh, page, check_answers_card_number:) super(id, hsh, page) @id = "income1_value_check" - @check_answer_label = "Buyer 1 income confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.income1_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/buyer2_income_value_check.rb b/app/models/form/sales/questions/buyer2_income_value_check.rb index 37b6cb380..6b0bab5c2 100644 --- a/app/models/form/sales/questions/buyer2_income_value_check.rb +++ b/app/models/form/sales/questions/buyer2_income_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2IncomeValueCheck < ::Form::Question def initialize(id, hsh, page, check_answers_card_number:) super(id, hsh, page) @id = "income2_value_check" - @check_answer_label = "Buyer 2 income confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.income2_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/config/locales/en.yml b/config/locales/en.yml index 7d5cf5460..5da3563bf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -712,10 +712,6 @@ en: message: "Net income is lower than expected based on the household’s working situation. Are you sure this is correct?" in_soft_max_range: message: "Net income is higher than expected based on the household’s working situation. Are you sure this is correct?" - income: - under_soft_min_for_economic_status: - title_text: "You told us income was %{income}." - hint_text: "This is less than we would expect for someone in this working situation." over_soft_max_for_la_buyer_1: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" over_soft_max_for_la_buyer_2: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" over_soft_max_for_la_combined: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?" diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml index ffb870e15..7f70746d2 100644 --- a/config/locales/forms/2023/sales/soft_validations.en.yml +++ b/config/locales/forms/2023/sales/soft_validations.en.yml @@ -19,7 +19,7 @@ en: title_text: "You told us this person is aged %{age} years and retired." informative_text: "The minimum expected retirement age in England is 66." old_persons_shared_ownership_value_check: - age_header: "" + page_header: "" check_answer_label: "Shared ownership confirmation" hint_text: "" question_text: "Are you sure this is correct?" @@ -27,4 +27,17 @@ en: joint_purchase: "You told us the buyers are using the Older Persons Shared Ownership scheme." not_joint_purchase: "You told us the buyer is using the Older Persons Shared Ownership scheme." informative_text: "At least one buyer must be aged 65 years and over to use this scheme." - + income1_value_check: + page_header: "" + check_answer_label: "Buyer 1 income confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us income was %{income}." + informative_text: "This is less than we would expect for someone in this working situation." + income2_value_check: + page_header: "" + check_answer_label: "Buyer 2 income confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us income was %{income}." + informative_text: "This is less than we would expect for someone in this working situation." diff --git a/config/locales/forms/2024/sales/soft_validations.en.yml b/config/locales/forms/2024/sales/soft_validations.en.yml index 6307b9242..fc5c933ea 100644 --- a/config/locales/forms/2024/sales/soft_validations.en.yml +++ b/config/locales/forms/2024/sales/soft_validations.en.yml @@ -19,7 +19,7 @@ en: title_text: "You told us this person is aged %{age} years and retired." informative_text: "The minimum expected retirement age in England is 66." old_persons_shared_ownership_value_check: - age_header: "" + page_header: "" check_answer_label: "Shared ownership confirmation" hint_text: "" question_text: "Are you sure this is correct?" @@ -27,4 +27,17 @@ en: joint_purchase: "You told us the buyers are using the Older Persons Shared Ownership scheme." not_joint_purchase: "You told us the buyer is using the Older Persons Shared Ownership scheme." informative_text: "At least one buyer must be aged 65 years and over to use this scheme." - + income1_value_check: + page_header: "" + check_answer_label: "Buyer 1 income confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us income was %{income}." + informative_text: "This is less than we would expect for someone in this working situation." + income2_value_check: + page_header: "" + check_answer_label: "Buyer 2 income confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us income was %{income}." + informative_text: "This is less than we would expect for someone in this working situation." diff --git a/spec/models/form/sales/pages/buyer1_income_min_value_check_spec.rb b/spec/models/form/sales/pages/buyer1_income_min_value_check_spec.rb index 1736daef7..79d61ce06 100644 --- a/spec/models/form/sales/pages/buyer1_income_min_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer1_income_min_value_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::Buyer1IncomeMinValueCheck, type: :model do let(:page_id) { "prefix_buyer_1_income_min_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/pages/buyer2_income_min_value_check_spec.rb b/spec/models/form/sales/pages/buyer2_income_min_value_check_spec.rb index 887dcab29..44b85ef9e 100644 --- a/spec/models/form/sales/pages/buyer2_income_min_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer2_income_min_value_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::Buyer2IncomeMinValueCheck, type: :model do let(:page_id) { "prefix_buyer_2_income_min_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection)