mirror of
https://github.com/Crocmagnon/checkout.git
synced 2024-11-22 16:18:03 +01:00
Fix no basket report
This commit is contained in:
parent
f9b207a5eb
commit
e1b456ab3c
5 changed files with 26 additions and 13 deletions
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-04-26 20:35+0200\n"
|
||||
"POT-Creation-Date: 2022-04-26 21:11+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
|
@ -5,7 +5,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-04-26 20:35+0200\n"
|
||||
"POT-Creation-Date: 2022-04-26 21:11+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-04-26 20:35+0200\n"
|
||||
"POT-Creation-Date: 2022-04-26 21:11+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -203,7 +203,7 @@ msgid "Product"
|
|||
msgstr ""
|
||||
|
||||
#: purchase/templates/purchase/snippets/report_products.html:7
|
||||
#: purchase/views/reports.py:65
|
||||
#: purchase/views/reports.py:70
|
||||
msgid "# sold"
|
||||
msgstr ""
|
||||
|
||||
|
@ -219,14 +219,18 @@ msgstr ""
|
|||
msgid "Basket successfully deleted."
|
||||
msgstr ""
|
||||
|
||||
#: purchase/views/reports.py:70
|
||||
#: purchase/views/reports.py:28
|
||||
msgid "No sale to report"
|
||||
msgstr ""
|
||||
|
||||
#: purchase/views/reports.py:75
|
||||
msgid "Turnover by product"
|
||||
msgstr ""
|
||||
|
||||
#: purchase/views/reports.py:106
|
||||
#: purchase/views/reports.py:113
|
||||
msgid "Basket count by hour"
|
||||
msgstr ""
|
||||
|
||||
#: purchase/views/reports.py:111
|
||||
#: purchase/views/reports.py:118
|
||||
msgid "Turnover by hour"
|
||||
msgstr ""
|
||||
|
|
|
@ -5,7 +5,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2022-04-26 20:35+0200\n"
|
||||
"POT-Creation-Date: 2022-04-26 21:11+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -200,7 +200,7 @@ msgid "Product"
|
|||
msgstr "Produit"
|
||||
|
||||
#: purchase/templates/purchase/snippets/report_products.html:7
|
||||
#: purchase/views/reports.py:65
|
||||
#: purchase/views/reports.py:70
|
||||
msgid "# sold"
|
||||
msgstr "Nb. vendus"
|
||||
|
||||
|
@ -216,14 +216,18 @@ msgstr "Panier correctement modifié."
|
|||
msgid "Basket successfully deleted."
|
||||
msgstr "Panier correctement supprimé."
|
||||
|
||||
#: purchase/views/reports.py:70
|
||||
#: purchase/views/reports.py:28
|
||||
msgid "No sale to report"
|
||||
msgstr "Aucune vente à afficher"
|
||||
|
||||
#: purchase/views/reports.py:75
|
||||
msgid "Turnover by product"
|
||||
msgstr "Chiffre d'affaires par produit"
|
||||
|
||||
#: purchase/views/reports.py:106
|
||||
#: purchase/views/reports.py:113
|
||||
msgid "Basket count by hour"
|
||||
msgstr "Nombre de paniers par heure"
|
||||
|
||||
#: purchase/views/reports.py:111
|
||||
#: purchase/views/reports.py:118
|
||||
msgid "Turnover by hour"
|
||||
msgstr "Chiffre d'affaires par heure"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import datetime
|
||||
from io import StringIO
|
||||
|
||||
from django.contrib import messages
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic import TemplateView
|
||||
from matplotlib import pyplot as plt
|
||||
|
@ -22,6 +23,11 @@ class ReportsView(ProtectedViewsMixin, TemplateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
baskets = list(Basket.objects.priced().order_by("created_at"))
|
||||
if not baskets:
|
||||
messages.warning(self.request, _("No sale to report"))
|
||||
return context
|
||||
|
||||
dates = Basket.objects.values_list("created_at__date", flat=True).distinct()
|
||||
average_basket_by_day = {
|
||||
date: Basket.objects.by_date(date).average_basket() for date in dates
|
||||
|
@ -32,7 +38,6 @@ class ReportsView(ProtectedViewsMixin, TemplateView):
|
|||
|
||||
products = Product.objects.with_turnover().with_sold()
|
||||
products_plot = self.get_products_plot(products)
|
||||
baskets = list(Basket.objects.priced().order_by("created_at"))
|
||||
by_hour_plot = self.by_hour_plot(baskets)
|
||||
context.update(
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue