@extends('layouts.app') @section('title', 'M-Pesa Duplicate Cleanup') @section('content') {{-- ═══ HEADER ═══ --}}

M-Pesa Duplicate Cleanup

Same M-Pesa code + amount + patient appearing more than once. Review each group and delete the extra copies.

to
@if(empty($groups))
🎉

No duplicate M-Pesa payments found

No payments share the same M-Pesa code + amount + patient in this date range.

@else
⚠ Important: Each group below contains payments that look identical (same M-Pesa code, same amount, same patient). These are almost always duplicate saves from a double-clicked submit button. Pick ONE copy to keep (usually the earliest) and click Delete on the others. Deletion is permanent — the row plus its invoice (if no other payments share it) will be removed. Bank-verified rows can't be deleted from this screen.
@foreach($groups as $group) @php $first = $group['rows']->first(); @endphp
{{ $group['mpesa_code'] }} KES {{ number_format($group['amount']) }} {{ $first->invoice?->patient?->full_name ?? $first->patient?->full_name ?? '—' }} @if($first->invoice?->patient?->mrn ?? $first->patient?->mrn) ({{ $first->invoice?->patient?->mrn ?? $first->patient?->mrn }}) @endif {{ $group['copies'] }} copies
@foreach($group['rows'] as $idx => $p) @endforeach
Created Visit Description Received By Status Action
{{ $p->created_at->format('d M Y H:i:s') }} {{ $p->invoice?->visit?->visit_number ?? $p->invoice?->invoice_number ?? '—' }} {{ $p->description ?? '—' }} {{ $p->receiver->name ?? '—' }} @if($p->isBankVerified()) ✓ Verified @elseif($idx === 0) Earliest (suggested keep) @else Duplicate copy @endif @if($p->isBankVerified()) Locked @else @endif
@endforeach @endif @endsection