Browse Source

CLDC-3753: Update soft income validations

pull/2779/head
Rachael Booth 7 months ago
parent
commit
4680888d37
  1. 6
      app/models/form/sales/pages/buyer1_income_discounted_max_value_check.rb
  2. 33
      app/models/form/sales/pages/buyer1_income_ecstat_max_value_check.rb
  3. 6
      app/models/form/sales/pages/buyer2_income_discounted_max_value_check.rb
  4. 33
      app/models/form/sales/pages/buyer2_income_ecstat_max_value_check.rb
  5. 2
      app/models/form/sales/pages/combined_income_max_value_check.rb
  6. 2
      app/models/form/sales/subsections/household_characteristics.rb
  7. 6
      app/models/form/sales/subsections/income_benefits_and_savings.rb
  8. 8
      app/models/form/sales/subsections/property_information.rb
  9. 69
      app/models/validations/sales/soft_validations.rb
  10. 30
      config/locales/forms/2023/sales/soft_validations.en.yml
  11. 14
      config/locales/forms/2024/sales/soft_validations.en.yml
  12. 20
      config/locales/forms/2025/sales/soft_validations.en.yml
  13. 2
      spec/models/form/sales/pages/buyer1_income_discounted_max_value_check_spec.rb
  14. 2
      spec/models/form/sales/pages/buyer2_income_discounted_max_value_check_spec.rb
  15. 61
      spec/models/form/sales/subsections/household_characteristics_spec.rb
  16. 23
      spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

6
app/models/form/sales/pages/buyer1_income_max_value_check.rb → app/models/form/sales/pages/buyer1_income_discounted_max_value_check.rb

@ -1,12 +1,12 @@
class Form::Sales::Pages::Buyer1IncomeMaxValueCheck < ::Form::Page class Form::Sales::Pages::Buyer1IncomeDiscountedMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:) def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection) super(id, hsh, subsection)
@depends_on = [ @depends_on = [
{ {
"income1_over_soft_max?" => true, "income1_over_soft_max_for_discounted_ownership?" => true,
}, },
] ]
@copy_key = "sales.soft_validations.income1_value_check.max" @copy_key = "sales.soft_validations.income1_value_check.max.discounted"
@title_text = { @title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [

33
app/models/form/sales/pages/buyer1_income_ecstat_max_value_check.rb

@ -0,0 +1,33 @@
class Form::Sales::Pages::Buyer1IncomeEcstatMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection)
@depends_on = [
{
"income1_over_soft_max_for_ecstat?" => true,
},
]
@copy_key = "sales.soft_validations.income1_value_check.max.ecstat"
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "income1",
"i18n_template" => "income",
},
],
}
@informative_text = {}
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer1IncomeValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number),
]
end
def interruption_screen_question_ids
%w[ecstat1 income1]
end
end

6
app/models/form/sales/pages/buyer2_income_max_value_check.rb → app/models/form/sales/pages/buyer2_income_discounted_max_value_check.rb

@ -1,12 +1,12 @@
class Form::Sales::Pages::Buyer2IncomeMaxValueCheck < ::Form::Page class Form::Sales::Pages::Buyer2IncomeDiscountedMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:) def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection) super(id, hsh, subsection)
@depends_on = [ @depends_on = [
{ {
"income2_over_soft_max?" => true, "income2_over_soft_max_for_discounted_ownership?" => true,
}, },
] ]
@copy_key = "sales.soft_validations.income2_value_check.max" @copy_key = "sales.soft_validations.income2_value_check.max.discounted"
@title_text = { @title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [ "arguments" => [

33
app/models/form/sales/pages/buyer2_income_ecstat_max_value_check.rb

@ -0,0 +1,33 @@
class Form::Sales::Pages::Buyer2IncomeEcstatMaxValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number:)
super(id, hsh, subsection)
@depends_on = [
{
"income2_over_soft_max_for_ecstat?" => true,
},
]
@copy_key = "sales.soft_validations.income2_value_check.max.ecstat"
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "income2",
"i18n_template" => "income",
},
],
}
@informative_text = {}
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer2IncomeValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number),
]
end
def interruption_screen_question_ids
%w[ecstat2 income2]
end
end

2
app/models/form/sales/pages/combined_income_max_value_check.rb

