@extends('admin.layouts.app') @section('title', 'Payment Received List') @section('page_title', 'Payment Received List') @section('content')
Payment Received List
Print Report
@php $_pmList = explode(',', App\Models\Setting::where('key', 'payment_methods')->value('value') ?? 'Cash,Bank,Cheque,Mobile Banking'); @endphp
@php $totalReceived = 0; @endphp @forelse($payments as $payment) @php $totalReceived += $payment->credit; // Get sale from voucher or direct reference $sale = null; if($payment->reference_type === 'Sale' && $payment->reference_id) { $sale = $payment->sale; } elseif($payment->reference_type === 'Voucher' && $payment->reference_id) { $voucher = $payment->voucher; if($voucher && $voucher->sale_id) { $sale = \App\Models\Sale::with('branch', 'items')->find($voucher->sale_id); } } // Get invoice $invoiceNo = $sale ? $sale->invoice_no : '-'; if($invoiceNo === '-') { preg_match('/Invoice:\s*([A-Z0-9-]+)/', $payment->description ?? '', $invoiceMatch); $invoiceNo = $invoiceMatch[1] ?? '-'; } // Get branch $branchName = $payment->branch->name ?? '-'; if($branchName === '-' && $sale) { $branchName = $sale->branch->name ?? '-'; } // Get shipment numbers $shipmentNo = $payment->shipment_number ?? '-'; if($shipmentNo === '-' && $sale) { $shipmentNo = $sale->items->pluck('shipment_number')->filter()->unique()->implode(', ') ?: '-'; } $paymentMethod = '-'; if($payment->voucher && preg_match('/\(([^)]+)\)/', $payment->voucher->description ?? '', $vm)) { $paymentMethod = $vm[1]; } elseif(preg_match('/Method:\s*([^,]+)/', $payment->description ?? '', $methodMatch)) { $paymentMethod = trim($methodMatch[1]); } elseif(preg_match_all('/\(([^)]+)\)/', $payment->description ?? '', $methodMatches)) { $last = end($methodMatches[1]); if(!preg_match('/^(Disc|TDS|VDS)/', $last)) { $paymentMethod = $last; } } @endphp @empty @endforelse
Date Customer Branch Shipment No Invoice No Description Payment Method Amount Received Actions
{{ date('d-m-Y', strtotime($payment->date)) }} {{ $payment->customer->name ?? 'N/A' }} {{ $branchName }} {{ $shipmentNo }} {{ $invoiceNo }} {{ $payment->description ?? '-' }} {{ $paymentMethod }} {{ number_format($payment->credit, 2) }} @if($sale) @endif
No payments received found
Total Received: {{ number_format($totalReceived, 2) }}
{{ $payments->links('pagination::bootstrap-5') }}
@endsection