fix: dashboard fixtures
This commit is contained in:
parent
1dcf103398
commit
ecddf3358d
@ -8,8 +8,7 @@ import json
|
||||
def get_data():
|
||||
return frappe._dict({
|
||||
"dashboards": get_dashboards(),
|
||||
"charts": get_charts(),
|
||||
"number_cards": get_number_cards(),
|
||||
"charts": get_charts()
|
||||
})
|
||||
|
||||
def get_dashboards():
|
||||
@ -24,73 +23,55 @@ def get_dashboards():
|
||||
|
||||
def get_charts():
|
||||
return [
|
||||
{
|
||||
"name": "Category-wise Asset Value",
|
||||
"chart_name": "Category-wise Asset Value",
|
||||
"chart_type": "Report",
|
||||
"report_name": "Category-wise Asset Value",
|
||||
"is_custom": 1,
|
||||
"x_field": "asset_category",
|
||||
"timeseries": 0,
|
||||
"filters_json": "{}",
|
||||
"type": "Donut",
|
||||
"doctype": "Dashboard Chart",
|
||||
"y_axis": [
|
||||
{
|
||||
"parent": "Category-wise Asset Value",
|
||||
"parentfield": "y_axis",
|
||||
"parenttype": "Dashboard Chart",
|
||||
"y_field": "asset_value",
|
||||
"doctype": "Dashboard Chart Field"
|
||||
}
|
||||
],
|
||||
"custom_options": json.dumps({
|
||||
"type": "donut",
|
||||
"height": 300,
|
||||
"axisOptions": {"shortenYAxisNumbers": 1}
|
||||
})
|
||||
},
|
||||
{
|
||||
"name": "Location-wise Asset Value",
|
||||
"chart_name": "Location-wise Asset Value",
|
||||
"chart_type": "Report",
|
||||
"report_name": "Location-wise Asset Value",
|
||||
"is_custom": 1,
|
||||
"x_field": "location",
|
||||
"timeseries": 0,
|
||||
"filters_json": "{}",
|
||||
"type": "Donut",
|
||||
"doctype": "Dashboard Chart",
|
||||
"y_axis": [
|
||||
{
|
||||
"parent": "Location-wise Asset Value",
|
||||
"parentfield": "y_axis",
|
||||
"parenttype": "Dashboard Chart",
|
||||
"y_field": "asset_value",
|
||||
"doctype": "Dashboard Chart Field"
|
||||
}
|
||||
],
|
||||
"custom_options": json.dumps({
|
||||
"type": "donut",
|
||||
"height": 300,
|
||||
"axisOptions": {"shortenYAxisNumbers": 1}
|
||||
})
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def get_number_cards():
|
||||
return [
|
||||
{
|
||||
"name": "Asset Value",
|
||||
"label": "Asset Value ",
|
||||
"function": "Sum",
|
||||
"aggregate_function_based_on": "gross_purchase_amount",
|
||||
"document_type": "Asset",
|
||||
"is_public": 0,
|
||||
"show_percentage_stats": 1,
|
||||
"stats_time_interval": "Monthly",
|
||||
"filters_json": "[]",
|
||||
"doctype": "Number Card"
|
||||
}
|
||||
]
|
||||
{
|
||||
"name": "Category-wise Asset Value",
|
||||
"chart_name": "Category-wise Asset Value",
|
||||
"chart_type": "Report",
|
||||
"report_name": "Fixed Asset Report",
|
||||
"is_custom": 1,
|
||||
"x_field": "asset_category",
|
||||
"timeseries": 0,
|
||||
"filters_json": json.dumps("""{"status":"In Location","group_by":"Asset Category","is_existing_asset":0}"""),
|
||||
"type": "Donut",
|
||||
"doctype": "Dashboard Chart",
|
||||
"y_axis": [
|
||||
{
|
||||
"parent": "Category-wise Asset Value",
|
||||
"parentfield": "y_axis",
|
||||
"parenttype": "Dashboard Chart",
|
||||
"y_field": "asset_value",
|
||||
"doctype": "Dashboard Chart Field"
|
||||
}
|
||||
],
|
||||
"custom_options": json.dumps({
|
||||
"type": "donut",
|
||||
"height": 300,
|
||||
"axisOptions": {"shortenYAxisNumbers": 1}
|
||||
})
|
||||
},
|
||||
{
|
||||
"name": "Location-wise Asset Value",
|
||||
"chart_name": "Location-wise Asset Value",
|
||||
"chart_type": "Report",
|
||||
"report_name": "Location-wise Asset Value",
|
||||
"is_custom": 1,
|
||||
"x_field": "location",
|
||||
"timeseries": 0,
|
||||
"filters_json": json.dumps("""{"status":"In Location","group_by":"Location","is_existing_asset":0}"""),
|
||||
"type": "Donut",
|
||||
"doctype": "Dashboard Chart",
|
||||
"y_axis": [
|
||||
{
|
||||
"parent": "Location-wise Asset Value",
|
||||
"parentfield": "y_axis",
|
||||
"parenttype": "Dashboard Chart",
|
||||
"y_field": "asset_value",
|
||||
"doctype": "Dashboard Chart Field"
|
||||
}
|
||||
],
|
||||
"custom_options": json.dumps({
|
||||
"type": "donut",
|
||||
"height": 300,
|
||||
"axisOptions": {"shortenYAxisNumbers": 1}
|
||||
})
|
||||
}]
|
||||
|
@ -10,7 +10,7 @@ def execute(filters=None):
|
||||
filters = frappe._dict(filters or {})
|
||||
columns = get_columns(filters)
|
||||
data = get_data(filters)
|
||||
chart = prepare_chart_data(data, columns)
|
||||
chart = prepare_chart_data(data) if not filters.get("group_by") else {}
|
||||
|
||||
return columns, data, None, chart
|
||||
|
||||
@ -89,20 +89,25 @@ def get_data(filters):
|
||||
|
||||
return data
|
||||
|
||||
def prepare_chart_data(data, columns):
|
||||
label_values_map = {}
|
||||
def prepare_chart_data(data):
|
||||
labels, asset_values, depreciated_amounts = [], [], []
|
||||
for d in data:
|
||||
if not label_values_map.get(d.get('asset_category')):
|
||||
label_values_map[d.get('asset_category')] = 0
|
||||
label_values_map[d.get('asset_category')] += d.get('asset_value')
|
||||
labels.append(d.asset_id)
|
||||
asset_values.append(d.asset_value)
|
||||
depreciated_amounts.append(d.depreciated_amount)
|
||||
|
||||
return {
|
||||
"data" : {
|
||||
"labels": label_values_map.keys(),
|
||||
"datasets": [{ "values": label_values_map.values() }]
|
||||
"labels": labels,
|
||||
"datasets": [
|
||||
{ 'name': _('Asset Value'), 'values': asset_values },
|
||||
{ 'name': _('Depreciatied Amount'), 'values': depreciated_amounts}
|
||||
]
|
||||
},
|
||||
"type": "bar",
|
||||
"barOptions": {
|
||||
"stacked": 1
|
||||
},
|
||||
"type": 'donut',
|
||||
"height": 250
|
||||
}
|
||||
|
||||
def get_finance_book_value_map(filters):
|
||||
|
Loading…
x
Reference in New Issue
Block a user