@ -3,7 +3,7 @@ class Form::Sales::Pages::CombinedIncomeMaxValueCheck < ::Form::Page
super(id, hsh, subsection) super(id, hsh, subsection)
@depends_on = [ @depends_on = [
{ {
"combined_income_over_soft_max?" => true, "combined_income_over_soft_max_for_discounted_ownership?" => true,
}, },
] ]
@copy_key = "sales.soft_validations.combined_income_value_check" @copy_key = "sales.soft_validations.combined_income_value_check"

2
app/models/form/sales/subsections/household_characteristics.rb

@ -29,6 +29,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1), Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1),
(Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?), (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?),
Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self), Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self),
(Form::Sales::Pages::Buyer1IncomeEcstatMaxValueCheck.new("working_situation_buyer_1_income_max_value_check", nil, self, check_answers_card_number: 1) if form.start_year_2025_or_later?),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
@ -45,6 +46,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2),
(Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check_joint_purchase", nil, self, person_index: 2) if form.start_year_2024_or_later?), (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check_joint_purchase", nil, self, person_index: 2) if form.start_year_2024_or_later?),
Form::Sales::Pages::Buyer2IncomeMinValueCheck.new("working_situation_buyer_2_income_min_value_check", nil, self), Form::Sales::Pages::Buyer2IncomeMinValueCheck.new("working_situation_buyer_2_income_min_value_check", nil, self),
(Form::Sales::Pages::Buyer2IncomeEcstatMaxValueCheck.new("working_situation_buyer_2_income_max_value_check", nil, self, check_answers_card_number: 2) if form.start_year_2025_or_later?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_working_situation_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_working_situation_student_not_child_value_check", nil, self, person_index: 2),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_2_live_in_property_value_check", nil, self, person_index: 2), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_2_live_in_property_value_check", nil, self, person_index: 2),

6
app/models/form/sales/subsections/income_benefits_and_savings.rb

@ -10,7 +10,8 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
@pages ||= [ @pages ||= [
Form::Sales::Pages::Buyer1Income.new(nil, nil, self), Form::Sales::Pages::Buyer1Income.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("buyer_1_income_min_value_check", 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, check_answers_card_number: 1), (Form::Sales::Pages::Buyer1IncomeEcstatMaxValueCheck.new("buyer_1_income_ecstat_max_value_check", nil, self, check_answers_card_number: 1) if form.start_year_2025_or_later?),
Form::Sales::Pages::Buyer1IncomeDiscountedMaxValueCheck.new("buyer_1_income_discounted_max_value_check", nil, self, check_answers_card_number: 1),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_1_combined_income_max_value_check", nil, self, check_answers_card_number: 1), Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_1_combined_income_max_value_check", nil, self, check_answers_card_number: 1),
Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self, 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::Buyer1Mortgage.new(nil, nil, self),
@ -18,7 +19,8 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
Form::Sales::Pages::Buyer2Income.new(nil, nil, self), Form::Sales::Pages::Buyer2Income.new(nil, nil, self),
Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self, 2), 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::Buyer2IncomeMinValueCheck.new("buyer_2_income_min_value_check", nil, self),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("buyer_2_income_max_value_check", nil, self, check_answers_card_number: 2), (Form::Sales::Pages::Buyer2IncomeEcstatMaxValueCheck.new("buyer_2_income_ecstat_max_value_check", nil, self, check_answers_card_number: 2) if form.start_year_2025_or_later?),
Form::Sales::Pages::Buyer2IncomeDiscountedMaxValueCheck.new("buyer_2_income_discounted_max_value_check", nil, self, check_answers_card_number: 2),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_2_combined_income_max_value_check", nil, self, check_answers_card_number: 2), Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("buyer_2_combined_income_max_value_check", nil, self, check_answers_card_number: 2),
Form::Sales::Pages::Buyer2Mortgage.new(nil, nil, self), Form::Sales::Pages::Buyer2Mortgage.new(nil, nil, self),
Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2), Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2),

8
app/models/form/sales/subsections/property_information.rb

@ -31,8 +31,8 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::UprnSelection.new(nil, nil, self), Form::Sales::Pages::UprnSelection.new(nil, nil, self),
Form::Sales::Pages::AddressFallback.new(nil, nil, self), Form::Sales::Pages::AddressFallback.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil), Form::Sales::Pages::Buyer1IncomeDiscountedMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil), Form::Sales::Pages::Buyer2IncomeDiscountedMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil), Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self),
] ]
@ -42,8 +42,8 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::UprnConfirmation.new(nil, nil, self), Form::Sales::Pages::UprnConfirmation.new(nil, nil, self),
Form::Sales::Pages::Address.new(nil, nil, self), Form::Sales::Pages::Address.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil), Form::Sales::Pages::Buyer1IncomeDiscountedMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil), Form::Sales::Pages::Buyer2IncomeDiscountedMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil), Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self),
] ]

