diff --git a/app/Filament/Imports/ProductionPlanImporter.php b/app/Filament/Imports/ProductionPlanImporter.php index c57fae40..ce391fb3 100644 --- a/app/Filament/Imports/ProductionPlanImporter.php +++ b/app/Filament/Imports/ProductionPlanImporter.php @@ -132,24 +132,28 @@ class ProductionPlanImporter extends Importer if(!$itemAgaPlant){ $warnMsg[] = 'Item not found against plant code'; } + else { + $line = $itemAgaPlant->line_id; - $line = $itemAgaPlant->line_id; - - if(!$line){ - $warnMsg[] = 'Line not mapped for that item code'; + if (!$line) { + $warnMsg[] = 'Line not mapped for that item code'; + } } $user = Filament::auth()->user(); $operatorName = $user->name; - if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) { - $warnMsg[] = 'Invalid plan quantity found'; + if (!empty($this->data['plan_quantity'])) { + if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) { + $warnMsg[] = 'Invalid plan quantity found'; + } } if (! empty($warnMsg)) { throw new RowImportFailedException(implode(', ', $warnMsg)); } else { + $productionPlan = ProductionPlan::where('plant_id', $plant->id) ->where('line_id', $line) ->where('item_id', $itemAgaPlant->id)