Merge pull request 'solved issue in production plan importer' (#1185) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s

Reviewed-on: #1185
This commit was merged in pull request #1185.
This commit is contained in:
2026-10-06 06:57:58 +00:00

View File

@@ -16,6 +16,7 @@ use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import; use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Str; use Str;
use Illuminate\Support\Facades\Log;
class ProductionPlanImporter extends Importer class ProductionPlanImporter extends Importer
{ {
@@ -152,36 +153,6 @@ class ProductionPlanImporter extends Importer
if (! empty($warnMsg)) { if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg)); throw new RowImportFailedException(implode(', ', $warnMsg));
} else {
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
->where('line_id', $line)
->where('item_id', $itemAgaPlant->id)
->latest()
->first();
if ($productionPlan) {
$recordDate = now();
$month = $recordDate->month;
$year = $recordDate->year;
$previousRecord = ProductionPlan::where('plant_id', $plant->id)
->whereMonth('created_at', $month)
->whereYear('created_at', $year)
->first();
$workingDays = $previousRecord?->working_days ?? null;
$productionPlan->update([
'plan_quantity' => $this->data['plan_quantity'],
'working_days' => $workingDays,
'operator_id' => $operatorName,
]);
$productionPlan->save();
return null;
}
} }
$recordDate = now(); $recordDate = now();
@@ -198,8 +169,8 @@ class ProductionPlanImporter extends Importer
$productionPlan1 = ProductionPlan::where('plant_id', $plant->id) $productionPlan1 = ProductionPlan::where('plant_id', $plant->id)
->where('line_id', $line) ->where('line_id', $line)
->where('item_id', $itemAgaPlant->id) ->where('item_id', $itemAgaPlant->id)
->whereYear('created_at', now()->year) ->whereYear('created_at', $recordDate->year)
->whereMonth('created_at', now()->month) ->whereMonth('created_at', $recordDate->month)
->first(); ->first();
if ($productionPlan1) { if ($productionPlan1) {