solved issue in production plan importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Pint / pint (pull_request) Successful in 3m55s
Laravel Larastan / larastan (pull_request) Failing after 4m9s

This commit is contained in:
dhanabalan
2026-10-06 12:27:46 +05:30
parent 755a0093e2
commit 9b203dfe8c

View File

@@ -16,6 +16,7 @@ use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
use Illuminate\Support\Facades\Log;
class ProductionPlanImporter extends Importer
{
@@ -152,36 +153,6 @@ class ProductionPlanImporter extends Importer
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)
->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();
@@ -198,8 +169,8 @@ class ProductionPlanImporter extends Importer
$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)
->whereYear('created_at', $recordDate->year)
->whereMonth('created_at', $recordDate->month)
->first();
if ($productionPlan1) {