Calculate prize using normal and happy hour prize
This commit is contained in:
2017-02-25 20:02:48 +01:00
parent 6d16a473bf
commit fa00563195
3 changed files with 67 additions and 8 deletions

View File

@@ -71,10 +71,19 @@ class Desk(models.Model):
def accounting_for(self):
t = Accounting.objects.filter(client=self.client, desk_no=self.desk_no)[:3][::-1]
client = self.client
location = client.location
if t.__len__() > 0:
a = t[t.__len__() - 1]
if a.time_to is None:
prize = utils.get_prize_for(start=a.time_from, end=datetime.now(timezone.utc), pph=self.prize)
prize = utils.get_prize_for(
start=a.time_from,
end=datetime.now(timezone.utc),
pph=self.prize,
hh_start=location.happy_hour_start,
hh_end=location.happy_hour_end,
pphh=self.prize_hh,
)
if prize != a.prize:
a.prize = prize
return t
@@ -148,7 +157,10 @@ def process_location_data():
acc.prize = utils.get_prize_for(
start=acc.time_from,
end=ld.tst,
pph=desk.prize
pph=desk.prize,
hh_start=cli.location.happy_hour_start,
hh_end=cli.location.happy_hour_end,
pphh=desk.prize_hh,
)
acc.save()
ld.delete()