69
app/models/validations/sales/soft_validations.rb

@ -2,41 +2,59 @@ module Validations::Sales::SoftValidations
include Validations::Sales::SaleInformationValidations include Validations::Sales::SaleInformationValidations
ALLOWED_INCOME_RANGES_SALES = { ALLOWED_INCOME_RANGES_SALES = {
1 => OpenStruct.new(soft_min: 5000), 2024 => {
2 => OpenStruct.new(soft_min: 1500), 1 => OpenStruct.new(soft_min: 5000),
3 => OpenStruct.new(soft_min: 1000), 2 => OpenStruct.new(soft_min: 1500),
5 => OpenStruct.new(soft_min: 2000), 3 => OpenStruct.new(soft_min: 1000),
0 => OpenStruct.new(soft_min: 2000), 5 => OpenStruct.new(soft_min: 2000),
0 => OpenStruct.new(soft_min: 2000),
},
2025 => {
1 => OpenStruct.new(soft_min: 13_400, soft_max: 150_000),
2 => OpenStruct.new(soft_min: 2_600, soft_max: 80_000),
3 => OpenStruct.new(soft_min: 2_080, soft_max: 30_000),
4 => OpenStruct.new(soft_min: 520, soft_max: 23_400),
5 => OpenStruct.new(soft_min: 520, soft_max: 80_000),
6 => OpenStruct.new(soft_min: 520, soft_max: 50_000),
7 => OpenStruct.new(soft_min: 520, soft_max: 30_000),
8 => OpenStruct.new(soft_min: 520, soft_max: 150_000),
9 => OpenStruct.new(soft_min: 520, soft_max: 150_000),
0 => OpenStruct.new(soft_min: 520, soft_max: 150_000),
},
}.freeze }.freeze
def income1_under_soft_min? def income1_under_soft_min?
return false unless ecstat1 && income1 && ALLOWED_INCOME_RANGES_SALES[ecstat1] income_under_soft_min?(income1, ecstat1)
income1 < ALLOWED_INCOME_RANGES_SALES[ecstat1][:soft_min]
end end
def income2_under_soft_min? def income2_under_soft_min?
return false unless ecstat2 && income2 && ALLOWED_INCOME_RANGES_SALES[ecstat2] income_under_soft_min?(income2, ecstat2)
income2 < ALLOWED_INCOME_RANGES_SALES[ecstat2][:soft_min]
end end
def income1_over_soft_max? def income1_over_soft_max_for_discounted_ownership?
return unless income1 && la && discounted_ownership_sale? return unless income1 && la && discounted_ownership_sale?
income_over_soft_max?(income1) income_over_discounted_sale_soft_max?(income1)
end
def income1_over_soft_max_for_ecstat?
income_over_soft_max?(income1, ecstat1)
end end
def income2_over_soft_max? def income2_over_soft_max_for_discounted_ownership?
return unless income2 && la && discounted_ownership_sale? return unless income2 && la && discounted_ownership_sale?
income_over_soft_max?(income2) income_over_discounted_sale_soft_max?(income2)
end end
def combined_income_over_soft_max? def income2_over_soft_max_for_ecstat?
income_over_soft_max?(income2, ecstat2)
end
def combined_income_over_soft_max_for_discounted_ownership?
return unless income1 && income2 && la && discounted_ownership_sale? return unless income1 && income2 && la && discounted_ownership_sale?
income_over_soft_max?(income1 + income2) income_over_discounted_sale_soft_max?(income1 + income2)
end end
def staircase_bought_above_fifty? def staircase_bought_above_fifty?
@ -184,7 +202,22 @@ private
) )
end end
def income_over_soft_max?(income) def income_under_soft_min?(income, ecstat)
return unless income && ecstat
income_ranges = form.start_year_2025_or_later? ? ALLOWED_INCOME_RANGES_SALES[2025] : ALLOWED_INCOME_RANGES_SALES[2024]
return false unless income_ranges[ecstat]
income < income_ranges[ecstat][:soft_min]
end
def income_over_soft_max?(income, ecstat)
return unless income && ecstat && form.start_year_2025_or_later?
income > ALLOWED_INCOME_RANGES_SALES[2025][ecstat][:soft_max]
end
def income_over_discounted_sale_soft_max?(income)
(london_property? && income > 90_000) || (property_not_in_london? && income > 80_000) (london_property? && income > 90_000) || (property_not_in_london? && income > 80_000)
end end
end end

