From 4f20a94f60dd0da3b43caae6f991592d701e58e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 17 Jan 2024 13:04:29 +0100 Subject: [PATCH] fix some func to get balance --- flaschengeist/plugins/balance/balance_controller.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/flaschengeist/plugins/balance/balance_controller.py b/flaschengeist/plugins/balance/balance_controller.py index 5201d76..82aa6f7 100644 --- a/flaschengeist/plugins/balance/balance_controller.py +++ b/flaschengeist/plugins/balance/balance_controller.py @@ -36,7 +36,7 @@ def get_limit(user: User) -> float: def get_balance(user, start: datetime = None, end: datetime = None): - query = db.session.query(func.sum(Transaction.amount)) + query = db.session.query(func.sum(Transaction._amount)) if start: query = query.filter(start <= Transaction.time) if end: @@ -75,8 +75,8 @@ def get_balances( @debit.expression def debit(cls): a = ( - db.select(func.sum(Transaction.amount)) - .where(cls.id_ == Transaction._sender_id, Transaction.amount) + db.select(func.sum(Transaction._amount)) + .where(cls.id_ == Transaction._sender_id, Transaction._amount) .scalar_subquery() ) return case([(a, a)], else_=0) @@ -88,8 +88,8 @@ def get_balances( @credit.expression def credit(cls): b = ( - db.select(func.sum(Transaction.amount)) - .where(cls.id_ == Transaction._receiver_id, Transaction.amount) + db.select(func.sum(Transaction._amount)) + .where(cls.id_ == Transaction._receiver_id, Transaction._amount) .scalar_subquery() ) return case([(b, b)], else_=0)