Skip to content

Commit

Permalink
fix: annual income and expenses in digest
Browse files Browse the repository at this point in the history
(cherry picked from commit 52305e3)

# Conflicts:
#	erpnext/accounts/utils.py
  • Loading branch information
GursheenK authored and mergify[bot] committed Nov 24, 2023
1 parent 7601861 commit 7dce68b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions erpnext/accounts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion erpnext/setup/doctype/email_digest/email_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ def get_year_to_date_balance(self, root_type, fieldname):
"""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":
Expand Down

0 comments on commit 7dce68b

Please sign in to comment.