30
config/locales/forms/2023/sales/soft_validations.en.yml

@ -18,7 +18,7 @@ en:
question_text: "Are you sure this person is retired?" question_text: "Are you sure this person is retired?"
title_text: "You told us this person is aged %{age} years and retired." title_text: "You told us this person is aged %{age} years and retired."
informative_text: "The minimum expected retirement age in England is 66." informative_text: "The minimum expected retirement age in England is 66."
old_persons_shared_ownership_value_check: old_persons_shared_ownership_value_check:
page_header: "" page_header: ""
check_answer_label: "Shared ownership confirmation" check_answer_label: "Shared ownership confirmation"
@ -28,7 +28,7 @@ en:
joint_purchase: "You told us the buyers are using the Older Persons Shared Ownership scheme." 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." 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." informative_text: "At least one buyer must be aged 65 years and over to use this scheme."
income1_value_check: income1_value_check:
check_answer_label: "Buyer 1 income confirmation" check_answer_label: "Buyer 1 income confirmation"
hint_text: "" hint_text: ""
@ -38,9 +38,10 @@ en:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
informative_text: "This is less than we would expect for someone in this working situation." informative_text: "This is less than we would expect for someone in this working situation."
max: max:
page_header: "" discounted:
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" page_header: ""
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?"
income2_value_check: income2_value_check:
check_answer_label: "Buyer 2 income confirmation" check_answer_label: "Buyer 2 income confirmation"
hint_text: "" hint_text: ""
@ -50,8 +51,9 @@ en:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
informative_text: "This is less than we would expect for someone in this working situation." informative_text: "This is less than we would expect for someone in this working situation."
max: max:
page_header: "" discounted:
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" page_header: ""
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?"
combined_income_value_check: combined_income_value_check:
page_header: "" page_header: ""
@ -110,7 +112,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Are you sure?" question_text: "Are you sure?"
title_text: "You told us practical completion or handover date is more than 3 years before sale completion date." title_text: "You told us practical completion or handover date is more than 3 years before sale completion date."
value_value_check: value_value_check:
page_header: "" page_header: ""
check_answer_label: "Purchase price confirmation" check_answer_label: "Purchase price confirmation"
@ -141,14 +143,14 @@ en:
question_text: "Are you sure that the deposit is this much higher than the buyer's savings?" question_text: "Are you sure that the deposit is this much higher than the buyer's savings?"
title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}."
informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have."
wheel_value_check: wheel_value_check:
page_header: "" page_header: ""
check_answer_label: "Does anyone in the household use a wheelchair?" check_answer_label: "Does anyone in the household use a wheelchair?"
hint_text: "" hint_text: ""
question_text: "You told us that someone in the household uses a wheelchair." question_text: "You told us that someone in the household uses a wheelchair."
title_text: "You told us that someone in the household uses a wheelchair." title_text: "You told us that someone in the household uses a wheelchair."
buyer_livein_value_check: buyer_livein_value_check:
buyer1: buyer1:
page_header: "" page_header: ""
@ -164,7 +166,7 @@ en:
question_text: "Are you sure this is correct?" question_text: "Are you sure this is correct?"
title_text: "You told us that buyer 2 will not live in the property." title_text: "You told us that buyer 2 will not live in the property."
informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property." informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property."
student_not_child_value_check: student_not_child_value_check:
page_header: "" page_header: ""
check_answer_label: "Student not a child confirmation" check_answer_label: "Student not a child confirmation"
@ -172,7 +174,7 @@ en:
question_text: "Are you sure this person is not a child?" question_text: "Are you sure this person is not a child?"
title_text: "You told us this person is a student aged between 16 and 19." title_text: "You told us this person is a student aged between 16 and 19."
informative_text: "Are you sure this person is not a child?" informative_text: "Are you sure this person is not a child?"
partner_under_16_value_check: partner_under_16_value_check:
page_header: "" page_header: ""
check_answer_label: "Partner under 16 confirmation" check_answer_label: "Partner under 16 confirmation"
@ -180,7 +182,7 @@ en:
question_text: "Are you sure this is correct?" question_text: "Are you sure this is correct?"
title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1." title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1."
informative_text: "Are you sure this is correct?" informative_text: "Are you sure this is correct?"
multiple_partners_value_check: multiple_partners_value_check:
page_header: "" page_header: ""
check_answer_label: "Multiple partners confirmation" check_answer_label: "Multiple partners confirmation"
@ -196,7 +198,7 @@ en:
question_text: "Are you sure this is correct?" question_text: "Are you sure this is correct?"
title_text: "You told us that the monthly charges were %{mscharge}." title_text: "You told us that the monthly charges were %{mscharge}."
informative_text: "This is higher than we would expect." informative_text: "This is higher than we would expect."
extra_borrowing_value_check: extra_borrowing_value_check:
page_header: "" page_header: ""
check_answer_label: "Extra borrowing confirmation" check_answer_label: "Extra borrowing confirmation"

