This commit is contained in:
yumoqing 2026-03-25 17:15:55 +08:00
parent a967858d75
commit 4216ffc20b

View File

@ -1,22 +1,22 @@
userid = await get_user() userid = await get_user()
userorgid = await get_userorgid() userorgid = await get_userorgid()
async with get_sor_context(request._run_ns, 'accounting') as sor: async with get_sor_context(request._run_ns, 'accounting') as sor:
sql = """select b.id, a.name, b.balance_at, c.balance from sql = """select b.id, a.name, b.balance_at, c.balance from
subject a, account b, subject a, account b,
(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 (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
where c.accountid = b.id where c.accountid = b.id
and b.subjectid = a.id and b.subjectid = a.id
and b.orgid = ${orgid}$ and b.orgid = ${orgid}$
""" """
ns = {'orgid': userorgid} ns = {'orgid': userorgid}
recs = await sor.sqlExe(sql, ns) recs = await sor.sqlExe(sql, ns)
data = [] data = []
for r in recs: for r in recs:
data.append({ data.append({
'account': r.name, 'account': r.name,
'balance': r.balance 'balance': r.balance
}) })
return { return {
'status': 'ok', 'status': 'ok',
'data': data 'data': data
} }