From f089bccf74cc8df3dbbbaec3dd8e14aab3c136f7 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Fri, 27 Jan 2023 16:12:25 +0000 Subject: [PATCH] feat: wip add dynamic text for soft min only --- .../form/sales/pages/buyer1_income_value_check.rb | 15 +++++++++++++++ .../sales/questions/buyer1_income_value_check.rb | 2 +- app/models/sales_log.rb | 4 ++++ app/models/validations/sales/soft_validations.rb | 2 +- config/locales/en.yml | 1 + 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/models/form/sales/pages/buyer1_income_value_check.rb b/app/models/form/sales/pages/buyer1_income_value_check.rb index 04540c47f..818f34f37 100644 --- a/app/models/form/sales/pages/buyer1_income_value_check.rb +++ b/app/models/form/sales/pages/buyer1_income_value_check.rb @@ -6,6 +6,21 @@ class Form::Sales::Pages::Buyer1IncomeValueCheck < ::Form::Page "income1_under_soft_min?" => true, }, ] + @title_text = { + "translation" => "soft_validations.net_income.below_soft_min", + "arguments" => [ + { + "key" => "income1", + "label" => true, + "i18n_template" => "income1", + }, + { + "key" => "allowed_income_soft_min", + "label" => false, + "i18n_template" => "soft_min", + }, + ], + } @informative_text = {} 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 0913dd788..8843d6736 100644 --- a/app/models/form/sales/questions/buyer1_income_value_check.rb +++ b/app/models/form/sales/questions/buyer1_income_value_check.rb @@ -3,7 +3,7 @@ class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question super @id = "income1_value_check" @check_answer_label = "Income confirmation" - @header = "Are you sure this income is correct?" + @header = "Are you sure this is correct?" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index aa3eb1c09..7fdd623cd 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -211,4 +211,8 @@ class SalesLog < Log def old_persons_shared_ownership? type == 24 end + + def allowed_income_soft_min + ALLOWED_INCOME_RANGES[ecstat1].soft_min + end end diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 742e505a5..9439428b7 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -10,7 +10,7 @@ module Validations::Sales::SoftValidations def income1_under_soft_min? return false unless ecstat1 && income1 && ALLOWED_INCOME_RANGES[ecstat1] - income1 < ALLOWED_INCOME_RANGES[ecstat1][:soft_min] + income1 < ALLOWED_INCOME_RANGES[ecstat1] [:soft_min] end def mortgage_over_soft_max? diff --git a/config/locales/en.yml b/config/locales/en.yml index 7bb70cbe4..6407a4cc4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -434,6 +434,7 @@ en: 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: message: "Net income is higher than expected based on the lead tenant’s working situation. Are you sure this is correct?" + below_soft_min: "You said income was %{income1}, which is below this working situation's minimum (%{soft_min})" rent: min: title_text: "You told us the rent is %{brent}"