@extends('layouts.app')
@section('title',ucfirst($type))
@section('content')
<div class="page-head"><div><h1>{{ ucfirst($type) }}</h1><p>{{ $type==='receipts'?'Customer collections posted to cash/bank and receivables.':($type==='payments'?'Supplier payments posted to payables and cash/bank.':'Operating expenses with VAT and double-entry posting.') }}</p></div><a href="{{ route('treasury.create',$type) }}" class="btn btn-primary btn-dense"><i class="bi bi-plus-lg me-1"></i>New {{ rtrim($type,'s') }}</a></div>
<div class="d-flex gap-2 mb-2"><a class="btn btn-sm {{ $type==='receipts'?'btn-dark':'btn-light border' }}" href="{{ route('treasury.index','receipts') }}">Receipts</a><a class="btn btn-sm {{ $type==='payments'?'btn-dark':'btn-light border' }}" href="{{ route('treasury.index','payments') }}">Payments</a><a class="btn btn-sm {{ $type==='expenses'?'btn-dark':'btn-light border' }}" href="{{ route('treasury.index','expenses') }}">Expenses</a></div>
<div class="card-erp"><div class="table-responsive"><table class="table table-dense"><thead>@if($type==='receipts')<tr><th>Receipt</th><th>Date</th><th>Customer</th><th>Method</th><th>Reference</th><th class="text-end">Amount</th><th>Status</th></tr>@elseif($type==='payments')<tr><th>Payment</th><th>Date</th><th>Supplier</th><th>Method</th><th>Reference</th><th class="text-end">Amount</th><th>Status</th></tr>@else<tr><th>Expense</th><th>Date</th><th>Account</th><th>Payment account</th><th>Reference</th><th class="text-end">Taxable</th><th class="text-end">VAT</th><th class="text-end">Total</th></tr>@endif</thead><tbody>@forelse($records as $r)@if($type==='receipts')<tr><td class="fw-bold text-accent">{{ $r->receipt_no }}</td><td>{{ $r->receipt_date->format('d M Y') }}</td><td>{{ $r->customer?->name_en }}</td><td>{{ ucfirst($r->payment_method) }}</td><td>{{ $r->reference?:'—' }}</td><td class="text-end fw-bold">{{ number_format((float)$r->amount,2) }}</td><td><span class="badge status-{{ $r->status }}">{{ strtoupper($r->status) }}</span></td></tr>@elseif($type==='payments')<tr><td class="fw-bold text-accent">{{ $r->payment_no }}</td><td>{{ $r->payment_date->format('d M Y') }}</td><td>{{ $r->supplier?->name_en }}</td><td>{{ ucfirst($r->payment_method) }}</td><td>{{ $r->reference?:'—' }}</td><td class="text-end fw-bold">{{ number_format((float)$r->amount,2) }}</td><td><span class="badge status-{{ $r->status }}">{{ strtoupper($r->status) }}</span></td></tr>@else<tr><td class="fw-bold text-accent">{{ $r->expense_no }}</td><td>{{ $r->expense_date->format('d M Y') }}</td><td>{{ $r->expenseAccount?->name_en }}</td><td>{{ $r->paymentAccount?->name_en }}</td><td>{{ $r->reference?:'—' }}</td><td class="text-end">{{ number_format((float)$r->taxable_amount,2) }}</td><td class="text-end">{{ number_format((float)$r->vat_amount,2) }}</td><td class="text-end fw-bold">{{ number_format((float)$r->total_amount,2) }}</td></tr>@endif @empty<tr><td colspan="8" class="text-center text-muted py-5">No {{ $type }} posted.</td></tr>@endforelse</tbody></table></div>@if($records->hasPages())<div class="card-erp-body border-top">{{ $records->links() }}</div>@endif</div>
@endsection
