Make sure total is calculated as a Decimal

This commit is contained in:
Raphael Michel
2019-02-12 16:27:37 +01:00
parent 78544cdb30
commit 55841ea660
2 changed files with 5 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
from decimal import Decimal
from django.conf import settings
from django.contrib import messages
from django.core.exceptions import ValidationError
@@ -460,7 +462,7 @@ class PaymentStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
def _total_order_value(self):
total = get_cart_total(self.request)
total += sum([f.value for f in get_fees(self.request.event, self.request, total, self.invoice_address, None)])
return total
return Decimal(total)
@cached_property
def provider_forms(self):

View File

@@ -1,5 +1,6 @@
from collections import defaultdict
from datetime import datetime, timedelta
from decimal import Decimal
from functools import wraps
from itertools import groupby
@@ -198,7 +199,7 @@ def get_cart_total(request):
else:
request._cart_total_cache = CartPosition.objects.filter(
cart_id=get_or_create_cart_id(request), event=request.event
).aggregate(sum=Sum('price'))['sum'] or 0
).aggregate(sum=Sum('price'))['sum'] or Decimal('0.00')
return request._cart_total_cache