From 1ffa2d439be8fdc7dd99d360a56089ddc1de4949 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 16 Nov 2026 11:35:40 +0530 Subject: [PATCH] Added logic for particualr plan for line in production report --- app/Console/Commands/SendProductionReport.php | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/SendProductionReport.php b/app/Console/Commands/SendProductionReport.php index f53a7fa4..d8c5ff93 100644 --- a/app/Console/Commands/SendProductionReport.php +++ b/app/Console/Commands/SendProductionReport.php @@ -174,6 +174,7 @@ class SendProductionReport extends Command foreach ($lines as $line) { + $hasProduction = false; $dayproductionQuantity = 0; $nightproductionQuantity = 0; $productionQuantity = 0; @@ -265,16 +266,16 @@ class SendProductionReport extends Command // $capacityQuan = $totalHourlyQuantity * 22.5; - $leaveDates = ProductionCalendar::where('plant_id', $plant->id) - ->whereMonth('created_at', $month) - ->whereYear('created_at', $year) - ->value('leave_dates'); + // $leaveDates = ProductionCalendar::where('plant_id', $plant->id) + // ->whereMonth('created_at', $month) + // ->whereYear('created_at', $year) + // ->value('leave_dates'); - $leaveDates = $leaveDates ? array_map('trim', explode(',', $leaveDates)) : []; + // $leaveDates = $leaveDates ? array_map('trim', explode(',', $leaveDates)) : []; - if (in_array($startDate->format('Y-m-d'), $leaveDates)) { - $totalTargetQuantity = 0; - } + // if (in_array($startDate->format('Y-m-d'), $leaveDates)) { + // $totalTargetQuantity = 0; + // } if (strtolower($line->type) == 'fg line') { @@ -333,6 +334,26 @@ class SendProductionReport extends Command ->count(); } + if ($productionQuantity > 0) { + $hasProduction = true; + } + + $leaveDates = ProductionCalendar::where('plant_id', $plant->id) + ->whereMonth('created_at', $month) + ->whereYear('created_at', $year) + ->value('leave_dates'); + + $leaveDates = $leaveDates + ? array_map('trim', explode(',', $leaveDates)) + : []; + + if ( + in_array($startDate->format('Y-m-d'), $leaveDates) + && !$hasProduction + ) { + $totalTargetQuantity = 0; + } + if ($totalTargetQuantity > 0) { $efficiency = ($productionQuantity / $totalTargetQuantity) * 100; } else { -- 2.49.1