mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-21 10:26:30 +00:00
fix: Update indexing to populate correct values in trends report chart
(cherry picked from commit b08d66113c)
This commit is contained in:
@@ -24,22 +24,28 @@ def get_chart_data(data, conditions, filters):
|
|||||||
|
|
||||||
datapoints = []
|
datapoints = []
|
||||||
|
|
||||||
start = 3 if filters.get("based_on") in ["Item", "Supplier"] else 1
|
if filters.get("based_on") in ["Supplier"]:
|
||||||
|
start = 3
|
||||||
|
elif filters.get("based_on") in ["Item"]:
|
||||||
|
start = 2
|
||||||
|
else:
|
||||||
|
start = 1
|
||||||
|
|
||||||
if filters.get("group_by"):
|
if filters.get("group_by"):
|
||||||
start += 1
|
start += 1
|
||||||
|
|
||||||
# fetch only periodic columns as labels
|
# fetch only periodic columns as labels
|
||||||
columns = conditions.get("columns")[start:-2][1::2]
|
columns = conditions.get("columns")[start:-2][2::2]
|
||||||
labels = [column.split(":")[0] for column in columns]
|
labels = [column.split(":")[0] for column in columns]
|
||||||
datapoints = [0] * len(labels)
|
datapoints = [0] * len(labels)
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
# If group by filter, don't add first row of group (it's already summed)
|
# If group by filter, don't add first row of group (it's already summed)
|
||||||
if not row[start - 1]:
|
if not row[start]:
|
||||||
continue
|
continue
|
||||||
# Remove None values and compute only periodic data
|
# Remove None values and compute only periodic data
|
||||||
row = [x if x else 0 for x in row[start:-2]]
|
row = [x if x else 0 for x in row[start:-2]]
|
||||||
row = row[1::2]
|
row = row[2::2]
|
||||||
|
|
||||||
for i in range(len(row)):
|
for i in range(len(row)):
|
||||||
datapoints[i] += row[i]
|
datapoints[i] += row[i]
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ def get_data(filters, conditions):
|
|||||||
elif filters.get("group_by") == "Supplier":
|
elif filters.get("group_by") == "Supplier":
|
||||||
sel_col = "t1.supplier"
|
sel_col = "t1.supplier"
|
||||||
|
|
||||||
if filters.get("based_on") in ["Item", "Customer", "Supplier"]:
|
if filters.get("based_on") in ["Customer", "Supplier"]:
|
||||||
inc = 3
|
inc = 3
|
||||||
|
elif filters.get("based_on") in ["Item"]:
|
||||||
|
inc = 2
|
||||||
else:
|
else:
|
||||||
inc = 1
|
inc = 1
|
||||||
|
|
||||||
|
|||||||
@@ -25,22 +25,28 @@ def get_chart_data(data, conditions, filters):
|
|||||||
|
|
||||||
datapoints = []
|
datapoints = []
|
||||||
|
|
||||||
start = 3 if filters.get("based_on") in ["Item", "Customer"] else 1
|
if filters.get("based_on") in ["Customer"]:
|
||||||
|
start = 3
|
||||||
|
elif filters.get("based_on") in ["Item"]:
|
||||||
|
start = 2
|
||||||
|
else:
|
||||||
|
start = 1
|
||||||
|
|
||||||
if filters.get("group_by"):
|
if filters.get("group_by"):
|
||||||
start += 1
|
start += 1
|
||||||
|
|
||||||
# fetch only periodic columns as labels
|
# fetch only periodic columns as labels
|
||||||
columns = conditions.get("columns")[start:-2][1::2]
|
columns = conditions.get("columns")[start:-2][2::2]
|
||||||
labels = [column.split(":")[0] for column in columns]
|
labels = [column.split(":")[0] for column in columns]
|
||||||
datapoints = [0] * len(labels)
|
datapoints = [0] * len(labels)
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
# If group by filter, don't add first row of group (it's already summed)
|
# If group by filter, don't add first row of group (it's already summed)
|
||||||
if not row[start - 1]:
|
if not row[start]:
|
||||||
continue
|
continue
|
||||||
# Remove None values and compute only periodic data
|
# Remove None values and compute only periodic data
|
||||||
row = [x if x else 0 for x in row[start:-2]]
|
row = [x if x else 0 for x in row[start:-2]]
|
||||||
row = row[1::2]
|
row = row[2::2]
|
||||||
|
|
||||||
for i in range(len(row)):
|
for i in range(len(row)):
|
||||||
datapoints[i] += row[i]
|
datapoints[i] += row[i]
|
||||||
|
|||||||
@@ -24,22 +24,28 @@ def get_chart_data(data, conditions, filters):
|
|||||||
|
|
||||||
datapoints = []
|
datapoints = []
|
||||||
|
|
||||||
start = 3 if filters.get("based_on") in ["Item", "Customer"] else 1
|
if filters.get("based_on") in ["Customer"]:
|
||||||
|
start = 3
|
||||||
|
elif filters.get("based_on") in ["Item"]:
|
||||||
|
start = 2
|
||||||
|
else:
|
||||||
|
start = 1
|
||||||
|
|
||||||
if filters.get("group_by"):
|
if filters.get("group_by"):
|
||||||
start += 1
|
start += 1
|
||||||
|
|
||||||
# fetch only periodic columns as labels
|
# fetch only periodic columns as labels
|
||||||
columns = conditions.get("columns")[start:-2][1::2]
|
columns = conditions.get("columns")[start:-2][2::2]
|
||||||
labels = [column.split(":")[0] for column in columns]
|
labels = [column.split(":")[0] for column in columns]
|
||||||
datapoints = [0] * len(labels)
|
datapoints = [0] * len(labels)
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
# If group by filter, don't add first row of group (it's already summed)
|
# If group by filter, don't add first row of group (it's already summed)
|
||||||
if not row[start - 1]:
|
if not row[start]:
|
||||||
continue
|
continue
|
||||||
# Remove None values and compute only periodic data
|
# Remove None values and compute only periodic data
|
||||||
row = [x if x else 0 for x in row[start:-2]]
|
row = [x if x else 0 for x in row[start:-2]]
|
||||||
row = row[1::2]
|
row = row[2::2]
|
||||||
|
|
||||||
for i in range(len(row)):
|
for i in range(len(row)):
|
||||||
datapoints[i] += row[i]
|
datapoints[i] += row[i]
|
||||||
|
|||||||
Reference in New Issue
Block a user