{{-- resources/views/returns/index.blade.php --}} @extends('layouts.app') @section('title', 'Return History') @section('content') @php /** * Group returns by return_no (preferred). * If return_no missing, fallback grouping: type-party-date-note */ $groups = collect($returns->items() ?? $returns)->groupBy(function ($r) { $key = $r->return_no ?? null; if ($key) return $key; $date = $r->date ? \Carbon\Carbon::parse($r->date)->format('Y-m-d') : 'no-date'; $note = trim((string)($r->note ?? '')); return "{$r->type}-{$r->party_id}-{$date}-{$note}"; }); // nice group label helper $getPartyName = function($row) { if ($row->type === 'customer') return optional($row->customer)->name ?? '—'; return optional($row->supplier)->name ?? '—'; }; $getTypeBadge = function($row) { if ($row->type === 'customer') { return 'Customer'; } return 'Supplier'; }; @endphp
| ID | Return No | Type | Party | Date | Total | Note | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $first->id }} | {{ $returnNo }} | {!! $getTypeBadge($first) !!} |
{{ $partyName }}
{{ $first->type === 'customer' ? 'From Customer (Return In)' : 'To Supplier (Return Out)' }}
|
{{ $dateLabel }} | {{ number_format($groupTotal, 2) }} |
{{ $first->note ?? '-' }}
Click to view items
|
||||||||||||||||
|
||||||||||||||||||||||
| No returns found. | ||||||||||||||||||||||