{% extends 'base.html.twig' %} {% block title %}AI Insights{% endblock %} {% block content %}
ℹ️
Context included in your analysis

Reliable tracking starts in {{ dataset.context.trackingStarted }}. This is your partner's first full-pay month after maternity leave, so earlier income is not treated as your normal household baseline.

{% if not aiConfigured %}
🔑
AI recommendations are ready to activate

Add OPENAI_API_KEY=your-key to .env.local, then clear the production cache. Monthly averages below already work without AI.

{% endif %}
Current spending
£{{ dataset.current.totalSpending|number_format(2) }}
Day {{ dataset.daysElapsed }} of {{ dataset.totalDays }}
Past monthly average
£{{ dataset.averageMonthlySpend|number_format(2) }}
Across {{ dataset.historyCount }} completed period{{ dataset.historyCount == 1 ? '' : 's' }}
Projected this period
£{{ dataset.projectedCurrentSpend|number_format(2) }}
Bills counted once + day-to-day pace
Saved this period
£{{ dataset.current.savings|number_format(2) }}
From £{{ dataset.current.workIncome|number_format(2) }} work income
{% if analysis %} {% if not analysisIsCurrent %}
↻
Showing your last AI analysis

Your spending data has changed or the analysis is over 24 hours old. Use “Refresh AI analysis” for recommendations based on the latest figures.

{% endif %}
AI analysis

Your spending coach

Potential monthly opportunity £{{ analysis.estimatedTotalMonthlySaving|number_format(2) }}

{{ analysis.summary }}

{% if analysis.patterns|length > 0 %}
{% for pattern in analysis.patterns %}
{{ pattern.impact == 'positive' ? '↗' : (pattern.impact == 'watch' ? '!' : '•') }}

{{ pattern.title }}

{{ pattern.evidence }}

{% endfor %}
{% endif %} {% if analysis.recommendations|length > 0 %}

Recommended next moves

{% for recommendation in analysis.recommendations %}
{{ loop.index }}

{{ recommendation.title }}

{{ recommendation.priority }}

{{ recommendation.action }}

{{ recommendation.reason }}
£{{ recommendation.estimated_monthly_saving|number_format(2) }} possible / month
{% endfor %}
{% endif %}
{% elseif aiConfigured %}
✨

Your data is ready

Generate an analysis to spot repeated patterns and get practical saving suggestions. Unchanged results are cached for 24 hours.

{% endif %}

Average spending by category

Completed payday periods only, with the live period shown separately.

{{ dataset.historyCount }}-period average
{% if dataset.categoryComparison|length > 0 %}
{% for row in dataset.categoryComparison %} {% endfor %}
Category Monthly average Current so far Vs average Budget
{{ row.category|replace({'_': ' '})|title }} £{{ row.average|number_format(2) }} £{{ row.current|number_format(2) }} {% if row.differencePercent is null %} New {% elseif row.difference > 0 %} +{{ row.differencePercent|number_format(1) }}% {% elseif row.difference < 0 %} {{ row.differencePercent|number_format(1) }}% {% else %} 0% {% endif %} {{ row.budget is not null ? '£' ~ row.budget|number_format(2) : '—' }}
{% else %}

Add more historical expenses to calculate monthly category averages.

{% endif %}
{% if dataset.historical|length > 0 %}

Completed period history

A quick view of income, spending and savings movement.

{% for period in dataset.historical %} {% endfor %}
PeriodDatesIncomeSpentSaved
{{ period.label }} {{ period.start|date('d M') }} – {{ period.endDisplay|date('d M') }} £{{ period.totalIncome|number_format(2) }} £{{ period.totalSpending|number_format(2) }} £{{ period.savings|number_format(2) }}
{% endif %}
🔒

Privacy: AI analysis receives category totals, budgets, income totals and period dates only. Merchant names, transaction descriptions, account IDs and personal names are not sent.

{% endblock %}