fix calculating prize
This commit is contained in:
parent
3483c823a0
commit
7a2fed8ad0
@ -18,6 +18,7 @@ def display_client(client, desk_no):
|
||||
if not desk.enabled:
|
||||
return ''
|
||||
acc = desk.accounting_set.all()[:3][::-1]
|
||||
_calc_prize(desk, acc)
|
||||
html = '<div class="col col-12 col-lg-6">\n'
|
||||
html += ' <div class="table-info alert {}">\n'.format(_get_alert_name(desk))
|
||||
html += ' <h4 style="text-align: center">({}) {}</h4>\n'.format(desk_no, desk.name)
|
||||
@ -57,6 +58,16 @@ def _get_alert_name(desk):
|
||||
a = acc[-1]
|
||||
if a.time_to is None:
|
||||
alert = 'alert-info'
|
||||
before5min = datetime.now() - timedelta(minutes=5)
|
||||
if desk.client.last_seen is not None and desk.client.last_seen < before5min:
|
||||
alert = 'alert-danger'
|
||||
return alert
|
||||
|
||||
|
||||
def _calc_prize(desk, acc):
|
||||
if acc is not None and len(acc) > 0:
|
||||
a = acc[-1]
|
||||
if a.time_to is None:
|
||||
prize, u1, u2 = utils.get_prize_for(
|
||||
start=a.time_from,
|
||||
end=datetime.now(),
|
||||
@ -68,7 +79,3 @@ def _get_alert_name(desk):
|
||||
prize = '{0:.2f}'.format(prize)
|
||||
if prize != a.prize:
|
||||
a.prize = prize
|
||||
before5min = datetime.now() - timedelta(minutes=5)
|
||||
if desk.client.last_seen is not None and desk.client.last_seen < before5min:
|
||||
alert = 'alert-danger'
|
||||
return alert
|
||||
|
Loading…
Reference in New Issue
Block a user