diff --git a/public/js/wn/form/formatters.js b/public/js/wn/form/formatters.js
index d4fcab00c7..398065afd2 100644
--- a/public/js/wn/form/formatters.js
+++ b/public/js/wn/form/formatters.js
@@ -17,7 +17,7 @@ wn.form.formatters = {
format_number(value, null, decimals)) + "";
},
Int: function(value) {
- return value==null ? "": cint(value);
+ return value==null ? "": "
" + cint(value) + "
";
},
Percent: function(value) {
return "" + flt(value, 2) + "%" + "
";
diff --git a/public/js/wn/views/query_report.js b/public/js/wn/views/query_report.js
index 97942fe0c9..37af0e4d87 100644
--- a/public/js/wn/views/query_report.js
+++ b/public/js/wn/views/query_report.js
@@ -136,8 +136,9 @@ wn.views.QueryReport = Class.extend({
refresh: function() {
// Run
var me =this;
- this.waiting = wn.messages.waiting(this.wrapper.find(".waiting-area").toggle(true),
+ this.waiting = wn.messages.waiting(this.wrapper.find(".waiting-area").empty().toggle(true),
"Loading Report...");
+ this.wrapper.find(".results").toggle(false);
var filters = {};
$.each(this.filters || [], function(i, f) {
filters[f.df.fieldname] = f.get_parsed_value();
diff --git a/webnotes/widgets/query_report.py b/webnotes/widgets/query_report.py
index e7e87501d0..deb355ec4c 100644
--- a/webnotes/widgets/query_report.py
+++ b/webnotes/widgets/query_report.py
@@ -95,13 +95,21 @@ def run(report_name, filters=None):
def add_total_row(result, columns):
total_row = [""]*len(columns)
+ has_percent = []
for row in result:
for i, col in enumerate(columns):
col = col.split(":")
- if len(col) > 1 and col[1] in ["Currency", "Int", "Float"] and flt(row[i]):
- total_row[i] = flt(total_row[i]) + flt(row[i])
+ if len(col) > 1:
+ if col[1] in ["Currency", "Int", "Float", "Percent"] and flt(row[i]):
+ total_row[i] = flt(total_row[i]) + flt(row[i])
+ if col[1] == "Percent" and i not in has_percent:
+ has_percent.append(i)
+
+ for i in has_percent:
+ total_row[i] = total_row[i] / len(result)
+
first_col = columns[0].split(":")
- if len(first_col) > 1 and first_col[1] not in ["Currency", "Int", "Float"]:
+ if len(first_col) > 1 and first_col[1] not in ["Currency", "Int", "Float", "Percent"]:
total_row[0] = "Total"
result.append(total_row)