Browse Source

sales analytics based on sales order/delivery note/sales invoice

version-14
Nabin Hait 12 years ago
parent
commit
df5c9817b6
2 changed files with 13 additions and 8 deletions
  1. +5
    -2
      public/js/wn/views/grid_report.js
  2. +8
    -6
      webnotes/widgets/report_dump.py

+ 5
- 2
public/js/wn/views/grid_report.js View File

@@ -580,6 +580,7 @@ wn.views.GridReport = Class.extend({
return date==v.year_start_date ? true : null; return date==v.year_start_date ? true : null;
}).length; }).length;
}); });
} }
// set label as last date of period // set label as last date of period
@@ -715,11 +716,13 @@ wn.views.TreeGridReport = wn.views.GridReportWithPlot.extend({
if(!tmap[v.parent]) tmap[v.parent] = []; if(!tmap[v.parent]) tmap[v.parent] = [];
tmap[v.parent].push(v); tmap[v.parent].push(v);
}); });
this.tl = [];
if (!this.tl) this.tl = {};
if (!this.tl[parent_doctype]) this.tl[parent_doctype] = [];
$.each(wn.report_dump.data[parent_doctype], function(i, parent) { $.each(wn.report_dump.data[parent_doctype], function(i, parent) {
if(tmap[parent.name]) { if(tmap[parent.name]) {
$.each(tmap[parent.name], function(i, d) { $.each(tmap[parent.name], function(i, d) {
me.tl.push($.extend(copy_dict(parent), d));
me.tl[parent_doctype].push($.extend(copy_dict(parent), d));
}); });
} }
}); });


+ 8
- 6
webnotes/widgets/report_dump.py View File

@@ -34,6 +34,8 @@ def get_data():
start = datetime.datetime.now() start = datetime.datetime.now()
for d in doctypes: for d in doctypes:
args = data_map[d] args = data_map[d]
dt = d.find("[") != -1 and d[:d.find("[")] or d
conditions = order_by = "" conditions = order_by = ""
if args.get("force_index"): if args.get("force_index"):
conditions = " force index (%s) " % args["force_index"] conditions = " force index (%s) " % args["force_index"]
@@ -41,17 +43,17 @@ def get_data():
conditions += " where " + " and ".join(args["conditions"]) conditions += " where " + " and ".join(args["conditions"])
if args.get("order_by"): if args.get("order_by"):
order_by = " order by " + args["order_by"] order_by = " order by " + args["order_by"]
table = args.get("from") or ("`tab%s`" % d)
table = args.get("from") or ("`tab%s`" % dt)
out[d] = {}
out[dt] = {}
start = datetime.datetime.now() start = datetime.datetime.now()
out[d]["data"] = [list(t) for t in webnotes.conn.sql("""select %s from %s %s %s""" \
out[dt]["data"] = [list(t) for t in webnotes.conn.sql("""select %s from %s %s %s""" \
% (",".join(args["columns"]), table, conditions, order_by))] % (",".join(args["columns"]), table, conditions, order_by))]
out[d]["time"] = str(datetime.datetime.now() - start)
out[d]["columns"] = map(lambda c: c.split(" as ")[-1], args["columns"])
out[dt]["time"] = str(datetime.datetime.now() - start)
out[dt]["columns"] = map(lambda c: c.split(" as ")[-1], args["columns"])
if args.get("links"): if args.get("links"):
out[d]["links"] = args["links"]
out[dt]["links"] = args["links"]
for d in out: for d in out:
unused_links = [] unused_links = []


Loading…
Cancel
Save