update calculating prize for accounting

This commit is contained in:
2017-03-02 20:51:43 +01:00
parent d4a68683fa
commit 4df4a095cb
3 changed files with 25 additions and 28 deletions

View File

@@ -71,24 +71,6 @@ class Desk(models.Model):
prize_hh = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True,
verbose_name="Preis Happy Hour")
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,
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
def __str__(self):
return '{}, {}'.format(self.client.uuid, self.name)
@@ -105,6 +87,8 @@ class Accounting(models.Model):
prize = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, verbose_name="Preis")
billed = models.BooleanField(default=False, verbose_name="Abgerechnet")
reporter_uuid = models.UUIDField(blank=True, null=True, verbose_name='Reporter UUID')
prize_normal = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, verbose_name="Preis Normalzeit")
prize_hh = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True, verbose_name="Preis Happy Hour")
def __str__(self):
return '{}: {} -> {}, {}, {}'.format(self.desk, self.time_from, self.time_to, self.prize, self.billed)
@@ -157,7 +141,7 @@ def process_location_data():
if len(ac) > 0:
acc = ac[0]
acc.time_to = ld.tst
acc.prize = utils.get_prize_for(
acc.prize, acc.prize_normal, acc.prize_hh = utils.get_prize_for(
start=acc.time_from,
end=ld.tst,
pph=desk.prize,