@extends('layouts.app') @section('title', 'Statement — '.$customer->display_name) @section('content')

Account statement

{{ $customer->display_name }} · {{ $customer->customer_number }} · {{ $from->format('d M Y') }} to {{ $to->format('d M Y') }}

← Back to profile
@php $balance = 0; $rows = $invoices->map(fn ($i) => ['date' => $i->issue_date, 'type' => 'Invoice '.$i->invoice_number, 'ref' => $i->invoice_number, 'debit' => (float) $i->total, 'credit' => 0.0, 'status' => $i->status]) ->concat($payments->map(fn ($p) => ['date' => \Carbon\Carbon::parse($p->paid_at), 'type' => 'Payment — '.title_case_words($p->method), 'ref' => $p->reference, 'debit' => 0.0, 'credit' => (float) $p->amount, 'status' => $p->status])) ->sortBy(fn ($r) => $r['date'])->values(); @endphp

Transaction ledger

{{ $rows->count() }} movement(s)
@forelse ($rows as $row) @php $balance += $row['debit'] - $row['credit']; @endphp @empty @endforelse @if ($rows->isNotEmpty()) @endif
DateDescriptionReferenceDebitCreditBalanceStatus
{{ $row['date']->format('d M Y') }} {{ $row['type'] }} {{ $row['ref'] }} {{ $row['debit'] > 0 ? money($row['debit'], $customer->currency) : '—' }} {{ $row['credit'] > 0 ? money($row['credit'], $customer->currency) : '—' }} {{ money($balance, $customer->currency) }} {{ $row['status'] }}
@include('components.empty-state', ['icon' => '📄', 'title' => 'No transactions in this period'])
Closing balance {{ money($invoices->sum('total'), $customer->currency) }} {{ money($payments->sum('amount'), $customer->currency) }} {{ money($balance, $customer->currency) }}
@endsection