2017-02-01 17:52:16 +01:00
|
|
|
import uuid
|
2017-01-03 19:26:51 +01:00
|
|
|
from django.db import models
|
2017-02-04 06:51:09 +01:00
|
|
|
from django.contrib.auth.models import User
|
2017-01-03 19:26:51 +01:00
|
|
|
|
|
|
|
|
2017-02-01 13:51:15 +01:00
|
|
|
class LocationData(models.Model):
|
|
|
|
location_id = models.CharField(max_length=32, blank=False, null=False)
|
|
|
|
table_no = models.IntegerField(blank=False, null=False)
|
|
|
|
tst = models.DateTimeField(blank=False, null=False)
|
|
|
|
on_off = models.BooleanField(blank=False, null=False)
|
|
|
|
processed = models.BooleanField(default=False)
|
|
|
|
error_msg = models.CharField(max_length=16000, blank=True, null=True)
|
2017-01-03 19:26:51 +01:00
|
|
|
|
2017-01-06 18:53:26 +01:00
|
|
|
def __str__(self):
|
2017-02-01 13:51:15 +01:00
|
|
|
return str(self.location_id)
|
2017-01-06 18:53:26 +01:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2017-02-01 13:51:15 +01:00
|
|
|
return str(self.location_id)
|
2017-01-06 18:53:26 +01:00
|
|
|
|
2017-01-03 20:13:47 +01:00
|
|
|
|
2017-02-01 13:51:15 +01:00
|
|
|
class Location(models.Model):
|
2017-02-04 06:51:09 +01:00
|
|
|
users = models.ManyToManyField(User, related_name='locations')
|
2017-02-01 13:51:15 +01:00
|
|
|
code = models.CharField(max_length=16, unique=True)
|
|
|
|
name = models.CharField(max_length=64, unique=True)
|
|
|
|
street = models.CharField(max_length=64, blank=True, null=True)
|
|
|
|
plz = models.CharField(max_length=8, blank=True, null=True)
|
|
|
|
city = models.CharField(max_length=64, blank=True, null=True)
|
|
|
|
phone = models.CharField(max_length=64, blank=True, null=True)
|
|
|
|
email = models.EmailField(blank=True, null=True)
|
|
|
|
url = models.URLField(blank=True,null=True)
|
2017-01-03 19:26:51 +01:00
|
|
|
|
2017-01-06 18:53:26 +01:00
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
2017-01-03 20:13:47 +01:00
|
|
|
|
2017-02-01 13:51:15 +01:00
|
|
|
class Client(models.Model):
|
2017-02-01 17:52:16 +01:00
|
|
|
uuid = models.UUIDField(unique=True, default=uuid.uuid4)
|
2017-02-01 13:51:15 +01:00
|
|
|
location = models.ForeignKey(Location)
|
|
|
|
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)
|
2017-01-06 18:53:26 +01:00
|
|
|
|
2017-02-01 20:25:33 +01:00
|
|
|
def accounting_for(self, desk_no):
|
2017-02-02 20:43:32 +01:00
|
|
|
return Accounting.objects.filter(location=self.location, client_id=self.id, desk_no=desk_no)[:2][::-1]
|
2017-02-01 20:25:33 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2017-01-06 18:53:26 +01:00
|
|
|
def __str__(self):
|
2017-02-01 17:52:16 +01:00
|
|
|
return self.location.name
|
2017-01-06 18:53:26 +01:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2017-02-01 17:52:16 +01:00
|
|
|
return self.location.name
|
2017-02-01 20:25:33 +01:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ['-time_from']
|