diff --git a/app/models/form/sales/pages/combined_income_max_value_check.rb b/app/models/form/sales/pages/combined_income_max_value_check.rb new file mode 100644 index 000000000..ae26ab4a8 --- /dev/null +++ b/app/models/form/sales/pages/combined_income_max_value_check.rb @@ -0,0 +1,28 @@ +class Form::Sales::Pages::CombinedIncomeMaxValueCheck < ::Form::Page + def initialize(id, hsh, subsection, buyer_index:) + super(id, hsh, subsection) + @depends_on = [ + { + "combined_income_over_soft_max?" => true, + }, + ] + @title_text = { + "translation" => "soft_validations.income.over_soft_max_for_la_combined", + "arguments" => [ + { + "key" => "field_formatted_as_currency", + "arguments_for_key" => "combined_income", + "i18n_template" => "combined_income", + } + ], + } + @informative_text = {} + @buyer_index = buyer_index + end + + def questions + @questions ||= [ + Form::Sales::Questions::CombinedIncomeValueCheck.new(nil, nil, self, buyer_index: @buyer_index), + ] + end +end diff --git a/app/models/form/sales/questions/combined_income_value_check.rb b/app/models/form/sales/questions/combined_income_value_check.rb new file mode 100644 index 000000000..b824e770d --- /dev/null +++ b/app/models/form/sales/questions/combined_income_value_check.rb @@ -0,0 +1,25 @@ +class Form::Sales::Questions::CombinedIncomeValueCheck < ::Form::Question + def initialize(id, hsh, page, buyer_index:) + super(id, hsh, page) + @id = "combined_income_value_check" + @check_answer_label = "Combined income confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "combined_income_value_check" => 0, + }, + { + "combined_income_value_check" => 1, + }, + ], + } + @check_answers_card_number = buyer_index + @page = page + end +end diff --git a/app/models/form/sales/subsections/income_benefits_and_savings.rb b/app/models/form/sales/subsections/income_benefits_and_savings.rb index e2728b6e2..b52c444d3 100644 --- a/app/models/form/sales/subsections/income_benefits_and_savings.rb +++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb @@ -11,6 +11,7 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection Form::Sales::Pages::Buyer1Income.new(nil, nil, self), Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("buyer_1_income_min_value_check", nil, self), Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("buyer_1_income_max_value_check", nil, self), + Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_1_combined_income_max_value_check", nil, self, buyer_index: 1), Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self, 1), Form::Sales::Pages::Buyer1Mortgage.new(nil, nil, self), Form::Sales::Pages::MortgageValueCheck.new("buyer_1_mortgage_value_check", nil, self, 1), @@ -18,6 +19,7 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self, 2), Form::Sales::Pages::Buyer2IncomeMinValueCheck.new("buyer_2_income_min_value_check", nil, self), Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("buyer_2_income_max_value_check", nil, self), + Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_2_combined_income_max_value_check", nil, self, buyer_index: 2), Form::Sales::Pages::Buyer2Mortgage.new(nil, nil, self), Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2), Form::Sales::Pages::HousingBenefits.new("housing_benefits_joint_purchase", nil, self, joint_purchase: true), diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 1cfa91acb..16d15094c 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -357,4 +357,8 @@ class SalesLog < Log def beds_for_la_sale_range beds.nil? ? nil : [beds, LaSaleRange::MAX_BEDS].min end + + def combined_income + income1 + income2 + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index ee59fa7ac..1b43605cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -506,7 +506,7 @@ en: income: under_soft_min_for_economic_status: "You said income was %{income}, which is below this working situation's minimum (%{minimum})" over_soft_max_for_la: "You told us the income of this buyer is %{income}, which seems high." - over_soft_max_for_la_combined: "You told us the income of this household is %{income}, which seems high." + over_soft_max_for_la_combined: "You told us the income of this household is %{combined_income}, which seems high." rent: outside_range_title: "You told us the rent is %{brent}" min_hint_text: "The minimum rent expected for this type of property in this local authority is £%{soft_min_for_period}." diff --git a/db/migrate/20230405132300_add_combined_income_value_check_to_sales_log.rb b/db/migrate/20230405132300_add_combined_income_value_check_to_sales_log.rb new file mode 100644 index 000000000..bdf052288 --- /dev/null +++ b/db/migrate/20230405132300_add_combined_income_value_check_to_sales_log.rb @@ -0,0 +1,5 @@ +class AddCombinedIncomeValueCheckToSalesLog < ActiveRecord::Migration[7.0] + def change + add_column :sales_logs, :combined_income_value_check, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 225129dfd..016e953bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_20_084057) do +ActiveRecord::Schema[7.0].define(version: 2023_04_05_132300) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -571,6 +571,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_20_084057) do t.integer "nationalbuy2" t.integer "discounted_sale_value_check" t.integer "student_not_child_value_check" + t.integer "combined_income_value_check" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["old_id"], name: "index_sales_logs_on_old_id", unique: true