14
config/locales/forms/2024/sales/soft_validations.en.yml

@ -36,8 +36,9 @@ en:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
informative_text: "This is less than we would expect for someone in this working situation." informative_text: "This is less than we would expect for someone in this working situation."
max: max:
page_header: "" discounted:
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" page_header: ""
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?"
income2_value_check: income2_value_check:
check_answer_label: "Buyer 2 income confirmation" check_answer_label: "Buyer 2 income confirmation"
@ -48,8 +49,9 @@ en:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
informative_text: "This is less than we would expect for someone in this working situation." informative_text: "This is less than we would expect for someone in this working situation."
max: max:
page_header: "" discounted:
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" page_header: ""
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?"
combined_income_value_check: combined_income_value_check:
page_header: "" page_header: ""
@ -108,7 +110,7 @@ en:
hint_text: "" hint_text: ""
question_text: "Are you sure?" question_text: "Are you sure?"
title_text: "You told us practical completion or handover date is more than 3 years before sale completion date." title_text: "You told us practical completion or handover date is more than 3 years before sale completion date."
value_value_check: value_value_check:
page_header: "" page_header: ""
check_answer_label: "Purchase price confirmation" check_answer_label: "Purchase price confirmation"
@ -202,7 +204,7 @@ en:
question_text: "Are you sure this is correct?" question_text: "Are you sure this is correct?"
title_text: "You told us that the monthly charges were %{mscharge}." title_text: "You told us that the monthly charges were %{mscharge}."
informative_text: "This is higher than we would expect." informative_text: "This is higher than we would expect."
extra_borrowing_value_check: extra_borrowing_value_check:
page_header: "" page_header: ""
check_answer_label: "Extra borrowing confirmation" check_answer_label: "Extra borrowing confirmation"

20
config/locales/forms/2025/sales/soft_validations.en.yml

@ -36,8 +36,13 @@ en:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
informative_text: "This is less than we would expect for someone in this working situation." informative_text: "This is less than we would expect for someone in this working situation."
max: max:
page_header: "" discounted:
title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" page_header: ""
title_text: "You told us the income of buyer 1 is %{income}. This seems high for this sale type. Are you sure this is correct?"
ecstat:
page_header: ""
title_text: "You told us the income of buyer 1 is %{income}."
informative_text: "This is more than we would expect for someone in this working situation."
income2_value_check: income2_value_check:
check_answer_label: "Buyer 2 income confirmation" check_answer_label: "Buyer 2 income confirmation"
@ -48,15 +53,20 @@ en:
title_text: "You told us income was %{income}." title_text: "You told us income was %{income}."
informative_text: "This is less than we would expect for someone in this working situation." informative_text: "This is less than we would expect for someone in this working situation."
max: max:
page_header: "" discounted:
title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" page_header: ""
title_text: "You told us the income of buyer 2 is %{income}. This seems high for this sale type. Are you sure this is correct?"
ecstat:
page_header: ""
title_text: "You told us the income of buyer 2 is %{income}."
informative_text: "This is more than we would expect for someone in this working situation."
combined_income_value_check: combined_income_value_check:
page_header: "" page_header: ""
check_answer_label: "Combined income confirmation" check_answer_label: "Combined income confirmation"
hint_text: "" hint_text: ""
question_text: "Are you sure this is correct?" question_text: "Are you sure this is correct?"
title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?" title_text: "You told us the combined income of this household is %{combined_income}. This seems high for this sale type. Are you sure this is correct?"
mortgage_value_check: mortgage_value_check:
page_header: "" page_header: ""

2
spec/models/form/sales/pages/buyer1_income_max_value_check_spec.rb → spec/models/form/sales/pages/buyer1_income_discounted_max_value_check_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer1IncomeMaxValueCheck, type: :model do RSpec.describe Form::Sales::Pages::Buyer1IncomeDiscountedMaxValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: 1) } subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: 1) }
let(:page_id) { "prefix_buyer_1_income_max_value_check" } let(:page_id) { "prefix_buyer_1_income_max_value_check" }

