mirror of
https://github.com/frappe/erpnext.git
synced 2026-11-15 21:20:55 +00:00
fix: refresh company total monthly sales on daily and monthly frequency
(cherry picked from commit 204a20037ca18890b133a732cf42035b3fe219ba)
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
},
|
||||
{
|
||||
"default": "Each Transaction",
|
||||
"description": "How often should Project and Company be updated based on Sales Transactions?",
|
||||
"description": "How often should Project and Company be updated based on Sales Transactions? Daily refreshes nightly; Monthly refreshes on the 1st of each month.",
|
||||
"fieldname": "sales_update_frequency",
|
||||
"fieldtype": "Select",
|
||||
"label": "Sales Update Frequency in Company and Project",
|
||||
|
||||
@@ -838,13 +838,26 @@ def update_transactions_annual_history(company, commit=False):
|
||||
|
||||
|
||||
def cache_companies_monthly_sales_history():
|
||||
refresh_total_monthly_sales = _should_refresh_total_monthly_sales()
|
||||
companies = [d["name"] for d in frappe.get_list("Company")]
|
||||
for company in companies:
|
||||
update_company_monthly_sales(company)
|
||||
update_transactions_annual_history(company)
|
||||
if refresh_total_monthly_sales:
|
||||
update_company_current_month_sales(company)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
def _should_refresh_total_monthly_sales():
|
||||
# "Each Transaction" updates on submit; refresh the cached figure for the
|
||||
# scheduled frequencies only ("Monthly" just on the 1st).
|
||||
frequency = frappe.get_single_value("Selling Settings", "sales_update_frequency")
|
||||
if frequency == "Monthly":
|
||||
return frappe.utils.now_datetime().day == 1
|
||||
return frequency == "Daily"
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children(doctype, parent=None, company=None, is_root=False):
|
||||
if parent is None or parent == "All Companies":
|
||||
|
||||
Reference in New Issue
Block a user