110 lines
4.4 KiB
Python
110 lines
4.4 KiB
Python
import uuid
|
|
from django.contrib.postgres.fields import ArrayField
|
|
from django.db import models
|
|
|
|
|
|
class Accounts(models.Model):
|
|
"""Customer accounts with service agreements."""
|
|
full_name = models.CharField(max_length=255)
|
|
short_name = models.CharField(primary_key=True, max_length=3)
|
|
street_address = models.CharField(max_length=255, blank=True, null=True)
|
|
city = models.CharField(max_length=255, blank=True, null=True)
|
|
state = models.CharField(max_length=2, blank=True, null=True)
|
|
zip_code = models.CharField(max_length=5, blank=True, null=True)
|
|
|
|
class Meta:
|
|
managed = False
|
|
db_table = 'accounts'
|
|
|
|
|
|
class ServiceDays(models.Model):
|
|
"""Weekly service schedule for each account."""
|
|
short_name = models.ForeignKey(Accounts, models.CASCADE, db_column='short_name', primary_key=True)
|
|
mon_serv = models.BooleanField(blank=True, null=True)
|
|
tues_serv = models.BooleanField(blank=True, null=True)
|
|
wed_serv = models.BooleanField(blank=True, null=True)
|
|
thurs_serv = models.BooleanField(blank=True, null=True)
|
|
fri_serv = models.BooleanField(blank=True, null=True)
|
|
sat_serv = models.BooleanField(blank=True, null=True)
|
|
sun_serv = models.BooleanField(blank=True, null=True)
|
|
weekend_serv = models.BooleanField(blank=True, null=True)
|
|
exception_serv = models.BooleanField(blank=True, null=True)
|
|
|
|
class Meta:
|
|
managed = False
|
|
db_table = 'service_days'
|
|
|
|
|
|
class ServiceVisits(models.Model):
|
|
"""Individual service visit records."""
|
|
short_name = models.ForeignKey(Accounts, models.CASCADE, db_column='short_name')
|
|
date = models.DateField()
|
|
status = models.CharField(max_length=10, blank=True, null=True)
|
|
team_member = ArrayField(models.TextField(), blank=True, null=True)
|
|
id = models.UUIDField(primary_key=True)
|
|
notes = models.TextField(blank=True, null=True)
|
|
|
|
class Meta:
|
|
managed = False
|
|
db_table = 'service_visits'
|
|
|
|
|
|
class MonthlyRevenue(models.Model):
|
|
"""Monthly revenue and labor tracking per account."""
|
|
short_name = models.ForeignKey(Accounts, models.CASCADE, db_column='short_name')
|
|
revenue = models.IntegerField(blank=True, null=True)
|
|
labor = models.IntegerField(blank=True, null=True)
|
|
id = models.UUIDField(primary_key=True)
|
|
|
|
class Meta:
|
|
managed = False
|
|
db_table = 'monthly_revenue'
|
|
|
|
|
|
class AccountStatus(models.Model):
|
|
"""Account status and bonding information."""
|
|
short_name = models.ForeignKey(Accounts, models.CASCADE, db_column='short_name')
|
|
is_active = models.BooleanField(blank=True, null=True)
|
|
last_day = models.DateField(blank=True, null=True)
|
|
is_bonded = models.BooleanField(blank=True, null=True)
|
|
id = models.UUIDField(primary_key=True)
|
|
|
|
class Meta:
|
|
managed = False
|
|
db_table = 'account_status'
|
|
|
|
|
|
class Stores(models.Model):
|
|
"""Store/location information for project-based clients."""
|
|
store = models.CharField(max_length=4, blank=True, null=True, unique=True)
|
|
src = models.CharField(max_length=10, blank=True, null=True)
|
|
street_address = models.CharField(max_length=255, blank=True, null=True)
|
|
city = models.CharField(max_length=100, blank=True, null=True)
|
|
state = models.CharField(max_length=10, blank=True, null=True)
|
|
zip_code = models.CharField(max_length=10, blank=True, null=True)
|
|
phone = models.CharField(max_length=20, blank=True, null=True)
|
|
entity = models.CharField(max_length=100, blank=True, null=True)
|
|
store_contact = models.CharField(max_length=100, blank=True, null=True)
|
|
store_contact_email = models.CharField(max_length=100, blank=True, null=True)
|
|
super_contact = models.CharField(max_length=100, blank=True, null=True)
|
|
super_contact_email = models.CharField(max_length=100, blank=True, null=True)
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
class Meta:
|
|
managed = False
|
|
db_table = 'stores'
|
|
|
|
|
|
class Projects(models.Model):
|
|
"""Project tracking for store-based work."""
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
store = models.ForeignKey(Stores, models.CASCADE, db_column='store', to_field='store')
|
|
date = models.DateField()
|
|
status = models.CharField(max_length=10, blank=True, null=True)
|
|
punchlist = models.BinaryField(blank=True, null=True)
|
|
|
|
class Meta:
|
|
managed = False
|
|
unique_together = ('store', 'date')
|
|
db_table = 'projects'
|