fix: Totals row in Query Report (#6590)

* fix: Totals row in Query Report

* fix: Remove quotes around Total
This commit is contained in:
Faris Ansari 2018-12-10 17:21:02 +05:30 committed by Suraj Shetty
parent 19453b8862
commit e71d412fc8
4 changed files with 25 additions and 13 deletions

View file

@ -81,6 +81,9 @@ def generate_report_result(report, filters=None, user=None):
if result:
result = get_filtered_data(report.ref_doctype, columns, result, user)
if cint(report.add_total_row) and result:
result = add_total_row(result, columns)
return {
"result": result,
"columns": columns,
@ -325,10 +328,7 @@ def add_total_row(result, columns, meta = None):
first_col_fieldtype = columns[0].get("fieldtype")
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent", "Date"]:
if first_col_fieldtype == "Link":
total_row[0] = "'" + _("Total") + "'"
else:
total_row[0] = _("Total")
total_row[0] = _("Total")
result.append(total_row)
return result

View file

@ -393,17 +393,24 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
}
render_datatable() {
let data = this.data;
if (this.raw_data.add_total_row) {
data = data.slice();
data.splice(-1, 1);
}
if (this.datatable) {
this.datatable.options.treeView = this.tree_report;
this.datatable.refresh(this.data, this.columns);
this.datatable.refresh(data, this.columns);
} else {
let datatable_options = {
columns: this.columns,
data: this.data,
data: data,
inlineFilters: true,
treeView: this.tree_report,
layout: 'fixed',
cellHeight: 33
cellHeight: 33,
showTotalRow: this.raw_data.add_total_row
};
if (this.report_settings.get_datatable_options) {
@ -815,12 +822,17 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
filters = Object.assign(frappe.urllib.get_dict("prepared_report_name"), filters);
}
const visible_idx = this.datatable.datamanager.getFilteredRowIndices();
if (visible_idx.length + 1 === this.data.length) {
visible_idx.push(visible_idx.length);
}
const args = {
cmd: 'frappe.desk.query_report.export_query',
report_name: this.report_name,
file_format_type: file_format,
filters: filters,
visible_idx: this.datatable.datamanager.getFilteredRowIndices(),
visible_idx: visible_idx,
};
open_url_post(frappe.request.url, args);

View file

@ -19,7 +19,7 @@
"awesomplete": "^1.1.2",
"cookie": "^0.3.1",
"express": "^4.16.2",
"frappe-datatable": "^1.6.1",
"frappe-datatable": "^1.6.2",
"frappe-gantt": "^0.1.0",
"fuse.js": "^3.2.0",
"highlight.js": "^9.12.0",

View file

@ -1219,10 +1219,10 @@ forwarded@~0.1.2:
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=
frappe-datatable@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.6.1.tgz#e57850923b5f307fd02328c522c5abe35a17dd89"
integrity sha512-u2l4I2Pwu4jTLSBF7vW7EDwzcRdfrlKbgaUCyhDUYlOhWl0sRt6rO2ZmIhU7znSYz7TNkKkAt7hkI+x+Mg6ONw==
frappe-datatable@^1.6.2:
version "1.6.2"
resolved "https://registry.yarnpkg.com/frappe-datatable/-/frappe-datatable-1.6.2.tgz#4144e2e15740a8b90dfd133410384214ee882ff9"
integrity sha512-ES0wJnSa9LGCWpCDg7WKYeuHobWKsQJQn0t8rXvuscypg87BmW6EZAJRa1bL6E0HXrjyr7p5yNXH2LyUyiULkQ==
dependencies:
hyperlist "^1.0.0-beta"
lodash "^4.17.5"