28 lines
874 B
Python
28 lines
874 B
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
|
|
class Category(models.Model):
|
|
name = models.CharField(max_length=100, unique=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
class Meta:
|
|
verbose_name_plural = "Categories"
|
|
|
|
class Expense(models.Model):
|
|
CURRENCY_CHOICES = [
|
|
('COP', 'Colombian Pesos'),
|
|
('EUR', 'Euros'),
|
|
('USD', 'US Dollars'),
|
|
]
|
|
|
|
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
|
currency = models.CharField(max_length=3, choices=CURRENCY_CHOICES)
|
|
category = models.ForeignKey(Category, on_delete=models.PROTECT)
|
|
payer = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
date = models.DateField()
|
|
description = models.TextField(blank=True)
|
|
|
|
def __str__(self):
|
|
return f'{self.amount} {self.currency} - {self.category} - {self.date}' |