fix queue management

This commit is contained in:
Robert Einsle 2017-02-06 21:25:45 +01:00
parent 528e4647f3
commit 24a8099b83
2 changed files with 30 additions and 19 deletions

View File

@ -9,23 +9,34 @@ from . import utils
def process_location_data(): def process_location_data():
data = models.LocationData.objects.filter(processed=False) data = models.LocationData.objects.filter(processed=False)
for ld in data: for ld in data:
cli = models.Client.objects.get(uuid=ld.location_id) cli = models.Client.objects.filter(uuid=ld.location_id)
ac = models.Accounting.objects.filter(client=cli).order_by('time_from').reverse()[0] if cli.count() < 1:
if ld.on_off: ld.processed = True
if ac.time_to is None: ld.error_msg = 'No location object found. Stopp processing!'
ac.time_to = datetime.now()
ac.save()
ac = models.Accounting(
client=cli,
desk_no=ld.table_no,
time_from=ld.tst,
)
ac.save()
ld.processed=True
ld.save() ld.save()
# TODO Send error eMail to Admin
else: else:
ac.time_to = ld.tst cli = cli[0]
ac.prize = utils.get_prize_for(start=ac.time_from, end=ac.time_to, pph=cli.desk1_prize_ht) ac = models.Accounting.objects.filter(client=cli).order_by('time_from').reverse()
ac.save() if ld.on_off:
ld.processed=True if ac.count() > 0 and ac[0].time_to is None:
ld.save() ac[0].time_to = datetime.now()
ac[0].save()
# TODO Send error eMail to Admin
acc = models.Accounting(
client=cli,
desk_no=ld.table_no,
time_from=ld.tst,
)
acc.save()
ld.delete()
else:
acc = ac[0]
acc.time_to = ld.tst
acc.prize = utils.get_prize_for(
start=acc.time_from,
end=ld.tst,
pph=cli.desk1_prize_ht
)
acc.save()
ld.delete()

View File

@ -1,7 +1,7 @@
from datetime import datetime, date, time from datetime import datetime, date, time
def get_prize_for(start, end=datetime.now(), pph=0): def get_prize_for(start, end, pph=0):
""" """
calculate prize of billard table rental calculate prize of billard table rental