From abf33605f5cd86fef537eda2001c0023f3718f14 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 6 Jul 2026 12:12:55 +0530 Subject: [PATCH] changed logic of total box count in wire master print --- app/Http/Controllers/PalletPrintController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PalletPrintController.php b/app/Http/Controllers/PalletPrintController.php index 203c3e9..0a7b1ca 100644 --- a/app/Http/Controllers/PalletPrintController.php +++ b/app/Http/Controllers/PalletPrintController.php @@ -201,10 +201,20 @@ class PalletPrintController extends Controller // ->distinct('wire_packing_number') // ->count('wire_packing_number'); + // $totalBoxes = WireMasterPacking::where('plant_id', $plant) + // ->whereIn('customer_po_master_id', $customerPoIds) + // ->distinct('wire_packing_number') + // ->count('wire_packing_number'); + $totalBoxes = WireMasterPacking::where('plant_id', $plant) ->whereIn('customer_po_master_id', $customerPoIds) - ->distinct('wire_packing_number') - ->count('wire_packing_number'); + ->select('wire_packing_number') + ->groupBy('wire_packing_number') + ->havingRaw( + 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', + ['Completed'] + ) + ->count(); // $completedPallets = WireMasterPacking::where('plant_id', $plant) // ->where('customer_po_master_id', $customerId)