|
|
|
@ -50,7 +50,7 @@ module Validations::Sales::SaleInformationValidations |
|
|
|
# When a percentage discount is used, a percentage tolerance is needed to account for rounding errors |
|
|
|
# When a percentage discount is used, a percentage tolerance is needed to account for rounding errors |
|
|
|
tolerance = record.discount ? record.value * 0.05 / 100 : 1 |
|
|
|
tolerance = record.discount ? record.value * 0.05 / 100 : 1 |
|
|
|
|
|
|
|
|
|
|
|
if over_tolerance?(record.mortgage_deposit_and_grant_total, record.value_with_discount, tolerance, true) && record.discounted_ownership_sale? |
|
|
|
if over_tolerance?(record.mortgage_deposit_and_grant_total, record.value_with_discount, tolerance, strict: true) && record.discounted_ownership_sale? |
|
|
|
%i[mortgageused mortgage value deposit ownershipsch discount grant].each do |field| |
|
|
|
%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_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")) |
|
|
|
end |
|
|
|
end |
|
|
|
|