summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/budget/models.py3
-rw-r--r--app/budget/templates/budget/luxpurchase_list.html2
-rw-r--r--app/budget/views.py4
3 files changed, 5 insertions, 4 deletions
diff --git a/app/budget/models.py b/app/budget/models.py
index 7b7da75..6d1d113 100644
--- a/app/budget/models.py
+++ b/app/budget/models.py
@@ -41,13 +41,14 @@ class LuxPurchaseStatsManager(models.Manager):
return self.filter(date_recorded__range=(start_date, end_date)).aggregate(Sum('amount'))
def get_monthly_spending_by_category(self, cat, number_of_months=1):
+ cat = LuxSpendingCategory.objects.get(name=cat)
today = timezone.now()
month = today.replace(day=1).month
start_month = month - number_of_months + 1
start_date = datetime.date(timezone.now().year, start_month, 1)
last_day = calendar.monthrange(timezone.now().year, month)[1]
end_date = datetime.date(timezone.now().year, month, last_day)
- return self.filter(date_recorded__range=(start_date, end_date)).filter(category=cat).aggregate(Sum('amount'))
+ return self.filter(date_recorded__range=(start_date, end_date)).filter(cat=cat).aggregate(Sum('amount'))
class LuxPurchase(models.Model):
diff --git a/app/budget/templates/budget/luxpurchase_list.html b/app/budget/templates/budget/luxpurchase_list.html
index 20e0d4e..c03f14d 100644
--- a/app/budget/templates/budget/luxpurchase_list.html
+++ b/app/budget/templates/budget/luxpurchase_list.html
@@ -17,7 +17,7 @@
<tr>
<td><a href="{{object.get_absolute_url}}">{{object.date_recorded|date:"m/j"}}</a></td>
<td>{{object.source.name}}</td>
- <td>{{object.get_category_display}}</td>
+ <td>{{object.category.name}}</td>
<td>${{object.amount}}</td>
</tr>
{% endfor %}
diff --git a/app/budget/views.py b/app/budget/views.py
index c168ae1..fe558a5 100644
--- a/app/budget/views.py
+++ b/app/budget/views.py
@@ -52,6 +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['food_total'] = LuxPurchase.stats.get_monthly_spending_by_category(0, 1)
- context['lodge_total'] = LuxPurchase.stats.get_monthly_spending_by_category(3, 1)
+ context['food_total'] = LuxPurchase.stats.get_monthly_spending_by_category("Groceries & Home", 1)
+ context['lodge_total'] = LuxPurchase.stats.get_monthly_spending_by_category("Lodging", 1)
return context