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 fe04d11b2c4..71da3e17635 100644 --- a/erpnext/accounts/doctype/financial_report_template/financial_report_template.js +++ b/erpnext/accounts/doctype/financial_report_template/financial_report_template.js @@ -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: