From afc2d957363b33ee552b5730a04044da6c2f7c30 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 21 Oct 2025 11:06:02 +0530 Subject: [PATCH] fix: correct monthly sales history (backport #50056) (#50179) fix: correct monthly sales history (#50056) * fix: correct monthly sales history * fix: correct monthly sales history calculation * chore: remove unrelated file accidentally committed --------- (cherry picked from commit f51ed30c23146cca7f98c7789b0e6ea394af144f) Co-authored-by: Ahmed AbuKhatwa <82771130+AhmedAbokhatwa@users.noreply.github.com> Co-authored-by: AhmedAbukhatwa --- erpnext/setup/doctype/company/company.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py index e5f26073a33..eb1e33acafe 100644 --- a/erpnext/setup/doctype/company/company.py +++ b/erpnext/setup/doctype/company/company.py @@ -763,13 +763,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))