Pie chart for ageing analysis in accounts receivale/payable
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 365212a..786f904 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -16,7 +16,10 @@
def run(self, args):
party_naming_by = frappe.db.get_value(args.get("naming_by")[0], None, args.get("naming_by")[1])
- return self.get_columns(party_naming_by, args), self.get_data(party_naming_by, args)
+ columns = self.get_columns(party_naming_by, args)
+ data = self.get_data(party_naming_by, args)
+ graph_data = self.get_graph_data(columns, data)
+ return columns, data, None, graph_data
def get_columns(self, party_naming_by, args):
columns = [_("Posting Date") + ":Date:80", _(args.get("party_type")) + ":Link/" + args.get("party_type") + ":200"]
@@ -39,6 +42,8 @@
})
columns += [_("Age (Days)") + ":Int:80"]
+
+ self.ageing_col_idx_start = len(columns)
if not "range1" in self.filters:
self.filters["range1"] = "30"
@@ -46,7 +51,7 @@
self.filters["range2"] = "60"
if not "range3" in self.filters:
self.filters["range3"] = "90"
-
+
for label in ("0-{range1}".format(**self.filters),
"{range1}-{range2}".format(**self.filters),
"{range2}-{range3}".format(**self.filters),
@@ -250,6 +255,23 @@
return self.gl_entries_map.get(party, {})\
.get(against_voucher_type, {})\
.get(against_voucher, [])
+
+ def get_graph_data(self, columns, data):
+ ageing_columns = columns[self.ageing_col_idx_start : self.ageing_col_idx_start+4]
+
+ range_totals = [[d.get("label")] for d in ageing_columns]
+
+ for d in data:
+ for i in xrange(4):
+ range_totals[i].append(d[self.ageing_col_idx_start + i])
+
+ return {
+ "data": {
+ 'columns': range_totals,
+ 'type': 'pie'
+ }
+ }
+
def execute(filters=None):
args = {