@extends('layouts.app')
@section('title','Customer Statement')
@section('content')
<div class="page-head"><div><h1>{{ $customer->name_en }}</h1><p>{{ $customer->customer_code }} · {{ $customer->name_ar }} · VAT {{ $customer->vat_number?:'Not registered' }}</p></div><div class="text-end"><small class="text-muted d-block">Outstanding balance</small><strong class="fs-4 text-accent">SAR {{ number_format((float)$customer->outstanding_balance,2) }}</strong></div></div><div class="card-erp"><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Date</th><th>Reference</th><th>Transaction</th><th>Description</th><th class="text-end">Debit</th><th class="text-end">Credit</th><th class="text-end">Running balance</th></tr></thead><tbody>@php $running=0; @endphp @foreach($openings as $o) @php $d=$o->type==='receivable'?(float)$o->amount:0;$c=$o->type==='advance'?(float)$o->amount:0;$running+=$d-$c; @endphp <tr><td>{{ $o->opening_date->format('d M Y') }}</td><td>{{ $o->reference }}</td><td>Opening balance</td><td>{{ ucfirst($o->type) }}</td><td class="text-end">{{ number_format($d,2) }}</td><td class="text-end">{{ number_format($c,2) }}</td><td class="text-end fw-bold">{{ number_format($running,2) }}</td></tr>@endforeach @foreach($entries as $e) @php $running+=(float)$e->debit-(float)$e->credit; @endphp <tr><td>{{ $e->transaction_date->format('d M Y') }}</td><td>{{ $e->reference_number }}</td><td>{{ str_replace('_',' ',$e->transaction_type) }}</td><td>{{ $e->description }}</td><td class="text-end">{{ number_format((float)$e->debit,2) }}</td><td class="text-end">{{ number_format((float)$e->credit,2) }}</td><td class="text-end fw-bold">{{ number_format($running,2) }}</td></tr>@endforeach @if(!$openings->count()&&!$entries->count())<tr><td colspan="7" class="text-center text-muted py-5">No account activity.</td></tr>@endif</tbody></table></div></div>
@endsection
