From 7dce68bdccb73e9e0b5e0d92abeba9ce7b474b61 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Wed, 22 Nov 2023 18:38:33 +0530 Subject: [PATCH 1/3] fix: annual income and expenses in digest (cherry picked from commit 52305e3000decb84aad1a99557e13a0bb2b68ec4) # Conflicts: # erpnext/accounts/utils.py --- erpnext/accounts/utils.py | 7 +++++++ erpnext/setup/doctype/email_digest/email_digest.py | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index bd917e5edef..c78c8944db3 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -179,6 +179,11 @@ def get_balance_on( in_account_currency=True, cost_center=None, ignore_account_permission=False, +<<<<<<< HEAD +======= + account_type=None, + start_date=None, +>>>>>>> 52305e3000 (fix: annual income and expenses in digest) ): if not account and frappe.form_dict.get("account"): account = frappe.form_dict.get("account") @@ -192,6 +197,8 @@ def get_balance_on( cost_center = frappe.form_dict.get("cost_center") cond = ["is_cancelled=0"] + if start_date: + cond.append("posting_date >= %s" % frappe.db.escape(cstr(start_date))) if date: cond.append("posting_date <= %s" % frappe.db.escape(cstr(date))) else: diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index 4fc20e61036..b9e225728e8 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -382,9 +382,10 @@ class EmailDigest(Document): """Get income to date""" balance = 0.0 count = 0 + fy_start_date = get_fiscal_year().get("year_start_date") for account in self.get_root_type_accounts(root_type): - balance += get_balance_on(account, date=self.future_to_date) + balance += get_balance_on(account, date=self.future_to_date, start_date=fy_start_date) count += get_count_on(account, fieldname, date=self.future_to_date) if fieldname == "income": From b0aa4efd3da478fb6940687406c744a0698dd0b9 Mon Sep 17 00:00:00 2001 From: Gursheen Anand Date: Wed, 22 Nov 2023 19:28:57 +0530 Subject: [PATCH 2/3] fix: fiscal year using future date (cherry picked from commit 728cc9f725264e057d9331362b256ea8d0f80b83) --- erpnext/setup/doctype/email_digest/email_digest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py index b9e225728e8..6ed44fff686 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.py +++ b/erpnext/setup/doctype/email_digest/email_digest.py @@ -382,7 +382,7 @@ class EmailDigest(Document): """Get income to date""" balance = 0.0 count = 0 - fy_start_date = get_fiscal_year().get("year_start_date") + fy_start_date = get_fiscal_year(self.future_to_date)[1] for account in self.get_root_type_accounts(root_type): balance += get_balance_on(account, date=self.future_to_date, start_date=fy_start_date) From aea169d4d47df960c1ed3329ddc59cfa462e1f53 Mon Sep 17 00:00:00 2001 From: Gursheen Kaur Anand <40693548+GursheenK@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:30:19 +0530 Subject: [PATCH 3/3] chore: resolve conflicts --- erpnext/accounts/utils.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index c78c8944db3..2836056b0c9 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -179,11 +179,7 @@ def get_balance_on( in_account_currency=True, cost_center=None, ignore_account_permission=False, -<<<<<<< HEAD -======= - account_type=None, start_date=None, ->>>>>>> 52305e3000 (fix: annual income and expenses in digest) ): if not account and frappe.form_dict.get("account"): account = frappe.form_dict.get("account")