2
spec/models/form/sales/pages/buyer2_income_max_value_check_spec.rb → spec/models/form/sales/pages/buyer2_income_discounted_max_value_check_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" require "rails_helper"
RSpec.describe Form::Sales::Pages::Buyer2IncomeMaxValueCheck, type: :model do RSpec.describe Form::Sales::Pages::Buyer2IncomeDiscountedMaxValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: 2) } subject(:page) { described_class.new(page_id, page_definition, subsection, check_answers_card_number: 2) }
let(:page_id) { "prefix_buyer_2_income_max_value_check" } let(:page_id) { "prefix_buyer_2_income_max_value_check" }

61
spec/models/form/sales/subsections/household_characteristics_spec.rb

@ -16,10 +16,11 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
expect(household_characteristics.section).to eq(section) expect(household_characteristics.section).to eq(section)
end end
context "with 2022/23 form" do context "with 2023/24 form" do
before do before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1)) allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1))
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2024_or_later?).and_return(false)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct pages" do it "has correct pages" do
@ -54,6 +55,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
age_2_buyer_retirement_value_check age_2_buyer_retirement_value_check
buyer_2_age_student_not_child_value_check buyer_2_age_student_not_child_value_check
buyer_2_gender_identity buyer_2_gender_identity
buyer_2_ethnic_group
buyer_2_ethnic_background_black
buyer_2_ethnic_background_asian
buyer_2_ethnic_background_arab
buyer_2_ethnic_background_mixed
buyer_2_ethnic_background_white
buyer_2_nationality
buyer_2_working_situation buyer_2_working_situation
working_situation_2_retirement_value_check_joint_purchase working_situation_2_retirement_value_check_joint_purchase
working_situation_buyer_2_income_min_value_check working_situation_buyer_2_income_min_value_check
@ -117,21 +125,19 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
end end
end end
context "with 2023/24 form" do context "with 2024/25 form" do
before do before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1)) allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 4, 1))
allow(form).to receive(:start_year_2024_or_later?).and_return(false) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2025_or_later?).and_return(false)
end end
it "has correct pages" do it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq( expect(household_characteristics.pages.map(&:id)).to eq(
%w[ %w[
buyer_interview_joint_purchase
buyer_interview
privacy_notice_joint_purchase
privacy_notice
buyer_1_age buyer_1_age
age_1_retirement_value_check age_1_retirement_value_check
age_1_not_retired_value_check
age_1_old_persons_shared_ownership_joint_purchase_value_check age_1_old_persons_shared_ownership_joint_purchase_value_check
age_1_old_persons_shared_ownership_value_check age_1_old_persons_shared_ownership_value_check
buyer_1_gender_identity buyer_1_gender_identity
@ -144,6 +150,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_nationality buyer_1_nationality
buyer_1_working_situation buyer_1_working_situation
working_situation_1_retirement_value_check working_situation_1_retirement_value_check
working_situation_1_not_retired_value_check
working_situation_buyer_1_income_min_value_check working_situation_buyer_1_income_min_value_check
buyer_1_live_in_property buyer_1_live_in_property
buyer_1_live_in_property_value_check buyer_1_live_in_property_value_check
@ -153,6 +160,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
age_2_old_persons_shared_ownership_joint_purchase_value_check age_2_old_persons_shared_ownership_joint_purchase_value_check
age_2_old_persons_shared_ownership_value_check age_2_old_persons_shared_ownership_value_check
age_2_buyer_retirement_value_check age_2_buyer_retirement_value_check
age_2_buyer_not_retired_value_check
buyer_2_age_student_not_child_value_check buyer_2_age_student_not_child_value_check
buyer_2_gender_identity buyer_2_gender_identity
buyer_2_ethnic_group buyer_2_ethnic_group
@ -164,6 +172,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_2_nationality buyer_2_nationality
buyer_2_working_situation buyer_2_working_situation
working_situation_2_retirement_value_check_joint_purchase working_situation_2_retirement_value_check_joint_purchase
working_situation_2_not_retired_value_check_joint_purchase
working_situation_buyer_2_income_min_value_check working_situation_buyer_2_income_min_value_check
buyer_2_working_situation_student_not_child_value_check buyer_2_working_situation_student_not_child_value_check
buyer_2_live_in_property buyer_2_live_in_property
@ -172,63 +181,89 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
number_of_others_in_property_joint_purchase number_of_others_in_property_joint_purchase
person_2_known person_2_known
person_2_relationship_to_buyer_1 person_2_relationship_to_buyer_1
relationship_2_partner_under_16_value_check
relationship_2_multiple_partners_value_check
relationship_2_student_not_child_value_check relationship_2_student_not_child_value_check
person_2_age person_2_age
age_2_retirement_value_check age_2_retirement_value_check
age_2_not_retired_value_check
age_2_student_not_child_value_check age_2_student_not_child_value_check
age_2_partner_under_16_value_check
person_2_gender_identity person_2_gender_identity
person_2_working_situation person_2_working_situation
working_situation_2_retirement_value_check working_situation_2_retirement_value_check
working_situation_2_not_retired_value_check
working_situation_2_student_not_child_value_check working_situation_2_student_not_child_value_check
person_3_known person_3_known
person_3_relationship_to_buyer_1 person_3_relationship_to_buyer_1
relationship_3_partner_under_16_value_check
relationship_3_multiple_partners_value_check
relationship_3_student_not_child_value_check relationship_3_student_not_child_value_check
person_3_age person_3_age
age_3_retirement_value_check age_3_retirement_value_check
age_3_not_retired_value_check
age_3_student_not_child_value_check age_3_student_not_child_value_check
age_3_partner_under_16_value_check
person_3_gender_identity person_3_gender_identity
person_3_working_situation person_3_working_situation
working_situation_3_retirement_value_check working_situation_3_retirement_value_check
working_situation_3_not_retired_value_check
working_situation_3_student_not_child_value_check working_situation_3_student_not_child_value_check
person_4_known person_4_known
person_4_relationship_to_buyer_1 person_4_relationship_to_buyer_1
relationship_4_partner_under_16_value_check
relationship_4_multiple_partners_value_check
relationship_4_student_not_child_value_check relationship_4_student_not_child_value_check
person_4_age person_4_age
age_4_retirement_value_check age_4_retirement_value_check
age_4_not_retired_value_check
age_4_student_not_child_value_check age_4_student_not_child_value_check
age_4_partner_under_16_value_check
person_4_gender_identity person_4_gender_identity
person_4_working_situation person_4_working_situation
working_situation_4_retirement_value_check working_situation_4_retirement_value_check
working_situation_4_not_retired_value_check
working_situation_4_student_not_child_value_check working_situation_4_student_not_child_value_check
person_5_known person_5_known
person_5_relationship_to_buyer_1 person_5_relationship_to_buyer_1
relationship_5_partner_under_16_value_check
relationship_5_multiple_partners_value_check
relationship_5_student_not_child_value_check relationship_5_student_not_child_value_check
person_5_age person_5_age
age_5_retirement_value_check age_5_retirement_value_check
age_5_not_retired_value_check
age_5_student_not_child_value_check age_5_student_not_child_value_check
age_5_partner_under_16_value_check
person_5_gender_identity person_5_gender_identity
person_5_working_situation person_5_working_situation
working_situation_5_retirement_value_check working_situation_5_retirement_value_check
working_situation_5_not_retired_value_check
working_situation_5_student_not_child_value_check working_situation_5_student_not_child_value_check
person_6_known person_6_known
person_6_relationship_to_buyer_1 person_6_relationship_to_buyer_1
relationship_6_partner_under_16_value_check
relationship_6_multiple_partners_value_check
relationship_6_student_not_child_value_check relationship_6_student_not_child_value_check
person_6_age person_6_age
age_6_retirement_value_check age_6_retirement_value_check
age_6_not_retired_value_check
age_6_student_not_child_value_check age_6_student_not_child_value_check
age_6_partner_under_16_value_check
person_6_gender_identity person_6_gender_identity
person_6_working_situation person_6_working_situation
working_situation_6_retirement_value_check working_situation_6_retirement_value_check
working_situation_6_not_retired_value_check
working_situation_6_student_not_child_value_check working_situation_6_student_not_child_value_check
], ],
) )
end end
end end
context "with 2024/25 form" do context "with 2025/26 form" do
before do before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 4, 1)) allow(form).to receive(:start_date).and_return(Time.zone.local(2025, 4, 1))
allow(form).to receive(:start_year_2024_or_later?).and_return(true) allow(form).to receive(:start_year_2024_or_later?).and_return(true)
allow(form).to receive(:start_year_2025_or_later?).and_return(true)
end end
it "has correct pages" do it "has correct pages" do
@ -251,6 +286,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_1_retirement_value_check working_situation_1_retirement_value_check
working_situation_1_not_retired_value_check working_situation_1_not_retired_value_check
working_situation_buyer_1_income_min_value_check working_situation_buyer_1_income_min_value_check
working_situation_buyer_1_income_max_value_check
buyer_1_live_in_property buyer_1_live_in_property
buyer_1_live_in_property_value_check buyer_1_live_in_property_value_check
buyer_2_relationship_to_buyer_1 buyer_2_relationship_to_buyer_1
@ -273,6 +309,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_2_retirement_value_check_joint_purchase working_situation_2_retirement_value_check_joint_purchase
working_situation_2_not_retired_value_check_joint_purchase working_situation_2_not_retired_value_check_joint_purchase
working_situation_buyer_2_income_min_value_check working_situation_buyer_2_income_min_value_check
working_situation_buyer_2_income_max_value_check
buyer_2_working_situation_student_not_child_value_check buyer_2_working_situation_student_not_child_value_check
buyer_2_live_in_property buyer_2_live_in_property
buyer_2_live_in_property_value_check buyer_2_live_in_property_value_check
@ -354,7 +391,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_6_not_retired_value_check working_situation_6_not_retired_value_check
working_situation_6_student_not_child_value_check working_situation_6_student_not_child_value_check
], ],
) )
end end
end end

