Revised and simplify the data model definition.
This commit is contained in:
parent
00ee0cc3bb
commit
bbd3d0e470
@ -32,25 +32,19 @@ class Account(DirtyFieldsMixin, models.Model):
|
|||||||
"""An account."""
|
"""An account."""
|
||||||
id = models.PositiveIntegerField(primary_key=True)
|
id = models.PositiveIntegerField(primary_key=True)
|
||||||
parent = models.ForeignKey(
|
parent = models.ForeignKey(
|
||||||
"self", on_delete=models.PROTECT, null=True, blank=True,
|
"self", on_delete=models.PROTECT, null=True,
|
||||||
related_name="child_set")
|
related_name="child_set")
|
||||||
code = models.CharField(max_length=5, unique=True)
|
code = models.CharField(max_length=5, unique=True)
|
||||||
title_zh_hant = models.CharField(
|
title_zh_hant = models.CharField(max_length=32)
|
||||||
max_length=32, db_column="title_zhtw")
|
title_en = models.CharField(max_length=128, null=True)
|
||||||
title_en = models.CharField(max_length=128, null=True, blank=True)
|
title_zh_hans = models.CharField(max_length=32, null=True)
|
||||||
title_zh_hans = models.CharField(
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
max_length=32, null=True, blank=True, db_column="title_zhcn")
|
|
||||||
created_at = models.DateTimeField(
|
|
||||||
auto_now_add=True, db_column="created")
|
|
||||||
created_by = models.ForeignKey(
|
created_by = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
||||||
db_column="createdby",
|
|
||||||
related_name="created_accounting_accounts")
|
related_name="created_accounting_accounts")
|
||||||
updated_at = models.DateTimeField(
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
auto_now_add=True, db_column="updated")
|
|
||||||
updated_by = models.ForeignKey(
|
updated_by = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
||||||
db_column="updatedby",
|
|
||||||
related_name="updated_accounting_accounts")
|
related_name="updated_accounting_accounts")
|
||||||
CASH = "1111"
|
CASH = "1111"
|
||||||
ACCUMULATED_BALANCE = "3351"
|
ACCUMULATED_BALANCE = "3351"
|
||||||
@ -142,17 +136,13 @@ class Transaction(DirtyFieldsMixin, models.Model):
|
|||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
ord = models.PositiveSmallIntegerField(default=1)
|
ord = models.PositiveSmallIntegerField(default=1)
|
||||||
notes = models.CharField(max_length=128, null=True, blank=True)
|
notes = models.CharField(max_length=128, null=True, blank=True)
|
||||||
created_at = models.DateTimeField(
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
auto_now_add=True, db_column="created")
|
|
||||||
created_by = models.ForeignKey(
|
created_by = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
||||||
db_column="createdby",
|
|
||||||
related_name="created_accounting_transactions")
|
related_name="created_accounting_transactions")
|
||||||
updated_at = models.DateTimeField(
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
auto_now_add=True, db_column="updated")
|
|
||||||
updated_by = models.ForeignKey(
|
updated_by = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
||||||
db_column="updatedby",
|
|
||||||
related_name="updated_accounting_transactions")
|
related_name="updated_accounting_transactions")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -369,17 +359,13 @@ class Record(DirtyFieldsMixin, models.Model):
|
|||||||
Account, on_delete=models.PROTECT)
|
Account, on_delete=models.PROTECT)
|
||||||
summary = models.CharField(max_length=128, blank=True, null=True)
|
summary = models.CharField(max_length=128, blank=True, null=True)
|
||||||
amount = models.PositiveIntegerField()
|
amount = models.PositiveIntegerField()
|
||||||
created_at = models.DateTimeField(
|
created_at = models.DateTimeField(auto_now_add=True)
|
||||||
auto_now_add=True, db_column="created")
|
|
||||||
created_by = models.ForeignKey(
|
created_by = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
||||||
db_column="createdby",
|
|
||||||
related_name="created_accounting_records")
|
related_name="created_accounting_records")
|
||||||
updated_at = models.DateTimeField(
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
auto_now_add=True, db_column="updated")
|
|
||||||
updated_by = models.ForeignKey(
|
updated_by = models.ForeignKey(
|
||||||
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
settings.AUTH_USER_MODEL, on_delete=models.PROTECT,
|
||||||
db_column="updatedby",
|
|
||||||
related_name="updated_accounting_records")
|
related_name="updated_accounting_records")
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -41,7 +41,7 @@ class Country(DirtyFieldsMixin, models.Model):
|
|||||||
"User", on_delete=models.PROTECT,
|
"User", on_delete=models.PROTECT,
|
||||||
db_column="createdby", related_name="created_countries")
|
db_column="createdby", related_name="created_countries")
|
||||||
updated_at = models.DateTimeField(
|
updated_at = models.DateTimeField(
|
||||||
auto_now_add=True, db_column="updated")
|
auto_now=True, db_column="updated")
|
||||||
updated_by = models.ForeignKey(
|
updated_by = models.ForeignKey(
|
||||||
"User", on_delete=models.PROTECT,
|
"User", on_delete=models.PROTECT,
|
||||||
db_column="updatedby", related_name="updated_countries")
|
db_column="updatedby", related_name="updated_countries")
|
||||||
@ -87,7 +87,7 @@ class User(DirtyFieldsMixin, models.Model):
|
|||||||
"self", on_delete=models.PROTECT,
|
"self", on_delete=models.PROTECT,
|
||||||
db_column="createdby", related_name="created_users")
|
db_column="createdby", related_name="created_users")
|
||||||
updated_at = models.DateTimeField(
|
updated_at = models.DateTimeField(
|
||||||
auto_now_add=True, db_column="updated")
|
auto_now=True, db_column="updated")
|
||||||
updated_by = models.ForeignKey(
|
updated_by = models.ForeignKey(
|
||||||
"self", on_delete=models.PROTECT,
|
"self", on_delete=models.PROTECT,
|
||||||
db_column="updatedby", related_name="updated_users")
|
db_column="updatedby", related_name="updated_users")
|
||||||
|
Loading…
Reference in New Issue
Block a user