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
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:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user