chore: Added Dynamic Charts to DN and PR Trends Reports
This commit is contained in:
parent
10bd2417ff
commit
bb95cd5fd8
@ -51,7 +51,10 @@ erpnext.get_purchase_trends_filters = function() {
|
||||
{ "value": "Supplier Group", "label": __("Supplier Group") },
|
||||
{ "value": "Project", "label": __("Project") }
|
||||
],
|
||||
"default": "Item"
|
||||
"default": "Item",
|
||||
"dashboard_config": {
|
||||
"read_only": 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname":"group_by",
|
||||
|
@ -27,7 +27,10 @@ erpnext.get_sales_trends_filters = function() {
|
||||
{ "value": "Territory", "label": __("Territory") },
|
||||
{ "value": "Project", "label": __("Project") }
|
||||
],
|
||||
"default": "Item"
|
||||
"default": "Item",
|
||||
"dashboard_config": {
|
||||
"read_only": 1,
|
||||
}
|
||||
},
|
||||
{
|
||||
"fieldname":"group_by",
|
||||
|
@ -10,7 +10,7 @@ from erpnext.stock.utils import get_stock_value_from_bin
|
||||
@frappe.whitelist()
|
||||
@cache_source
|
||||
def get(chart_name = None, chart = None, no_cache = None, filters = None, from_date = None,
|
||||
to_date = None, timespan = None, time_interval = None):
|
||||
to_date = None, timespan = None, time_interval = None, heatmap_year = None):
|
||||
labels, datapoints = [], []
|
||||
filters = frappe.parse_json(filters)
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from erpnext.controllers.trends import get_columns,get_data
|
||||
|
||||
def execute(filters=None):
|
||||
@ -10,5 +11,31 @@ def execute(filters=None):
|
||||
data = []
|
||||
conditions = get_columns(filters, "Delivery Note")
|
||||
data = get_data(filters, conditions)
|
||||
|
||||
return conditions["columns"], data
|
||||
|
||||
chart_data = get_chart_data(data)
|
||||
|
||||
return conditions["columns"], data, None, chart_data
|
||||
|
||||
def get_chart_data(data):
|
||||
labels, datapoints = [], []
|
||||
|
||||
if len(data) > 10:
|
||||
data = sorted(data, key = lambda i: i[-1],reverse=True)
|
||||
data = data[:10]
|
||||
|
||||
for row in data:
|
||||
labels.append(row[0])
|
||||
datapoints.append(row[-1])
|
||||
|
||||
return {
|
||||
"data": {
|
||||
"labels" : labels,
|
||||
"datasets" : [
|
||||
{
|
||||
"name": _("Total Revenue"),
|
||||
"values": datapoints
|
||||
}
|
||||
]
|
||||
},
|
||||
"type" : "bar"
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from erpnext.controllers.trends import get_columns,get_data
|
||||
|
||||
def execute(filters=None):
|
||||
@ -11,4 +12,31 @@ def execute(filters=None):
|
||||
conditions = get_columns(filters, "Purchase Receipt")
|
||||
data = get_data(filters, conditions)
|
||||
|
||||
return conditions["columns"], data
|
||||
chart_data = get_chart_data(data)
|
||||
|
||||
return conditions["columns"], data, None, chart_data
|
||||
|
||||
def get_chart_data(data):
|
||||
labels, datapoints = [], []
|
||||
|
||||
if len(data) > 10:
|
||||
data = sorted(data, key = lambda i: i[-1],reverse=True)
|
||||
data = data[:10]
|
||||
|
||||
for row in data:
|
||||
labels.append(row[0])
|
||||
datapoints.append(row[-1])
|
||||
|
||||
return {
|
||||
"data": {
|
||||
"labels" : labels,
|
||||
"datasets" : [
|
||||
{
|
||||
"name": _("Total Expenditure"),
|
||||
"values": datapoints
|
||||
}
|
||||
]
|
||||
},
|
||||
"type" : "bar",
|
||||
"colors":["#5e64ff"]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user