Browse Source

feat: combined income value check

pull/1518/head
natdeanlewissoftwire 3 years ago
parent
commit
f68c67125b
  1. 28
      app/models/form/sales/pages/combined_income_max_value_check.rb
  2. 25
      app/models/form/sales/questions/combined_income_value_check.rb
  3. 2
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  4. 4
      app/models/sales_log.rb
  5. 2
      config/locales/en.yml
  6. 5
      db/migrate/20230405132300_add_combined_income_value_check_to_sales_log.rb
  7. 1
      db/schema.rb

28
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

25
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

2
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),

4
app/models/sales_log.rb

@ -349,4 +349,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

2
config/locales/en.yml

@ -511,7 +511,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}."

5
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

1
db/schema.rb

@ -572,6 +572,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_31_094840) 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

Loading…
Cancel
Save