fix: PR and DN trend report charts, group by fixes

This commit is contained in:
marination 2020-05-19 13:58:13 +05:30
parent 64b36dba4f
commit 658f29915a
2 changed files with 14 additions and 4 deletions

View File

@ -12,17 +12,22 @@ def execute(filters=None):
conditions = get_columns(filters, "Delivery Note")
data = get_data(filters, conditions)
chart_data = get_chart_data(data)
chart_data = get_chart_data(data, filters)
return conditions["columns"], data, None, chart_data
def get_chart_data(data):
def get_chart_data(data, filters):
if not data:
return []
labels, datapoints = [], []
if filters.get("group_by"):
# consider only consolidated row
data = [row for row in data if row[0]]
if len(data) > 10:
# get top 10 if data too long
data = sorted(data, key = lambda i: i[-1],reverse=True)
data = data[:10]

View File

@ -12,17 +12,22 @@ def execute(filters=None):
conditions = get_columns(filters, "Purchase Receipt")
data = get_data(filters, conditions)
chart_data = get_chart_data(data)
chart_data = get_chart_data(data, filters)
return conditions["columns"], data, None, chart_data
def get_chart_data(data):
def get_chart_data(data, filters):
if not data:
return []
labels, datapoints = [], []
if filters.get("group_by"):
# consider only consolidated row
data = [row for row in data if row[0]]
if len(data) > 10:
# get top 10 if data too long
data = sorted(data, key = lambda i: i[-1],reverse=True)
data = data[:10]