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 @@
Produit | {% if display_prices %}Prix unitaire | {% endif %}Quantité | |||
---|---|---|---|---|---|
Produit | {% if display_prices %}Prix unitaire (€) | {% endif %}Quantité | {% if display_prices %}Somme (€) | {% endif %}||
{{ product }}{% if product.rupture %} (rupture){% endif %} | - {% if display_prices %}{{ product.price | round(2) }} € | {% endif %}{{ order[product].quantity }} x {{ product.unit }} | + {% if display_prices %} +{{ product.price | round(2) }} € | + {% endif %} +{{ order[product].quantity }} x {{ product.unit }} | + {% if display_prices %} +{{ order.total([product], delivery, group_id, False) }} | + {% endif %}
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)