From 8b686a5721b16d144737f280eb9c2db3a446e70c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 19 May 2020 19:08:30 +0530 Subject: [PATCH] feat: stock module dashboard and onboarding --- erpnext/accounts/dashboard_fixtures.py | 4 +- .../warehouse_wise_stock_value.py | 2 +- erpnext/stock/dashboard_fixtures.py | 194 +++++++----------- erpnext/stock/desk_page/stock/stock.json | 8 +- .../stock/module_onboarding/stock/stock.json | 14 +- .../create_a_purchase_receipt.json} | 10 +- .../create_a_supplier.json} | 10 +- ...oduction_to_price_list_and_item_price.json | 19 -- .../introduction_to_stock_entry.json | 4 +- .../setup_your_warehouse.json | 20 ++ .../delivery_note_trends.py | 2 +- .../purchase_receipt_trends.py | 2 +- .../stock/report/stock_ageing/stock_ageing.py | 4 +- 13 files changed, 132 insertions(+), 161 deletions(-) rename erpnext/stock/onboarding_step/{create_a_price_list/create_a_price_list.json => create_a_purchase_receipt/create_a_purchase_receipt.json} (56%) rename erpnext/stock/onboarding_step/{create_a_warehouse/create_a_warehouse.json => create_a_supplier/create_a_supplier.json} (57%) delete mode 100644 erpnext/stock/onboarding_step/introduction_to_price_list_and_item_price/introduction_to_price_list_and_item_price.json create mode 100644 erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json diff --git a/erpnext/accounts/dashboard_fixtures.py b/erpnext/accounts/dashboard_fixtures.py index cdd375802d..1eed5a0f9c 100644 --- a/erpnext/accounts/dashboard_fixtures.py +++ b/erpnext/accounts/dashboard_fixtures.py @@ -81,7 +81,7 @@ def get_charts(): "timespan": "Last Year", "color": "#a83333", "value_based_on": "base_net_total", - "filters_json": json.dumps({"docstatus": 1}), + "filters_json": json.dumps([["Purchase Invoice", "docstatus", "=", 1]]), "chart_type": "Sum", "timeseries": 1, "based_on": "posting_date", @@ -99,7 +99,7 @@ def get_charts(): "timespan": "Last Year", "color": "#7b933d", "value_based_on": "base_net_total", - "filters_json": json.dumps({"docstatus": 1}), + "filters_json": json.dumps([["Sales Invoice", "docstatus", "=", 1]]), "chart_type": "Sum", "timeseries": 1, "based_on": "posting_date", diff --git a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py index 05a5068752..374a34ea7c 100644 --- a/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py +++ b/erpnext/stock/dashboard_chart_source/warehouse_wise_stock_value/warehouse_wise_stock_value.py @@ -29,7 +29,7 @@ def get(chart_name = None, chart = None, no_cache = None, filters = None, from_d if not warehouses: return [] - sorted_warehouse_map = sorted(warehouses, key = lambda i: i['balance'],reverse=True) + sorted_warehouse_map = sorted(warehouses, key = lambda i: i['balance'], reverse=True) if len(sorted_warehouse_map) > 10: sorted_warehouse_map = sorted_warehouse_map[:10] diff --git a/erpnext/stock/dashboard_fixtures.py b/erpnext/stock/dashboard_fixtures.py index d1a3a146a2..0f1fd128f0 100644 --- a/erpnext/stock/dashboard_fixtures.py +++ b/erpnext/stock/dashboard_fixtures.py @@ -3,6 +3,7 @@ import frappe import json +from frappe import _ from frappe.utils import nowdate from erpnext.accounts.utils import get_fiscal_year @@ -34,39 +35,72 @@ def get_dashboards(): "name": "Stock", "dashboard_name": "Stock", "charts": [ - { "chart": "Item Shortage Summary", "width": "Half"}, - { "chart": "Stock Ageing", "width": "Half"}, - { "chart": "Item Wise Annual Revenue", "width": "Half"}, - { "chart": "Item Wise Annual Expenditure", "width": "Half"}, - { "chart": "Warehouse wise Stock Value", "width": "Full"} + { "chart": "Warehouse wise Stock Value", "width": "Full"}, + { "chart": "Purchase Receipt Trends", "width": "Half"}, + { "chart": "Delivery Trends", "width": "Half"}, + { "chart": "Oldest Items", "width": "Half"}, + { "chart": "Item Shortage Summary", "width": "Half"} ], "cards": [ - { "card": "Purchase Receipts to Bill"}, - { "card": "Amount Payable against Receipt"}, - { "card": "Delivery Notes to Bill"}, - { "card": "Amount Receivable against Delivery"} + { "card": "Total Active Items"}, + { "card": "Total Warehouses"}, + { "card": "Total Stock Value"} ] }] def get_charts(): return [ { - "name": "Item Shortage Summary", - "chart_name": "Item Shortage Summary", - "chart_type": "Report", "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "company": company.name - }), - "is_custom": 1, + "name": "Purchase Receipt Trends", + "time_interval": "Monthly", + "chart_name": _("Purchase Receipt Trends"), + "timespan": "Last Year", + "color": "#7b933d", + "value_based_on": "base_net_total", + "filters_json": json.dumps([["Purchase Receipt", "docstatus", "=", 1]]), + "chart_type": "Sum", + "timeseries": 1, + "based_on": "posting_date", + "owner": "Administrator", + "document_type": "Purchase Receipt", + "type": "Bar", + "width": "Half", + "is_public": 1 + }, + { + "doctype": "Dashboard Chart", + "name": "Delivery Trends", + "time_interval": "Monthly", + "chart_name": _("Delivery Trends"), + "timespan": "Last Year", + "color": "#7b933d", + "value_based_on": "base_net_total", + "filters_json": json.dumps([["Delivery Note", "docstatus", "=", 1]]), + "chart_type": "Sum", + "timeseries": 1, + "based_on": "posting_date", + "owner": "Administrator", + "document_type": "Delivery Note", + "type": "Bar", + "width": "Half", + "is_public": 1 + }, + { + "name": "Warehouse wise Stock Value", + "chart_name": _("Warehouse wise Stock Value"), + "chart_type": "Custom", + "doctype": "Dashboard Chart", + "filters_json": json.dumps({}), + "is_custom": 0, "is_public": 1, "owner": "Administrator", - "report_name": "Item Shortage Report", + "source": "Warehouse wise Stock Value", "type": "Bar" }, { - "name": "Stock Ageing", - "chart_name": "Stock Ageing", + "name": "Oldest Items", + "chart_name": _("Oldest Items"), "chart_type": "Report", "custom_options": json.dumps({ "colors": ["#5e64ff"] @@ -84,127 +118,55 @@ def get_charts(): "type": "Bar" }, { - "name": "Item Wise Annual Revenue", - "chart_name": "Item Wise Annual Revenue", + "name": "Item Shortage Summary", + "chart_name": _("Item Shortage Summary"), "chart_type": "Report", - "custom_options": json.dumps({ - "axisOptions": {"shortenYAxisNumbers": 1}, - "tooltipOptions": {}, - "colors":["#5e64ff"] - }), "doctype": "Dashboard Chart", "filters_json": json.dumps({ - "period": "Monthly", - "based_on": "Item", - "fiscal_year": fiscal_year_name, "company": company.name }), "is_custom": 1, "is_public": 1, "owner": "Administrator", - "report_name": "Delivery Note Trends", - "type": "Bar" - }, - { - "name": "Item Wise Annual Expenditure", - "chart_name": "Item Wise Annual Expenditure", - "chart_type": "Report", - "custom_options": json.dumps({ - "axisOptions": {"shortenYAxisNumbers": 1}, - "tooltipOptions": {} - }), - "doctype": "Dashboard Chart", - "filters_json": json.dumps({ - "period": "Monthly", - "based_on": "Item", - "fiscal_year": fiscal_year_name, - "company": company.name, - "period_based_on": "posting_date" - }), - "is_custom": 1, - "is_public": 1, - "owner": "Administrator", - "report_name": "Purchase Receipt Trends", - "type": "Bar" - }, - { - "name": "Warehouse wise Stock Value", - "chart_name": "Warehouse wise Stock Value", - "chart_type": "Custom", - "doctype": "Dashboard Chart", - "filters_json": json.dumps({}), - "is_custom": 0, - "is_public": 1, - "owner": "Administrator", - "source": "Warehouse wise Stock Value", + "report_name": "Item Shortage Report", "type": "Bar" } - ] def get_number_cards(): return [ { - "name": "Amount Payable against Receipt", - "label": "Amount Payable against Receipt", - "function": "Sum", - "aggregate_function_based_on": "base_grand_total", - "doctype": "Number Card", - "document_type": "Purchase Receipt", - "filters_json": json.dumps( - [["Purchase Receipt","status","=","To Bill",False], - ["Purchase Receipt","company","=", company.name, False], - ["Purchase Receipt", "posting_date", "Between", [start_date,end_date], False]] - ), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "name": "Amount Receivable against Delivery", - "label": "Amount Receivable against Delivery", - "function": "Sum", - "aggregate_function_based_on": "base_grand_total", - "doctype": "Number Card", - "document_type": "Delivery Note", - "filters_json": json.dumps( - [["Delivery Note","company","=",company.name,False], - ["Delivery Note","status","=","To Bill",False], - ["Delivery Note", "posting_date", "Between", [start_date,end_date], False]] - ), - "is_public": 1, - "owner": "Administrator", - "show_percentage_stats": 1, - "stats_time_interval": "Daily" - }, - { - "name": "Purchase Receipts to Bill", - "label": "Purchase Receipts to Bill", + "name": "Total Active Items", + "label": _("Total Active Items"), "function": "Count", "doctype": "Number Card", - "document_type": "Purchase Receipt", - "filters_json": json.dumps( - [["Purchase Receipt","status","=","To Bill",False], - ["Purchase Receipt","company","=", company.name, False], - ["Purchase Receipt", "posting_date", "Between", [start_date,end_date], False]] - ), + "document_type": "Item", + "filters_json": json.dumps([["Item", "disabled", "=", 0]]), "is_public": 1, "owner": "Administrator", "show_percentage_stats": 1, - "stats_time_interval": "Daily" + "stats_time_interval": "Monthly" }, { - "name": "Delivery Notes to Bill", - "label": "Delivery Notes to Bill", + "name": "Total Warehouses", + "label": _("Total Warehouses"), "function": "Count", "doctype": "Number Card", - "document_type": "Delivery Note", - "filters_json": json.dumps( - [["Delivery Note","company","=",company.name,False], - ["Delivery Note","status","=","To Bill",False], - ["Delivery Note", "posting_date", "Between", [start_date,end_date], False]] - ), + "document_type": "Warehouse", + "filters_json": json.dumps([["Warehouse", "disabled", "=", 0]]), + "is_public": 1, + "owner": "Administrator", + "show_percentage_stats": 1, + "stats_time_interval": "Monthly" + }, + { + "name": "Total Stock Value", + "label": _("Total Stock Value"), + "function": "Sum", + "aggregate_function_based_on": "stock_value", + "doctype": "Number Card", + "document_type": "Bin", + "filters_json": json.dumps([]), "is_public": 1, "owner": "Administrator", "show_percentage_stats": 1, diff --git a/erpnext/stock/desk_page/stock/stock.json b/erpnext/stock/desk_page/stock/stock.json index 6b93449ecd..4506664c1e 100644 --- a/erpnext/stock/desk_page/stock/stock.json +++ b/erpnext/stock/desk_page/stock/stock.json @@ -54,10 +54,11 @@ "docstatus": 0, "doctype": "Desk Page", "extends_another_page": 0, + "hide_custom": 0, "idx": 0, "is_standard": 1, "label": "Stock", - "modified": "2020-05-15 04:11:36.326013", + "modified": "2020-05-19 17:36:08.185652", "modified_by": "Administrator", "module": "Stock", "name": "Stock", @@ -112,6 +113,11 @@ "label": "Stock Balance", "link_to": "Stock Balance", "type": "Report" + }, + { + "label": "Stock Dashboard", + "link_to": "Stock", + "type": "Dashboard" } ], "shortcuts_label": "Quick Access" diff --git a/erpnext/stock/module_onboarding/stock/stock.json b/erpnext/stock/module_onboarding/stock/stock.json index 5208dcbbf8..de24575a14 100644 --- a/erpnext/stock/module_onboarding/stock/stock.json +++ b/erpnext/stock/module_onboarding/stock/stock.json @@ -19,21 +19,18 @@ "documentation_url": "https://docs.erpnext.com/docs/user/manual/en/stock", "idx": 0, "is_complete": 0, - "modified": "2020-05-19 13:13:19.157316", + "modified": "2020-05-19 19:03:23.602423", "modified_by": "Administrator", "module": "Stock", "name": "Stock", "owner": "Administrator", "steps": [ { - "step": "Create a Warehouse" + "step": "Setup your Warehouse" }, { "step": "Create a Product" }, - { - "step": "Stock Settings" - }, { "step": "Introduction to Stock Entry" }, @@ -41,10 +38,13 @@ "step": "Create a Stock Entry" }, { - "step": "Introduction to Price List and Item Price" + "step": "Create a Supplier" }, { - "step": "Create a Price List" + "step": "Create a Purchase Receipt" + }, + { + "step": "Stock Settings" } ], "subtitle": "Inventory, Warehouses, Analysis and more.", diff --git a/erpnext/stock/onboarding_step/create_a_price_list/create_a_price_list.json b/erpnext/stock/onboarding_step/create_a_purchase_receipt/create_a_purchase_receipt.json similarity index 56% rename from erpnext/stock/onboarding_step/create_a_price_list/create_a_price_list.json rename to erpnext/stock/onboarding_step/create_a_purchase_receipt/create_a_purchase_receipt.json index ce5b5ecf86..b7811a46df 100644 --- a/erpnext/stock/onboarding_step/create_a_price_list/create_a_price_list.json +++ b/erpnext/stock/onboarding_step/create_a_purchase_receipt/create_a_purchase_receipt.json @@ -1,6 +1,6 @@ { "action": "Create Entry", - "creation": "2020-05-15 03:26:41.917046", + "creation": "2020-05-19 18:59:13.266713", "docstatus": 0, "doctype": "Onboarding Step", "idx": 0, @@ -8,12 +8,12 @@ "is_mandatory": 0, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-15 03:33:09.305991", + "modified": "2020-05-19 18:59:13.266713", "modified_by": "Administrator", - "name": "Create a Price List", + "name": "Create a Purchase Receipt", "owner": "Administrator", - "reference_document": "Price List", + "reference_document": "Purchase Receipt", "show_full_form": 1, - "title": "Create a Price List", + "title": "Create a Purchase Receipt", "validate_action": 1 } \ No newline at end of file diff --git a/erpnext/stock/onboarding_step/create_a_warehouse/create_a_warehouse.json b/erpnext/stock/onboarding_step/create_a_supplier/create_a_supplier.json similarity index 57% rename from erpnext/stock/onboarding_step/create_a_warehouse/create_a_warehouse.json rename to erpnext/stock/onboarding_step/create_a_supplier/create_a_supplier.json index 3269125efc..7a64224bd4 100644 --- a/erpnext/stock/onboarding_step/create_a_warehouse/create_a_warehouse.json +++ b/erpnext/stock/onboarding_step/create_a_supplier/create_a_supplier.json @@ -1,6 +1,6 @@ { "action": "Create Entry", - "creation": "2020-05-12 18:00:03.027704", + "creation": "2020-05-14 22:09:10.043554", "docstatus": 0, "doctype": "Onboarding Step", "idx": 0, @@ -8,12 +8,12 @@ "is_mandatory": 0, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-12 18:27:44.128737", + "modified": "2020-05-14 22:09:10.043554", "modified_by": "Administrator", - "name": "Create a Warehouse", + "name": "Create a Supplier", "owner": "Administrator", - "reference_document": "Warehouse", + "reference_document": "Supplier", "show_full_form": 0, - "title": "Setup your Purchase Warehouse", + "title": "Create a Supplier", "validate_action": 1 } \ No newline at end of file diff --git a/erpnext/stock/onboarding_step/introduction_to_price_list_and_item_price/introduction_to_price_list_and_item_price.json b/erpnext/stock/onboarding_step/introduction_to_price_list_and_item_price/introduction_to_price_list_and_item_price.json deleted file mode 100644 index f75523ab29..0000000000 --- a/erpnext/stock/onboarding_step/introduction_to_price_list_and_item_price/introduction_to_price_list_and_item_price.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "action": "Watch Video", - "creation": "2020-05-15 03:26:01.386069", - "docstatus": 0, - "doctype": "Onboarding Step", - "idx": 0, - "is_complete": 0, - "is_mandatory": 0, - "is_single": 0, - "is_skipped": 0, - "modified": "2020-05-15 03:31:01.267728", - "modified_by": "Administrator", - "name": "Introduction to Price List and Item Price", - "owner": "Administrator", - "show_full_form": 0, - "title": "Let's take a brief look at Price List and Item Price", - "validate_action": 1, - "video_url": "https://www.youtube.com/watch?v=lY6hAQM1I28" -} \ No newline at end of file diff --git a/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json b/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json index 229bcd49cf..447611fe47 100644 --- a/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json +++ b/erpnext/stock/onboarding_step/introduction_to_stock_entry/introduction_to_stock_entry.json @@ -8,12 +8,12 @@ "is_mandatory": 0, "is_single": 0, "is_skipped": 0, - "modified": "2020-05-15 03:30:39.606147", + "modified": "2020-05-19 18:55:41.457289", "modified_by": "Administrator", "name": "Introduction to Stock Entry", "owner": "Administrator", "show_full_form": 0, - "title": "Introduction to the backbone of Stock, Stock Entry.", + "title": "Introduction to the multi-purpose stock transaction", "validate_action": 1, "video_url": "https://www.youtube.com/watch?v=Njt107hlY3I" } \ No newline at end of file diff --git a/erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json b/erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json new file mode 100644 index 0000000000..557c905bd6 --- /dev/null +++ b/erpnext/stock/onboarding_step/setup_your_warehouse/setup_your_warehouse.json @@ -0,0 +1,20 @@ +{ + "action": "Go to Page", + "creation": "2020-05-19 18:54:19.383397", + "docstatus": 0, + "doctype": "Onboarding Step", + "idx": 0, + "is_complete": 0, + "is_mandatory": 0, + "is_single": 0, + "is_skipped": 0, + "modified": "2020-05-19 18:54:19.383397", + "modified_by": "Administrator", + "name": "Setup your Warehouse", + "owner": "Administrator", + "path": "Tree/Warehouse", + "reference_document": "Warehouse", + "show_full_form": 0, + "title": "Setup your Warehouse", + "validate_action": 1 +} \ No newline at end of file diff --git a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py index 40a639bc09..5a931e7efa 100644 --- a/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py +++ b/erpnext/stock/report/delivery_note_trends/delivery_note_trends.py @@ -40,7 +40,7 @@ def get_chart_data(data, filters): "labels" : labels, "datasets" : [ { - "name": _("Total Revenue"), + "name": _("Total Delivered Amount"), "values": datapoints } ] diff --git a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py index 3b8d8d2dcd..43f1f373d3 100644 --- a/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py +++ b/erpnext/stock/report/purchase_receipt_trends/purchase_receipt_trends.py @@ -40,7 +40,7 @@ def get_chart_data(data, filters): "labels" : labels, "datasets" : [ { - "name": _("Total Expenditure"), + "name": _("Total Received Amount"), "values": datapoints } ] diff --git a/erpnext/stock/report/stock_ageing/stock_ageing.py b/erpnext/stock/report/stock_ageing/stock_ageing.py index c5b8f43f96..af99780155 100644 --- a/erpnext/stock/report/stock_ageing/stock_ageing.py +++ b/erpnext/stock/report/stock_ageing/stock_ageing.py @@ -53,7 +53,7 @@ def get_average_age(fifo_queue, to_date): age_qty += batch_age * 1 total_qty += 1 - return (age_qty / total_qty) if total_qty else 0.0 + return flt(age_qty / total_qty, 2) if total_qty else 0.0 def get_columns(filters): columns = [ @@ -242,6 +242,8 @@ def get_chart_data(data, filters): if filters.get("show_warehouse_wise_stock"): return {} + data.sort(key = lambda row: row[6], reverse=True) + if len(data) > 10: data = data[:10]