Skip to content

Commit

Permalink
fix: Trailing opening entries in Accounts closing balance (#36175)
Browse files Browse the repository at this point in the history
fix: Trailing opening entries in Accounts closing balance (#36175)

(cherry picked from commit fbea61b)

Co-authored-by: Deepesh Garg <deepeshgarg6@gmail.com>
  • Loading branch information
mergify[bot] and deepeshgarg007 authored Jul 18, 2023
1 parent ea66f18 commit 8a607db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ 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(
_("The GL Entries will be processed in the background, it can take a few minutes."),
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 = []
Expand Down Expand Up @@ -321,15 +323,15 @@ 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,
)
from erpnext.accounts.general_ledger import make_gl_entries

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"
)
Expand Down
7 changes: 3 additions & 4 deletions erpnext/patches/v14_0/update_closing_balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 8a607db

Please sign in to comment.