billid = params_kw.get('billid') print(f'{billid=}') db = DBPools() async with db.sqlorContext('kboss') as sor: sql1 = """select * from bill_detail where billid=${billid}$ order by accounting_orgid, participantid, subjectname """ sql2 = """select a.* from account a, subject b where a.subjectid = b.id and a.accounting_orgid=${accounting_orgid}$ and a.orgid=${participantid}$ and b.name=${subjectname}$ and a.del_flg='0' and b.del_flg = '0' """ rets = [] recs = await sor.sqlExe(sql1, {'billid':billid}) for r in recs: accs = await sor.sqlExe(sql2, r.copy()) for acc in accs: ret = await getAccountInfo(sor, acc['id']) ret['balance_at'] = '借' if acc['balance_at'] == '0' else '贷' ret['accounting_dir'] = r['accounting_dir'] ret['amount'] = r['amount'] print(f'{acc=}') rets.append(ret) return { "total":len(rets), "rows":rets } return { "total":0, "rows":[] }