Fixed the sign of the amount in income statement.

This commit is contained in:
依瑪貓 2023-03-07 23:15:46 +08:00
parent 9f1e724875
commit 3c200d0dc6

View File

@ -272,8 +272,8 @@ class IncomeStatement:
if self.__period.end is not None: if self.__period.end is not None:
conditions.append(Transaction.date <= self.__period.end) conditions.append(Transaction.date <= self.__period.end)
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_balance: sa.Select \ select_balance: sa.Select \
= sa.select(JournalEntry.account_id, balance_func)\ = sa.select(JournalEntry.account_id, balance_func)\
.join(Transaction).join(Account)\ .join(Transaction).join(Account)\