diff options
author | luxagraf <sng@luxagraf.net> | 2020-08-15 11:58:34 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2020-08-15 11:58:34 -0400 |
commit | b66d000ee469539ce7aea557b612c0444177e36d (patch) | |
tree | 273547921dc6f9ded2a5681b82514c68e28ba448 /app/unused_apps/expenses/models.py | |
parent | d3e57c1bd17ad3e71810235a672d4782136901a5 (diff) |
archived old unused apps and migrated fieldnotes to posts
Diffstat (limited to 'app/unused_apps/expenses/models.py')
-rw-r--r-- | app/unused_apps/expenses/models.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/app/unused_apps/expenses/models.py b/app/unused_apps/expenses/models.py new file mode 100644 index 0000000..fbcdd7a --- /dev/null +++ b/app/unused_apps/expenses/models.py @@ -0,0 +1,62 @@ +from django.db import models +from django.urls import reverse +from django.utils import timezone + +CATS = ( + ('1', "Groceries"), + ('2', "Restaurants"), + ('3', "Camping"), + ('4', "Petrol"), + ('5', "Bus"), + ('6', "Misc"), +) + + +class Trip(models.Model): + name = models.CharField(max_length=200) + slug = models.SlugField() + start = models.DateTimeField(default=timezone.now, blank=True, null=True) + end = models.DateTimeField(default=timezone.now, blank=True, null=True) + dek = models.TextField(null=True, blank=True) + + def __str__(self): + return self.name + + def get_absolute_url(self): + return reverse("expenses:list_expense", kwargs={"slug": self.slug}) + +class Month(models.Model): + name = models.CharField(max_length=200) + year = models.IntegerField() + date = models.DateTimeField(default=timezone.now) + notes = models.TextField(null=True, blank=True) + + def __str__(self): + return "%s %s" %(self.name, self.year) + +class LuxExpense(models.Model): + category = models.CharField(max_length=2, choices=CATS, default=1) + amount = models.DecimalField(max_digits=8, decimal_places=2) + month = models.ForeignKey(Month, on_delete=models.CASCADE, null=True) + + def __str__(self): + return '%s-%s' %(self.month, self.get_category_display()) + + + +class Expense(models.Model): + name = models.CharField(max_length=200) + amount = models.DecimalField(max_digits=8, decimal_places=2) + date = models.DateTimeField(default=timezone.now) + notes = models.TextField(null=True, blank=True) + category = models.CharField(max_length=2, choices=CATS, default=1) + trip = models.ForeignKey(Trip, on_delete=models.CASCADE, null=True) + + class Meta: + ordering = ('-date',) + + def __str__(self): + return self.name + + def date_month(self): + return self.date.strftime("%b %Y") |