@php $companyName = App\Models\Setting::where('key', 'company_name')->value('value') ?? 'Inventory Management System'; $companyAddress = App\Models\Setting::where('key', 'company_address')->value('value') ?? ''; @endphp

{{ $companyName }}

{{ $companyAddress }}

Payment Received Report

@if(request('from_date') || request('to_date')) Period: {{ request('from_date') ?? '...' }} to {{ request('to_date') ?? '...' }}
@endif @if(request('customer_id')) Customer: {{ App\Models\Customer::find(request('customer_id'))->name ?? '' }}
@endif @if(request('payment_method')) Payment Method: {{ ucfirst(request('payment_method')) }}
@endif Generated: {{ date('d-m-Y h:i A') }}

@php $total = 0; @endphp @foreach($payments as $payment) @php $total += $payment->credit; $invoiceNo = '-'; if($payment->sale) { $invoiceNo = $payment->sale->invoice_no; } else { preg_match('/Invoice:\s*([A-Z0-9-]+)/', $payment->description, $m); $invoiceNo = $m[1] ?? '-'; } $method = '-'; if($payment->voucher && preg_match('/\(([^)]+)\)/', $payment->voucher->description ?? '', $vm)) { $method = $vm[1]; } elseif(preg_match('/Method:\s*([^,]+)/', $payment->description ?? '', $m)) { $method = trim($m[1]); } elseif(preg_match_all('/\(([^)]+)\)/', $payment->description ?? '', $ms)) { $last = end($ms[1]); if(!preg_match('/^(Disc|TDS|VDS)/', $last)) { $method = $last; } } @endphp @endforeach
Date Customer Branch Shipment No Invoice No Description Method Amount
{{ date('d-m-Y', strtotime($payment->date)) }} {{ $payment->customer->name ?? 'N/A' }} {{ $payment->branch->name ?? '-' }} {{ $payment->shipment_number ?: ($payment->sale ? $payment->sale->items->pluck('shipment_number')->filter()->unique()->implode(', ') : '-') }} {{ $invoiceNo }} {{ $payment->description }} {{ $method }} {{ number_format($payment->credit, 2) }}
Total Received: {{ number_format($total, 2) }}