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
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:
@@ -38,13 +38,13 @@ class ProductionPlanImporter extends Importer
|
||||
->label('Plant Code')
|
||||
->relationship(resolveUsing: 'code')
|
||||
->rules(['required']),
|
||||
ImportColumn::make('line')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Line Name')
|
||||
->example(['4 inch pump line', '4 inch pump line'])
|
||||
->label('Line Name')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
// ImportColumn::make('line')
|
||||
// ->requiredMapping()
|
||||
// ->exampleHeader('Line Name')
|
||||
// ->example(['4 inch pump line', '4 inch pump line'])
|
||||
// ->label('Line Name')
|
||||
// ->relationship(resolveUsing: 'name')
|
||||
// ->rules(['required']),
|
||||
ImportColumn::make('item')
|
||||
->requiredMapping()
|
||||
->exampleHeader('Item Code')
|
||||
@@ -113,12 +113,6 @@ class ProductionPlanImporter extends Importer
|
||||
|
||||
if (! $plant) {
|
||||
$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)) {
|
||||
@@ -139,6 +133,12 @@ class ProductionPlanImporter extends Importer
|
||||
$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();
|
||||
|
||||
$operatorName = $user->name;
|
||||
@@ -151,7 +151,7 @@ class ProductionPlanImporter extends Importer
|
||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||
} else {
|
||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line->id)
|
||||
->where('line_id', $line)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->latest()
|
||||
->first();
|
||||
@@ -191,17 +191,44 @@ class ProductionPlanImporter extends Importer
|
||||
|
||||
$workingDays = $previousRecord?->working_days ?? null;
|
||||
|
||||
ProductionPlan::updateOrCreate([
|
||||
'plant_id' => $plant->id,
|
||||
'line_id' => $line->id,
|
||||
'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,
|
||||
]);
|
||||
$productionPlan1 = ProductionPlan::where('plant_id', $plant->id)
|
||||
->where('line_id', $line)
|
||||
->where('item_id', $itemAgaPlant->id)
|
||||
->whereYear('created_at', now()->year)
|
||||
->whereMonth('created_at', now()->month)
|
||||
->first();
|
||||
|
||||
if ($productionPlan1) {
|
||||
$productionPlan1->update([
|
||||
'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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user