From 38b3cbd0906f08c812bc585231b06e990ae0231d Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 15:25:09 +0300 Subject: [PATCH] =?utf8?q?ERP-360=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= =?utf8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B0?= =?utf8?q?=D0=B2=D1=82=D0=BE=D0=BF=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index bfc58c15..f14d68b0 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -1561,6 +1561,7 @@ class CronController extends Controller return ExitCode::OK; } + public function actionAutoplannogrammaCalculate() { $date = new \DateTime(); @@ -1610,11 +1611,10 @@ class CronController extends Controller foreach ($records as $record) { $existingRecords[$record->week . '_' . $record->product_id] = $record; } - foreach ($forecast as $item) { $key = $item['week'] . '_' . $item['product_id']; $model = $existingRecords[$key] ?? null; - + $this->stderr(implode("\n", $item), BaseConsole::FG_GREEN); if (!$model) { $model = new Autoplannogramma(); $model->month = $month; @@ -1624,10 +1624,14 @@ class CronController extends Controller $model->store_id = $item['store_id']; $model->is_archive = false; $model->capacity_type = 1; + $model->quantity = $item['forecast_week_pieces']; } - $model->quantity = $item['forecast_week_pieces']; - $model->quantity_forecast = $item['forecast_week_pieces']; + $needsUpdate = $model->quantity_forecast != $item['forecast_week_pieces']; + + if ($needsUpdate) { + $model->quantity_forecast = $item['forecast_week_pieces']; + } if (!$model->save()) { $errors = []; -- 2.39.5