From b26f07ab5a2e6965b2e763b46e9570dddf5c6aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Wed, 7 Apr 2021 22:07:03 +0200 Subject: [PATCH] Display shipping prices in the order summary --- copanier/models.py | 13 ++++++++----- copanier/templates/includes/order_summary.html | 13 +++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/copanier/models.py b/copanier/models.py index 66d559b..bd4bdaf 100644 --- a/copanier/models.py +++ b/copanier/models.py @@ -293,12 +293,15 @@ class Order(Base): p.quantity * _get_price(ref) for ref, p in self.products.items() ) - total_shipping = 0 - if include_shipping: - for producer in producers: - total_shipping = total_shipping + delivery.shipping_for(email, producer) + shipping = self.compute_shipping(delivery, producers, email) if include_shipping else 0 - return round(total_products + total_shipping, 2) + return round(total_products + shipping, 2) + + def compute_shipping(self, delivery, producers, email): + total_shipping = 0 + for producer in producers: + total_shipping = total_shipping + delivery.shipping_for(email, producer) + return total_shipping @property def has_adjustments(self): diff --git a/copanier/templates/includes/order_summary.html b/copanier/templates/includes/order_summary.html index efd1581..4b2ff41 100644 --- a/copanier/templates/includes/order_summary.html +++ b/copanier/templates/includes/order_summary.html @@ -1,13 +1,18 @@ - {% if display_prices %}{% endif %} + {% if display_prices %}{% endif %}{% if display_prices %}{% endif %} {% for product in delivery.products %} {% if order[product].quantity %} - {% if display_prices %}{% endif %} + {% if display_prices %} + + {% endif %} + + {% if display_prices %} + + {% endif %} - {% if product.rupture %}{% endif %} {% endif %} {% endfor %}
ProduitPrix unitaireQuantité
ProduitPrix unitaire (€)QuantitéSomme (€)
{{ product }}{% if product.rupture %} (rupture){% endif %}{{ product.price | round(2) }} €{{ order[product].quantity }} x {{ product.unit }}{{ product.price | round(2) }} €{{ order[product].quantity }} x {{ product.unit }}{{ order.total([product], delivery, group_id, False) }}
-

Total: {{ order.total(delivery.products, delivery, group_id) if order else 0 }} €

+

Total: {{ order.total(delivery.products, delivery, group_id) if order else 0 }} € (dont {{ order.compute_shipping(delivery, delivery.producers, group_id) | round(2) }} de port)