@extends('layouts.app') @section('title', 'Payments') @php use App\Enums\Currency; use App\Enums\PaymentMethod; use Illuminate\Support\Str; @endphp @section('content')
{{-- Page header --}}

Payments

{{ number_format($totalCount) }} {{ Str::plural('payment', $totalCount) }} recorded

{{-- Flash messages --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Stats row --}}

Total Collected

{{ $defaultCurrency->symbol() }} {{ number_format((float) $totalCollected, 2) }}

All time

This Month

{{ $defaultCurrency->symbol() }} {{ number_format((float) $thisMonth, 2) }}

{{ now()->format('F Y') }}

Payment Records

{{ number_format($totalCount) }}

All time

Most Used Method

@if($mostUsedMethod) @php $pm = $mostUsedMethod->payment_method; $methodLabel = $pm instanceof \App\Enums\PaymentMethod ? $pm->label() : (\App\Enums\PaymentMethod::tryFrom((string) $pm)?->label() ?? (string) $pm ?? '—'); @endphp

{{ $methodLabel }}

{{ $mostUsedMethod->count }} payments

@else

@endif
{{-- Currency breakdown --}} @if($byCurrency->isNotEmpty())
@foreach($byCurrency as $bc) @php $bcRaw = $bc->payment_currency; $cur = $bcRaw instanceof \App\Enums\Currency ? $bcRaw : \App\Enums\Currency::tryFrom((string) $bcRaw); $currSymbol = $cur?->symbol() ?? (string) $bcRaw; $currDisplay = $cur?->value ?? (string) $bcRaw; @endphp
{{ $currSymbol }} {{ $currDisplay }} {{ number_format((float) $bc->total_original, 2) }} · {{ $bc->count }} {{ Str::plural('payment', $bc->count) }}
@endforeach
@endif {{-- Filters --}}
@if(request()->anyFilled(['search', 'currency', 'method', 'date_from', 'date_to', 'client_id'])) Clear @endif
{{-- Table --}}
@if($payments->isEmpty())

No payments found

@if(request()->anyFilled(['search', 'currency', 'method', 'date_from', 'date_to', 'client_id'])) Clear filters @endif
@else
@foreach($payments as $payment) @php $isCross = $payment->payment_currency && $payment->currency && $payment->payment_currency !== $payment->currency; // Resolve payment_method to enum regardless of whether it arrived as string or enum $pmEnum = $payment->payment_method instanceof \App\Enums\PaymentMethod ? $payment->payment_method : \App\Enums\PaymentMethod::tryFrom((string) ($payment->payment_method ?? '')); $methodColor = match($pmEnum?->value) { 'bank_transfer' => 'bg-slate-100 text-slate-700', 'wise' => 'bg-blue-100 text-blue-700', 'payoneer' => 'bg-emerald-100 text-emerald-700', 'jazzcash' => 'bg-orange-100 text-orange-700', 'easypaisa' => 'bg-green-100 text-green-700', 'paypal' => 'bg-indigo-100 text-indigo-700', default => 'bg-slate-100 text-slate-500', }; @endphp @endforeach
Date Client Invoice Paid In Base ({{ $defaultCurrency->value }}) Method Notes Actions

{{ $payment->paid_at->format('d M Y') }}

{{ $payment->paid_at->format('H:i') }}

@if($payment->invoice?->client) {{ $payment->invoice->client->name }} @else @endif @if($payment->invoice) {{ $payment->invoice->invoice_number }} @if($payment->invoice->currency) {{ $payment->invoice->currency->value }} @endif @else @endif @if($isCross)

{{ $payment->payment_currency->symbol() }} {{ number_format((float) $payment->payment_amount, 2) }}

@ {{ number_format((float) $payment->exchange_rate, 4) }} @else {{ $defaultCurrency->symbol() }} {{ number_format((float) $payment->amount, 2) }} @endif
{{ $defaultCurrency->symbol() }} {{ number_format((float) $payment->amount, 2) }} @if($pmEnum) {{ $pmEnum->label() }} @else @endif @if($payment->notes) {{ Str::limit($payment->notes, 30) }} @else @endif
@if($payment->invoice) View Invoice → @endif @can('invoices.record-payment')
@csrf @method('DELETE')
@endcan
@if($payments->hasPages())
{{ $payments->links() }}
@endif @endif
@endsection