{{-- spl Table goes here --}}
@php
$itemList = \App\Models\FabricsReceive::select('book_no', 'buyer_id', 'buyer_name', 'order_style', 'batch_id', 'color_name', 'lot', 'dia', 'gsm', 'cons_dz', 'parts', 'rack_no', 'self_bin_no','fabric_type', DB::raw('SUM(receive_qty) as total_receive_qty'))
->where('buyer_id', $fabricsChallanDataInputs[0]['buyer_id'])
->where('order_style', $fabricsChallanDataInputs[0]['order_style'])
->groupBy('book_no', 'buyer_id', 'buyer_name', 'order_style', 'batch_id', 'color_name', 'lot', 'dia', 'gsm', 'cons_dz', 'parts', 'rack_no', 'self_bin_no','fabric_type')
->get();
$dlv_cutting = \App\Models\FabricsIssue::select('book_no', 'buyer_id', 'buyer_name', 'order_style', 'batch_id', 'color_name', 'lot', 'dia', 'gsm', 'cons_dz', 'parts', 'rack_no', 'self_bin_no','fabric_type', DB::raw('SUM(dlv_cutting) as total_dlv_cutting'))
->where('buyer_id', $fabricsChallanDataInputs[0]['buyer_id'])
->where('order_style', $fabricsChallanDataInputs[0]['order_style'])
->groupBy('book_no', 'buyer_id', 'buyer_name', 'order_style', 'batch_id', 'color_name', 'lot', 'dia', 'gsm', 'cons_dz', 'parts', 'rack_no', 'self_bin_no','fabric_type')
->get();
// Calculate balance quantity for each item
$balance_qty = [];
foreach ($itemList as $item) {
$found = false;
foreach ($dlv_cutting as $issue) {
if ($item->parts == $issue->parts) {
$total_dlv_cutting[$item->parts] = $issue->total_dlv_cutting;
$found = true;
break;
}
}
// If no issue found for a particular part, set balance_qty as total received qty
if (!$found) {
$total_dlv_cutting[$item->parts] = 0;
}
}
foreach ($itemList as $item) {
$found = false;
foreach ($dlv_cutting as $issue) {
if ($item->parts == $issue->parts) {
$balance_qty[$item->parts] = $item->total_receive_qty - $issue->total_dlv_cutting;
$found = true;
break;
}
}
// If no issue found for a particular part, set balance_qty as total received qty
if (!$found) {
$balance_qty[$item->parts] = 0;
}
}
// dd($balance_qty)
// dd($dlv_cutting, $itemList)
// die
@endphp
Sl# |
Book No |
Batch Id |
Type Name |
Total Receive Qty
|
Total Issue Qty
|
Balance Qty |
@php $sl=0 @endphp
@foreach ($itemList as $item)
{{ ++$sl }} |
{{ $item->book_no }} |
{{ $item->batch_id }} |
{{ $item->parts }} |
{{ $item->total_receive_qty }}
|
{{ $total_dlv_cutting[$item->parts] ?? 0 }}
|
{{ $balance_qty[$item->parts] ?? 0 }}
|
@endforeach