Add cash register summary view

This commit is contained in:
Skia 2016-09-13 02:04:49 +02:00
parent b0ce448ec7
commit 6cf253365b
8 changed files with 171 additions and 48 deletions

View File

@ -26,6 +26,7 @@
<li><a href="{{ url('counter:admin_list') }}">{% trans %}General counters management{% endtrans %}</a></li> <li><a href="{{ url('counter:admin_list') }}">{% trans %}General counters management{% endtrans %}</a></li>
<li><a href="{{ url('counter:product_list') }}">{% trans %}Products management{% endtrans %}</a></li> <li><a href="{{ url('counter:product_list') }}">{% trans %}Products management{% endtrans %}</a></li>
<li><a href="{{ url('counter:producttype_list') }}">{% trans %}Product types management{% endtrans %}</a></li> <li><a href="{{ url('counter:producttype_list') }}">{% trans %}Product types management{% endtrans %}</a></li>
<li><a href="{{ url('counter:cash_summary_list') }}">{% trans %}Cash register summaries{% endtrans %}</a></li>
{% endif %} {% endif %}
{% for b in settings.SITH_COUNTER_BARS %} {% for b in settings.SITH_COUNTER_BARS %}
{% if user.is_in_group(b[1]+" admin") %} {% if user.is_in_group(b[1]+" admin") %}

View File

@ -346,6 +346,14 @@ class CashRegisterSummary(models.Model):
def __str__(self): def __str__(self):
return "At %s by %s - Total: %s" % (self.counter, self.user, self.get_total()) return "At %s by %s - Total: %s" % (self.counter, self.user, self.get_total())
def is_owned_by(self, user):
"""
Method to see if that object can be edited by the given user
"""
if user.is_in_group(settings.SITH_GROUPS['counter-admin']['name']):
return True
return False
def get_total(self): def get_total(self):
t = 0 t = 0
for it in self.items.all(): for it in self.items.all():

View File

