1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

fix a rounding error with coupons

This commit is contained in:
Sylvain 2021-02-08 15:42:45 +01:00
parent 0e7226c85c
commit d1584604b3

View File

@ -25,7 +25,7 @@ class CouponService
unless coupon_object.nil?
if coupon_object.status(user_id, total) == 'active'
if coupon_object.type == 'percent_off'
price -= price * coupon_object.percent_off / 100.00
price -= (price * coupon_object.percent_off / 100.00).truncate
elsif coupon_object.type == 'amount_off'
# do not apply cash coupon unless it has a lower amount that the total price
price -= coupon_object.amount_off if coupon_object.amount_off <= price