From 433dda76802ccc5296bb4e89715a5ad480b86c5c Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 3 May 2023 10:28:26 +0100 Subject: [PATCH] Update validation message: net income --- .../lettings/pages/net_income_value_check.rb | 20 +++++++++++---- app/models/validations/soft_validations.rb | 4 +++ config/forms/2022_2023.json | 25 ++++++++++++------- config/locales/en.yml | 4 +-- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/app/models/form/lettings/pages/net_income_value_check.rb b/app/models/form/lettings/pages/net_income_value_check.rb index 7507026cc..f5ffd78c1 100644 --- a/app/models/form/lettings/pages/net_income_value_check.rb +++ b/app/models/form/lettings/pages/net_income_value_check.rb @@ -3,14 +3,13 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page super @id = "net_income_value_check" @depends_on = [{ "net_income_soft_validation_triggered?" => true }] - @title_text = { "translation" => "soft_validations.net_income.title_text" } - @informative_text = { - "translation" => "soft_validations.net_income.hint_text", + @title_text = { + "translation" => "soft_validations.net_income.title_text", "arguments" => [ { - "key" => "ecstat1", + "key" => "incfreq", "label" => true, - "i18n_template" => "ecstat1", + "i18n_template" => "incfreq", }, { "key" => "field_formatted_as_currency", @@ -19,6 +18,17 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page }, ], } + + @informative_text = { + "translation" => "soft_validations.net_income.hint_text", + "arguments" => [ + { + "key" => "net_income_higher_or_lower_text", + "label" => false, + "i18n_template" => "net_income_higher_or_lower_text", + }, + ], + } end def questions diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index bfede001a..303f525cd 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -93,6 +93,10 @@ module Validations::SoftValidations voiddate.present? && startdate.present? && voiddate.between?(startdate.to_date - TEN_YEARS_IN_DAYS, startdate.to_date - TWO_YEARS_IN_DAYS) end + def net_income_higher_or_lower_text + net_income_in_soft_max_range? ? "higher" : "lower" + end + private def details_known_or_lead_tenant?(tenant_number) diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index bde3c70d2..5a65e6f0e 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -7299,23 +7299,30 @@ } ], "title_text": { - "translation": "soft_validations.net_income.title_text" - }, - "informative_text": { - "translation": "soft_validations.net_income.hint_text", - "arguments": [ + "translation": "soft_validations.net_income.title_text", + "arguments" :[ { - "key": "ecstat1", + "key": "incfreq", "label": true, - "i18n_template": "ecstat1" + "i18n_template": "incfreq" }, { - "key": "earnings", - "label": true, + "key": "field_formatted_as_currency", + "arguments_for_key": "earnings", "i18n_template": "earnings" } ] }, + "informative_text": { + "translation": "soft_validations.net_income.hint_text", + "arguments": [ + { + "key": "net_income_higher_or_lower_text", + "label": false, + "i18n_template": "net_income_higher_or_lower_text" + } + ] + }, "questions": { "net_income_value_check": { "check_answer_label": "Net income confirmation", diff --git a/config/locales/en.yml b/config/locales/en.yml index dad51b10c..4989f3b70 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -518,8 +518,8 @@ en: soft_validations: net_income: - title_text: "Net income is outside the expected range based on the lead tenant’s working situation" - hint_text: "

You told us the lead tenant’s working situation is: %{ecstat1}.

The household income you have entered is %{earnings}.

" + title_text: "You told us the lead tenant’s income is %{earnings} %{incfreq}." + hint_text: "This is %{net_income_higher_or_lower_text} than we would expect for their working situation." in_soft_min_range: message: "Net income is lower than expected based on the lead tenant’s working situation. Are you sure this is correct?" in_soft_max_range: