-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
47 lines (40 loc) · 2.2 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Mapping Models
"""
from django.db import models
from apps.workspaces.models import Workspace
class TenantMapping(models.Model):
"""
Tenant Mapping
"""
id = models.AutoField(primary_key=True)
tenant_name = models.CharField(max_length=255, help_text='Xero Tenant name')
tenant_id = models.CharField(max_length=255, help_text='Xero Tenant id')
connection_id = models.CharField(max_length=255, help_text='Xero Connection id', null=True, blank=True)
workspace = models.OneToOneField(Workspace, on_delete=models.PROTECT, help_text='Reference to Workspace model')
created_at = models.DateTimeField(auto_now_add=True, help_text='Created at datetime')
updated_at = models.DateTimeField(auto_now=True, help_text='Updated at datetime')
class Meta:
unique_together = ('tenant_name', 'workspace')
db_table = 'tenant_mappings'
@staticmethod
def get_tenant_details(workspace_id):
return TenantMapping.objects.get(workspace_id=workspace_id)
class GeneralMapping(models.Model):
"""
General Mapping
"""
id = models.AutoField(primary_key=True)
bank_account_name = models.CharField(max_length=255, help_text='Xero bank account name', null=True)
bank_account_id = models.CharField(max_length=255, help_text='Xero bank account id', null=True)
payment_account_name = models.CharField(max_length=255, help_text='Xero Payment Account name', null=True)
payment_account_id = models.CharField(max_length=255, help_text='Xero payment account id', null=True)
workspace = models.OneToOneField(Workspace, on_delete=models.PROTECT, help_text='Reference to Workspace model',
related_name='general_mappings')
default_tax_code_name = models.CharField(max_length=255, help_text='Xero default Tax Code name', null=True)
default_tax_code_id = models.CharField(max_length=255, help_text='Xero default Tax Code ID', null=True)
created_at = models.DateTimeField(auto_now_add=True, help_text='Created at datetime')
updated_at = models.DateTimeField(auto_now=True, help_text='Updated at datetime')
class Meta:
unique_together = ('bank_account_name', 'workspace')
db_table = 'general_mappings'