From ccde503c5a0b81887eba33e0a17069d9ba08099b Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 13 Jul 2020 19:27:46 +0530 Subject: [PATCH 1/2] fix: Total Row in Reports --- .../js/frappe/views/reports/query_report.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index f82956adac..609e1feb46 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -861,8 +861,19 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { if (column.isHeader && !data && this.data) { // totalRow doesn't have a data object // proxy it using the first data object - // this is needed only for currency formatting - data = this.data[0]; + // applied to Float, Currency fields, needed only for currency formatting. + // make first data column have value 'Total' + let index = 1; + if (this.datatable && this.datatable.options.checkboxColumn) index = 2; + + if (column.colIndex === index && !value) { + value = "Total"; + column.fieldtype = "Data"; // avoid type issues for value if Date column + } + else if (in_list(["Currency", "Float"], column.fieldtype)) { + // proxy for currency and float + data = this.data[0]; + } } return frappe.format(value, column, {for_print: false, always_show_decimals: true}, data); From ac2493b391a4213f3412390b88b157a2fcf2bbd7 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 29 Jul 2020 11:00:59 +0530 Subject: [PATCH 2/2] style: use 1tbs braces for if-else --- frappe/public/js/frappe/views/reports/query_report.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frappe/public/js/frappe/views/reports/query_report.js b/frappe/public/js/frappe/views/reports/query_report.js index 609e1feb46..0701a34b76 100644 --- a/frappe/public/js/frappe/views/reports/query_report.js +++ b/frappe/public/js/frappe/views/reports/query_report.js @@ -869,8 +869,7 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList { if (column.colIndex === index && !value) { value = "Total"; column.fieldtype = "Data"; // avoid type issues for value if Date column - } - else if (in_list(["Currency", "Float"], column.fieldtype)) { + } else if (in_list(["Currency", "Float"], column.fieldtype)) { // proxy for currency and float data = this.data[0]; }