@ -0,0 +1,58 @@
{% extends "core/base.jinja" %}
{% from 'core/macros.jinja' import user_profile_link %}
{% block title %}
{% trans %}Cash register summary list{% endtrans %}
{% endblock %}
{% block content %}
{% if cashsummary_list %}
<h3>{% trans %}Cash register summary list{% endtrans %}</h3>
<h5>{% trans %}Theoric sums{% endtrans %}</h5>
<h6>{% trans %}Refillings{% endtrans %}</h6>
<p>
{% for b,s in refilling_sums.items() %}
{{ b }}: {{ s }} €<br/>
{% endfor %}
</p>
<h6>{% trans %}Cash register summaries{% endtrans %}</h6>
<p>
{% for b,s in summaries_sums.items() %}
{{ b }}: {{ s }} €<br/>
{% endfor %}
</p>
<table>
<thead>
<tr>
<td>{% trans %}User{% endtrans %}</td>
<td>{% trans %}Counter{% endtrans %}</td>
<td>{% trans %}Date{% endtrans %}</td>
<td>{% trans %}Total{% endtrans %}</td>
<td>{% trans %}Emptied{% endtrans %}</td>
<td>{% trans %}Comment{% endtrans %}</td>
</tr>
</thead>
<tbody>
{% for c in cashsummary_list.order_by('-date') %}
<tr>
<td>{{ user_profile_link(c.user) }}</td>
<td>{{ c.counter }}</td>
<td>{{ c.date|localtime|date(DATETIME_FORMAT) }} - {{ c.date|localtime|time(DATETIME_FORMAT) }}</td>
<td>{{ c.get_total() }} €</td>
{% if c.emptied %}
<td>{% trans %}yes{% endtrans %}</td>
{% else %}
<td></td>
{% endif %}
<td>{{ c.comment }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
{% trans %}There is no cash register summary in this website.{% endtrans %}
{% endif %}
{% endblock %}

View File

@ -14,6 +14,7 @@ urlpatterns = [
url(r'^admin$', CounterListView.as_view(), name='admin_list'), url(r'^admin$', CounterListView.as_view(), name='admin_list'),
url(r'^admin/new$', CounterCreateView.as_view(), name='new'), url(r'^admin/new$', CounterCreateView.as_view(), name='new'),
url(r'^admin/delete/(?P<counter_id>[0-9]+)$', CounterDeleteView.as_view(), name='delete'), url(r'^admin/delete/(?P<counter_id>[0-9]+)$', CounterDeleteView.as_view(), name='delete'),
url(r'^admin/cash_summary/list$', CashSummaryListView.as_view(), name='cash_summary_list'),
url(r'^admin/product/list$', ProductListView.as_view(), name='product_list'), url(r'^admin/product/list$', ProductListView.as_view(), name='product_list'),
url(r'^admin/product/list_archived$', ProductArchivedListView.as_view(), name='product_list_archived'), url(r'^admin/product/list_archived$', ProductArchivedListView.as_view(), name='product_list_archived'),
url(r'^admin/product/create$', ProductCreateView.as_view(), name='new_product'), url(r'^admin/product/create$', ProductCreateView.as_view(), name='new_product'),

View File

@ -12,7 +12,8 @@ from django.conf import settings
from django.db import DataError, transaction from django.db import DataError, transaction
import re import re
from datetime import date, timedelta import pytz
from datetime import date, timedelta, datetime
from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField from ajax_select.fields import AutoCompleteSelectField, AutoCompleteSelectMultipleField
from ajax_select import make_ajax_form, make_ajax_field from ajax_select import make_ajax_form, make_ajax_field
@ -407,6 +408,11 @@ class CounterTabsMixin(TabedViewMixin):
'slug': 'product_types', 'slug': 'product_types',
'name': _("Product types"), 'name': _("Product types"),
}, },
{
'url': reverse_lazy('counter:cash_summary_list'),
'slug': 'cash_summary',
'name': _("Cash register summaries"),
},
] ]
class CounterListView(CounterTabsMixin, CanViewMixin, ListView): class CounterListView(CounterTabsMixin, CanViewMixin, ListView):
@ -687,3 +693,24 @@ class CounterActivityView(DetailView):
pk_url_kwarg = "counter_id" pk_url_kwarg = "counter_id"
template_name = 'counter/activity.jinja' template_name = 'counter/activity.jinja'
class CashSummaryListView(CanEditPropMixin, CounterTabsMixin, ListView):
"""Display a list of cash summaries"""
model = CashRegisterSummary
template_name = 'counter/cash_summary_list.jinja'
context_object_name = "cashsummary_list"
current_tab = "cash_summary"
def get_context_data(self, **kwargs):
""" Add sums to the context """
kwargs = super(CashSummaryListView, self).get_context_data(**kwargs)
kwargs['summaries_sums'] = {}
kwargs['refilling_sums'] = {}
for c in Counter.objects.filter(type="BAR").all():
last_summary = CashRegisterSummary.objects.filter(counter=c, emptied=True).order_by('-date').first()
if last_summary:
last_date = last_summary.date
else:
last_date = datetime(year=1994, month=5, day=17, tzinfo=pytz.UTC) # My birth date should be old enough
kwargs['summaries_sums'][c.name] = sum([s.get_total() for s in CashRegisterSummary.objects.filter(counter=c, date__gt=last_date).all()])
kwargs['refilling_sums'][c.name] = sum([s.amount for s in Refilling.objects.filter(counter=c, date__gt=last_date).all()])
return kwargs

