Created table in the dashboard with the last expenses

This commit is contained in:
JKuijperM 2026-06-11 13:14:21 +02:00
parent 2c2ef350b0
commit 53253bcc83
2 changed files with 32 additions and 0 deletions

View File

@ -179,6 +179,34 @@
<canvas id="categoryChart"></canvas>
</div>
</section>
<section>
<h3>Gastos Recientes</h3>
<table class="table">
<thead>
<tr>
<th>Fecha</th>
<th>cuenta</th>
<th>Categoría</th>
<th>Concepto</th>
<th>Importe</th>
</tr>
</thead>
<tbody>
{% for exp in recent_expenses %}
<tr>
<td>{{ exp.date|date:"d/m/Y" }}</td>
<td>{{ exp.account.name }}</td>
<td>{{ exp.category.name }}</td>
<td>{{ exp.description|default:"-" }}</td>
<td style="color: #d9534f; font-weight: bold;">{{ exp.amount|floatformat:2 }}</td>
</tr>
{% empty %}
<tr><td colspan="7">No hay gastos recientes registrados</td></tr>
{% endfor %}
</tbody>
</table>
</section>
</div>
<div style="clear: both; margin-top: 2rem;"></div>

View File

@ -460,6 +460,9 @@ def dashboard(request):
# Goals
goals = Goal.objects.filter(owner=request.user)
# Recent expenses
recent_expenses = Expense.objects.filter(owner=request.user).order_by('-date', '-id')[:7]
# Send the data to the dashboard
return render(
request,
@ -491,6 +494,7 @@ def dashboard(request):
"accounts_charts": accounts_charts,
"period": period,
"goals": goals,
"recent_expenses": recent_expenses,
},
)