show daily sale on location detail page
This commit is contained in:
parent
f25ee6d198
commit
a5c5c37a63
@ -1,4 +1,4 @@
|
|||||||
{% load display_client %}
|
{% load display_client display_daily_sale %}
|
||||||
{% if location.clients.all %}
|
{% if location.clients.all %}
|
||||||
{% for cli in location.clients.all %}
|
{% for cli in location.clients.all %}
|
||||||
{% for i in "12345678" %}
|
{% for i in "12345678" %}
|
||||||
@ -10,3 +10,8 @@
|
|||||||
<div class="alert alert-danger">Keine Tische angelegt!</div>
|
<div class="alert alert-danger">Keine Tische angelegt!</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<div class="col">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
{{ location|display_daily_sale }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
18
billard/templatetags/display_daily_sale.py
Normal file
18
billard/templatetags/display_daily_sale.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
from django import template
|
||||||
|
from billard.models import Accounting
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from django.db.models import Sum
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter(is_safe=True)
|
||||||
|
def display_daily_sale(location):
|
||||||
|
start_date = datetime.now().replace(hour=5, minute=0, second=0, microsecond=0)
|
||||||
|
end_date = start_date + timedelta(days=1)
|
||||||
|
prize__sum = Accounting.objects.filter(billed=True,
|
||||||
|
desk__client__location=location,
|
||||||
|
account_tst__range=(start_date, end_date)).aggregate(Sum('prize'))
|
||||||
|
if prize__sum['prize__sum'] is None:
|
||||||
|
prize__sum['prize__sum'] = 0
|
||||||
|
return "Tagesumsatz: {0:.2f} EUR".format(prize__sum['prize__sum'])
|
Loading…
Reference in New Issue
Block a user