{% extends "base.html" %} {% block title %}Insights{% endblock %} {% block content %}

Financial Insights

{% if months_with_data == 0 %}
No data yet. Add transactions to see your financial trends.
{% else %}
Avg Savings Rate
{{ "%.0f"|format(avg_savings_rate_pct) }}%
last {{ months_with_data }} month{% if months_with_data != 1 %}s{% endif %}
Income Stability
{{ income_stability | capitalize }}
{% if income_stability == "stable" %}CV < 10% {% elif income_stability == "moderate" %}CV 10–25% {% else %}CV > 25%{% endif %}
Savings Streak
{{ savings_streak }}
{% if savings_streak == 0 %}no positive months {% elif savings_streak == 1 %}month running {% else %}months running{% endif %}
{% if savings_history | length > 1 %} {% set rates = savings_history | map(attribute='savings_rate_pct') | list %} {% set max_rate = rates | max %} {% set min_rate = rates | min %} {% set range_rate = (max_rate - min_rate) if (max_rate - min_rate) > 0 else 1 %} {% set chart_h = 80 %} {% set chart_w = 480 %} {% set n = savings_history | length %} {% set step = (chart_w / (n - 1)) if n > 1 else chart_w %}
Savings Rate — {{ n }} Months
{% set target_y = chart_h - ((20 - min_rate) / range_rate * chart_h) %} {% if target_y >= 0 and target_y <= chart_h %} 20% target {% endif %} {% for entry in savings_history %} {% set cx = (loop.index0 * step) | int %} {% set cy = (chart_h - ((entry.savings_rate_pct - min_rate) / range_rate * chart_h)) | int %} {% endfor %} {{ savings_history[0].label }} {% if n > 2 %} {% set mid_i = (n // 2) %} {{ savings_history[mid_i].label }} {% endif %} {{ savings_history[-1].label }}
{% endif %}
Monthly Breakdown
{% for entry in savings_history | reverse %} {% endfor %}
Month Income Saved Rate
{{ entry.label }} ${{ "%.0f"|format(entry.income_cents / 100) }} {% if entry.net_cents >= 0 %}${{ "%.0f"|format(entry.net_cents / 100) }}{% else %}−${{ "%.0f"|format((entry.net_cents * -1) / 100) }}{% endif %} {{ "%.1f"|format(entry.savings_rate_pct) }}%
{% endif %}
{% endblock %}