@php $grandTotals = [ 'order_qty' => 0, 'shipped_qty' => 0, 'shipped_value' => 0, 'short_qty' => 0, 'short_value' => 0, 'excess_qty' => 0, 'excess_value' => 0, ]; @endphp
@php // Group shipment data by color and size $groupedData = []; foreach ($shipmentData as $shipment) { $key = $shipment->color . '|' . $shipment->size; if (!isset($groupedData[$key])) { $groupedData[$key] = [ 'color' => $shipment->color, 'size' => $shipment->size, 'total_shipped_qty' => 0, 'total_shipped_value' => 0, 'total_excess_short_shipment_qty' => 0, 'total_excess_short_shipment_value' => 0 ]; } $groupedData[$key]['total_shipped_qty'] += $shipment->shipped_qty; $groupedData[$key]['total_shipped_value'] += $shipment->shipped_value; $groupedData[$key]['total_excess_short_shipment_qty'] += $shipment->excess_short_shipment_qty; $groupedData[$key]['total_excess_short_shipment_value'] += $shipment->excess_short_shipment_value; } @endphp @forelse($groupedData as $key => $shipment) @php $job = App\Models\Job::where('job_no', $jobNo) ->where('color', $shipment['color']) ->where('size', $shipment['size']) ->first(); $order_qty = $job->color_quantity ?? 0; $unit_price = $job->unit_price ?? 0; $short_qty = max(0, $order_qty - $shipment['total_shipped_qty']); $short_value = $short_qty * $unit_price; // Update grand totals $grandTotals['order_qty'] += $order_qty; $grandTotals['shipped_qty'] += $shipment['total_shipped_qty']; $grandTotals['shipped_value'] += $shipment['total_shipped_value']; $grandTotals['short_qty'] += $short_qty; $grandTotals['short_value'] += $short_value; $grandTotals['excess_qty'] += $shipment['total_excess_short_shipment_qty']; $grandTotals['excess_value'] += $shipment['total_excess_short_shipment_value']; @endphp @empty @endforelse @if(!empty($groupedData)) @endif
Color Size Order Qty Shipped Qty Shipped Value Short Qty Short Value Excess Qty Excess Value Actions
{{ $shipment['color'] }} {{ $shipment['size'] }} {{ number_format($order_qty) }} {{ number_format($shipment['total_shipped_qty']) }} ${{ number_format($shipment['total_shipped_value'], 2) }} {{ number_format($short_qty) }} ${{ number_format($short_value, 2) }} {{ number_format($shipment['total_excess_short_shipment_qty']) }} ${{ number_format($shipment['total_excess_short_shipment_value'], 2) }} History
No Shipment Data Found

No shipment records exist for this job

Grand Totals: {{ number_format($grandTotals['order_qty']) }} {{ number_format($grandTotals['shipped_qty']) }} ${{ number_format($grandTotals['shipped_value'], 2) }} {{ number_format($grandTotals['short_qty']) }} ${{ number_format($grandTotals['short_value'], 2) }} {{ number_format($grandTotals['excess_qty']) }} ${{ number_format($grandTotals['excess_value'], 2) }}