chore: docs and added new field for tpv domain

This commit is contained in:
2025-01-13 18:08:57 +01:00
parent 475b53a7e3
commit 2ff2d08565
12 changed files with 101 additions and 43 deletions
+21 -13
View File
@@ -1,3 +1,5 @@
from decimal import Decimal
from django.db.models import Sum
from django.http.response import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect, reverse
@@ -79,7 +81,7 @@ class CartDetail(TemplateView, CreateView):
return {
"cart": cart,
"items": cart_items,
"title": web_settings.web_title,
"web_title": web_settings.web_title,
"description": _("resumen del carrito"),
}
@@ -148,15 +150,21 @@ class OrderDetail(TemplateView):
items = OrderLine.objects.select_related("product").filter(
order=order, product__is_shipping_method=False
)
shipping_cost = (
OrderLine.objects.select_related("product")
.filter(
order=order,
product__is_shipping_method=True,
)
.aggregate(amount=Sum("total"))
.get("amount")
)
shipping_cost = OrderLine.objects.select_related("product").filter(
order=order,
product__is_shipping_method=True,
).aggregate(amount=Sum("total")).get("amount") or Decimal("0")
base_total = OrderLine.objects.select_related("product").filter(
order=order,
product__is_shipping_method=False,
).aggregate(amount=Sum("base_total")).get("amount") or Decimal("0")
tax_total = OrderLine.objects.select_related("product").filter(
order=order,
product__is_shipping_method=False,
).aggregate(amount=Sum("taxes")).get("amount") or Decimal("0")
return {
"order": order,
@@ -165,9 +173,9 @@ class OrderDetail(TemplateView):
"merchant_parameters": parameters.get("Ds_MerchantParameters"),
"signature": parameters.get("Ds_Signature"),
"redsys_target_url": redsys_client.get_target_url(),
"total": order.total,
"base_total": order.base_total,
"tax_total": order.total - order.base_total,
"total": round(order.total, 2),
"base_total": round(base_total, 2),
"tax_total": round(tax_total, 2),
"shipping_cost": round(shipping_cost, 2),
}