From f34a8e7d90d9aa75153d62fdbca01b5cb9cd0571 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 17 Jun 2025 13:03:41 +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 --- .../js/autoplannogramma/autoplannogramma.js | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/erp24/web/js/autoplannogramma/autoplannogramma.js b/erp24/web/js/autoplannogramma/autoplannogramma.js index cab6cf97..37df4449 100644 --- a/erp24/web/js/autoplannogramma/autoplannogramma.js +++ b/erp24/web/js/autoplannogramma/autoplannogramma.js @@ -382,7 +382,7 @@ function getMonthNumberByWeek(week, year) { return startMonth; } -function generateTitleString(titleObj) { +const generateTitleString = (titleObj) => { if (!titleObj || typeof titleObj !== 'object') return ''; const typeTitles = { @@ -391,16 +391,18 @@ function generateTitleString(titleObj) { marketplace: 'Маркетплейс' }; - let parts = []; - - for (const [typeKey, typeValue] of Object.entries(titleObj)) { - if (!typeValue || typeof typeValue !== 'object') continue; - - let lines = Object.entries(typeValue) - .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`); - - parts.push(`${typeTitles[typeKey] || typeKey}:\n${lines.join('\n')}`); - } + const parts = Object.entries(titleObj) + .map(([typeKey, typeValue]) => { + const title = typeTitles[typeKey] || typeKey; + if (typeof typeValue === 'number') { + return `${title}: ${typeValue.toFixed(2)}`; + } + if (!typeValue || typeof typeValue !== 'object' || !typeValue[0]) return ''; + const lines = Object.entries(typeValue[1]?.details || {}) + .map(([key, val]) => `- ${key.replace(/_/g, ' ')}: ${parseFloat(val).toFixed(2)}`); + return `${title}: ${parseFloat(typeValue[0]).toFixed(2)}\n${lines.join('\n')}`; + }) + .filter(Boolean); return parts.join('\n\n'); -} +}; \ No newline at end of file -- 2.39.5