Renamed the variable select_trial_balance to select_balances in the __query_balances method of the TrialBalance report.

This commit is contained in:
依瑪貓 2023-03-07 08:27:52 +08:00
parent d7ac8a3dcf
commit 81fbb380b4

View File

@ -510,13 +510,13 @@ class TrialBalance(Report[TrialBalanceRow]):
balance_func: sa.Function = sa.func.sum(sa.case( balance_func: sa.Function = sa.func.sum(sa.case(
(JournalEntry.is_debit, JournalEntry.amount), (JournalEntry.is_debit, JournalEntry.amount),
else_=-JournalEntry.amount)).label("balance") else_=-JournalEntry.amount)).label("balance")
select_trial_balance: sa.Select \ select_balances: sa.Select \
= sa.select(JournalEntry.account_id, balance_func)\ = sa.select(JournalEntry.account_id, balance_func)\
.join(Transaction).join(Account)\ .join(Transaction).join(Account)\
.filter(*conditions)\ .filter(*conditions)\
.group_by(JournalEntry.account_id)\ .group_by(JournalEntry.account_id)\
.order_by(Account.base_code, Account.no) .order_by(Account.base_code, Account.no)
balances: list[sa.Row] = db.session.execute(select_trial_balance).all() balances: list[sa.Row] = db.session.execute(select_balances).all()
accounts: dict[int, Account] \ accounts: dict[int, Account] \
= {x.id: x for x in Account.query = {x.id: x for x in Account.query
.filter(Account.id.in_([x.account_id for x in balances])).all()} .filter(Account.id.in_([x.account_id for x in balances])).all()}