fix: Assets module onboarding and dashboard
This commit is contained in:
parent
4f024128af
commit
054aafa1d7
@ -3,7 +3,10 @@
|
||||
|
||||
import frappe
|
||||
import json
|
||||
from frappe.utils import nowdate, add_months
|
||||
from frappe.utils import nowdate, add_months, get_date_str
|
||||
from frappe import _
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
|
||||
|
||||
def get_data():
|
||||
return frappe._dict({
|
||||
@ -20,17 +23,25 @@ def get_dashboards():
|
||||
{ "chart": "Asset Value Analytics", "width": "Full" },
|
||||
{ "chart": "Category-wise Asset Value", "width": "Half" },
|
||||
{ "chart": "Location-wise Asset Value", "width": "Half" },
|
||||
]
|
||||
],
|
||||
"cards": [
|
||||
{"card": "Total Assets"},
|
||||
{"card": "New Assets (This Year)"},
|
||||
{"card": "Asset Value"}
|
||||
]
|
||||
}]
|
||||
|
||||
fiscal_year = get_fiscal_year(date=nowdate())
|
||||
year_start_date = get_date_str(fiscal_year[1])
|
||||
year_end_date = get_date_str(fiscal_year[2])
|
||||
|
||||
|
||||
def get_charts():
|
||||
company = get_company_for_dashboards()
|
||||
fiscal_year = get_fiscal_year()
|
||||
|
||||
return [
|
||||
{
|
||||
"name": "Asset Value Analytics",
|
||||
"chart_name": "Asset Value Analytics",
|
||||
"chart_name": _("Asset Value Analytics"),
|
||||
"chart_type": "Report",
|
||||
"report_name": "Fixed Asset Register",
|
||||
"is_custom": 1,
|
||||
@ -44,10 +55,10 @@ def get_charts():
|
||||
"company": company,
|
||||
"status": "In Location",
|
||||
"filter_based_on": "Fiscal Year",
|
||||
"from_fiscal_year": fiscal_year,
|
||||
"to_fiscal_year": fiscal_year,
|
||||
"period_start_date": add_months(nowdate(), -12),
|
||||
"period_end_date": nowdate(),
|
||||
"from_fiscal_year": fiscal_year[0],
|
||||
"to_fiscal_year": fiscal_year[0],
|
||||
"period_start_date": year_start_date,
|
||||
"period_end_date": year_end_date,
|
||||
"date_based_on": "Purchase Date",
|
||||
"group_by": "--Select a group--"
|
||||
}),
|
||||
@ -63,7 +74,7 @@ def get_charts():
|
||||
},
|
||||
{
|
||||
"name": "Category-wise Asset Value",
|
||||
"chart_name": "Category-wise Asset Value",
|
||||
"chart_name": _("Category-wise Asset Value"),
|
||||
"chart_type": "Report",
|
||||
"report_name": "Fixed Asset Register",
|
||||
"x_field": "asset_category",
|
||||
@ -125,9 +136,33 @@ def get_charts():
|
||||
|
||||
def get_number_cards():
|
||||
return [
|
||||
{
|
||||
"name": "Total Assets",
|
||||
"label": _("Total Assets"),
|
||||
"function": "Count",
|
||||
"document_type": "Asset",
|
||||
"is_public": 1,
|
||||
"show_percentage_stats": 1,
|
||||
"stats_time_interval": "Monthly",
|
||||
"filters_json": "[]",
|
||||
"doctype": "Number Card",
|
||||
},
|
||||
{
|
||||
"name": "New Assets (This Year)",
|
||||
"label": _("New Assets (This Year)"),
|
||||
"function": "Count",
|
||||
"document_type": "Asset",
|
||||
"is_public": 1,
|
||||
"show_percentage_stats": 1,
|
||||
"stats_time_interval": "Monthly",
|
||||
"filters_json": json.dumps([
|
||||
['Asset', 'creation', 'between', [year_start_date, year_end_date]]
|
||||
]),
|
||||
"doctype": "Number Card",
|
||||
},
|
||||
{
|
||||
"name": "Asset Value",
|
||||
"label": "Asset Value",
|
||||
"label": _("Asset Value"),
|
||||
"function": "Sum",
|
||||
"aggregate_function_based_on": "value_after_depreciation",
|
||||
"document_type": "Asset",
|
||||
@ -135,7 +170,7 @@ def get_number_cards():
|
||||
"show_percentage_stats": 1,
|
||||
"stats_time_interval": "Monthly",
|
||||
"filters_json": "[]",
|
||||
"doctype": "Number Card",
|
||||
"doctype": "Number Card"
|
||||
}
|
||||
]
|
||||
|
||||
@ -148,13 +183,3 @@ def get_company_for_dashboards():
|
||||
if company_list:
|
||||
return company_list[0].name
|
||||
return None
|
||||
|
||||
def get_fiscal_year():
|
||||
fiscal_year = frappe.defaults.get_defaults().fiscal_year
|
||||
if fiscal_year:
|
||||
return fiscal_year
|
||||
else:
|
||||
fiscal_year_list = frappe.get_list("Fiscal Year")
|
||||
if fiscal_year_list:
|
||||
return fiscal_year_list[0].name
|
||||
return None
|
@ -29,10 +29,11 @@
|
||||
"docstatus": 0,
|
||||
"doctype": "Desk Page",
|
||||
"extends_another_page": 0,
|
||||
"hide_custom": 0,
|
||||
"idx": 0,
|
||||
"is_standard": 1,
|
||||
"label": "Assets",
|
||||
"modified": "2020-05-12 17:35:14.770662",
|
||||
"modified": "2020-05-20 18:05:23.994795",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Assets",
|
||||
@ -55,6 +56,11 @@
|
||||
"label": "Fixed Asset Register",
|
||||
"link_to": "Fixed Asset Register",
|
||||
"type": "Report"
|
||||
},
|
||||
{
|
||||
"label": "Assets Dashboard",
|
||||
"link_to": "Asset",
|
||||
"type": "Dashboard"
|
||||
}
|
||||
]
|
||||
}
|
@ -26,10 +26,13 @@
|
||||
"step": "Create a Fixed Asset Item"
|
||||
},
|
||||
{
|
||||
"step": "Purchase the Asset Item"
|
||||
"step": "Create an Asset Category"
|
||||
},
|
||||
{
|
||||
"step": "Create the Asset"
|
||||
"step": "Purchase an Asset Item"
|
||||
},
|
||||
{
|
||||
"step": "Create an Asset"
|
||||
}
|
||||
],
|
||||
"subtitle": "Assets, Depreciations, Repairs and more",
|
||||
|
@ -9,8 +9,8 @@
|
||||
"is_skipped": 0,
|
||||
"modified": "2020-05-08 13:21:53.332538",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Create the Asset",
|
||||
"name": "Create an Asset",
|
||||
"owner": "Administrator",
|
||||
"reference_document": "Asset",
|
||||
"title": "Create the Asset"
|
||||
"title": "Create an Asset"
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"action": "Create Entry",
|
||||
"creation": "2020-05-08 13:21:53.332538",
|
||||
"docstatus": 0,
|
||||
"doctype": "Onboarding Step",
|
||||
"idx": 0,
|
||||
"is_complete": 0,
|
||||
"is_mandatory": 0,
|
||||
"is_skipped": 0,
|
||||
"modified": "2020-05-08 13:21:53.332538",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Create an Asset Category",
|
||||
"owner": "Administrator",
|
||||
"reference_document": "Asset Category",
|
||||
"title": "Create an Asset Category"
|
||||
}
|
@ -9,8 +9,8 @@
|
||||
"is_skipped": 0,
|
||||
"modified": "2020-05-08 13:21:28.208059",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Purchase the Asset Item",
|
||||
"name": "Purchase an Asset Item",
|
||||
"owner": "Administrator",
|
||||
"reference_document": "Purchase Receipt",
|
||||
"title": "Purchase the Asset Item"
|
||||
"title": "Purchase an Asset Item"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user