Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1022 error on trial balance #1024

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions erpnext/accounts/report/trial_balance/trial_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import frappe
from frappe import _
from frappe.boot import DocType
from frappe.query_builder.functions import Sum
from frappe.utils import add_days, cstr, flt, formatdate, getdate

Expand Down Expand Up @@ -143,13 +144,23 @@ def get_rootwise_opening_balances(filters, report_type):
)

if not ignore_closing_balances:
last_period_closing_voucher = frappe.db.get_all(
"Period Closing Voucher",
filters={"docstatus": 1, "company": filters.company, "period_end_date": ("<", filters.from_date)},
fields=["period_end_date", "name"],
order_by="period_end_date desc",
limit=1,
PeriodClosingVoucher = DocType('Period Closing Voucher')

query = (
frappe.qb.from_(PeriodClosingVoucher)
.select(
PeriodClosingVoucher.period_end_date,
PeriodClosingVoucher.name
)
.where(
(PeriodClosingVoucher.docstatus == 1) &
(PeriodClosingVoucher.company == filters.company) &
(PeriodClosingVoucher.period_end_date < filters.from_date)
)
.orderby(PeriodClosingVoucher.period_end_date, order=frappe.qb.desc)
.limit(1)
)
last_period_closing_voucher = query.run()

accounting_dimensions = get_accounting_dimensions(as_list=False)

Expand Down
Loading