Binary file not shown.

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-12 17:36+0200\n" "POT-Creation-Date: 2016-09-13 01:57+0200\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -164,6 +164,7 @@ msgstr "type de cible"
#: accounting/models.py:190 club/templates/club/club_members.jinja:8 #: accounting/models.py:190 club/templates/club/club_members.jinja:8
#: club/templates/club/club_old_members.jinja:8 #: club/templates/club/club_old_members.jinja:8
#: counter/templates/counter/cash_summary_list.jinja:27
#: launderette/templates/launderette/launderette_admin.jinja:44 #: launderette/templates/launderette/launderette_admin.jinja:44
msgid "User" msgid "User"
msgstr "Utilisateur" msgstr "Utilisateur"
@ -270,7 +271,7 @@ msgstr "Liste des types comptable"
#: accounting/templates/accounting/journal_details.jinja:9 #: accounting/templates/accounting/journal_details.jinja:9
#: accounting/templates/accounting/operation_edit.jinja:9 #: accounting/templates/accounting/operation_edit.jinja:9
#: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:9 #: accounting/templates/accounting/simplifiedaccountingtype_list.jinja:9
#: core/templates/core/user_tools.jinja:39 #: core/templates/core/user_tools.jinja:40
msgid "Accounting" msgid "Accounting"
msgstr "Comptabilité" msgstr "Comptabilité"
@ -289,7 +290,7 @@ msgstr "Il n'y a pas de types comptable dans ce site web."
#: accounting/templates/accounting/bank_account_details.jinja:4 #: accounting/templates/accounting/bank_account_details.jinja:4
#: accounting/templates/accounting/bank_account_details.jinja:13 #: accounting/templates/accounting/bank_account_details.jinja:13
#: core/templates/core/user_tools.jinja:46 #: core/templates/core/user_tools.jinja:47
msgid "Bank account: " msgid "Bank account: "
msgstr "Compte en banque : " msgstr "Compte en banque : "
@ -325,7 +326,7 @@ msgstr "Nouveau compte club"
#: accounting/templates/accounting/club_account_details.jinja:53 #: accounting/templates/accounting/club_account_details.jinja:53
#: accounting/templates/accounting/journal_details.jinja:66 club/views.py:52 #: accounting/templates/accounting/journal_details.jinja:66 club/views.py:52
#: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31 #: core/templates/core/file.jinja:38 core/templates/core/page.jinja:31
#: core/templates/core/user_tools.jinja:33 core/views/user.py:145 #: core/templates/core/user_tools.jinja:34 core/views/user.py:145
#: counter/templates/counter/counter_list.jinja:17 #: counter/templates/counter/counter_list.jinja:17
#: counter/templates/counter/counter_list.jinja:31 #: counter/templates/counter/counter_list.jinja:31
#: counter/templates/counter/counter_list.jinja:45 #: counter/templates/counter/counter_list.jinja:45
@ -448,6 +449,7 @@ msgstr "No"
#: core/templates/core/user_account_detail.jinja:17 #: core/templates/core/user_account_detail.jinja:17
#: core/templates/core/user_account_detail.jinja:46 #: core/templates/core/user_account_detail.jinja:46
#: core/templates/core/user_account_detail.jinja:79 #: core/templates/core/user_account_detail.jinja:79
#: counter/templates/counter/cash_summary_list.jinja:29
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
@ -472,7 +474,7 @@ msgid "Done"
msgstr "Effectué" msgstr "Effectué"
#: accounting/templates/accounting/journal_details.jinja:34 #: accounting/templates/accounting/journal_details.jinja:34
#: counter/views.py:614 #: counter/templates/counter/cash_summary_list.jinja:32 counter/views.py:615
msgid "Comment" msgid "Comment"
msgstr "Commentaire" msgstr "Commentaire"
@ -647,6 +649,7 @@ msgstr "Total : "
#: club/templates/club/club_sellings.jinja:19 club/views.py:159 #: club/templates/club/club_sellings.jinja:19 club/views.py:159
#: core/templates/core/user_account_detail.jinja:18 #: core/templates/core/user_account_detail.jinja:18
#: core/templates/core/user_account_detail.jinja:47 #: core/templates/core/user_account_detail.jinja:47
#: counter/templates/counter/cash_summary_list.jinja:28
msgid "Counter" msgid "Counter"
msgstr "Comptoir" msgstr "Comptoir"
@ -674,6 +677,7 @@ msgstr "Quantité"
#: club/templates/club/club_sellings.jinja:24 #: club/templates/club/club_sellings.jinja:24
#: core/templates/core/user_account.jinja:9 #: core/templates/core/user_account.jinja:9
#: core/templates/core/user_account_detail.jinja:51 #: core/templates/core/user_account_detail.jinja:51
#: counter/templates/counter/cash_summary_list.jinja:30
msgid "Total" msgid "Total"
msgstr "Total" msgstr "Total"
@ -684,7 +688,7 @@ msgid "Payment method"
msgstr "Méthode de paiement" msgstr "Méthode de paiement"
#: club/templates/club/club_tools.jinja:4 #: club/templates/club/club_tools.jinja:4
#: core/templates/core/user_tools.jinja:58 #: core/templates/core/user_tools.jinja:59
msgid "Club tools" msgid "Club tools"
msgstr "Outils club" msgstr "Outils club"
@ -1580,6 +1584,7 @@ msgstr "Compte utilisateur"
#: core/templates/core/user_account.jinja:38 #: core/templates/core/user_account.jinja:38
#: core/templates/core/user_account_detail.jinja:13 #: core/templates/core/user_account_detail.jinja:13
#: counter/templates/counter/cash_summary_list.jinja:12
msgid "Refillings" msgid "Refillings"
msgstr "Rechargements" msgstr "Rechargements"
@ -1719,8 +1724,8 @@ msgstr "Groupes"
msgid "Subscriptions" msgid "Subscriptions"
msgstr "Cotisations" msgstr "Cotisations"
#: core/templates/core/user_tools.jinja:22 counter/views.py:393 #: core/templates/core/user_tools.jinja:22 counter/views.py:394
#: counter/views.py:527 #: counter/views.py:528
msgid "Counters" msgid "Counters"
msgstr "Comptoirs" msgstr "Comptoirs"
@ -1740,11 +1745,16 @@ msgstr "Gestion des produits"
msgid "Product types management" msgid "Product types management"
msgstr "Gestion des types de produit" msgstr "Gestion des types de produit"
#: core/templates/core/user_tools.jinja:42 #: core/templates/core/user_tools.jinja:29
#: counter/templates/counter/cash_summary_list.jinja:18
msgid "Cash register summaries"
msgstr "Relevés de caisse"
#: core/templates/core/user_tools.jinja:43
msgid "General accounting" msgid "General accounting"
msgstr "Comptabilité générale" msgstr "Comptabilité générale"
#: core/templates/core/user_tools.jinja:51 #: core/templates/core/user_tools.jinja:52
msgid "Club account: " msgid "Club account: "
msgstr "Compte club : " msgstr "Compte club : "
@ -1912,7 +1922,7 @@ msgstr "rechargement"
msgid "unit price" msgid "unit price"
msgstr "prix unitaire" msgstr "prix unitaire"
#: counter/models.py:253 counter/models.py:363 eboutic/models.py:104 #: counter/models.py:253 counter/models.py:371 eboutic/models.py:104
msgid "quantity" msgid "quantity"
msgstr "quantité" msgstr "quantité"
@ -1945,24 +1955,25 @@ msgstr "coffre vidée"
msgid "cash register summary" msgid "cash register summary"
msgstr "relevé de caisse" msgstr "relevé de caisse"
#: counter/models.py:361 #: counter/models.py:369
msgid "cash summary" msgid "cash summary"
msgstr "relevé" msgstr "relevé"
#: counter/models.py:362 #: counter/models.py:370
msgid "value" msgid "value"
msgstr "valeur" msgstr "valeur"
#: counter/models.py:364 #: counter/models.py:372
msgid "check" msgid "check"
msgstr "chèque" msgstr "chèque"
#: counter/models.py:367 #: counter/models.py:375
msgid "cash register summary item" msgid "cash register summary item"
msgstr "élément de relevé de caisse" msgstr "élément de relevé de caisse"
#: counter/templates/counter/activity.jinja:5 #: counter/templates/counter/activity.jinja:5
#: counter/templates/counter/activity.jinja:9 #: counter/templates/counter/activity.jinja:9
#, python-format
msgid "%(counter_name)s activity" msgid "%(counter_name)s activity"
msgstr "Activité sur %(counter_name)s" msgstr "Activité sur %(counter_name)s"
@ -1975,6 +1986,27 @@ msgstr "Barmans"
msgid "Make a cash register summary" msgid "Make a cash register summary"
msgstr "Faire un relevé de caisse" msgstr "Faire un relevé de caisse"
#: counter/templates/counter/cash_summary_list.jinja:5
#: counter/templates/counter/cash_summary_list.jinja:10
msgid "Cash register summary list"
msgstr "Liste des relevés de caisse"
#: counter/templates/counter/cash_summary_list.jinja:11
msgid "Theoric sums"
msgstr "Sommes théoriques"
#: counter/templates/counter/cash_summary_list.jinja:31 counter/views.py:616
msgid "Emptied"
msgstr "Coffre vidé"
#: counter/templates/counter/cash_summary_list.jinja:43
msgid "yes"
msgstr "oui"
#: counter/templates/counter/cash_summary_list.jinja:53
msgid "There is no cash register summary in this website."
msgstr "Il n'y a pas de relevé de caisse dans ce site web."
#: counter/templates/counter/counter_click.jinja:34 #: counter/templates/counter/counter_click.jinja:34
#: launderette/templates/launderette/launderette_admin.jinja:8 #: launderette/templates/launderette/launderette_admin.jinja:8
msgid "Selling" msgid "Selling"
@ -2095,112 +2127,108 @@ msgstr "Nouveau type de produit"
msgid "There is no product types in this website." msgid "There is no product types in this website."
msgstr "Il n'y a pas de types de produit dans ce site web." msgstr "Il n'y a pas de types de produit dans ce site web."
#: counter/views.py:35 #: counter/views.py:36
msgid "Select user" msgid "Select user"
msgstr "Choisir un utilisateur" msgstr "Choisir un utilisateur"
#: counter/views.py:51 #: counter/views.py:52
msgid "User not found" msgid "User not found"
msgstr "Utilisateur non trouvé" msgstr "Utilisateur non trouvé"
#: counter/views.py:84 #: counter/views.py:85
msgid "Bad credentials" msgid "Bad credentials"
msgstr "Mauvais identifiants" msgstr "Mauvais identifiants"
#: counter/views.py:86 #: counter/views.py:87
msgid "User is not barman" msgid "User is not barman"
msgstr "L'utilisateur n'est pas barman." msgstr "L'utilisateur n'est pas barman."
#: counter/views.py:266 #: counter/views.py:267
msgid "END" msgid "END"
msgstr "FIN" msgstr "FIN"
#: counter/views.py:268 #: counter/views.py:269
msgid "CAN" msgid "CAN"
msgstr "ANN" msgstr "ANN"
#: counter/views.py:298 #: counter/views.py:299
msgid "You have not enough money to buy all the basket" msgid "You have not enough money to buy all the basket"
msgstr "Vous n'avez pas assez d'argent pour acheter le panier" msgstr "Vous n'avez pas assez d'argent pour acheter le panier"
#: counter/views.py:388 #: counter/views.py:389
msgid "Counter administration" msgid "Counter administration"
msgstr "Administration des comptoirs" msgstr "Administration des comptoirs"
#: counter/views.py:398 #: counter/views.py:399
msgid "Products" msgid "Products"
msgstr "Produits" msgstr "Produits"
#: counter/views.py:403 #: counter/views.py:404
msgid "Archived products" msgid "Archived products"
msgstr "Produits archivés" msgstr "Produits archivés"
#: counter/views.py:408 #: counter/views.py:409
msgid "Product types" msgid "Product types"
msgstr "Types de produit" msgstr "Types de produit"
#: counter/views.py:524 #: counter/views.py:525
msgid "Parent product" msgid "Parent product"
msgstr "Produit parent" msgstr "Produit parent"
#: counter/views.py:525 #: counter/views.py:526
msgid "Buying groups" msgid "Buying groups"
msgstr "Groupes d'achat" msgstr "Groupes d'achat"
#: counter/views.py:594 #: counter/views.py:595
msgid "10 cents" msgid "10 cents"
msgstr "10 centimes" msgstr "10 centimes"
#: counter/views.py:595 #: counter/views.py:596
msgid "20 cents" msgid "20 cents"
msgstr "20 centimes" msgstr "20 centimes"
#: counter/views.py:596 #: counter/views.py:597
msgid "50 cents" msgid "50 cents"
msgstr "50 centimes" msgstr "50 centimes"
#: counter/views.py:597 #: counter/views.py:598
msgid "1 euro" msgid "1 euro"
msgstr "1 €" msgstr "1 €"
#: counter/views.py:598 #: counter/views.py:599
msgid "2 euros" msgid "2 euros"
msgstr "2 €" msgstr "2 €"
#: counter/views.py:599 #: counter/views.py:600
msgid "5 euros" msgid "5 euros"
msgstr "5 €" msgstr "5 €"
#: counter/views.py:600 #: counter/views.py:601
msgid "10 euros" msgid "10 euros"
msgstr "10 €" msgstr "10 €"
#: counter/views.py:601 #: counter/views.py:602
msgid "20 euros" msgid "20 euros"
msgstr "20 €" msgstr "20 €"
#: counter/views.py:602 #: counter/views.py:603
msgid "50 euros" msgid "50 euros"
msgstr "50 €" msgstr "50 €"
#: counter/views.py:603 #: counter/views.py:604
msgid "100 euros" msgid "100 euros"
msgstr "100 €" msgstr "100 €"
#: counter/views.py:604 counter/views.py:606 counter/views.py:608 #: counter/views.py:605 counter/views.py:607 counter/views.py:609
#: counter/views.py:610 counter/views.py:612 #: counter/views.py:611 counter/views.py:613
msgid "Check amount" msgid "Check amount"
msgstr "Montant du chèque" msgstr "Montant du chèque"
#: counter/views.py:605 counter/views.py:607 counter/views.py:609 #: counter/views.py:606 counter/views.py:608 counter/views.py:610
#: counter/views.py:611 counter/views.py:613 #: counter/views.py:612 counter/views.py:614
msgid "Check quantity" msgid "Check quantity"
msgstr "Nombre de chèque" msgstr "Nombre de chèque"
#: counter/views.py:615
msgid "Emptied"
msgstr "Coffre vidé"
#: eboutic/models.py:49 #: eboutic/models.py:49
msgid "validated" msgid "validated"
msgstr "validé" msgstr "validé"

View File

@ -122,7 +122,7 @@ TEMPLATES = [
"enabled": False, "enabled": False,
}, },
"autoescape": True, "autoescape": True,
"auto_reload": DEBUG, "auto_reload": True,
"translation_engine": "django.utils.translation", "translation_engine": "django.utils.translation",
} }
}, },