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 ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
|
|
@ -5,7 +5,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -203,7 +203,7 @@ msgid "Product"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: purchase/templates/purchase/snippets/report_products.html:7
|
#: purchase/templates/purchase/snippets/report_products.html:7
|
||||||
#: purchase/views/reports.py:65
|
#: purchase/views/reports.py:70
|
||||||
msgid "# sold"
|
msgid "# sold"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -219,14 +219,18 @@ msgstr ""
|
||||||
msgid "Basket successfully deleted."
|
msgid "Basket successfully deleted."
|
||||||
msgstr ""
|
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"
|
msgid "Turnover by product"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: purchase/views/reports.py:106
|
#: purchase/views/reports.py:113
|
||||||
msgid "Basket count by hour"
|
msgid "Basket count by hour"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: purchase/views/reports.py:111
|
#: purchase/views/reports.py:118
|
||||||
msgid "Turnover by hour"
|
msgid "Turnover by hour"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -5,7 +5,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -200,7 +200,7 @@ msgid "Product"
|
||||||
msgstr "Produit"
|
msgstr "Produit"
|
||||||
|
|
||||||
#: purchase/templates/purchase/snippets/report_products.html:7
|
#: purchase/templates/purchase/snippets/report_products.html:7
|
||||||
#: purchase/views/reports.py:65
|
#: purchase/views/reports.py:70
|
||||||
msgid "# sold"
|
msgid "# sold"
|
||||||
msgstr "Nb. vendus"
|
msgstr "Nb. vendus"
|
||||||
|
|
||||||
|
@ -216,14 +216,18 @@ msgstr "Panier correctement modifié."
|
||||||
msgid "Basket successfully deleted."
|
msgid "Basket successfully deleted."
|
||||||
msgstr "Panier correctement supprimé."
|
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"
|
msgid "Turnover by product"
|
||||||
msgstr "Chiffre d'affaires par produit"
|
msgstr "Chiffre d'affaires par produit"
|
||||||
|
|
||||||
#: purchase/views/reports.py:106
|
#: purchase/views/reports.py:113
|
||||||
msgid "Basket count by hour"
|
msgid "Basket count by hour"
|
||||||
msgstr "Nombre de paniers par heure"
|
msgstr "Nombre de paniers par heure"
|
||||||
|
|
||||||
#: purchase/views/reports.py:111
|
#: purchase/views/reports.py:118
|
||||||
msgid "Turnover by hour"
|
msgid "Turnover by hour"
|
||||||
msgstr "Chiffre d'affaires par heure"
|
msgstr "Chiffre d'affaires par heure"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import datetime
|
import datetime
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
|
from django.contrib import messages
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
|
@ -22,6 +23,11 @@ class ReportsView(ProtectedViewsMixin, TemplateView):
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**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()
|
dates = Basket.objects.values_list("created_at__date", flat=True).distinct()
|
||||||
average_basket_by_day = {
|
average_basket_by_day = {
|
||||||
date: Basket.objects.by_date(date).average_basket() for date in dates
|
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 = Product.objects.with_turnover().with_sold()
|
||||||
products_plot = self.get_products_plot(products)
|
products_plot = self.get_products_plot(products)
|
||||||
baskets = list(Basket.objects.priced().order_by("created_at"))
|
|
||||||
by_hour_plot = self.by_hour_plot(baskets)
|
by_hour_plot = self.by_hour_plot(baskets)
|
||||||
context.update(
|
context.update(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue