diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index 347bcc61ccbd201f34165fa16167a7d580f591a7..f86305435ffb13ddd0fba7c807de3692abbbd5af 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -797,13 +797,11 @@ def update_company_current_month_sales(company): def update_company_monthly_sales(company): """Cache past year monthly sales of every company based on sales invoices""" - import json - from frappe.utils.goal import get_monthly_results - filter_str = f"company = {frappe.db.escape(company)} and status != 'Draft' and docstatus=1" + filter_dict = {"company": company, "status": ["!=", "Draft"], "docstatus": 1} month_to_value_dict = get_monthly_results( - "Sales Invoice", "base_grand_total", "posting_date", filter_str, "sum" + "Sales Invoice", "base_grand_total", "posting_date", filter_dict, "sum" ) frappe.db.set_value("Company", company, "sales_monthly_history", json.dumps(month_to_value_dict))