show accounting data from table

This commit is contained in:
2017-02-01 20:25:33 +01:00
parent 90974ea783
commit 16243def6d
4 changed files with 76 additions and 18 deletions

View File

@@ -46,8 +46,35 @@ class Client(models.Model):
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):
return Accounting.objects.filter(location=self.location, desk_no=desk_no)[:2][::-1]
def accounting_1(self):
return self.accounting_for(1)
def accounting_2(self):
return self.accounting_for(2)
def __str__(self):
return str(self.uuid)
def __unicode__(self):
return str(self.location.name)
class Accounting(models.Model):
location = models.ForeignKey(Location)
client = models.ForeignKey(Client)
desk_no = models.IntegerField()
time_from = models.DateTimeField()
time_to = models.DateTimeField(blank=True, null=True)
prize = models.DecimalField(max_digits=5, decimal_places=2, blank=True, null=True)
def __str__(self):
return self.location.name
def __unicode__(self):
return self.location.name
class Meta:
ordering = ['-time_from']