| # |
Product |
Description |
Quantity |
Batch |
Mfg Date |
Exp Date |
Unit Price |
Total |
@php
$groupedProducts = $purchase_order->products->groupBy('name')->map(
function ($products, $name)
{
$firstProduct = $products->first();
$quantity = $products->sum('pivot.quantity');
$sub_total = $products->sum(
function ($product) {
return $product->pivot->quantity * $product->pivot->unit_price;
});
return [
'description' => $firstProduct->pivot->description,
'quantity' => $quantity,
'batch' => $firstProduct->pivot->batch,
'mfg_date' => $firstProduct->pivot->mfg_date,
'exp_date' => $firstProduct->pivot->exp_date,
'unit_price' => $firstProduct->pivot->unit_price,
'sub_total' => $sub_total,
];
});
@endphp
@foreach($groupedProducts as $index => $details)
| {{ $loop->iteration }} |
{{ $index }} |
{{ $details['description'] }} |
{{ $details['quantity'] }} |
{{ $details['batch'] }} |
{{ $details['mfg_date'] }} |
{{ $details['exp_date'] }} |
{{ $details['unit_price'] }} |
{{ $details['sub_total'] }} |
@endforeach
| Total |
{{ $purchase_order->total }} |
@if(!$purchase_order->received)
Receive Inventory
@endif