recode precision test to allow slight rounding errors
This commit is contained in:
parent
00543bc7d9
commit
280834f8fb
|
@ -93,8 +93,8 @@ module Spree::PaypalExpress
|
||||||
# paypal expects this sum to work out (TODO: shift to AM code? and throw wobbly?)
|
# paypal expects this sum to work out (TODO: shift to AM code? and throw wobbly?)
|
||||||
# there might be rounding issues when it comes to tax, though you can capture slightly extra
|
# there might be rounding issues when it comes to tax, though you can capture slightly extra
|
||||||
opts[:money] = opts.slice(:subtotal, :tax, :shipping, :handling).values.sum
|
opts[:money] = opts.slice(:subtotal, :tax, :shipping, :handling).values.sum
|
||||||
if opts[:money] != spree_total
|
if (opts[:money].to_f - spree_total.to_f).abs > 0.01
|
||||||
raise "Ouch - precision problems: #{opts[:money]} vs #{spree_total}"
|
raise "Ouch - precision problems: #{opts[:money].to_f} vs #{spree_total.to_f}, diff #{opts[:money].to_f - spree_total.to_f}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# prepare the numbers for the gateway
|
# prepare the numbers for the gateway
|
||||||
|
|
Loading…
Reference in New Issue