fix: taxes on cart detail
This commit is contained in:
@@ -66,7 +66,10 @@ MIDDLEWARE = DJANGO_MIDDLEWARE + PROJECT_MIDDLEWARE
|
|||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
INSTALLED_APPS += ["silk"]
|
INSTALLED_APPS += ["silk"]
|
||||||
MIDDLEWARE += ["silk.middleware.SilkyMiddleware", "django_browser_reload.middleware.BrowserReloadMiddleware",]
|
MIDDLEWARE += [
|
||||||
|
"silk.middleware.SilkyMiddleware",
|
||||||
|
"django_browser_reload.middleware.BrowserReloadMiddleware",
|
||||||
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = "config.urls"
|
ROOT_URLCONF = "config.urls"
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -16,4 +16,7 @@ urlpatterns = [
|
|||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
|
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
urlpatterns += [path("silk/", include("silk.urls")), path("__reload__/", include("django_browser_reload.urls")),]
|
urlpatterns += [
|
||||||
|
path("silk/", include("silk.urls")),
|
||||||
|
path("__reload__/", include("django_browser_reload.urls")),
|
||||||
|
]
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ def cart(request, *args, **kwargs):
|
|||||||
for item in items:
|
for item in items:
|
||||||
price = ProductPrice.objects.filter(product=item.product, current=True).first()
|
price = ProductPrice.objects.filter(product=item.product, current=True).first()
|
||||||
base_total += price.price * item.quantity
|
base_total += price.price * item.quantity
|
||||||
tax_total += round(price.price * Decimal(price.tax.value / 100), 2)
|
tax_total += round(
|
||||||
|
price.price * Decimal(price.tax.value / 100) * item.quantity, 2
|
||||||
|
)
|
||||||
|
|
||||||
total = base_total + tax_total
|
total = base_total + tax_total
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -166,8 +166,10 @@ class OrderDetail(TemplateView):
|
|||||||
order=order,
|
order=order,
|
||||||
product__is_shipping_method=False,
|
product__is_shipping_method=False,
|
||||||
).aggregate(amount=Sum("taxes")).get("amount") or Decimal("0")
|
).aggregate(amount=Sum("taxes")).get("amount") or Decimal("0")
|
||||||
|
settings = WebSettings.load()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"web_title": settings.web_title,
|
||||||
"order": order,
|
"order": order,
|
||||||
"items": items,
|
"items": items,
|
||||||
"signature_version": parameters.get("Ds_SignatureVersion"),
|
"signature_version": parameters.get("Ds_SignatureVersion"),
|
||||||
@@ -197,7 +199,9 @@ class OrdersView(TemplateView, FilteredQuerysetMixin, PaginatedQuerysetMixin):
|
|||||||
template_name = "web/orders.html"
|
template_name = "web/orders.html"
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Order.objects.filter(user=self.request.user).exclude(status=Order.Statuses.STATUS_PENDING)
|
return Order.objects.filter(user=self.request.user).exclude(
|
||||||
|
status=Order.Statuses.STATUS_PENDING
|
||||||
|
)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
settings = WebSettings.load()
|
settings = WebSettings.load()
|
||||||
|
|||||||
Reference in New Issue
Block a user