@php use Illuminate\Support\Carbon; $eur = fn ($n) => '€'.number_format((float) $n, 0); $eur2 = fn ($n) => '€'.number_format((float) $n, 2); $num = fn ($n) => number_format((float) $n); $pct = fn ($n) => number_format((float) $n * 100, 1).'%'; $mult = fn ($n) => number_format((float) $n, 2).'×'; $ord = function (int $n) { $s = ['th', 'st', 'nd', 'rd']; $v = $n % 100; return $n.($s[($v - 20) % 10] ?? $s[$v] ?? $s[0]); }; $d = $analysis['donations']; $st = $analysis['standing']; $mo = $analysis['momentum']; // Chart row builders from the payload. $dow = collect($d['by_dow'])->map(fn ($r) => ['label' => $r['label'], 'value' => $r['sum'], 'display' => $eur($r['sum']).' · '.$num($r['count']).' gifts', 'x' => $r['label']])->all(); $mon = collect($d['by_month'])->map(fn ($r) => ['label' => $r['label'], 'value' => $r['sum'], 'display' => $eur($r['sum']).' · '.$num($r['count']).' gifts', 'x' => $r['label']])->all(); $hour = collect($d['by_hour'])->map(fn ($r) => ['label' => $r['label'].':00', 'value' => $r['count'], 'display' => $num($r['count']).' gifts · '.$eur($r['sum']), 'x' => ((int) $r['label']) % 3 === 0 ? $r['label'] : ''])->all(); $sizes = collect($d['sizes'])->map(fn ($count, $label) => ['label' => $label, 'value' => $count, 'display' => $num($count).' gifts', 'x' => $label])->values()->all(); $trendSum = collect($d['trend'])->map(fn ($r) => ['label' => $r['label'], 'value' => $r['sum'], 'display' => $eur($r['sum']).' · '.$num($r['count']).' gifts', 'x' => $r['label']])->all(); $trendAvg = collect($d['trend'])->map(fn ($r) => ['label' => $r['label'], 'value' => $r['average'], 'display' => $eur($r['average']).' avg · '.$num($r['count']).' gifts', 'x' => $r['label']])->all(); @endphp
Financial analysis

{{ $title }}

{{ $subject->u_ident }} · their donation position & standing in the charity

Back
{{-- Standing within the charity's finances (all-time, not windowed). --}} Standing in the charity (all time)
{{ $eur($st['raised']) }} {{ $pct($st['share_of_revenue']) }} {{ $ord($st['rank']) }} of {{ $num($st['fundraiser_count']) }} @if ($st['fundraiser_count'] > 0)Top {{ max(1, (int) ceil($st['rank'] / $st['fundraiser_count'] * 100)) }}%@else — @endif {{ $mult($st['vs_average_raised']) }} (avg {{ $eur($st['average_raised']) }}) {{ $eur2($st['my_average_gift']) }} (platform {{ $eur2($st['platform_average_gift']) }})
{{-- Cost coverage / net contribution (this one fundraiser, one voucher). --}} Net contribution & cost coverage
{{ $eur($st['event_cost']) }} {{ $pct($st['cost_coverage']) }} {{ $eur($st['net_to_charity']) }} {{ $st['voucher_status'] }}
{{-- Momentum (all-time pace toward goal). --}} @if ($mo['has']) Momentum
{{ $num($mo['days_active']) }} {{ $num($mo['days_since_last']) }} days {{ $eur($mo['per_week_amount']) }} {{ number_format($mo['per_week_count'], 1) }} @if ($mo['goal_pct'] !== null) {{ $mo['goal_pct'] }}% of {{ $eur($mo['goal']) }} @endif
@endif {{-- Interval selector (rolling/YTD windows) for the donation breakdown below. --}} Timeframe @foreach ($analysis['intervals'] as $key => $label) {{ $label }} @endforeach {{-- Donation KPIs (selected timeframe). --}}
{{ $num($d['count']) }} {{ $eur($d['total']) }} {{ $eur2($d['average']) }} {{ $eur2($d['median']) }} {{ $eur2($d['min']) }} {{ $eur2($d['max']) }} {{ $num($d['donors']) }} {{ $num($d['repeat_donors']) }}
@if ($d['count'] === 0)

No donations in this timeframe.

@else
By day of week
@include('admin.analysis._chart', ['rows' => $dow, 'unit' => 'eur', 'aria' => 'Donations by day of week'])
By hour of day (Dublin)
@include('admin.analysis._chart', ['rows' => $hour, 'unit' => 'count', 'aria' => 'Donations by hour of day'])
By month of year
@include('admin.analysis._chart', ['rows' => $mon, 'unit' => 'eur', 'aria' => 'Donations by month of year'])
Gift-size distribution
@include('admin.analysis._chart', ['rows' => $sizes, 'unit' => 'count', 'aria' => 'Donations by size band'])
Total raised over time
@include('admin.analysis._chart', ['rows' => $trendSum, 'unit' => 'eur', 'aria' => 'Total raised by month'])
Average gift over time
@include('admin.analysis._chart', ['rows' => $trendAvg, 'unit' => 'eur', 'aria' => 'Average gift by month'])
@endif @push('scripts') @vite('resources/js/analysis.js') @endpush