2022-05-19 16:09:28 +02:00
|
|
|
import uuid
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
|
|
|
|
class Transaction(models.Model):
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
name = models.CharField(max_length=256)
|
|
|
|
description = models.TextField()
|
|
|
|
value = models.DecimalField(max_digits=12, decimal_places=2)
|
|
|
|
date = models.DateField()
|
|
|
|
|
2022-05-19 16:14:23 +02:00
|
|
|
def __str__(self):
|
|
|
|
return f"{self.date} {self.name}: {self.value}€"
|
|
|
|
|
2022-05-19 16:09:28 +02:00
|
|
|
|
|
|
|
class Invoice(models.Model):
|
|
|
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
|
|
|
name = models.CharField(max_length=256)
|
|
|
|
file = models.FileField(upload_to="invoices/")
|
|
|
|
transaction = models.ForeignKey(Transaction, on_delete=models.CASCADE)
|
2022-05-19 16:14:23 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return f"{self.name}: {self.transaction}"
|