Add invoices calls

This commit is contained in:
Skia 2016-09-29 18:17:44 +02:00
parent ddceb82abf
commit 51f342a7d3
6 changed files with 109 additions and 28 deletions

View File

@ -30,8 +30,16 @@
<tr>
<td>{{ s.date|localtime|date(DATETIME_FORMAT) }} {{ s.date|localtime|time(DATETIME_FORMAT) }}</td>
<td>{{ s.counter }}</td>
{% if s.seller %}
<td><a href="{{ s.seller.get_absolute_url() }}">{{ s.seller.get_display_name() }}</a></td>
{% else %}
<td></td>
{% endif %}
{% if s.customer %}
<td><a href="{{ s.customer.user.get_absolute_url() }}">{{ s.customer.user.get_display_name() }}</a></td>
{% else %}
<td></td>
{% endif %}
<td>{{ s.label }}</td>
<td>{{ s.quantity }}</td>
<td>{{ s.quantity * s.unit_price }} €</td>

View File

@ -0,0 +1,34 @@
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}Invoices call{% endtrans %}
{% endblock %}
{% block content %}
<h3>{% trans %}Invoices call{% endtrans %}</h3>
<form method="get" action="">
<select name="month">
{% for m in months %}
<option value="{{ m|date("Y-m") }}">{{ m|date("Y-m") }}</option>
{% endfor %}
</select>
<input type="submit" value="{% trans %}Go{% endtrans %}" />
</form>
<table>
<thead>
<td>{% trans %}Club{% endtrans %}</td>
<td>{% trans %}Sum{% endtrans %}</td>
</thead>
<tbody>
{% for i in sums %}
<tr>
<td>{{ i['club__name'] }}</td>
<td>{{ i['selling_sum'] }} €</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -16,6 +16,7 @@ urlpatterns = [
url(r'^admin$', CounterListView.as_view(), name='admin_list'),
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/invoices_call$', InvoiceCallView.as_view(), name='invoices_call'),
url(r'^admin/cash_summary/list$', CashSummaryListView.as_view(), name='cash_summary_list'),
url(r'^admin/cash_summary/(?P<cashsummary_id>[0-9]+)$', CashSummaryEditView.as_view(), name='cash_summary_edit'),
url(r'^admin/product/list$', ProductListView.as_view(), name='product_list'),

View File

@ -1,6 +1,6 @@
from django.shortcuts import render
from django.core.exceptions import PermissionDenied
from django.views.generic import ListView, DetailView, RedirectView
from django.views.generic import ListView, DetailView, RedirectView, TemplateView
from django.views.generic.edit import UpdateView, CreateView, DeleteView, ProcessFormView, FormMixin
from django.forms.models import modelform_factory
from django.forms import CheckboxSelectMultiple
@ -459,6 +459,11 @@ class CounterAdminTabsMixin(TabedViewMixin):
'slug': 'cash_summary',
'name': _("Cash register summaries"),
},
{
'url': reverse_lazy('counter:invoices_call'),
'slug': 'invoices_call',
'name': _("Invoices call"),
},
]
class CounterListView(CounterAdminTabsMixin, CanViewMixin, ListView):
@ -908,3 +913,29 @@ class CashSummaryListView(CanEditPropMixin, CounterAdminTabsMixin, ListView):
kwargs['refilling_sums'][c.name] = sum([s.amount for s in Refilling.objects.filter(counter=c, date__gt=last_date).all()])
return kwargs
class InvoiceCallView(CounterAdminTabsMixin, TemplateView):
template_name = 'counter/invoices_call.jinja'
current_tab = 'invoices_call'
def get_context_data(self, **kwargs):
""" Add sums to the context """
kwargs = super(InvoiceCallView, self).get_context_data(**kwargs)
kwargs['months'] = Selling.objects.datetimes('date', 'month', order='DESC')
start_date = None
end_date = None
try:
start_date = datetime.strptime(self.request.GET['month'], '%Y-%m')
except:
start_date = datetime(year=timezone.now().year, month=(timezone.now().month+10)%12+1, day=1)
end_date = (start_date + timedelta(days=32)).replace(day=1, hour=0, minute=0, microsecond=0)
from django.db.models import Sum, Case, When, F, DecimalField
kwargs['sums'] = Selling.objects.values('club__name').annotate(selling_sum=Sum(
Case(When(date__gte=start_date,
date__lt=end_date,
then=F('unit_price')*F('quantity')),
output_field=CurrencyField()
)
)).exclude(selling_sum=None).order_by('-selling_sum')
return kwargs
#).exclude(selling_sum=None).order_by('-selling_sum').all()[:100]

