From fccf903f7237cc6cbc1d0720cf9be2b1d14cec4f Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 18 Jun 2025 15:49:38 +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 | 2 +- .../AutoPlannogrammaController.php | 53 +++---------------- .../js/autoplannogramma/autoplannogramma.js | 21 ++++---- 3 files changed, 18 insertions(+), 58 deletions(-) diff --git a/erp24/commands/CronController.php b/erp24/commands/CronController.php index bdc52b33..af2924e6 100644 --- a/erp24/commands/CronController.php +++ b/erp24/commands/CronController.php @@ -1660,7 +1660,7 @@ class CronController extends Controller 'capacity_type' => 1, 'details' => json_encode($details, JSON_UNESCAPED_UNICODE), 'calculate' => $quantity, - 'modify' => $quantity, + 'modify' => round($total, 2), 'total' => round($total, 2) ]); diff --git a/erp24/controllers/AutoPlannogrammaController.php b/erp24/controllers/AutoPlannogrammaController.php index 2970b812..155af6ff 100644 --- a/erp24/controllers/AutoPlannogrammaController.php +++ b/erp24/controllers/AutoPlannogrammaController.php @@ -124,7 +124,8 @@ class AutoPlannogrammaController extends BaseController 'p1n.id AS product_id', 'p1n.name AS product_name', 'a.store_id', - 'a.quantity', + 'a.modify', + 'a.details', 'a.month' ]) ->asArray() @@ -141,56 +142,18 @@ class AutoPlannogrammaController extends BaseController 'product_id' => $productId, 'name' => $productName, 'values' => [], + 'title' => [], ]; } $result[$productId]['values'][] = [ 'id' => $model['plan_id'], - 'quantity' => (int)$model['quantity'], + 'quantity' => (int)$model['modify'], 'store_id' => (int)$model['store_id'], + 'title' => !empty($model['details']) ? json_decode($model['details'], true) : null, ]; } - $forecast = (new AutoPlannogrammaService())->getWeeklyBouquetProductsForecast($filters['month'], $filters['year'], null, $filters['week']); - - foreach ($result as &$productData) { - foreach ($productData['values'] as &$value) { - $storeId = $value['store_id'] ?? null; - $quantity = $value['quantity'] ?? 0; - $value['title'] = []; - - if (!isset($forecast[$storeId])) { - continue; - } - - - foreach (['offline', 'marketplace', 'online'] as $channel) { - $channelData = $forecast[$storeId][$channel] ?? []; - $titleData = []; - - if (isset($channelData['share']) && is_numeric($channelData['share'])) { - $titleData[0] = round($quantity * $channelData['share'], 2); - } - - if (isset($productData['product_id']) && isset($forecast[$storeId][$productData['product_id']][$channel])) { - $details = $forecast[$storeId][$productData['product_id']][$channel]; - $titleData[0] = $titleData[0] ?? round($quantity * array_sum($details), 2); - $titleData[1] = ['details' => array_map(fn($val) => round($val, 2), $details)]; - } - - $value['title'][$channel] = $titleData ?: []; - } - - $value['title']['write_offs'] = null; - if (isset($value['id']) && is_numeric($value['id'])) { - $autoplannogramma = Autoplannogramma::findOne(['id' => $value['id']]); - if ($autoplannogramma) { - $value['title']['write_offs'] = $autoplannogramma->writeoffs_forecast; - } - } - } - } - return array_values($result); } @@ -208,7 +171,7 @@ class AutoPlannogrammaController extends BaseController if (isset($item['id'])) { $model = Autoplannogramma::findOne($item['id']); if ($model !== null) { - $model->quantity = $item['value']; + $model->modify = $item['value']; $model->auto_forecast = false; } } else { @@ -218,8 +181,8 @@ class AutoPlannogrammaController extends BaseController $model->year = $item['year'] ?? null; $model->month = $item['month'] ?? null; $model->week = $item['week'] ?? null; - $model->quantity = $item['value']; - $model->quantity_forecast = 0; + $model->modify = $item['value']; + $model->calculate = 0; $model->auto_forecast = false; } diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index 7294845e..fa0cfa4d 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -395,23 +395,20 @@ const generateTitleString = (titleObj) => { offline: 'Оффлайн', online: 'Онлайн', marketplace: 'Маркетплейс', - write_offs: 'Списания' + writeOffs: 'Списания' }; const parts = Object.entries(titleObj) .map(([typeKey, typeValue]) => { const title = typeTitles[typeKey] || typeKey; - - if (Array.isArray(typeValue) && typeValue.length >= 1) { - const numericValue = parseFloat(typeValue[0]); - const details = typeValue[1]?.details || {}; - const lines = Object.entries(details) + if ( + typeof typeValue === 'object' && + typeValue !== null && + typeof typeValue.groups === 'object' + ) { + const lines = Object.entries(typeValue.groups) .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`); - return `${title}: ${numericValue.toFixed(2)}${lines.length ? '\n' + lines.join('\n') : ''}`; - } - - if (typeof typeValue === 'number') { - return `${title}: ${typeValue.toFixed(2)}`; + return `${title}:\n${lines.join('\n')}`; } return ''; @@ -419,4 +416,4 @@ const generateTitleString = (titleObj) => { .filter(Boolean); return parts.join('\n\n'); -}; \ No newline at end of file +}; -- 2.39.5