Merge pull request #10987 from marination/total-row-query-report

fix: Total Row in Reports
This commit is contained in:
mergify[bot] 2020-07-29 05:45:20 +00:00 committed by GitHub
commit 9afc9b86c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -952,8 +952,18 @@ 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);