fix: dashboard fixtures
diff --git a/erpnext/assets/dashboard_fixtures.py b/erpnext/assets/dashboard_fixtures.py
index aa4eed2..22c4a3e 100644
--- a/erpnext/assets/dashboard_fixtures.py
+++ b/erpnext/assets/dashboard_fixtures.py
@@ -8,8 +8,7 @@
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_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"
- }
- ]
\ No newline at end of file
+ {
+ "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}
+ })
+ }]
diff --git a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
index c6b0c4e..81db576 100644
--- a/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
+++ b/erpnext/assets/report/fixed_asset_register/fixed_asset_register.py
@@ -10,7 +10,7 @@
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 @@
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": 'donut',
- "height": 250
+ "type": "bar",
+ "barOptions": {
+ "stacked": 1
+ },
}
def get_finance_book_value_map(filters):