@component('mail::message') # Weekly low-stock digest — {{ $weekStart }} to {{ $weekEnd }} @php $totalProducts = collect($groups)->sum(fn ($g) => count($g['rows'])); $totalShort = collect($groups)->sum(fn ($g) => collect($g['rows'])->sum(fn ($r) => (float) $r['shortfall'])); @endphp @if (count($groups) === 0) Good news — nothing is below its reorder level this week. No action needed. @else **{{ $totalProducts }} product(s) are short across {{ count($groups) }} location(s)** — suggested total order quantity **{{ number_format((float) $totalShort, 2) }}**. @foreach ($groups as $group) ### {{ strtoupper($group['location']['type']) }}: {{ $group['location']['name'] }} | Product | SKU | On hand | Reorder at | Order qty | |-|-|-|-|-| @foreach ($group['rows'] as $r) | {{ \Illuminate\Support\Str::limit($r['name'], 40) }} | {{ $r['sku'] }} | {{ $r['quantity'] }} | {{ $r['reorder_level'] }} | **{{ $r['shortfall'] }}** | @endforeach @endforeach The full report is attached as a PDF on the company letterhead — use the per-location order quantities to draft this week's purchase orders. @endif {{ config('app.name', 'ERP') }} — automated weekly purchasing digest @endcomponent