Merge pull request 'Changed logic in process order report' (#1454) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s

Reviewed-on: #1454
This commit was merged in pull request #1454.
This commit is contained in:
2026-11-17 11:27:11 +00:00

View File

@@ -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,