mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-11-22 08:08:04 +01:00
Add average basket
This commit is contained in:
parent
be6ec786db
commit
d16d9307f4
2 changed files with 9 additions and 3 deletions
|
@ -3,8 +3,11 @@
|
|||
|
||||
{% block content %}
|
||||
<h1>Reports</h1>
|
||||
<h2>Total turnover</h2>
|
||||
<ul><li>{{ total|currency }}</li></ul>
|
||||
<h2>General</h2>
|
||||
<ul>
|
||||
<li>Total turnover: {{ total|currency }}</li>
|
||||
<li>Average basket: {{ average_basket|currency }}</li>
|
||||
</ul>
|
||||
|
||||
<h2>Products</h2>
|
||||
{% include "purchase/snippets/report_products.html" %}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from django.db.models import Sum
|
||||
from django.db.models import Avg, Sum
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from purchase.models import Basket, PaymentMethod, Product
|
||||
|
@ -14,6 +14,9 @@ class ReportsView(ProtectedViewsMixin, TemplateView):
|
|||
context.update(
|
||||
{
|
||||
"total": Basket.objects.priced().aggregate(total=Sum("price"))["total"],
|
||||
"average_basket": Basket.objects.priced().aggregate(avg=Avg("price"))[
|
||||
"avg"
|
||||
],
|
||||
"products": Product.objects.with_turnover().with_sold(),
|
||||
"payment_methods": PaymentMethod.objects.with_turnover().with_sold(),
|
||||
"no_payment_method": Basket.objects.no_payment_method().priced(),
|
||||
|
|
Loading…
Reference in a new issue