diff --git a/src/common/locale/en/LC_MESSAGES/django.po b/src/common/locale/en/LC_MESSAGES/django.po index 6dff4ea..cfbd74a 100644 --- a/src/common/locale/en/LC_MESSAGES/django.po +++ b/src/common/locale/en/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \n" diff --git a/src/common/locale/fr/LC_MESSAGES/django.po b/src/common/locale/fr/LC_MESSAGES/django.po index 83635b4..8f3d4e0 100644 --- a/src/common/locale/fr/LC_MESSAGES/django.po +++ b/src/common/locale/fr/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \n" diff --git a/src/purchase/locale/en/LC_MESSAGES/django.po b/src/purchase/locale/en/LC_MESSAGES/django.po index dd11f7f..63ea1c6 100644 --- a/src/purchase/locale/en/LC_MESSAGES/django.po +++ b/src/purchase/locale/en/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/src/purchase/locale/fr/LC_MESSAGES/django.po b/src/purchase/locale/fr/LC_MESSAGES/django.po index 1a4ed45..a35b884 100644 --- a/src/purchase/locale/fr/LC_MESSAGES/django.po +++ b/src/purchase/locale/fr/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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" diff --git a/src/purchase/views/reports.py b/src/purchase/views/reports.py index 388089c..1b080da 100644 --- a/src/purchase/views/reports.py +++ b/src/purchase/views/reports.py @@ -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( {