diff --git a/server/server/api/models.py b/server/server/api/models.py index 71a8362..f8138e6 100644 --- a/server/server/api/models.py +++ b/server/server/api/models.py @@ -1,3 +1,30 @@ 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)