@extends('layouts.app')
@section('title','Payments')
@section('page_title','Payment Vouchers')
@section('content')
<div class="page-head"><div><h1>Payment Vouchers</h1><p>Vendor payments, customer refunds and other outgoing payments.</p></div>@if(auth()->user()->hasPermission('payments.create'))<a class="btn btn-primary" href="{{ route('payments.create') }}">+ New Payment</a>@endif</div>
<div class="card"><div class="toolbar"><form class="search"><input class="control" name="search" value="{{ request('search') }}" placeholder="Payment, party or reference"><select class="control" name="status"><option value="">All statuses</option>@foreach(\App\Enums\DocumentStatus::cases() as $s)<option value="{{ $s->value }}" @selected(request('status')===$s->value)>{{ ucwords(str_replace('_',' ',$s->value)) }}</option>@endforeach</select><button class="btn btn-secondary">Filter</button></form><span class="muted">{{ $payments->total() }} payments</span></div><div class="table-wrap"><table class="table"><thead><tr><th>Payment</th><th>Date</th><th>Type</th><th>Payee</th><th>Method</th><th>Amount</th><th>Allocated</th><th>Status</th><th></th></tr></thead><tbody>@forelse($payments as $p)@php($s=$p->status instanceof \App\Enums\DocumentStatus?$p->status->value:$p->status)<tr><td><strong>{{ $p->payment_number }}</strong><div class="muted">{{ $p->reference_number }}</div></td><td>{{ $p->payment_date->format('d M Y') }}</td><td>{{ ucwords(str_replace('_',' ',$p->payment_type)) }}</td><td>{{ $p->party?->legal_name }}</td><td>{{ ucwords(str_replace('_',' ',$p->payment_method)) }}</td><td>{{ $p->currency_code }} {{ number_format((float)$p->amount,2) }}</td><td>{{ number_format((float)$p->allocated_total,2) }}</td><td><span class="badge status-{{ $s }}">{{ ucwords(str_replace('_',' ',$s)) }}</span></td><td><a class="btn btn-secondary btn-sm" href="{{ route('payments.show',$p) }}">Open</a></td></tr>@empty<tr><td colspan="9" class="empty">No payments found.</td></tr>@endforelse</tbody></table></div>{{ $payments->links() }}</div>
@endsection
