From f5e6529baa08a2e73b5b36dcf30bbaa74ad815f7 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Wed, 4 Dec 2024 16:05:05 +0000 Subject: [PATCH] CLDC-3314: Skip BU error for ownershipsch in validate_discounted_ownership_value (#2837) --- .../validations/sales/sale_information_validations.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index 3825271c5..4b8948053 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -64,7 +64,7 @@ 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? deposit_and_grant_sentence = record.grant.present? ? ", cash deposit (#{record.field_formatted_as_currency('deposit')}), and grant (#{record.field_formatted_as_currency('grant')})" : " and cash deposit (#{record.field_formatted_as_currency('deposit')})" discount_sentence = record.discount.present? ? " (#{record.field_formatted_as_currency('value')}) subtracted by the sum of the full purchase price (#{record.field_formatted_as_currency('value')}) multiplied by the percentage discount (#{record.discount}%)" : "" - %i[mortgageused mortgage value deposit ownershipsch discount grant].each do |field| + %i[mortgageused mortgage value deposit discount grant].each do |field| record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.discounted_ownership_value", mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "", deposit_and_grant_sentence:, @@ -72,6 +72,12 @@ module Validations::Sales::SaleInformationValidations discount_sentence:, value_with_discount: record.field_formatted_as_currency("value_with_discount")).html_safe end + record.errors.add :ownershipsch, :skip_bu_error, message: I18n.t("validations.sales.sale_information.ownershipsch.discounted_ownership_value", + mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "", + deposit_and_grant_sentence:, + mortgage_deposit_and_grant_total: record.field_formatted_as_currency("mortgage_deposit_and_grant_total"), + discount_sentence:, + value_with_discount: record.field_formatted_as_currency("value_with_discount")).html_safe end end