Revised the __set_data method of the trial balance and the __query_balances of the income statement for consistency.

This commit is contained in:
2023-03-09 10:49:11 +08:00
parent ed7a8ac0fd
commit 8abe20dba5
2 changed files with 8 additions and 10 deletions

View File

@ -191,11 +191,10 @@ class TrialBalance(BaseReport):
balance_func: sa.Function = sa.func.sum(sa.case(
(JournalEntry.is_debit, JournalEntry.amount),
else_=-JournalEntry.amount)).label("balance")
select_balances: sa.Select \
= sa.select(Account.id, balance_func)\
select_balances: sa.Select = sa.select(Account.id, balance_func)\
.join(Transaction).join(Account)\
.filter(*conditions)\
.group_by(JournalEntry.account_id)\
.group_by(Account.id)\
.order_by(Account.base_code, Account.no)
balances: list[sa.Row] = db.session.execute(select_balances).all()
accounts: dict[int, Account] \