From c87aed2faa15e528c9d09705807d4fbf334a3c40 Mon Sep 17 00:00:00 2001 From: JamesRamm Date: Tue, 8 Aug 2017 15:08:25 +0100 Subject: [PATCH] Correct usage of decimal/float --- longclaw/longclawbasket/models.py | 1 - longclaw/longclawcheckout/utils.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/longclaw/longclawbasket/models.py b/longclaw/longclawbasket/models.py index 2d49d8a..753a6bc 100644 --- a/longclaw/longclawbasket/models.py +++ b/longclaw/longclawbasket/models.py @@ -39,4 +39,3 @@ class BasketItem(models.Model): self.delete() else: self.save() - diff --git a/longclaw/longclawcheckout/utils.py b/longclaw/longclawcheckout/utils.py index 1371f9d..86aef29 100644 --- a/longclaw/longclawcheckout/utils.py +++ b/longclaw/longclawcheckout/utils.py @@ -1,3 +1,4 @@ +from decimal import Decimal from django.utils.module_loading import import_string from django.utils import timezone from ipware.ip import get_real_ip @@ -70,7 +71,8 @@ def create_order(email, shipping_option, site_settings)['rate'] else: - shipping_rate = 0 + shipping_rate = Decimal(0) + order = Order( email=email, ip_address=ip_address, @@ -94,7 +96,7 @@ def create_order(email, if capture_payment: desc = 'Payment from {} for order id #{}'.format(email, order.id) transaction_id = GATEWAY.create_payment(request, - float(total) + shipping_rate, + total + shipping_rate, description=desc) order.payment_date = timezone.now() order.transaction_id = transaction_id