diff --git a/accounting/init.py b/accounting/init.py index a47ac48..5721684 100644 --- a/accounting/init.py +++ b/accounting/init.py @@ -19,16 +19,10 @@ async def all_my_accounts(request): b.id, a.name, b.balance_at, -case when c.balance is null then 0.00 else c.balance end as balance +b.balance from subject a, - account b left join - ( - select a.* - from acc_balance a, - (select accountid, max(acc_date) max_date from acc_balance group by accountid) b - where a.accountid=b.accountid and a.acc_date=b.max_date - ) c on c.accountid = b.id + account b where b.subjectid = a.id and b.orgid = ${orgid}$ """