diff --git a/erpnext/accounts/doctype/financial_report_template/financial_report_engine.py b/erpnext/accounts/doctype/financial_report_template/financial_report_engine.py index c79cbfe1448..1137b79a964 100644 --- a/erpnext/accounts/doctype/financial_report_template/financial_report_engine.py +++ b/erpnext/accounts/doctype/financial_report_template/financial_report_engine.py @@ -31,6 +31,7 @@ from erpnext.accounts.doctype.financial_report_template.financial_report_validat AccountFilterValidator, CalculationFormulaValidator, DependencyValidator, + get_valid_api_method, ) from erpnext.accounts.report.financial_statements import ( get_columns, @@ -1164,10 +1165,12 @@ class RowProcessor: def _process_api_row(self, row) -> RowData: api_path = row.calculation_formula - # TODO + + method = get_valid_api_method(api_path) try: - values = frappe.call(api_path, filters=self.context.filters, periods=self.period_list, row=row) + # nosemgrep: frappe-semgrep-rules.rules.security.frappe-codeinjection-eval + values = frappe.call(method, filters=self.context.filters, periods=self.period_list, row=row) if row.reverse_sign: values = [-1 * v for v in values] diff --git a/erpnext/accounts/doctype/financial_report_template/financial_report_template.js b/erpnext/accounts/doctype/financial_report_template/financial_report_template.js index 304da47577b..71da3e17635 100644 --- a/erpnext/accounts/doctype/financial_report_template/financial_report_template.js +++ b/erpnext/accounts/doctype/financial_report_template/financial_report_template.js @@ -163,7 +163,7 @@ function show_accounts_tree(template_rows, has_selection) { fieldname: "company", fieldtype: "Link", options: "Company", - label: "Company", + label: __("Company"), reqd: 1, default: frappe.defaults.get_user_default("Company"), onchange: () => { @@ -176,7 +176,7 @@ function show_accounts_tree(template_rows, has_selection) { fieldname: "view_type", fieldtype: "Select", options: ["Missing Accounts", "Filtered Accounts"], - label: "View", + label: __("View"), default: has_selection ? "Filtered Accounts" : "Missing Accounts", reqd: 1, onchange: () => { @@ -192,10 +192,10 @@ function show_accounts_tree(template_rows, has_selection) { { fieldname: "tip", fieldtype: "HTML", - label: "Tip", + label: __("Tip"), options: ` `, depends_on: has_selection ? "eval: false" : "eval: true", @@ -203,7 +203,7 @@ function show_accounts_tree(template_rows, has_selection) { { fieldname: "tree_area", fieldtype: "HTML", - label: "Chart of Accounts", + label: __("Chart of Accounts"), read_only: 1, depends_on: "eval: doc.company", }, @@ -288,14 +288,14 @@ function update_formula_label(frm, data_source) { if (!field) return; const labels = { - "Account Data": "Account Filter", - "Custom API": "API Method Path", + "Account Data": __("Account Filter"), + "Custom API": __("API Method Path"), }; grid.update_docfield_property( "calculation_formula", "label", - labels[data_source] || "Calculation Formula" + labels[data_source] || __("Calculation Formula") ); } @@ -370,7 +370,7 @@ function update_formula_description(frm, data_source) { description_html = `
Custom API Setup
-

Path to your custom method that returns financial data.

+

Path to your custom whitelisted method that returns financial data. It must permit GET requests.

Format: