From 93afbe143b0bd6f2b678366f5060ef3ffde40333 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Wed, 22 Jul 2020 18:07:39 +0530 Subject: [PATCH] feat: Export Selling Dashboard (#22776) * feat:Export Stock Dashboard * Export Selling Dashboard * Export Selling Dashboard --- .../item_wise_annual_sales.json | 24 +++ .../sales_order_analysis.json | 24 +++ .../sales_order_trends.json | 24 +++ .../top_customers/top_customers.json | 24 +++ erpnext/selling/dashboard_fixtures.py | 198 ------------------ .../active_customers/active_customers.json | 21 ++ .../annual_sales/annual_sales.json | 22 ++ .../sales_orders_to_bill.json | 21 ++ .../sales_orders_to_deliver.json | 21 ++ .../selling_dashboard/selling/selling.json | 46 ++++ 10 files changed, 227 insertions(+), 198 deletions(-) create mode 100644 erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json create mode 100644 erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json create mode 100644 erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json create mode 100644 erpnext/selling/dashboard_chart/top_customers/top_customers.json delete mode 100644 erpnext/selling/dashboard_fixtures.py create mode 100644 erpnext/selling/number_card/active_customers/active_customers.json create mode 100644 erpnext/selling/number_card/annual_sales/annual_sales.json create mode 100644 erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json create mode 100644 erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json create mode 100644 erpnext/selling/selling_dashboard/selling/selling.json diff --git a/erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json b/erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json new file mode 100644 index 0000000000..290e526f11 --- /dev/null +++ b/erpnext/selling/dashboard_chart/item_wise_annual_sales/item_wise_annual_sales.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Item-wise Annual Sales", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.474566", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"from_date\":\"2020-06-22\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 14:42:25.512675", + "modified_by": "Administrator", + "module": "Selling", + "name": "Item-wise Annual Sales", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Item-wise Sales History", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json b/erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json new file mode 100644 index 0000000000..5e1a0d9258 --- /dev/null +++ b/erpnext/selling/dashboard_chart/sales_order_analysis/sales_order_analysis.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Sales Order Analysis", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.440393", + "custom_options": "{\"type\": \"donut\", \"height\": 300, \"axisOptions\": {\"shortenYAxisNumbers\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"to_date\":\"frappe.datetime.nowdate()\"}", + "filters_json": "{\"status\":[\"To Bill\",\"To Deliver\"],\"group_by_so\":0,\"from_date\":\"2020-06-22\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 17:06:05.750660", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Analysis", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Sales Order Analysis", + "timeseries": 0, + "type": "Donut", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json b/erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json new file mode 100644 index 0000000000..914d915d94 --- /dev/null +++ b/erpnext/selling/dashboard_chart/sales_order_trends/sales_order_trends.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Sales Order Trends", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.508240", + "custom_options": "{\"type\": \"line\", \"axisOptions\": {\"shortenYAxisNumbers\": 1}, \"tooltipOptions\": {}, \"lineOptions\": {\"regionFill\": 1}}", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"fiscal_year\":\"frappe.sys_defaults.fiscal_year\"}", + "filters_json": "{\"period\":\"Monthly\",\"based_on\":\"Item\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 16:24:45.726270", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Order Trends", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Sales Order Trends", + "timeseries": 0, + "type": "Line", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_chart/top_customers/top_customers.json b/erpnext/selling/dashboard_chart/top_customers/top_customers.json new file mode 100644 index 0000000000..59a2ba37dd --- /dev/null +++ b/erpnext/selling/dashboard_chart/top_customers/top_customers.json @@ -0,0 +1,24 @@ +{ + "chart_name": "Top Customers", + "chart_type": "Report", + "creation": "2020-07-20 20:17:16.539281", + "custom_options": "", + "docstatus": 0, + "doctype": "Dashboard Chart", + "dynamic_filters_json": "{\"company\":\"frappe.defaults.get_user_default(\\\"Company\\\")\",\"fiscal_year\":\"frappe.sys_defaults.fiscal_year\"}", + "filters_json": "{\"period\":\"Yearly\",\"based_on\":\"Customer\"}", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "modified": "2020-07-22 17:03:10.320147", + "modified_by": "Administrator", + "module": "Selling", + "name": "Top Customers", + "number_of_groups": 0, + "owner": "Administrator", + "report_name": "Delivery Note Trends", + "timeseries": 0, + "type": "Bar", + "use_report_chart": 1, + "y_axis": [] +} \ No newline at end of file diff --git a/erpnext/selling/dashboard_fixtures.py b/erpnext/selling/dashboard_fixtures.py deleted file mode 100644 index 889cb88dce..0000000000 --- a/erpnext/selling/dashboard_fixtures.py +++ /dev/null @@ -1,198 +0,0 @@ -# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -import frappe -import json -from frappe import _ -from frappe.utils import nowdate -from erpnext.accounts.utils import get_fiscal_year - -def get_data(): - return frappe._dict({ - "dashboards": get_dashboards(), - "charts": get_charts(), - "number_cards": get_number_cards(), - }) - -def get_company_for_dashboards(): - company = frappe.defaults.get_defaults().company - if company: - return company - else: - company_list = frappe.get_list("Company") - if company_list: - return company_list[0].name - return None - -company = frappe.get_doc("Company", get_company_for_dashboards()) -fiscal_year = get_fiscal_year(nowdate(), as_dict=1) -fiscal_year_name = fiscal_year.get("name") -start_date = str(fiscal_year.get("year_start_date")) -end_date = str(fiscal_year.get("year_end_date")) - -def get_dashboards(): - return [{ - "name": "Selling", - "dashboard_name": "Selling", - "charts": [ - { "chart": "Sales Order Trends", "width": "Full"}, - { "chart": "Top Customers", "width": "Half"}, - { "chart": "Sales Order Analysis", "width": "Half"}, - { "chart": "Item-wise Annual Sales", "width": "Full"} - ], - "cards": [ - { "card": "Annual Sales"}, - { "card": "Sales Orders to Deliver"}, - { "card": "Sales Orders to Bill"}, - { "card": "Active Customers"} - ] - }] - -def get_charts(): - return [ - { - "name": "Sales Order Analysis", - "chart_name": _("Sales Order Analysis"), - "chart_type": "Report", - "custom_options": json.dumps({ - "type": "donut", - "height": 300, - "axisOptions": {"shortenYAxisNumbers": 1} - }), - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "from_date": start_date, - "to_date": end_date - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Sales Order Analysis", - "type": "Donut" - }, - { - "name": "Item-wise Annual Sales", - "chart_name": _("Item-wise Annual Sales"), - "chart_type": "Report", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "from_date": start_date, - "to_date": end_date - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Item-wise Sales History", - "type": "Bar" - }, - { - "name": "Sales Order Trends", - "chart_name": _("Sales Order Trends"), - "chart_type": "Report", - "custom_options": json.dumps({ - "type": "line", - "axisOptions": {"shortenYAxisNumbers": 1}, - "tooltipOptions": {}, - "lineOptions": { - "regionFill": 1 - } - }), - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "period": "Monthly", - "fiscal_year": fiscal_year_name, - "based_on": "Item" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Sales Order Trends", - "type": "Line" - }, - { - "name": "Top Customers", - "chart_name": _("Top Customers"), - "chart_type": "Report", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name, - "period": "Monthly", - "fiscal_year": fiscal_year_name, - "based_on": "Customer" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Delivery Note Trends", - "type": "Bar" - } - ] - -def get_number_cards(): - return [ - { - "name": "Annual Sales", - "aggregate_function_based_on": "base_net_total", - "doctype": "Number Card", - "document_type": "Sales Order", - "filters_json": json.dumps([ - ["Sales Order", "transaction_date", "Between", [start_date, end_date], False], - ["Sales Order", "status", "not in", ["Draft", "Cancelled", "Closed", None], False], - ["Sales Order", "docstatus", "=", 1, False], - ["Sales Order", "company", "=", company.name, False] - ]), - "function": "Sum", - "is_public": 1, - "label": _("Annual Sales"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - }, - { - "name": "Sales Orders to Deliver", - "doctype": "Number Card", - "document_type": "Sales Order", - "filters_json": json.dumps([ - ["Sales Order", "status", "in", ["To Deliver and Bill", "To Deliver", None], False], - ["Sales Order", "docstatus", "=", 1, False], - ["Sales Order", "company", "=", company.name, False] - ]), - "function": "Count", - "is_public": 1, - "label": _("Sales Orders to Deliver"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Weekly" - }, - { - "name": "Sales Orders to Bill", - "doctype": "Number Card", - "document_type": "Sales Order", - "filters_json": json.dumps([ - ["Sales Order", "status", "in", ["To Deliver and Bill", "To Bill", None], False], - ["Sales Order", "docstatus", "=", 1, False], - ["Sales Order", "company", "=", company.name, False] - ]), - "function": "Count", - "is_public": 1, - "label": _("Sales Orders to Bill"), - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Weekly" - }, - { - "name": "Active Customers", - "doctype": "Number Card", - "document_type": "Customer", - "filters_json": json.dumps([["Customer", "disabled", "=", "0"]]), - "function": "Count", - "is_public": 1, - "label": "Active Customers", - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Monthly" - } - ] \ No newline at end of file diff --git a/erpnext/selling/number_card/active_customers/active_customers.json b/erpnext/selling/number_card/active_customers/active_customers.json new file mode 100644 index 0000000000..3377634847 --- /dev/null +++ b/erpnext/selling/number_card/active_customers/active_customers.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:16.653866", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Customer", + "dynamic_filters_json": "", + "filters_json": "[[\"Customer\",\"disabled\",\"=\",\"0\"]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Active Customers", + "modified": "2020-07-22 14:20:32.268103", + "modified_by": "Administrator", + "module": "Selling", + "name": "Active Customers", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/selling/number_card/annual_sales/annual_sales.json b/erpnext/selling/number_card/annual_sales/annual_sales.json new file mode 100644 index 0000000000..8746ee4c6a --- /dev/null +++ b/erpnext/selling/number_card/annual_sales/annual_sales.json @@ -0,0 +1,22 @@ +{ + "aggregate_function_based_on": "base_net_total", + "creation": "2020-07-20 20:17:16.568132", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Order", + "dynamic_filters_json": "[[\"Sales Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Sales Order\",\"status\",\"not in\",[\"Draft\",\"Cancelled\",\"Closed\",null],false],[\"Sales Order\",\"docstatus\",\"=\",\"1\",false],[\"Sales Order\",\"modified\",\"Timespan\",\"this year\",false]]", + "function": "Sum", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Annual Sales", + "modified": "2020-07-22 16:56:33.747156", + "modified_by": "Administrator", + "module": "Selling", + "name": "Annual Sales", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json b/erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json new file mode 100644 index 0000000000..27fea45723 --- /dev/null +++ b/erpnext/selling/number_card/sales_orders_to_bill/sales_orders_to_bill.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:16.625001", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Order", + "dynamic_filters_json": "[[\"Sales Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Sales Order\",\"status\",\"in\",[\"To Deliver and Bill\",\"To Bill\",null],false],[\"Sales Order\",\"docstatus\",\"=\",\"1\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Sales Orders to Bill", + "modified": "2020-07-22 14:20:09.918626", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Orders to Bill", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json b/erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json new file mode 100644 index 0000000000..6e19cf4d3e --- /dev/null +++ b/erpnext/selling/number_card/sales_orders_to_deliver/sales_orders_to_deliver.json @@ -0,0 +1,21 @@ +{ + "creation": "2020-07-20 20:17:16.596857", + "docstatus": 0, + "doctype": "Number Card", + "document_type": "Sales Order", + "dynamic_filters_json": "[[\"Sales Order\",\"company\",\"=\",\"frappe.defaults.get_user_default(\\\"Company\\\")\"]]", + "filters_json": "[[\"Sales Order\",\"status\",\"in\",[\"To Deliver and Bill\",\"To Deliver\",null],false],[\"Sales Order\",\"docstatus\",\"=\",\"1\",false]]", + "function": "Count", + "idx": 0, + "is_public": 1, + "is_standard": 1, + "label": "Sales Orders to Deliver", + "modified": "2020-07-22 14:19:28.833784", + "modified_by": "Administrator", + "module": "Selling", + "name": "Sales Orders to Deliver", + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Weekly", + "type": "Document Type" +} \ No newline at end of file diff --git a/erpnext/selling/selling_dashboard/selling/selling.json b/erpnext/selling/selling_dashboard/selling/selling.json new file mode 100644 index 0000000000..52e6714965 --- /dev/null +++ b/erpnext/selling/selling_dashboard/selling/selling.json @@ -0,0 +1,46 @@ +{ + "cards": [ + { + "card": "Annual Sales" + }, + { + "card": "Sales Orders to Deliver" + }, + { + "card": "Sales Orders to Bill" + }, + { + "card": "Active Customers" + } + ], + "charts": [ + { + "chart": "Sales Order Trends", + "width": "Full" + }, + { + "chart": "Top Customers", + "width": "Half" + }, + { + "chart": "Sales Order Analysis", + "width": "Half" + }, + { + "chart": "Item-wise Annual Sales", + "width": "Full" + } + ], + "creation": "2020-07-20 20:17:16.688162", + "dashboard_name": "Selling", + "docstatus": 0, + "doctype": "Dashboard", + "idx": 0, + "is_default": 0, + "is_standard": 1, + "modified": "2020-07-22 15:31:22.299903", + "modified_by": "Administrator", + "module": "Selling", + "name": "Selling", + "owner": "Administrator" +} \ No newline at end of file