Changed logic in process order report #1454
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user