]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 10:03:41 +0000 (13:03 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 17 Jun 2025 10:03:41 +0000 (13:03 +0300)
erp24/web/js/autoplannogramma/autoplannogramma.js

index cab6cf973ca3d01839b01d0f37beebdfabc19fd3..37df44499539915791d2a785a726699a41651176 100644 (file)
@@ -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