Changed logic in process order report #1454
@@ -126,22 +126,21 @@ class SendProcessOrderReport extends Command
|
|||||||
|
|
||||||
$processOrder = $order->process_order;
|
$processOrder = $order->process_order;
|
||||||
|
|
||||||
$total = $processOrderTotals[$processOrder]->total_count ?? 0;
|
|
||||||
|
|
||||||
$notOk = $statusCounts[$processOrder]->notok_count ?? 0;
|
$notOk = $statusCounts[$processOrder]->notok_count ?? 0;
|
||||||
$ok = $statusCounts[$processOrder]->ok_count ?? 0;
|
$ok = $statusCounts[$processOrder]->ok_count ?? 0;
|
||||||
|
|
||||||
// Calculate percentages using OK + Not OK records
|
// Use order quantity as denominator
|
||||||
$validTotal = $ok + $notOk;
|
$totalOrderQuantity = (float) $order->order_quantity;
|
||||||
|
|
||||||
$notOkPerc = $validTotal > 0
|
$notOkPerc = $totalOrderQuantity > 0
|
||||||
? round(($notOk / $validTotal) * 100, 2)
|
? round(($notOk / $totalOrderQuantity) * 100, 2)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
$okPerc = $validTotal > 0
|
$okPerc = $totalOrderQuantity > 0
|
||||||
? round(($ok / $validTotal) * 100, 2)
|
? round(($ok / $totalOrderQuantity) * 100, 2)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
|
|
||||||
$tableData[] = [
|
$tableData[] = [
|
||||||
'no' => $no++,
|
'no' => $no++,
|
||||||
'plant' => $plant->name,
|
'plant' => $plant->name,
|
||||||
|
|||||||
Reference in New Issue
Block a user