From d1584604b37d88cc99ddeeccaecbc7493b8c7570 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Mon, 8 Feb 2021 15:42:45 +0100 Subject: [PATCH] fix a rounding error with coupons --- app/services/coupon_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/coupon_service.rb b/app/services/coupon_service.rb index 68287c727..05f8c9964 100644 --- a/app/services/coupon_service.rb +++ b/app/services/coupon_service.rb @@ -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