Dashboard #10
@ -142,11 +142,24 @@
|
|||||||
<span class="kpi-label">Categorías</span>
|
<span class="kpi-label">Categorías</span>
|
||||||
<span class="kpi-value">{{ kpi_categories }}</span>
|
<span class="kpi-value">{{ kpi_categories }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="kpi-card">
|
||||||
|
<span class="kpi-label"> Media diaria</span>
|
||||||
|
<span class="kpi-value">{{ daily_average|floatformat:2 }}€ / día</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if selected_month == today.month and selected_year == today.year %}
|
||||||
|
<div class="kpi-card" style="border-left: 4px solid #ff9f43;">
|
||||||
|
<span class="kpi-label">Proyección fin de mes</span>
|
||||||
|
<span class="kpi-value">{{ projected_end_of_month|floatformat:2 }}€</span>
|
||||||
|
<small style="color: gray; display:block;">Basado en tu ritmo de gasto actual</small>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% if compare_enabled %}
|
{% if compare_enabled %}
|
||||||
<section class="comparison">
|
<section class="comparison">
|
||||||
<h3>📊 Resumen comparativo</h3>
|
<h3>Resumen comparativo</h3>
|
||||||
<p>
|
<p>
|
||||||
Gastos periodo actual: <strong>{{ kpi_total|floatformat:2 }} €</strong><br>
|
Gastos periodo actual: <strong>{{ kpi_total|floatformat:2 }} €</strong><br>
|
||||||
Gastos periodo anterior: <strong>{{ kpi_previous_total|floatformat:2 }} €</strong><br>
|
Gastos periodo anterior: <strong>{{ kpi_previous_total|floatformat:2 }} €</strong><br>
|
||||||
@ -158,6 +171,30 @@
|
|||||||
{% if kpi_trend == "up" %}⚠️ Has gastado más que el periodo pasado. {% else %} ¡Bien! Has reducido tus gastos. {% endif %}
|
{% if kpi_trend == "up" %}⚠️ Has gastado más que el periodo pasado. {% else %} ¡Bien! Has reducido tus gastos. {% endif %}
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h3>Desglose de cambios por categoría</h3>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Categoría</th>
|
||||||
|
<th>Periodo Anterior</th>
|
||||||
|
<th>Periodo Actual</th>
|
||||||
|
<th>Variación</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for cat in category_comparison %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ cat.category }}</td>
|
||||||
|
<td>{{ cat.previous|floatformat:2 }}€</td>
|
||||||
|
<td>{{ cat.current|floatformat:2 }}€</td>
|
||||||
|
<td style="font-weight: bold; color: {% if cat.difference > 0 %}#d9534f{% else %}#5cb85c{% endif %};">
|
||||||
|
{% if cat.difference > 0 %}+{% endif %}{{ cat.difference|floatformat:2 }}€
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@ -354,6 +354,8 @@ def dashboard(request):
|
|||||||
})
|
})
|
||||||
|
|
||||||
#Graphic
|
#Graphic
|
||||||
|
daily_average = 0
|
||||||
|
projected_end_of_month = 0
|
||||||
if selected_month:
|
if selected_month:
|
||||||
by_day_qs = (
|
by_day_qs = (
|
||||||
expenses_filtered.annotate(day=ExtractDay("date"))
|
expenses_filtered.annotate(day=ExtractDay("date"))
|
||||||
@ -364,6 +366,14 @@ def dashboard(request):
|
|||||||
|
|
||||||
import calendar
|
import calendar
|
||||||
num_days = calendar.monthrange(selected_year, selected_month)[1]
|
num_days = calendar.monthrange(selected_year, selected_month)[1]
|
||||||
|
if selected_year == today.year and selected_month == today.month:
|
||||||
|
days_passed = today.day
|
||||||
|
else:
|
||||||
|
days_passed = calendar.monthrange(selected_year, selected_month)[1]
|
||||||
|
|
||||||
|
daily_average = total_amount / days_passed if days_passed > 0 else 0
|
||||||
|
total_days_in_month = calendar.monthrange(selected_year, selected_month)[1]
|
||||||
|
projected_end_of_month = daily_average * total_days_in_month
|
||||||
|
|
||||||
chart_labels = list(range(1, num_days + 1))
|
chart_labels = list(range(1, num_days + 1))
|
||||||
chart_totals = [day_totals.get(d, 0) for d in chart_labels]
|
chart_totals = [day_totals.get(d, 0) for d in chart_labels]
|
||||||
@ -469,6 +479,7 @@ def dashboard(request):
|
|||||||
"expenses/dashboard.html",
|
"expenses/dashboard.html",
|
||||||
{
|
{
|
||||||
"active_menu": "dashboard",
|
"active_menu": "dashboard",
|
||||||
|
"today": today,
|
||||||
"by_category": by_category,
|
"by_category": by_category,
|
||||||
"by_category_chart": by_category_chart,
|
"by_category_chart": by_category_chart,
|
||||||
"chart_labels": chart_labels,
|
"chart_labels": chart_labels,
|
||||||
@ -495,6 +506,8 @@ def dashboard(request):
|
|||||||
"period": period,
|
"period": period,
|
||||||
"goals": goals,
|
"goals": goals,
|
||||||
"recent_expenses": recent_expenses,
|
"recent_expenses": recent_expenses,
|
||||||
|
"daily_average": daily_average,
|
||||||
|
"projected_end_of_month": projected_end_of_month,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user