Add total amounts for the future
This commit is contained in:
parent
182fb01d3c
commit
fc1cf6dae9
@ -127,6 +127,19 @@ def dashboard(request):
|
|||||||
if selected_month:
|
if selected_month:
|
||||||
expenses_filtered = expenses_filtered.filter(date__month=selected_month)
|
expenses_filtered = expenses_filtered.filter(date__month=selected_month)
|
||||||
|
|
||||||
|
total_amount = expenses.aggregate(
|
||||||
|
total=Sum('amount')
|
||||||
|
)['total'] or 0
|
||||||
|
|
||||||
|
expense_count = expenses.count()
|
||||||
|
|
||||||
|
category_count = (
|
||||||
|
expenses
|
||||||
|
.values('category')
|
||||||
|
.distinct()
|
||||||
|
.count()
|
||||||
|
)
|
||||||
|
|
||||||
# ------------------
|
# ------------------
|
||||||
# Totals by category
|
# Totals by category
|
||||||
# -----------------
|
# -----------------
|
||||||
@ -189,4 +202,7 @@ def dashboard(request):
|
|||||||
'months': months,
|
'months': months,
|
||||||
'selected_year': selected_year,
|
'selected_year': selected_year,
|
||||||
'selected_month': selected_month,
|
'selected_month': selected_month,
|
||||||
|
'kpi_total': total_amount,
|
||||||
|
'kpi_count': expense_count,
|
||||||
|
'kpi_categories': category_count,
|
||||||
})
|
})
|
||||||
Loading…
Reference in New Issue
Block a user