Binary file not shown.

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-29 16:18+0200\n"
"POT-Creation-Date: 2016-09-29 18:19+0200\n"
"PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n"
@ -171,6 +171,7 @@ msgid "User"
msgstr "Utilisateur"
#: accounting/models.py:190 club/templates/club/club_detail.jinja:5
#: counter/templates/counter/invoices_call.jinja:19
msgid "Club"
msgstr "Club"
@ -297,7 +298,7 @@ msgstr "Compte en banque : "
#: accounting/templates/accounting/bank_account_details.jinja:15
#: accounting/templates/accounting/club_account_details.jinja:16
#: club/templates/club/club_sellings.jinja:40
#: club/templates/club/club_sellings.jinja:48
#: core/templates/core/file_detail.jinja:43
#: core/templates/core/group_list.jinja:13 core/templates/core/macros.jinja:61
#: core/templates/core/user_account_detail.jinja:67
@ -484,7 +485,7 @@ msgid "Done"
msgstr "Effectué"
#: accounting/templates/accounting/journal_details.jinja:34
#: counter/templates/counter/cash_summary_list.jinja:32 counter/views.py:692
#: counter/templates/counter/cash_summary_list.jinja:32 counter/views.py:697
msgid "Comment"
msgstr "Commentaire"
@ -1725,20 +1726,16 @@ msgid "Godfathers"
msgstr "Parrains"
#: core/templates/core/user_godfathers.jinja:18
#, fuzzy
#| msgid "Godfathers"
msgid "No godfathers"
msgstr "Parrains"
msgstr "Pas de parrains"
#: core/templates/core/user_godfathers.jinja:21
msgid "Godchildren"
msgstr "Fillots"
#: core/templates/core/user_godfathers.jinja:29
#, fuzzy
#| msgid "Godchildren"
msgid "No godchildren"
msgstr "Fillots"
msgstr "Pas de fillots"
#: core/templates/core/user_group.jinja:4
#, python-format
@ -1793,7 +1790,7 @@ msgid "Subscriptions"
msgstr "Cotisations"
#: core/templates/core/user_tools.jinja:23 counter/views.py:440
#: counter/views.py:579
#: counter/views.py:584
msgid "Counters"
msgstr "Comptoirs"
@ -2077,7 +2074,7 @@ msgstr "Liste des relevés de caisse"
msgid "Theoric sums"
msgstr "Sommes théoriques"
#: counter/templates/counter/cash_summary_list.jinja:31 counter/views.py:693
#: counter/templates/counter/cash_summary_list.jinja:31 counter/views.py:698
msgid "Emptied"
msgstr "Coffre vidé"
@ -2108,6 +2105,7 @@ msgstr "Pas de date de naissance renseigné"
#: counter/templates/counter/counter_click.jinja:52
#: counter/templates/counter/counter_click.jinja:86
#: counter/templates/counter/invoices_call.jinja:15
#: launderette/templates/launderette/launderette_admin.jinja:35
#: launderette/templates/launderette/launderette_click.jinja:13
msgid "Go"
@ -2183,6 +2181,15 @@ msgstr "Merci de vous identifier"
msgid "Barman: "
msgstr "Barman : "
#: counter/templates/counter/invoices_call.jinja:4
#: counter/templates/counter/invoices_call.jinja:8 counter/views.py:465
msgid "Invoices call"
msgstr "Appels à facture"
#: counter/templates/counter/invoices_call.jinja:20
msgid "Sum"
msgstr "Somme"
#: counter/templates/counter/last_ops.jinja:5
#: counter/templates/counter/last_ops.jinja:9
#, python-format
@ -2290,61 +2297,61 @@ msgstr "Produits archivés"
msgid "Product types"
msgstr "Types de produit"
#: counter/views.py:576
#: counter/views.py:581
msgid "Parent product"
msgstr "Produit parent"
#: counter/views.py:577
#: counter/views.py:582
msgid "Buying groups"
msgstr "Groupes d'achat"
#: counter/views.py:672
#: counter/views.py:677
msgid "10 cents"
msgstr "10 centimes"
#: counter/views.py:673
#: counter/views.py:678
msgid "20 cents"
msgstr "20 centimes"
#: counter/views.py:674
#: counter/views.py:679
msgid "50 cents"
msgstr "50 centimes"
#: counter/views.py:675
#: counter/views.py:680
msgid "1 euro"
msgstr "1 €"
#: counter/views.py:676
#: counter/views.py:681
msgid "2 euros"
msgstr "2 €"
#: counter/views.py:677
#: counter/views.py:682
msgid "5 euros"
msgstr "5 €"
#: counter/views.py:678
#: counter/views.py:683
msgid "10 euros"
msgstr "10 €"
#: counter/views.py:679
#: counter/views.py:684
msgid "20 euros"
msgstr "20 €"
#: counter/views.py:680
#: counter/views.py:685
msgid "50 euros"
msgstr "50 €"
#: counter/views.py:681
#: counter/views.py:686
msgid "100 euros"
msgstr "100 €"
#: counter/views.py:682 counter/views.py:684 counter/views.py:686
#: counter/views.py:688 counter/views.py:690
#: counter/views.py:687 counter/views.py:689 counter/views.py:691
#: counter/views.py:693 counter/views.py:695
msgid "Check amount"
msgstr "Montant du chèque"
#: counter/views.py:683 counter/views.py:685 counter/views.py:687
#: counter/views.py:689 counter/views.py:691
#: counter/views.py:688 counter/views.py:690 counter/views.py:692
#: counter/views.py:694 counter/views.py:696
msgid "Check quantity"
msgstr "Nombre de chèque"