@php $org = auth()->user()->organization ?? \App\Models\System\Organization::find(auth()->user()->organization_id); @endphp @extends('documents.procurement._layout', [ 'documentTitle' => 'Purchase History by Product', 'reference' => null, 'documentDate' => $reportDate, 'noAutoPrint' => true, ]) @section('header-meta')
|
Products {{ $byProduct->count() }} |
Total Lines {{ $items->count() }} |
Total Qty Ordered {{ number_format($items->sum('quantity')) }} |
No purchase history found for this period.
@else @foreach($byProduct as $productId => $productItems) @php $product = $productItems->first()->product; $totalQty = $productItems->sum('quantity'); $totalCost = $productItems->sum('total_cost_source'); $avgUnit = $totalQty > 0 ? $totalCost / $totalQty : 0; @endphpTotal ordered: {{ number_format($totalQty) }} {{ $product?->uom ?? '' }} · Total cost: {{ number_format($totalCost, 2) }} · Avg unit cost: {{ number_format($avgUnit, 4) }}
| LPO Ref | Supplier | Date | Status | Qty | UoM | Unit Cost (src) | Total Cost (src) |
|---|---|---|---|---|---|---|---|
| {{ $item->lpo?->lpo_reference ?? '—' }} | {{ $item->lpo?->supplier?->name ?? '—' }} | {{ $item->lpo?->purchase_date ? \Carbon\Carbon::parse($item->lpo->purchase_date)->format('d M Y') : '—' }} | {{ $item->lpo?->status ? ucwords(str_replace('_',' ',$item->lpo->status)) : '—' }} | {{ number_format((float)$item->quantity, 0) }} | {{ $item->quantity_uom ?? $product?->uom ?? '—' }} | {{ number_format((float)$item->unit_cost_source, 4) }} | {{ number_format((float)$item->total_cost_source, 2) }} |