From 4680888d37a5e653f22453e59cec331e39d3f8db Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Thu, 14 Nov 2024 11:13:23 +0000 Subject: [PATCH] CLDC-3753: Update soft income validations --- ...yer1_income_discounted_max_value_check.rb} | 6 +- .../buyer1_income_ecstat_max_value_check.rb | 33 +++++++++ ...yer2_income_discounted_max_value_check.rb} | 6 +- .../buyer2_income_ecstat_max_value_check.rb | 33 +++++++++ .../pages/combined_income_max_value_check.rb | 2 +- .../subsections/household_characteristics.rb | 2 + .../income_benefits_and_savings.rb | 6 +- .../sales/subsections/property_information.rb | 8 +-- .../validations/sales/soft_validations.rb | 69 ++++++++++++++----- .../forms/2023/sales/soft_validations.en.yml | 30 ++++---- .../forms/2024/sales/soft_validations.en.yml | 14 ++-- .../forms/2025/sales/soft_validations.en.yml | 20 ++++-- ...income_discounted_max_value_check_spec.rb} | 2 +- ...income_discounted_max_value_check_spec.rb} | 2 +- .../household_characteristics_spec.rb | 61 ++++++++++++---- .../income_benefits_and_savings_spec.rb | 23 ++++--- 16 files changed, 237 insertions(+), 80 deletions(-) rename app/models/form/sales/pages/{buyer1_income_max_value_check.rb => buyer1_income_discounted_max_value_check.rb} (78%) create mode 100644 app/models/form/sales/pages/buyer1_income_ecstat_max_value_check.rb rename app/models/form/sales/pages/{buyer2_income_max_value_check.rb => buyer2_income_discounted_max_value_check.rb} (78%) create mode 100644 app/models/form/sales/pages/buyer2_income_ecstat_max_value_check.rb rename spec/models/form/sales/pages/{buyer1_income_max_value_check_spec.rb => buyer1_income_discounted_max_value_check_spec.rb} (91%) rename spec/models/form/sales/pages/{buyer2_income_max_value_check_spec.rb => buyer2_income_discounted_max_value_check_spec.rb} (91%) diff --git a/app/models/form/sales/pages/buyer1_income_max_value_check.rb b/app/models/form/sales/pages/buyer1_income_discounted_max_value_check.rb similarity index 78% rename from app/models/form/sales/pages/buyer1_income_max_value_check.rb rename to app/models/form/sales/pages/buyer1_income_discounted_max_value_check.rb index 55599ff26..152302174 100644 --- a/app/models/form/sales/pages/buyer1_income_max_value_check.rb +++ b/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:) super(id, hsh, subsection) @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 = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ diff --git a/app/models/form/sales/pages/buyer1_income_ecstat_max_value_check.rb b/app/models/form/sales/pages/buyer1_income_ecstat_max_value_check.rb new file mode 100644 index 000000000..b9fd5c2a4 --- /dev/null +++ b/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 diff --git a/app/models/form/sales/pages/buyer2_income_max_value_check.rb b/app/models/form/sales/pages/buyer2_income_discounted_max_value_check.rb similarity index 78% rename from app/models/form/sales/pages/buyer2_income_max_value_check.rb rename to app/models/form/sales/pages/buyer2_income_discounted_max_value_check.rb index deece885e..1706dffc5 100644 --- a/app/models/form/sales/pages/buyer2_income_max_value_check.rb +++ b/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:) super(id, hsh, subsection) @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 = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ diff --git a/app/models/form/sales/pages/buyer2_income_ecstat_max_value_check.rb b/app/models/form/sales/pages/buyer2_income_ecstat_max_value_check.rb new file mode 100644 index 000000000..8fa593b69 --- /dev/null +++ b/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 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 index 1cd1fd851..89eea3027 100644 --- a/app/models/form/sales/pages/combined_income_max_value_check.rb +++ b/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) @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" diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index f1f01ba62..9b5f18c66 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/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::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::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::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1), 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::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::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::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_2_live_in_property_value_check", nil, self, person_index: 2), 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 19b6e7e03..80bf6f625 100644 --- a/app/models/form/sales/subsections/income_benefits_and_savings.rb +++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb @@ -10,7 +10,8 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection @pages ||= [ 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, 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::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self, 1), 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::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, 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::Buyer2Mortgage.new(nil, nil, self), Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2), diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 5d4021681..28c0ad004 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/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::AddressFallback.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::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_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::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::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::Address.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::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_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::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::AboutPriceValueCheck.new("about_price_la_value_check", nil, self), ] diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index fe05ec13c..7dba69077 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -2,41 +2,59 @@ module Validations::Sales::SoftValidations include Validations::Sales::SaleInformationValidations ALLOWED_INCOME_RANGES_SALES = { - 1 => OpenStruct.new(soft_min: 5000), - 2 => OpenStruct.new(soft_min: 1500), - 3 => OpenStruct.new(soft_min: 1000), - 5 => OpenStruct.new(soft_min: 2000), - 0 => OpenStruct.new(soft_min: 2000), + 2024 => { + 1 => OpenStruct.new(soft_min: 5000), + 2 => OpenStruct.new(soft_min: 1500), + 3 => OpenStruct.new(soft_min: 1000), + 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 def income1_under_soft_min? - return false unless ecstat1 && income1 && ALLOWED_INCOME_RANGES_SALES[ecstat1] - - income1 < ALLOWED_INCOME_RANGES_SALES[ecstat1][:soft_min] + income_under_soft_min?(income1, ecstat1) end def income2_under_soft_min? - return false unless ecstat2 && income2 && ALLOWED_INCOME_RANGES_SALES[ecstat2] - - income2 < ALLOWED_INCOME_RANGES_SALES[ecstat2][:soft_min] + income_under_soft_min?(income2, ecstat2) end - def income1_over_soft_max? + def income1_over_soft_max_for_discounted_ownership? 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 - def income2_over_soft_max? + def income2_over_soft_max_for_discounted_ownership? return unless income2 && la && discounted_ownership_sale? - income_over_soft_max?(income2) + income_over_discounted_sale_soft_max?(income2) 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? - income_over_soft_max?(income1 + income2) + income_over_discounted_sale_soft_max?(income1 + income2) end def staircase_bought_above_fifty? @@ -184,7 +202,22 @@ private ) 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) end end diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml index 20f131e90..90e9e2fe5 100644 --- a/config/locales/forms/2023/sales/soft_validations.en.yml +++ b/config/locales/forms/2023/sales/soft_validations.en.yml @@ -18,7 +18,7 @@ en: question_text: "Are you sure this person is 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." - + old_persons_shared_ownership_value_check: page_header: "" 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." 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." - + income1_value_check: check_answer_label: "Buyer 1 income confirmation" hint_text: "" @@ -38,9 +38,10 @@ en: title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: - page_header: "" - title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" - + discounted: + 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: check_answer_label: "Buyer 2 income confirmation" hint_text: "" @@ -50,8 +51,9 @@ en: title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: - page_header: "" - title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" + discounted: + 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: page_header: "" @@ -110,7 +112,7 @@ en: hint_text: "" question_text: "Are you sure?" title_text: "You told us practical completion or handover date is more than 3 years before sale completion date." - + value_value_check: page_header: "" 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?" 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." - + wheel_value_check: page_header: "" check_answer_label: "Does anyone in the household use a wheelchair?" hint_text: "" 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." - + buyer_livein_value_check: buyer1: page_header: "" @@ -164,7 +166,7 @@ en: question_text: "Are you sure this is correct?" 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." - + student_not_child_value_check: page_header: "" check_answer_label: "Student not a child confirmation" @@ -172,7 +174,7 @@ en: 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." informative_text: "Are you sure this person is not a child?" - + partner_under_16_value_check: page_header: "" check_answer_label: "Partner under 16 confirmation" @@ -180,7 +182,7 @@ en: 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." informative_text: "Are you sure this is correct?" - + multiple_partners_value_check: page_header: "" check_answer_label: "Multiple partners confirmation" @@ -196,7 +198,7 @@ en: question_text: "Are you sure this is correct?" title_text: "You told us that the monthly charges were %{mscharge}." informative_text: "This is higher than we would expect." - + extra_borrowing_value_check: page_header: "" check_answer_label: "Extra borrowing confirmation" diff --git a/config/locales/forms/2024/sales/soft_validations.en.yml b/config/locales/forms/2024/sales/soft_validations.en.yml index b9b1ad479..bc8536d9f 100644 --- a/config/locales/forms/2024/sales/soft_validations.en.yml +++ b/config/locales/forms/2024/sales/soft_validations.en.yml @@ -36,8 +36,9 @@ en: title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: - page_header: "" - title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" + discounted: + 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: check_answer_label: "Buyer 2 income confirmation" @@ -48,8 +49,9 @@ en: title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: - page_header: "" - title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" + discounted: + 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: page_header: "" @@ -108,7 +110,7 @@ en: hint_text: "" question_text: "Are you sure?" title_text: "You told us practical completion or handover date is more than 3 years before sale completion date." - + value_value_check: page_header: "" check_answer_label: "Purchase price confirmation" @@ -202,7 +204,7 @@ en: question_text: "Are you sure this is correct?" title_text: "You told us that the monthly charges were %{mscharge}." informative_text: "This is higher than we would expect." - + extra_borrowing_value_check: page_header: "" check_answer_label: "Extra borrowing confirmation" diff --git a/config/locales/forms/2025/sales/soft_validations.en.yml b/config/locales/forms/2025/sales/soft_validations.en.yml index c8f0990ba..6d9938834 100644 --- a/config/locales/forms/2025/sales/soft_validations.en.yml +++ b/config/locales/forms/2025/sales/soft_validations.en.yml @@ -36,8 +36,13 @@ en: title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: - page_header: "" - title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" + discounted: + 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: check_answer_label: "Buyer 2 income confirmation" @@ -48,15 +53,20 @@ en: title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: - page_header: "" - title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" + discounted: + 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: page_header: "" check_answer_label: "Combined income confirmation" hint_text: "" 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: page_header: "" diff --git a/spec/models/form/sales/pages/buyer1_income_max_value_check_spec.rb b/spec/models/form/sales/pages/buyer1_income_discounted_max_value_check_spec.rb similarity index 91% rename from spec/models/form/sales/pages/buyer1_income_max_value_check_spec.rb rename to spec/models/form/sales/pages/buyer1_income_discounted_max_value_check_spec.rb index fa5cf1e7c..0bf99984b 100644 --- a/spec/models/form/sales/pages/buyer1_income_max_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer1_income_discounted_max_value_check_spec.rb @@ -1,6 +1,6 @@ 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) } let(:page_id) { "prefix_buyer_1_income_max_value_check" } diff --git a/spec/models/form/sales/pages/buyer2_income_max_value_check_spec.rb b/spec/models/form/sales/pages/buyer2_income_discounted_max_value_check_spec.rb similarity index 91% rename from spec/models/form/sales/pages/buyer2_income_max_value_check_spec.rb rename to spec/models/form/sales/pages/buyer2_income_discounted_max_value_check_spec.rb index f467db18d..21ecd92d1 100644 --- a/spec/models/form/sales/pages/buyer2_income_max_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer2_income_discounted_max_value_check_spec.rb @@ -1,6 +1,6 @@ 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) } let(:page_id) { "prefix_buyer_2_income_max_value_check" } diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 3eb5042d8..8d46b6511 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/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) end - context "with 2022/23 form" do + context "with 2023/24 form" 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_2025_or_later?).and_return(false) end it "has correct pages" do @@ -54,6 +55,13 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model age_2_buyer_retirement_value_check buyer_2_age_student_not_child_value_check 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 working_situation_2_retirement_value_check_joint_purchase working_situation_buyer_2_income_min_value_check @@ -117,21 +125,19 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model end end - context "with 2023/24 form" do + context "with 2024/25 form" do before do - 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_date).and_return(Time.zone.local(2024, 4, 1)) + 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 it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( %w[ - buyer_interview_joint_purchase - buyer_interview - privacy_notice_joint_purchase - privacy_notice buyer_1_age 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_value_check buyer_1_gender_identity @@ -144,6 +150,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_1_nationality buyer_1_working_situation working_situation_1_retirement_value_check + working_situation_1_not_retired_value_check working_situation_buyer_1_income_min_value_check buyer_1_live_in_property 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_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_gender_identity buyer_2_ethnic_group @@ -164,6 +172,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_2_nationality buyer_2_working_situation 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 buyer_2_working_situation_student_not_child_value_check buyer_2_live_in_property @@ -172,63 +181,89 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model number_of_others_in_property_joint_purchase person_2_known 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 person_2_age age_2_retirement_value_check + age_2_not_retired_value_check age_2_student_not_child_value_check + age_2_partner_under_16_value_check person_2_gender_identity person_2_working_situation working_situation_2_retirement_value_check + working_situation_2_not_retired_value_check working_situation_2_student_not_child_value_check person_3_known 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 person_3_age age_3_retirement_value_check + age_3_not_retired_value_check age_3_student_not_child_value_check + age_3_partner_under_16_value_check person_3_gender_identity person_3_working_situation working_situation_3_retirement_value_check + working_situation_3_not_retired_value_check working_situation_3_student_not_child_value_check person_4_known 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 person_4_age age_4_retirement_value_check + age_4_not_retired_value_check age_4_student_not_child_value_check + age_4_partner_under_16_value_check person_4_gender_identity person_4_working_situation working_situation_4_retirement_value_check + working_situation_4_not_retired_value_check working_situation_4_student_not_child_value_check person_5_known 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 person_5_age age_5_retirement_value_check + age_5_not_retired_value_check age_5_student_not_child_value_check + age_5_partner_under_16_value_check person_5_gender_identity person_5_working_situation working_situation_5_retirement_value_check + working_situation_5_not_retired_value_check working_situation_5_student_not_child_value_check person_6_known 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 person_6_age age_6_retirement_value_check + age_6_not_retired_value_check age_6_student_not_child_value_check + age_6_partner_under_16_value_check person_6_gender_identity person_6_working_situation working_situation_6_retirement_value_check + working_situation_6_not_retired_value_check working_situation_6_student_not_child_value_check ], ) end end - context "with 2024/25 form" do + context "with 2025/26 form" 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_2025_or_later?).and_return(true) end 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_not_retired_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_value_check 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_not_retired_value_check_joint_purchase 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_live_in_property 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_student_not_child_value_check ], - ) + ) end end diff --git a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb index 22a84f2a9..af427ce08 100644 --- a/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb +++ b/spec/models/form/sales/subsections/income_benefits_and_savings_spec.rb @@ -12,17 +12,17 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model end 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 - let(:start_date) { Time.utc(2022, 2, 8) } + context "when before 2025" do + let(:form) { instance_double(Form, start_date: Time.utc(2024, 4, 1), start_year_2025_or_later?: false)} it "has correct pages" do - expect(subsection.pages.compact.map(&:id)).to eq( + expect(subsection.pages.map(&:id)).to eq( %w[ buyer_1_income 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_income_mortgage_value_check buyer_1_mortgage @@ -30,7 +30,7 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model buyer_2_income buyer_2_income_mortgage_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_mortgage buyer_2_mortgage_value_check @@ -44,20 +44,22 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model savings_deposit_value_check previous_ownership_joint_purchase previous_ownership_not_joint_purchase + previous_shared ], ) end end - context "when 2023" do - let(:start_date) { Time.utc(2023, 2, 8) } + context "when 2025" do + let(:form) { instance_double(Form, start_date: Time.utc(2025, 4, 1), start_year_2025_or_later?: true)} it "has correct pages" do expect(subsection.pages.map(&:id)).to eq( %w[ buyer_1_income 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_income_mortgage_value_check buyer_1_mortgage @@ -65,7 +67,8 @@ RSpec.describe Form::Sales::Subsections::IncomeBenefitsAndSavings, type: :model buyer_2_income buyer_2_income_mortgage_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_mortgage buyer_2_mortgage_value_check