From 518736fd11efdbd589e594e0972623071cb5d306 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 17 Nov 2026 16:56:53 +0530 Subject: [PATCH] Changed logic in process order report --- app/Console/Commands/SendProcessOrderReport.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/SendProcessOrderReport.php b/app/Console/Commands/SendProcessOrderReport.php index fcec2755..136650cc 100644 --- a/app/Console/Commands/SendProcessOrderReport.php +++ b/app/Console/Commands/SendProcessOrderReport.php @@ -126,22 +126,21 @@ class SendProcessOrderReport extends Command $processOrder = $order->process_order; - $total = $processOrderTotals[$processOrder]->total_count ?? 0; - $notOk = $statusCounts[$processOrder]->notok_count ?? 0; $ok = $statusCounts[$processOrder]->ok_count ?? 0; - // Calculate percentages using OK + Not OK records - $validTotal = $ok + $notOk; + // Use order quantity as denominator + $totalOrderQuantity = (float) $order->order_quantity; - $notOkPerc = $validTotal > 0 - ? round(($notOk / $validTotal) * 100, 2) + $notOkPerc = $totalOrderQuantity > 0 + ? round(($notOk / $totalOrderQuantity) * 100, 2) : 0; - $okPerc = $validTotal > 0 - ? round(($ok / $validTotal) * 100, 2) + $okPerc = $totalOrderQuantity > 0 + ? round(($ok / $totalOrderQuantity) * 100, 2) : 0; + $tableData[] = [ 'no' => $no++, 'plant' => $plant->name, -- 2.49.1