mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 04:28:27 +00:00
fix: correct monthly sales history (#50056)
* fix: correct monthly sales history * fix: correct monthly sales history calculation * chore: remove unrelated file accidentally committed --------- Co-authored-by: AhmedAbukhatwa <Ahmedabukhatwa1@gmail.com>
This commit is contained in:
@@ -790,13 +790,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))
|
||||
|
||||
Reference in New Issue
Block a user