Merge pull request #19288 from deepeshgarg007/analytics_chart_fix
fix: Chart fix in Analytics report when based on item
This commit is contained in:
commit
3f2c5c2319
@ -80,10 +80,14 @@ frappe.query_reports["Sales Analytics"] = {
|
||||
|
||||
var tree_type = frappe.query_report.filters[0].value;
|
||||
|
||||
if(tree_type == "Customer" || tree_type == "Item") {
|
||||
if(tree_type == "Customer") {
|
||||
row_values = data.slice(4,length-1).map(function (column) {
|
||||
return column.content;
|
||||
})
|
||||
} else if (tree_type == "Item") {
|
||||
row_values = data.slice(5,length-1).map(function (column) {
|
||||
return column.content;
|
||||
})
|
||||
}
|
||||
else {
|
||||
row_values = data.slice(3,length-1).map(function (column) {
|
||||
|
@ -136,7 +136,7 @@ class Analytics(object):
|
||||
if self.filters["value_quantity"] == 'Value':
|
||||
value_field = 'base_amount'
|
||||
else:
|
||||
value_field = 'qty'
|
||||
value_field = 'stock_qty'
|
||||
|
||||
self.entries = frappe.db.sql("""
|
||||
select i.item_code as entity, i.item_name as entity_name, i.stock_uom, i.{value_field} as value_field, s.{date_field}
|
||||
@ -338,8 +338,10 @@ class Analytics(object):
|
||||
def get_chart_data(self):
|
||||
length = len(self.columns)
|
||||
|
||||
if self.filters.tree_type in ["Customer", "Supplier", "Item"]:
|
||||
if self.filters.tree_type in ["Customer", "Supplier"]:
|
||||
labels = [d.get("label") for d in self.columns[2:length - 1]]
|
||||
elif self.filters.tree_type == "Item":
|
||||
labels = [d.get("label") for d in self.columns[3:length - 1]]
|
||||
else:
|
||||
labels = [d.get("label") for d in self.columns[1:length - 1]]
|
||||
self.chart = {
|
||||
|
Loading…
Reference in New Issue
Block a user