23
spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb

@ -12,17 +12,17 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
end end
describe "pages" do describe "pages" do
let(:section) { instance_double(Form::Sales::Sections::Household, form: instance_double(Form, start_date:)) } let(:section) { instance_double(Form::Sales::Sections::Household, form:) }
context "when 2022" do context "when before 2025" do
let(:start_date) { Time.utc(2022, 2, 8) } let(:form) { instance_double(Form, start_date: Time.utc(2024, 4, 1), start_year_2025_or_later?: false)}
it "has correct pages" do it "has correct pages" do
expect(subsection.pages.compact.map(&:id)).to eq( expect(subsection.pages.map(&:id)).to eq(
%w[ %w[
buyer_1_income buyer_1_income
buyer_1_income_min_value_check buyer_1_income_min_value_check
buyer_1_income_max_value_check buyer_1_income_discounted_max_value_check
buyer_1_combined_income_max_value_check buyer_1_combined_income_max_value_check
buyer_1_income_mortgage_value_check buyer_1_income_mortgage_value_check
buyer_1_mortgage buyer_1_mortgage
@ -30,7 +30,7 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
buyer_2_income buyer_2_income
buyer_2_income_mortgage_value_check buyer_2_income_mortgage_value_check
buyer_2_income_min_value_check buyer_2_income_min_value_check
buyer_2_income_max_value_check buyer_2_income_discounted_max_value_check
buyer_2_combined_income_max_value_check buyer_2_combined_income_max_value_check
buyer_2_mortgage buyer_2_mortgage
buyer_2_mortgage_value_check buyer_2_mortgage_value_check
@ -44,20 +44,22 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
savings_deposit_value_check savings_deposit_value_check
previous_ownership_joint_purchase previous_ownership_joint_purchase
previous_ownership_not_joint_purchase previous_ownership_not_joint_purchase
previous_shared
], ],
) )
end end
end end
context "when 2023" do context "when 2025" do
let(:start_date) { Time.utc(2023, 2, 8) } let(:form) { instance_double(Form, start_date: Time.utc(2025, 4, 1), start_year_2025_or_later?: true)}
it "has correct pages" do it "has correct pages" do
expect(subsection.pages.map(&:id)).to eq( expect(subsection.pages.map(&:id)).to eq(
%w[ %w[
buyer_1_income buyer_1_income
buyer_1_income_min_value_check buyer_1_income_min_value_check
buyer_1_income_max_value_check buyer_1_income_ecstat_max_value_check
buyer_1_income_discounted_max_value_check
buyer_1_combined_income_max_value_check buyer_1_combined_income_max_value_check
buyer_1_income_mortgage_value_check buyer_1_income_mortgage_value_check
buyer_1_mortgage buyer_1_mortgage
@ -65,7 +67,8 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model
buyer_2_income buyer_2_income
buyer_2_income_mortgage_value_check buyer_2_income_mortgage_value_check
buyer_2_income_min_value_check buyer_2_income_min_value_check
buyer_2_income_max_value_check buyer_2_income_ecstat_max_value_check
buyer_2_income_discounted_max_value_check
buyer_2_combined_income_max_value_check buyer_2_combined_income_max_value_check
buyer_2_mortgage buyer_2_mortgage
buyer_2_mortgage_value_check buyer_2_mortgage_value_check

Loading…
Cancel
Save