Added automatic update working days logic in production plan import
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Laravel Pint / pint (pull_request) Successful in 2m44s
Laravel Larastan / larastan (pull_request) Failing after 3m45s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Laravel Pint / pint (pull_request) Successful in 2m44s
Laravel Larastan / larastan (pull_request) Failing after 3m45s
This commit is contained in:
@@ -158,8 +158,20 @@ class ProductionPlanImporter extends Importer
|
|||||||
|
|
||||||
if ($productionPlan) {
|
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([
|
$productionPlan->update([
|
||||||
'plan_quantity' => $this->data['plan_quantity'],
|
'plan_quantity' => $this->data['plan_quantity'],
|
||||||
|
'working_days' => $workingDays,
|
||||||
'operator_id' => $operatorName,
|
'operator_id' => $operatorName,
|
||||||
]);
|
]);
|
||||||
$productionPlan->save();
|
$productionPlan->save();
|
||||||
@@ -168,12 +180,24 @@ class ProductionPlanImporter extends Importer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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::updateOrCreate([
|
ProductionPlan::updateOrCreate([
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'line_id' => $line->id,
|
'line_id' => $line->id,
|
||||||
'item_id' => $itemAgaPlant->id,
|
'item_id' => $itemAgaPlant->id,
|
||||||
// 'shift_id' => $shift->id,
|
// 'shift_id' => $shift->id,
|
||||||
'plan_quantity' => $this->data['plan_quantity'],
|
'plan_quantity' => $this->data['plan_quantity'],
|
||||||
|
'working_days' => $workingDays,
|
||||||
'created_at' =>now(),
|
'created_at' =>now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
'operator_id' => $operatorName,
|
'operator_id' => $operatorName,
|
||||||
|
|||||||
Reference in New Issue
Block a user