mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add more defensive code in TaxRateFinder
This commit is contained in:
@@ -75,7 +75,7 @@ class TaxRateFinder
|
||||
# to the included tax.
|
||||
def find_closest_tax_rates_from_included_tax(amount, included_tax)
|
||||
approximation = (included_tax / (amount - included_tax))
|
||||
return [] if approximation.infinite? || approximation.zero?
|
||||
return [] if approximation.infinite? || approximation.zero? || approximation.nan?
|
||||
|
||||
[Spree::TaxRate.order("ABS(amount - #{approximation})").first]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user