update template using new desk model

This commit is contained in:
2017-02-10 19:39:21 +01:00
parent 7b76fdc62c
commit 55cdfc0509
7 changed files with 107 additions and 64 deletions

View File

@@ -46,30 +46,6 @@ class Location(models.Model):
class Client(models.Model):
uuid = models.UUIDField(unique=True, default=uuid.uuid4, verbose_name="Identifier")
location = models.ForeignKey(Location, verbose_name="Standort")
desk1_enable = models.BooleanField()
desk1_name = models.CharField(max_length=32, blank=True, null=True)
desk1_prize_nt = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
desk1_prize_ht = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
desk2_enable = models.BooleanField()
desk2_name = models.CharField(max_length=32, blank=True, null=True)
desk2_prize_nt = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
desk2_prize_ht = models.DecimalField(max_digits=4, decimal_places=2, blank=True, null=True)
def accounting_for(self, desk_no, pht, pnt):
t = Accounting.objects.filter(client_id=self.id, desk_no=desk_no)[:3][::-1]
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=pht)
if prize != a.prize:
a.prize = prize
return t
def accounting_1(self):
return self.accounting_for(1, self.desk1_prize_ht, self.desk1_prize_nt)
def accounting_2(self):
return self.accounting_for(2, self.desk2_prize_ht, self.desk2_prize_nt)
def __str__(self):
return '{}, {}'.format(self.location.name, self.uuid)
@@ -80,7 +56,7 @@ class Client(models.Model):
class Desk(models.Model):
client = models.ForeignKey(Client, verbose_name='Client')
client = models.ForeignKey(Client, verbose_name='Client', related_name='desks')
desk_no = models.IntegerField(verbose_name='Tischnummer')
name = models.CharField(max_length=32, blank=True, null=True, verbose_name='Tischbezeichnung')
enabled = models.BooleanField(verbose_name='Tisch aktiv')