fix: PR and DN trend report charts, group by fixes
diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py
index d088b00..40a639b 100644
--- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py
+++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py
@@ -12,17 +12,22 @@
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]
diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
index 627c23b..3b8d8d2 100644
--- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
+++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py
@@ -12,17 +12,22 @@
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]