Saqib Ansari | 22aec57 | 2020-05-08 16:39:17 +0530 | [diff] [blame] | 1 | # Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | import frappe |
| 5 | import json |
| 6 | |
| 7 | |
| 8 | def get_data(): |
| 9 | return frappe._dict({ |
| 10 | "dashboards": get_dashboards(), |
| 11 | "charts": get_charts(), |
| 12 | "number_cards": get_number_cards(), |
| 13 | }) |
| 14 | |
| 15 | def get_dashboards(): |
| 16 | return [{ |
| 17 | "name": "Asset", |
| 18 | "dashboard_name": "Asset", |
| 19 | "charts": [ |
| 20 | { "chart": "Category-wise Asset Value" }, |
| 21 | { "chart": "Location-wise Asset Value" }, |
| 22 | ] |
| 23 | }] |
| 24 | |
| 25 | def get_charts(): |
| 26 | return [ |
| 27 | { |
| 28 | "name": "Category-wise Asset Value", |
| 29 | "chart_name": "Category-wise Asset Value", |
| 30 | "chart_type": "Report", |
| 31 | "report_name": "Category-wise Asset Value", |
| 32 | "is_custom": 1, |
| 33 | "x_field": "asset_category", |
| 34 | "timeseries": 0, |
| 35 | "filters_json": "{}", |
| 36 | "type": "Donut", |
| 37 | "doctype": "Dashboard Chart", |
| 38 | "y_axis": [ |
| 39 | { |
| 40 | "parent": "Category-wise Asset Value", |
| 41 | "parentfield": "y_axis", |
| 42 | "parenttype": "Dashboard Chart", |
| 43 | "y_field": "asset_value", |
| 44 | "doctype": "Dashboard Chart Field" |
| 45 | } |
| 46 | ], |
| 47 | "custom_options": json.dumps({ |
| 48 | "type": "donut", |
| 49 | "height": 300, |
| 50 | "axisOptions": {"shortenYAxisNumbers": 1} |
| 51 | }) |
| 52 | }, |
| 53 | { |
| 54 | "name": "Location-wise Asset Value", |
| 55 | "chart_name": "Location-wise Asset Value", |
| 56 | "chart_type": "Report", |
| 57 | "report_name": "Location-wise Asset Value", |
| 58 | "is_custom": 1, |
| 59 | "x_field": "location", |
| 60 | "timeseries": 0, |
| 61 | "filters_json": "{}", |
| 62 | "type": "Donut", |
| 63 | "doctype": "Dashboard Chart", |
| 64 | "y_axis": [ |
| 65 | { |
| 66 | "parent": "Location-wise Asset Value", |
| 67 | "parentfield": "y_axis", |
| 68 | "parenttype": "Dashboard Chart", |
| 69 | "y_field": "asset_value", |
| 70 | "doctype": "Dashboard Chart Field" |
| 71 | } |
| 72 | ], |
| 73 | "custom_options": json.dumps({ |
| 74 | "type": "donut", |
| 75 | "height": 300, |
| 76 | "axisOptions": {"shortenYAxisNumbers": 1} |
| 77 | }) |
| 78 | } |
| 79 | ] |
| 80 | |
| 81 | |
| 82 | def get_number_cards(): |
| 83 | return [ |
| 84 | { |
| 85 | "name": "Asset Value", |
| 86 | "label": "Asset Value ", |
| 87 | "function": "Sum", |
| 88 | "aggregate_function_based_on": "gross_purchase_amount", |
| 89 | "document_type": "Asset", |
| 90 | "is_public": 0, |
| 91 | "show_percentage_stats": 1, |
| 92 | "stats_time_interval": "Monthly", |
| 93 | "filters_json": "[]", |
| 94 | "doctype": "Number Card" |
| 95 | } |
| 96 | ] |