From 8a607db493212414a2c74704930b3aef2c15087a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:20:11 +0530 Subject: [PATCH] fix: Trailing opening entries in Accounts closing balance (#36175) fix: Trailing opening entries in Accounts closing balance (#36175) (cherry picked from commit fbea61bbc60a723c07595a8ae8e30982205388df) Co-authored-by: Deepesh Garg --- .../account_closing_balance/account_closing_balance.py | 4 +--- .../period_closing_voucher/period_closing_voucher.py | 8 +++++--- erpnext/patches/v14_0/update_closing_balances.py | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py b/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py index 7c842372de81..ea67051fb49a 100644 --- a/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py +++ b/erpnext/accounts/doctype/account_closing_balance/account_closing_balance.py @@ -14,10 +14,8 @@ class AccountClosingBalance(Document): pass -def make_closing_entries(closing_entries, voucher_name): +def make_closing_entries(closing_entries, voucher_name, company, closing_date): accounting_dimensions = get_accounting_dimensions() - company = closing_entries[0].get("company") - closing_date = closing_entries[0].get("closing_date") previous_closing_entries = get_previous_closing_entries( company, closing_date, accounting_dimensions diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index 641f4528c534..922722f04d3e 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -133,6 +133,8 @@ def make_gl_entries(self, get_opening_entries=False): gl_entries=gl_entries, closing_entries=closing_entries, voucher_name=self.name, + company=self.company, + closing_date=self.posting_date, queue="long", ) frappe.msgprint( @@ -140,7 +142,7 @@ def make_gl_entries(self, get_opening_entries=False): alert=True, ) else: - process_gl_entries(gl_entries, closing_entries, voucher_name=self.name) + process_gl_entries(gl_entries, closing_entries, self.name, self.company, self.posting_date) def get_grouped_gl_entries(self, get_opening_entries=False): closing_entries = [] @@ -321,7 +323,7 @@ def get_balances_based_on_dimensions( return query.run(as_dict=1) -def process_gl_entries(gl_entries, closing_entries, voucher_name=None): +def process_gl_entries(gl_entries, closing_entries, voucher_name, company, closing_date): from erpnext.accounts.doctype.account_closing_balance.account_closing_balance import ( make_closing_entries, ) @@ -329,7 +331,7 @@ def process_gl_entries(gl_entries, closing_entries, voucher_name=None): try: make_gl_entries(gl_entries, merge_entries=False) - make_closing_entries(gl_entries + closing_entries, voucher_name=voucher_name) + make_closing_entries(gl_entries + closing_entries, voucher_name, company, closing_date) frappe.db.set_value( "Period Closing Voucher", gl_entries[0].get("voucher_no"), "gle_processing_status", "Completed" ) diff --git a/erpnext/patches/v14_0/update_closing_balances.py b/erpnext/patches/v14_0/update_closing_balances.py index 2947b98740b5..2c842814839c 100644 --- a/erpnext/patches/v14_0/update_closing_balances.py +++ b/erpnext/patches/v14_0/update_closing_balances.py @@ -69,7 +69,6 @@ def execute(): entries = gl_entries + closing_entries - if entries: - make_closing_entries(entries, voucher_name=pcv.name) - i += 1 - company_wise_order[pcv.company].append(pcv.posting_date) + make_closing_entries(entries, pcv.name, pcv.company, pcv.posting_date) + company_wise_order[pcv.company].append(pcv.posting_date) + i += 1