Add Account, Stack, Transaction models

This commit is contained in:
Tanner Collin 2021-04-14 23:38:01 +00:00
parent 475f686dfe
commit c790f39741

View File

@ -1,3 +1,30 @@
from django.db import models from django.db import models
from django.contrib.auth.models import User
# Create your models here. import uuid
class Account(models.Model):
users = models.ManyToManyField(User)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=128)
details = models.TextField()
income = models.DecimalField(max_digits=12, decimal_places=2)
expenses = models.DecimalField(max_digits=12, decimal_places=2)
class Stack(models.Model):
account = models.ForeignKey(Account, related_name='stacks', on_delete=models.CASCADE)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=128)
details = models.TextField()
amount = models.DecimalField(max_digits=12, decimal_places=2)
class Transaction(models.Model):
stack = models.ForeignKey(Stack, related_name='transactions', on_delete=models.CASCADE)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
details = models.TextField()
amount = models.DecimalField(max_digits=12, decimal_places=2)