From 8d8225505029483d32c23b2b61e387f2f2550a8f Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:03:12 +0100 Subject: [PATCH] CLDC-3571 Discounted ownership validation (#2547) * Rename discount to deposit discount * Split about price rtb questions * Update error message * Update guidance partial * Fix top_guidance_partial method * Split about_price_not_rtb * Update guidance partial and validation * Fix bulk upload test * Update deposit routed_to and guidance --- .../form/sales/pages/about_price_rtb.rb | 17 ---- app/models/form/sales/pages/deposit.rb | 1 + .../form/sales/pages/deposit_discount.rb | 21 +++++ app/models/form/sales/pages/discount.rb | 21 ++--- .../{about_price_not_rtb.rb => grant.rb} | 5 +- app/models/form/sales/pages/purchase_price.rb | 18 ++++ .../form/sales/questions/deposit_amount.rb | 7 +- app/models/form/sales/questions/discount.rb | 1 + app/models/form/sales/questions/grant.rb | 1 + .../form/sales/questions/mortgage_amount.rb | 7 +- .../form/sales/questions/mortgageused.rb | 1 + .../form/sales/questions/purchase_price.rb | 1 + .../discounted_ownership_scheme.rb | 5 +- .../subsections/shared_ownership_scheme.rb | 4 +- .../sales/sale_information_validations.rb | 8 +- app/views/form/_radio_question.html.erb | 2 +- ...calculations_discounted_ownership.html.erb | 14 +++ ...ial_calculations_shared_ownership.html.erb | 2 +- config/locales/en.yml | 2 +- .../form/sales/pages/deposit_discount_spec.rb | 71 +++++++++++++++ spec/models/form/sales/pages/deposit_spec.rb | 4 +- spec/models/form/sales/pages/discount_spec.rb | 46 ++-------- ...ut_price_not_rtb_spec.rb => grant_spec.rb} | 6 +- ...ice_rtb_spec.rb => purchase_price_spec.rb} | 11 ++- .../discounted_ownership_scheme_spec.rb | 5 +- .../sale_information_validations_spec.rb | 86 ++++++++++--------- .../sales/year2024/row_parser_spec.rb | 2 +- 27 files changed, 231 insertions(+), 138 deletions(-) delete mode 100644 app/models/form/sales/pages/about_price_rtb.rb create mode 100644 app/models/form/sales/pages/deposit_discount.rb rename app/models/form/sales/pages/{about_price_not_rtb.rb => grant.rb} (64%) create mode 100644 app/models/form/sales/pages/purchase_price.rb create mode 100644 app/views/form/guidance/_financial_calculations_discounted_ownership.html.erb create mode 100644 spec/models/form/sales/pages/deposit_discount_spec.rb rename spec/models/form/sales/pages/{about_price_not_rtb_spec.rb => grant_spec.rb} (81%) rename spec/models/form/sales/pages/{about_price_rtb_spec.rb => purchase_price_spec.rb} (70%) diff --git a/app/models/form/sales/pages/about_price_rtb.rb b/app/models/form/sales/pages/about_price_rtb.rb deleted file mode 100644 index d8d20398f..000000000 --- a/app/models/form/sales/pages/about_price_rtb.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Form::Sales::Pages::AboutPriceRtb < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "about_price_rtb" - @header = "About the price of the property" - @depends_on = [{ - "right_to_buy?" => true, - }] - end - - def questions - @questions ||= [ - Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: 2), - Form::Sales::Questions::Discount.new(nil, nil, self), - ] - end -end diff --git a/app/models/form/sales/pages/deposit.rb b/app/models/form/sales/pages/deposit.rb index 72e6d163c..3e298e4f6 100644 --- a/app/models/form/sales/pages/deposit.rb +++ b/app/models/form/sales/pages/deposit.rb @@ -13,6 +13,7 @@ class Form::Sales::Pages::Deposit < ::Form::Page end def routed_to?(log, _user) + return false unless super return true if log.ownershipsch == 2 || (log.ownershipsch == 3 && log.mortgageused == 1) return false if log.stairowned_100? != @optional && form.start_year_after_2024? diff --git a/app/models/form/sales/pages/deposit_discount.rb b/app/models/form/sales/pages/deposit_discount.rb new file mode 100644 index 000000000..6931a7510 --- /dev/null +++ b/app/models/form/sales/pages/deposit_discount.rb @@ -0,0 +1,21 @@ +class Form::Sales::Pages::DepositDiscount < ::Form::Page + def initialize(id, hsh, subsection, optional:) + super(id, hsh, subsection) + @optional = optional + @header = "About the deposit" + end + + def questions + @questions ||= [ + Form::Sales::Questions::DepositDiscount.new(nil, nil, self), + ] + end + + def depends_on + if form.start_year_after_2024? + [{ "social_homebuy?" => true, "stairowned_100?" => @optional }] + else + [{ "social_homebuy?" => true }] + end + end +end diff --git a/app/models/form/sales/pages/discount.rb b/app/models/form/sales/pages/discount.rb index 267fda711..56670075b 100644 --- a/app/models/form/sales/pages/discount.rb +++ b/app/models/form/sales/pages/discount.rb @@ -1,21 +1,16 @@ class Form::Sales::Pages::Discount < ::Form::Page - def initialize(id, hsh, subsection, optional:) - super(id, hsh, subsection) - @optional = optional - @header = "About the deposit" + def initialize(id, hsh, subsection) + super + @id = "discount" + @header = "About the price of the property" + @depends_on = [{ + "right_to_buy?" => true, + }] end def questions @questions ||= [ - Form::Sales::Questions::DepositDiscount.new(nil, nil, self), + Form::Sales::Questions::Discount.new(nil, nil, self), ] end - - def depends_on - if form.start_year_after_2024? - [{ "social_homebuy?" => true, "stairowned_100?" => @optional }] - else - [{ "social_homebuy?" => true }] - end - end end diff --git a/app/models/form/sales/pages/about_price_not_rtb.rb b/app/models/form/sales/pages/grant.rb similarity index 64% rename from app/models/form/sales/pages/about_price_not_rtb.rb rename to app/models/form/sales/pages/grant.rb index 2f30548c7..7c7d2a625 100644 --- a/app/models/form/sales/pages/about_price_not_rtb.rb +++ b/app/models/form/sales/pages/grant.rb @@ -1,7 +1,7 @@ -class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page +class Form::Sales::Pages::Grant < ::Form::Page def initialize(id, hsh, subsection) super - @id = "about_price_not_rtb" + @id = "grant" @header = "About the price of the property" @depends_on = [{ "right_to_buy?" => false, @@ -11,7 +11,6 @@ class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: 2), Form::Sales::Questions::Grant.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb new file mode 100644 index 000000000..2203375ef --- /dev/null +++ b/app/models/form/sales/pages/purchase_price.rb @@ -0,0 +1,18 @@ +class Form::Sales::Pages::PurchasePrice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "purchase_price" + @header = "About the price of the property" + @depends_on = [{ "right_to_buy?" => true }, + { + "right_to_buy?" => false, + "rent_to_buy_full_ownership?" => false, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: 2), + ] + end +end diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb index 86bb456f3..e7e78b5c0 100644 --- a/app/models/form/sales/questions/deposit_amount.rb +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -13,7 +13,7 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question @ownershipsch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] @optional = optional - @top_guidance_partial = "financial_calculations_shared_ownership" if ownershipsch == 1 + @top_guidance_partial = top_guidance_partial end def derived?(log) @@ -32,4 +32,9 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan" end end + + def top_guidance_partial + return "financial_calculations_shared_ownership" if @ownershipsch == 1 + return "financial_calculations_discounted_ownership" if @ownershipsch == 2 + end end diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index fdee1e11c..f99203ebe 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -14,6 +14,7 @@ class Form::Sales::Questions::Discount < ::Form::Question If discount capped, enter capped % If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + @top_guidance_partial = "financial_calculations_discounted_ownership" end QUESTION_NUMBER_FROM_YEAR = { 2023 => 102, 2024 => 103 }.freeze diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb index 00b54e8d2..45b70d61f 100644 --- a/app/models/form/sales/questions/grant.rb +++ b/app/models/form/sales/questions/grant.rb @@ -12,6 +12,7 @@ class Form::Sales::Questions::Grant < ::Form::Question @prefix = "£" @hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] + @top_guidance_partial = "financial_calculations_discounted_ownership" end QUESTION_NUMBER_FROM_YEAR = { 2023 => 101, 2024 => 102 }.freeze diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index e38737c89..446583921 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -12,7 +12,7 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question @hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound." @ownershipsch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] - @top_guidance_partial = "financial_calculations_shared_ownership" if ownershipsch == 1 + @top_guidance_partial = top_guidance_partial end QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = { @@ -23,4 +23,9 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question def derived?(log) log&.mortgage_not_used? end + + def top_guidance_partial + return "financial_calculations_shared_ownership" if @ownershipsch == 1 + return "financial_calculations_discounted_ownership" if @ownershipsch == 2 + end end diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index 8dbe3a650..3c90a7856 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -8,6 +8,7 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question @answer_options = ANSWER_OPTIONS @ownershipsch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] + @top_guidance_partial = "financial_calculations_discounted_ownership" if @ownershipsch == 2 end def displayed_answer_options(log, _user = nil) diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index 428d0cce0..68c9436d3 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -12,6 +12,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question @hint_text = hint_text @ownership_sch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] + @top_guidance_partial = "financial_calculations_discounted_ownership" if ownershipsch == 2 end QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP = { diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index e8af859cf..8131df4a7 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -10,10 +10,11 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection @pages ||= [ Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership_joint_purchase", nil, self, ownershipsch: 2, joint_purchase: true), Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_discounted_ownership", nil, self, ownershipsch: 2, joint_purchase: false), - Form::Sales::Pages::AboutPriceRtb.new(nil, nil, self), + Form::Sales::Pages::PurchasePrice.new(nil, nil, self), + Form::Sales::Pages::Discount.new(nil, nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_price_value_check", nil, self), Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_value_check", nil, self), - Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), + Form::Sales::Pages::Grant.new(nil, nil, self), Form::Sales::Pages::GrantValueCheck.new(nil, nil, self), Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::DiscountedSaleValueCheck.new("discounted_sale_grant_value_check", nil, self), diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index bcf6d8be6..371e125bb 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -43,8 +43,8 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection (Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_after_2024?), Form::Sales::Pages::DepositValueCheck.new("deposit_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), - Form::Sales::Pages::Discount.new("discount", nil, self, optional: false), - (Form::Sales::Pages::Discount.new("discount_optional", nil, self, optional: true) if form.start_year_after_2024?), + Form::Sales::Pages::DepositDiscount.new("discount", nil, self, optional: false), + (Form::Sales::Pages::DepositDiscount.new("discount_optional", nil, self, optional: true) if form.start_year_after_2024?), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1), diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index e2706c751..d24e557ae 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -52,7 +52,13 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_deposit_and_grant_total, record.value_with_discount, tolerance, strict: !record.discount.nil?) && record.discounted_ownership_sale? %i[mortgageused mortgage value deposit ownershipsch discount grant].each do |field| - record.errors.add field, I18n.t("validations.sale_information.discounted_ownership_value", mortgage_deposit_and_grant_total: record.field_formatted_as_currency("mortgage_deposit_and_grant_total"), value_with_discount: record.field_formatted_as_currency("value_with_discount")) + record.errors.add field, I18n.t("validations.sale_information.discounted_ownership_value", + mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "", + deposit: record.field_formatted_as_currency("deposit"), + grant: record.grant.present? ? " (#{record.field_formatted_as_currency('grant')})" : "", + mortgage_deposit_and_grant_total: record.field_formatted_as_currency("mortgage_deposit_and_grant_total"), + discount_sentence: record.discount.present? ? " (#{record.field_formatted_as_currency('value')}) times by the discount (#{record.discount}%)" : "", + value_with_discount: record.field_formatted_as_currency("value_with_discount")).html_safe end end end diff --git a/app/views/form/_radio_question.html.erb b/app/views/form/_radio_question.html.erb index c15b31b58..41e98a1cc 100644 --- a/app/views/form/_radio_question.html.erb +++ b/app/views/form/_radio_question.html.erb @@ -1,4 +1,4 @@ -<%= render partial: "form/guidance/#{question.top_guidance_partial}" if question.top_guidance? %> +<%= render partial: "form/guidance/#{question.top_guidance_partial}", locals: { log: @log } if question.top_guidance? %> <% banner = question.notification_banner(@log) %> <% if banner %> <%= govuk_notification_banner( diff --git a/app/views/form/guidance/_financial_calculations_discounted_ownership.html.erb b/app/views/form/guidance/_financial_calculations_discounted_ownership.html.erb new file mode 100644 index 000000000..37a646983 --- /dev/null +++ b/app/views/form/guidance/_financial_calculations_discounted_ownership.html.erb @@ -0,0 +1,14 @@ +<% grant_page = log.form.get_question("grant", log).page %> +<% mortgage_page = log.form.get_question("mortgage", log).page %> +<% discount_page = log.form.get_question("discount", log).page %> +<% deposit_page = log.form.get_question("deposit", log).page %> +<%= govuk_details(summary_text: "How the financial values are calculated") do %> +
+ The mortgage amount <%= "(#{govuk_link_to 'Q105', send("#{log.class.name.underscore}_#{mortgage_page.id}_path", log)})".html_safe if mortgage_page.routed_to?(log, current_user) %> + cash deposit <%= "(#{govuk_link_to 'Q109', send("#{log.class.name.underscore}_#{deposit_page.id}_path", log)})".html_safe if deposit_page.routed_to?(log, current_user) %> + and grant <%= "(#{govuk_link_to 'Q102', send("#{log.class.name.underscore}_#{grant_page.id}_path", log)})".html_safe if grant_page.routed_to?(log, current_user) %> + added together must equal + the purchase price (<%= govuk_link_to "Q101", send("#{log.class.name.underscore}_#{log.form.get_question('value', log).page.id}_path", log) %>) + multiplied by the discount stake <%= "(#{govuk_link_to '103', send("#{log.class.name.underscore}_#{discount_page.id}_path", log)})".html_safe if discount_page.routed_to?(log, current_user) %> +
+<% end %> diff --git a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb index 8edbbd375..1164a3461 100644 --- a/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb +++ b/app/views/form/guidance/_financial_calculations_shared_ownership.html.erb @@ -1,4 +1,4 @@ -<%= govuk_details(summary_text: "How the financial values are calculated’") do %> +<%= govuk_details(summary_text: "How the financial values are calculated") do %>The mortgage amount (<%= govuk_link_to "Q92", send("#{log.class.name.underscore}_#{log.form.get_question('mortgage', log).page.id}_path", log) %>), cash deposit (<%= govuk_link_to "Q95", send("#{log.class.name.underscore}_#{log.form.get_question('deposit', log).page.id}_path", log) %>) diff --git a/config/locales/en.yml b/config/locales/en.yml index c204d91e6..771904911 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -644,7 +644,7 @@ en: must_be_after_hodate: "Sale completion date must be after practical completion or handover date" previous_property_type: property_type_bedsit: "A bedsit cannot have more than 1 bedroom" - discounted_ownership_value: "The mortgage, deposit, and grant when added together is %{mortgage_deposit_and_grant_total}, and the purchase price times by the discount is %{value_with_discount}. These figures should be the same" + discounted_ownership_value: "The mortgage%{mortgage}, cash deposit (%{deposit}), and grant%{grant} added together is %{mortgage_deposit_and_grant_total}.The full purchase price%{discount_sentence} is %{value_with_discount}.These two amounts should be the same." outright_sale_value: "The mortgage and deposit when added together is %{mortgage_and_deposit_total}, and the purchase price is %{value}. These figures should be the same." monthly_rent: higher_than_expected: "Basic monthly rent must be between £0.00 and £9,999.00" diff --git a/spec/models/form/sales/pages/deposit_discount_spec.rb b/spec/models/form/sales/pages/deposit_discount_spec.rb new file mode 100644 index 000000000..f4ffb85e5 --- /dev/null +++ b/spec/models/form/sales/pages/deposit_discount_spec.rb @@ -0,0 +1,71 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::DepositDiscount, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection, optional: false) } + + let(:page_id) { "discount" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + before do + allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: false, start_date: Time.zone.local(2023, 4, 1))) + end + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[cashdis]) + end + + it "has the correct id" do + expect(page.id).to eq("discount") + end + + it "has the correct header" do + expect(page.header).to eq("About the deposit") + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "social_homebuy?" => true }], + ) + end + + context "when optional" do + subject(:page) { described_class.new(page_id, page_definition, subsection, optional: true) } + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "social_homebuy?" => true }], + ) + end + end + + context "when it's a 2024 form" do + before do + allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: true, start_date: Time.zone.local(2024, 4, 1))) + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "social_homebuy?" => true, "stairowned_100?" => false }], + ) + end + + context "and optional" do + subject(:page) { described_class.new(page_id, page_definition, subsection, optional: true) } + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "social_homebuy?" => true, "stairowned_100?" => true }], + ) + end + end + end +end diff --git a/spec/models/form/sales/pages/deposit_spec.rb b/spec/models/form/sales/pages/deposit_spec.rb index af314a95a..3a3746ac6 100644 --- a/spec/models/form/sales/pages/deposit_spec.rb +++ b/spec/models/form/sales/pages/deposit_spec.rb @@ -5,8 +5,8 @@ RSpec.describe Form::Sales::Pages::Deposit, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, enabled?: true) } - let(:form) { instance_double(Form, start_year_after_2024?: false, start_date: Time.zone.local(2023, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, enabled?: true, depends_on: true) } + let(:form) { instance_double(Form, start_year_after_2024?: false, start_date: Time.zone.local(2023, 4, 1), depends_on_met: true) } let(:optional) { false } before do diff --git a/spec/models/form/sales/pages/discount_spec.rb b/spec/models/form/sales/pages/discount_spec.rb index bb65f1d6d..1a38bd634 100644 --- a/spec/models/form/sales/pages/discount_spec.rb +++ b/spec/models/form/sales/pages/discount_spec.rb @@ -1,9 +1,9 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::Discount, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection, optional: false) } + subject(:page) { described_class.new(page_id, page_definition, subsection) } - let(:page_id) { "discount" } + let(:page_id) { nil } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } @@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::Discount, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[cashdis]) + expect(page.questions.map(&:id)).to eq(%w[discount]) end it "has the correct id" do @@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::Discount, type: :model do end it "has the correct header" do - expect(page.header).to eq("About the deposit") + expect(page.header).to eq("About the price of the property") end it "has the correct description" do @@ -32,40 +32,8 @@ RSpec.describe Form::Sales::Pages::Discount, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "social_homebuy?" => true }], - ) - end - - context "when optional" do - subject(:page) { described_class.new(page_id, page_definition, subsection, optional: true) } - - it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "social_homebuy?" => true }], - ) - end - end - - context "when it's a 2024 form" do - before do - allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_after_2024?: true, start_date: Time.zone.local(2024, 4, 1))) - end - - it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "social_homebuy?" => true, "stairowned_100?" => false }], - ) - end - - context "and optional" do - subject(:page) { described_class.new(page_id, page_definition, subsection, optional: true) } - - it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "social_homebuy?" => true, "stairowned_100?" => true }], - ) - end - end + expect(page.depends_on).to eq([{ + "right_to_buy?" => true, + }]) end end diff --git a/spec/models/form/sales/pages/about_price_not_rtb_spec.rb b/spec/models/form/sales/pages/grant_spec.rb similarity index 81% rename from spec/models/form/sales/pages/about_price_not_rtb_spec.rb rename to spec/models/form/sales/pages/grant_spec.rb index 95ed0fdb7..f88cdf9ae 100644 --- a/spec/models/form/sales/pages/about_price_not_rtb_spec.rb +++ b/spec/models/form/sales/pages/grant_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutPriceNotRtb, type: :model do +RSpec.describe Form::Sales::Pages::Grant, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -12,11 +12,11 @@ RSpec.describe Form::Sales::Pages::AboutPriceNotRtb, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[value grant]) + expect(page.questions.map(&:id)).to eq(%w[grant]) end it "has the correct id" do - expect(page.id).to eq("about_price_not_rtb") + expect(page.id).to eq("grant") end it "has the correct header" do diff --git a/spec/models/form/sales/pages/about_price_rtb_spec.rb b/spec/models/form/sales/pages/purchase_price_spec.rb similarity index 70% rename from spec/models/form/sales/pages/about_price_rtb_spec.rb rename to spec/models/form/sales/pages/purchase_price_spec.rb index c7ce5c233..57cf526ad 100644 --- a/spec/models/form/sales/pages/about_price_rtb_spec.rb +++ b/spec/models/form/sales/pages/purchase_price_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutPriceRtb, type: :model do +RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -16,11 +16,11 @@ RSpec.describe Form::Sales::Pages::AboutPriceRtb, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[value discount]) + expect(page.questions.map(&:id)).to eq(%w[value]) end it "has the correct id" do - expect(page.id).to eq("about_price_rtb") + expect(page.id).to eq("purchase_price") end it "has the correct header" do @@ -32,8 +32,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceRtb, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ - "right_to_buy?" => true, - }]) + expect(page.depends_on).to eq([{ "right_to_buy?" => true }, + { "rent_to_buy_full_ownership?" => false, "right_to_buy?" => false }]) end end diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb index 9bb428569..e703e713a 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -16,10 +16,11 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model %w[ living_before_purchase_discounted_ownership_joint_purchase living_before_purchase_discounted_ownership - about_price_rtb + purchase_price + discount extra_borrowing_price_value_check percentage_discount_value_check - about_price_not_rtb + grant grant_value_check purchase_price_discounted_ownership discounted_sale_grant_value_check diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index 65359b30f..41b1d842d 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -235,13 +235,13 @@ RSpec.describe Validations::Sales::SaleInformationValidations do sale_information_validator.validate_discounted_ownership_value(record) - expect(record.errors["mortgageused"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") - expect(record.errors["mortgage"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") - expect(record.errors["value"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") - expect(record.errors["deposit"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") - expect(record.errors["ownershipsch"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") - expect(record.errors["discount"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") - expect(record.errors["grant"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £49,999.00. These figures should be the same") + expect(record.errors["mortgageused"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") + expect(record.errors["ownershipsch"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") + expect(record.errors["discount"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") + expect(record.errors["grant"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £49,999.00.These two amounts should be the same.") end it "adds an error if mortgage, deposit and grant at least 1 less than discounted value" do @@ -252,13 +252,13 @@ RSpec.describe Validations::Sales::SaleInformationValidations do sale_information_validator.validate_discounted_ownership_value(record) - expect(record.errors["mortgageused"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") - expect(record.errors["mortgage"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") - expect(record.errors["value"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") - expect(record.errors["deposit"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") - expect(record.errors["ownershipsch"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") - expect(record.errors["discount"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") - expect(record.errors["grant"]).to include("The mortgage, deposit, and grant when added together is £50,000.00, and the purchase price times by the discount is £50,001.00. These figures should be the same") + expect(record.errors["mortgageused"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") + expect(record.errors["ownershipsch"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") + expect(record.errors["discount"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") + expect(record.errors["grant"]).to include("The mortgage (£30,000.00), cash deposit (£5,000.00), and grant (£15,000.00) added together is £50,000.00.The full purchase price is £50,001.00.These two amounts should be the same.") end it "does not add an error if mortgage, deposit and grant total equals discounted value" do @@ -345,13 +345,13 @@ RSpec.describe Validations::Sales::SaleInformationValidations do sale_information_validator.validate_discounted_ownership_value(record) - expect(record.errors["mortgageused"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") - expect(record.errors["mortgage"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") - expect(record.errors["value"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") - expect(record.errors["deposit"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") - expect(record.errors["ownershipsch"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") - expect(record.errors["discount"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") - expect(record.errors["grant"]).to include("The mortgage, deposit, and grant when added together is £66,113.00, and the purchase price times by the discount is £66,051.00. These figures should be the same") + expect(record.errors["mortgageused"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") + expect(record.errors["ownershipsch"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") + expect(record.errors["discount"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") + expect(record.errors["grant"]).to include("The mortgage (£66,113.00), cash deposit (£0.00), and grant added together is £66,113.00.The full purchase price (£123,000.00) times by the discount (46.3%) is £66,051.00.These two amounts should be the same.") end it "does not add errors if mortgage and deposit total is exactly 0.05% x market value away from market value - discount" do @@ -379,13 +379,14 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "returns true if mortgage and deposit total does not equal market value" do record.deposit = 2_000 sale_information_validator.validate_discounted_ownership_value(record) - expect(record.errors["mortgageused"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") - expect(record.errors["mortgage"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") - expect(record.errors["value"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") - expect(record.errors["deposit"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") - expect(record.errors["ownershipsch"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") - expect(record.errors["discount"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") - expect(record.errors["grant"]).to include("The mortgage, deposit, and grant when added together is £12,000.00, and the purchase price times by the discount is £30,000.00. These figures should be the same") + + expect(record.errors["mortgageused"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") + expect(record.errors["ownershipsch"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") + expect(record.errors["discount"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") + expect(record.errors["grant"]).to include("The mortgage (£10,000.00), cash deposit (£2,000.00), and grant added together is £12,000.00.The full purchase price is £30,000.00.These two amounts should be the same.") end it "returns false if mortgage and deposit total equals market value" do @@ -425,13 +426,13 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "returns true if mortgage, grant and deposit total does not equal market value - discount" do record.mortgage = 10 sale_information_validator.validate_discounted_ownership_value(record) - expect(record.errors["mortgageused"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["mortgage"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["value"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["deposit"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["ownershipsch"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["discount"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["grant"]).to include("The mortgage, deposit, and grant when added together is £8,010.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") + expect(record.errors["mortgageused"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["ownershipsch"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["discount"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["grant"]).to include("The mortgage (£10.00), cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,010.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") end it "returns false if mortgage, grant and deposit total equals market value - discount" do @@ -453,13 +454,14 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "returns true if grant and deposit total does not equal market value - discount" do sale_information_validator.validate_discounted_ownership_value(record) - expect(record.errors["mortgageused"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["mortgage"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["value"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["deposit"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["ownershipsch"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["discount"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") - expect(record.errors["grant"]).to include("The mortgage, deposit, and grant when added together is £8,000.00, and the purchase price times by the discount is £18,000.00. These figures should be the same") + + expect(record.errors["mortgageused"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["mortgage"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["value"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["deposit"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["ownershipsch"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["discount"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") + expect(record.errors["grant"]).to include("The mortgage, cash deposit (£5,000.00), and grant (£3,000.00) added together is £8,000.00.The full purchase price (£20,000.00) times by the discount (10.0%) is £18,000.00.These two amounts should be the same.") end it "returns false if mortgage, grant and deposit total equals market value - discount" do diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 656ff7a2f..b00641756 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -1379,7 +1379,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "only adds errors to the discounted ownership field" do parser.valid? expect(parser.errors[:field_103]).to be_empty - expect(parser.errors[:field_117]).to include("The mortgage, deposit, and grant when added together is £100.00, and the purchase price times by the discount is £90.00. These figures should be the same") + expect(parser.errors[:field_117]).to include("The mortgage, cash deposit (£100.00), and grant added together is £100.00.The full purchase price (£100.00) times by the discount (10.0%) is £90.00.These two amounts should be the same.") expect(parser.errors[:field_126]).to be_empty end end