You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
32 lines
1.2 KiB
from django.db import models |
|
from django.contrib.auth.models import User |
|
from django.utils import timezone |
|
|
|
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) |
|
created_at = models.DateTimeField(default=timezone.now)
|
|
|