@extends('layouts.app')
@section('title','Bank Reconciliation')
@section('page_title','Bank Reconciliation')
@section('content')
<div class="page-head"><div><h1>{{ $reconciliation->bankAccount?->bank_name }} · {{ $reconciliation->statement_date->format('d M Y') }}</h1><p><span class="badge status-{{ $reconciliation->status }}">{{ ucfirst($reconciliation->status) }}</span></p></div><a class="btn btn-secondary" href="{{ route('bank.index') }}">Back</a></div>
<div class="grid grid-3"><div class="card metric"><div class="metric-label">Statement Balance</div><div class="metric-value">AED {{ number_format((float)$reconciliation->statement_ending_balance,2) }}</div></div><div class="card metric"><div class="metric-label">Book Balance</div><div class="metric-value">AED {{ number_format((float)$reconciliation->book_ending_balance,2) }}</div></div><div class="card metric"><div class="metric-label">Difference</div><div class="metric-value">AED {{ number_format((float)$reconciliation->difference,2) }}</div></div></div>
<div class="card" style="margin-top:18px"><div class="card-head"><strong>Cleared Transactions</strong></div><div class="table-wrap"><table class="table"><thead><tr><th>Date</th><th>Reference</th><th>Description</th><th>Debit</th><th>Credit</th></tr></thead><tbody>@foreach($reconciliation->items as $item)<tr><td>{{ $item->transaction->transaction_date->format('d M Y') }}</td><td>{{ $item->transaction->reference }}</td><td>{{ $item->transaction->description }}</td><td>{{ number_format((float)$item->transaction->debit,2) }}</td><td>{{ number_format((float)$item->transaction->credit,2) }}</td></tr>@endforeach</tbody></table></div></div>
@if($reconciliation->status==='draft')<div class="card" style="margin-top:18px"><div class="card-body"><form method="post" action="{{ route('bank.reconciliations.close',$reconciliation) }}">@csrf<button class="btn btn-primary" data-confirm="Close this reconciliation?">Close Reconciliation</button></form><p class="muted">Closing is allowed only when the difference is exactly zero.</p></div></div>@endif
@endsection
