mirror of
https://github.com/Lyxminxx/jast.git
synced 2026-10-11 12:51:51 +02:00
Ready for production deployment
This commit is contained in:
commit
e06c56e76e
23 files changed
+664
No files matched your search
@@ -0,0 +1,35 @@
|
||||
from django.db import (
|
||||
models,
|
||||
)
|
||||
from django.utils import(
|
||||
timezone
|
||||
)
|
||||
|
||||
class Transaction(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
|
||||
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
|
||||
date = models.DateField(default=timezone.now)
|
||||
|
||||
category = models.ForeignKey('Category', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['-date']
|
||||
|
||||
@property
|
||||
def is_income(self):
|
||||
return self.amount > 0
|
||||
|
||||
@property
|
||||
def is_expense(self):
|
||||
return self.amount < 0
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.date} | {self.title}: ${self.amount}"
|
||||
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
Reference in new issue
Block a user