Changed logic in process order report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 19s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 17s
Laravel Pint / pint (pull_request) Successful in 4m24s
Laravel Larastan / larastan (pull_request) Failing after 8m8s

This commit is contained in:
dhanabalan
2026-11-17 16:56:53 +05:30
parent 48849bc395
commit 518736fd11

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,