From 3ef69a673e7e2b27e5e7fb98cfe72c6f04d480bc Mon Sep 17 00:00:00 2001 From: Smit Vora Date: Thu, 11 Apr 2024 16:07:40 +0530 Subject: [PATCH] chore: fix better way to override totals in beta report --- .../gst_sales_register_beta.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/india_compliance/gst_india/report/gst_sales_register_beta/gst_sales_register_beta.js b/india_compliance/gst_india/report/gst_sales_register_beta/gst_sales_register_beta.js index 97fac25279..7ea7c6c1b1 100644 --- a/india_compliance/gst_india/report/gst_sales_register_beta/gst_sales_register_beta.js +++ b/india_compliance/gst_india/report/gst_sales_register_beta/gst_sales_register_beta.js @@ -97,6 +97,15 @@ frappe.query_reports["GST Sales Register Beta"] = { return value; }, + + // Override datatable hook for column total calculation + get_datatable_options(datatable_options) { + datatable_options.hooks = { + columnTotal: custom_report_column_total, + }; + + return datatable_options; + }, }; function set_sub_category_options(report) { @@ -113,12 +122,10 @@ function set_sub_category_options(report) { } } -frappe_report_column_total = frappe.utils.report_column_total; - -// Override datatable hook for column total calculation -frappe.utils.report_column_total = function (...args) { +custom_report_column_total = function (...args) { const summary_by = frappe.query_report.get_filter_value("summary_by"); - if (summary_by !== "Overview") return frappe_report_column_total.apply(this, args); + if (summary_by !== "Overview") + return frappe.utils.report_column_total.apply(this, args); const column_field = args[1].column.fieldname; if (column_field === "description") return;