fix: Trailing opening entries in Accounts closing balance (#36175)

This commit is contained in:
Deepesh Garg 2023-07-18 15:16:52 +05:30 committed by GitHub
parent 07d2b896c1
commit fbea61bbc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View File

@ -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

View File

@ -133,6 +133,8 @@ class PeriodClosingVoucher(AccountsController):
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 @@ class PeriodClosingVoucher(AccountsController):
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 @@ class PeriodClosingVoucher(AccountsController):
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"
)

View File

@ -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