From 7d0b445ebcf0065c0e7a18e3b8133b11058ee14d Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Tue, 28 Oct 2025 14:03:46 +0400 Subject: [PATCH] fixed table prefix --- .../doctype/formula_editor/formula_editor.js | 3 +-- formula_editor/public/js/formula_editor_generator.js | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/formula_editor/formula_editor/doctype/formula_editor/formula_editor.js b/formula_editor/formula_editor/doctype/formula_editor/formula_editor.js index 2d86c61..845a000 100644 --- a/formula_editor/formula_editor/doctype/formula_editor/formula_editor.js +++ b/formula_editor/formula_editor/doctype/formula_editor/formula_editor.js @@ -373,8 +373,7 @@ frappe.require([ // Они будут добавлены позже вместе с другими обработчиками // Добавляем функцию преобразования выражений - functions.push(generateTransformExpressionFunction(universal_fields, report_fields)); - + functions.push(generateTransformExpressionFunction(universal_fields, report_fields, table_doctypes)); // Добавляем функцию для работы с конкретными строками табличных частей functions.push(generateTableRowAccessFunction()); diff --git a/formula_editor/public/js/formula_editor_generator.js b/formula_editor/public/js/formula_editor_generator.js index caf21c8..e76576e 100644 --- a/formula_editor/public/js/formula_editor_generator.js +++ b/formula_editor/public/js/formula_editor_generator.js @@ -107,7 +107,11 @@ function delete_client_script_for_doctype(doctype) { }); } -function generateTransformExpressionFunction(universal_fields, report_fields) { +function generateTransformExpressionFunction(universal_fields, report_fields, table_doctypes) { + // Получаем список всех табличных частей динамически + const tableNames = table_doctypes ? Object.keys(table_doctypes) : []; + const tablePrefixesJson = JSON.stringify(tableNames); + return ` function transform_expression(expression, for_child_table = false, table_name = null) { let transformed = expression; @@ -211,7 +215,8 @@ function generateTransformExpressionFunction(universal_fields, report_fields) { }).filter(Boolean).join('\n')} // === Обработка val() и row() === - const tablePrefixes = ["items", "taxes", "packed_items", "payments", "advances", "timesheets", "payment_schedule", "sales_team"]; + // Динамически получаем список всех табличных частей из DocType + const tablePrefixes = ${tablePrefixesJson}; for (const prefix of tablePrefixes) { const sumPattern = new RegExp(\`sum\\\\(\${prefix}_([^)]+)\\\\)\`, 'g');