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

Reviewed-on: #1102
This commit was merged in pull request #1102.
This commit is contained in:
2026-09-26 09:43:37 +00:00

View File

@@ -38,13 +38,13 @@ class ProductionPlanImporter extends Importer
->label('Plant Code') ->label('Plant Code')
->relationship(resolveUsing: 'code') ->relationship(resolveUsing: 'code')
->rules(['required']), ->rules(['required']),
ImportColumn::make('line') // ImportColumn::make('line')
->requiredMapping() // ->requiredMapping()
->exampleHeader('Line Name') // ->exampleHeader('Line Name')
->example(['4 inch pump line', '4 inch pump line']) // ->example(['4 inch pump line', '4 inch pump line'])
->label('Line Name') // ->label('Line Name')
->relationship(resolveUsing: 'name') // ->relationship(resolveUsing: 'name')
->rules(['required']), // ->rules(['required']),
ImportColumn::make('item') ImportColumn::make('item')
->requiredMapping() ->requiredMapping()
->exampleHeader('Item Code') ->exampleHeader('Item Code')
@@ -113,12 +113,6 @@ class ProductionPlanImporter extends Importer
if (! $plant) { if (! $plant) {
$warnMsg[] = 'Plant not found'; $warnMsg[] = 'Plant not found';
} else {
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
}
if (! $line) {
$warnMsg[] = 'Line not found';
} }
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) { if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
@@ -139,6 +133,12 @@ class ProductionPlanImporter extends Importer
$warnMsg[] = 'Item not found against plant code'; $warnMsg[] = 'Item not found against plant code';
} }
$line = $itemAgaPlant->line_id;
if(!$line){
$warnMsg[] = 'Line not mapped for that item code';
}
$user = Filament::auth()->user(); $user = Filament::auth()->user();
$operatorName = $user->name; $operatorName = $user->name;
@@ -151,7 +151,7 @@ class ProductionPlanImporter extends Importer
throw new RowImportFailedException(implode(', ', $warnMsg)); throw new RowImportFailedException(implode(', ', $warnMsg));
} else { } else {
$productionPlan = ProductionPlan::where('plant_id', $plant->id) $productionPlan = ProductionPlan::where('plant_id', $plant->id)
->where('line_id', $line->id) ->where('line_id', $line)
->where('item_id', $itemAgaPlant->id) ->where('item_id', $itemAgaPlant->id)
->latest() ->latest()
->first(); ->first();
@@ -191,17 +191,44 @@ class ProductionPlanImporter extends Importer
$workingDays = $previousRecord?->working_days ?? null; $workingDays = $previousRecord?->working_days ?? null;
ProductionPlan::updateOrCreate([ $productionPlan1 = ProductionPlan::where('plant_id', $plant->id)
'plant_id' => $plant->id, ->where('line_id', $line)
'line_id' => $line->id, ->where('item_id', $itemAgaPlant->id)
'item_id' => $itemAgaPlant->id, ->whereYear('created_at', now()->year)
// 'shift_id' => $shift->id, ->whereMonth('created_at', now()->month)
'plan_quantity' => $this->data['plan_quantity'], ->first();
'working_days' => $workingDays,
'created_at' =>now(), if ($productionPlan1) {
'updated_at' => now(), $productionPlan1->update([
'operator_id' => $operatorName, 'plan_quantity' => $this->data['plan_quantity'],
]); 'working_days' => $workingDays,
'operator_id' => $operatorName,
'updated_at' => now(),
]);
} else {
ProductionPlan::create([
'plant_id' => $plant->id,
'line_id' => $line,
'item_id' => $itemAgaPlant->id,
'plan_quantity' => $this->data['plan_quantity'],
'working_days' => $workingDays,
'operator_id' => $operatorName,
'created_at' => now(),
'updated_at' => now(),
]);
}
// ProductionPlan::updateOrCreate([
// 'plant_id' => $plant->id,
// 'line_id' => $line,
// 'item_id' => $itemAgaPlant->id,
// // 'shift_id' => $shift->id,
// 'plan_quantity' => $this->data['plan_quantity'],
// 'working_days' => $workingDays,
// 'created_at' =>now(),
// 'updated_at' => now(),
// 'operator_id' => $operatorName,
// ]);
return null; return null;
} }