diff options
author | luxagraf <sng@luxagraf.net> | 2022-11-12 11:50:20 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2022-11-12 11:50:20 -0600 |
commit | b49342cd534a3384d86b49e3c77f632e0d01edc9 (patch) | |
tree | f720584c591a650b9a55a0058cb1b365fefa07aa /app | |
parent | adfa2d7328dedbf409b512f0d55e4ee85cea8dca (diff) |
bdgt: added category level monthly stats
Diffstat (limited to 'app')
-rw-r--r-- | app/budget/models.py | 20 | ||||
-rw-r--r-- | app/budget/templates/budget/luxpurchase_list.html | 12 | ||||
-rw-r--r-- | app/budget/views.py | 3 |
3 files changed, 34 insertions, 1 deletions
diff --git a/app/budget/models.py b/app/budget/models.py index f4c6ec0..7afc4e2 100644 --- a/app/budget/models.py +++ b/app/budget/models.py @@ -14,6 +14,26 @@ class LuxSource(models.Model): return self.name +class LuxFixedMonthly(models.Model): + name = models.CharField(max_length=200) + source = models.ForeignKey(LuxSource, on_delete=models.CASCADE) + CATEGORY = ( + (0, 'Grocery & Home'), + (1, 'Gas'), + (2, 'Bus'), + (3, 'Lodging'), + (4, 'Books'), + (5, 'Clothes'), + (6, 'Eating Out'), + (7, 'Misc'), + ) + category = models.IntegerField(choices=CATEGORY, default=0) + date_recorded = models.DateTimeField(auto_now_add=True) + + def __str__(self): + return self.name + + class LuxPurchaseStatsManager(models.Manager): def get_monthly_spending(self, month=timezone.now().month): diff --git a/app/budget/templates/budget/luxpurchase_list.html b/app/budget/templates/budget/luxpurchase_list.html index 765834a..20e0d4e 100644 --- a/app/budget/templates/budget/luxpurchase_list.html +++ b/app/budget/templates/budget/luxpurchase_list.html @@ -30,6 +30,18 @@ <td class="right">{{month}} Total:</td> <td>${{monthly_spending.amount__sum}}</td> </tr> + <tr> + <td></td> + <td></td> + <td class="right">{{month}} Food Total:</td> + <td>${{food_total.amount__sum}}</td> + </tr> + <tr> + <td></td> + <td></td> + <td class="right">{{month}} Lodging Total:</td> + <td>${{lodge_total.amount__sum}}</td> + </tr> </table> <h3>Previous Monthly Spending</h3> diff --git a/app/budget/views.py b/app/budget/views.py index 4a2ab74..c168ae1 100644 --- a/app/budget/views.py +++ b/app/budget/views.py @@ -52,5 +52,6 @@ class LuxPurchaseListView(PaginatedListView): context['month_2'] = month_2.strftime('%h') context['monthly_spending_3'] = LuxPurchase.stats.get_monthly_spending(month_3.month) context['month_3'] = month_3.strftime('%h') - context['cat'] = LuxPurchase.stats.get_monthly_spending_by_category(1, 3) + context['food_total'] = LuxPurchase.stats.get_monthly_spending_by_category(0, 1) + context['lodge_total'] = LuxPurchase.stats.get_monthly_spending_by_category(3, 1) return context |