From 08a9589c4dcc4b510f4be11bcf2b1148b4f3c3b4 Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 4 Jul 2025 15:41:44 +0300 Subject: [PATCH] =?utf8?q?=D0=9C=D0=B5=D1=82=D0=BA=D0=B0=20=D0=B0=D1=80?= =?utf8?q?=D1=85=D0=B8=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=82=D0=BE=D0=B2?= =?utf8?q?=D0=B0=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronController.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index 22f012bb..f3297a25 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -1875,7 +1875,7 @@ class CronController extends Controller ceil((float)$model->total) !== ceil($total) || json_encode($model->details, JSON_UNESCAPED_UNICODE) !== json_encode($details, JSON_UNESCAPED_UNICODE) ); - + $isArchive = self::isEditable($year, $month); if ($model->isNewRecord || $needsUpdate) { $model->setAttributes([ 'month' => $month, @@ -1883,7 +1883,7 @@ class CronController extends Controller 'week' => $week, 'product_id' => $productId, 'store_id' => $storeId, - 'is_archive' => false, + 'is_archive' => $isArchive, 'capacity_type' => 1, 'details' => json_encode($details, JSON_UNESCAPED_UNICODE), 'calculate' => $quantity, @@ -1948,5 +1948,14 @@ class CronController extends Controller return ExitCode::OK; } + public static function isEditable($year, $month): bool + { + $target = DateTime::createFromFormat('Y-n-j', "$year-$month-1"); + $target->modify('-2 month')->setDate($target->format('Y'), $target->format('n'), 27); + + $today = new DateTime(); + + return $today < $target; + } } -- 2.39.5