This commit is contained in:
yumoqing 2026-04-14 10:56:02 +08:00
parent 656205bac2
commit a833fa6790

View File

@ -216,19 +216,20 @@ class Accounting:
where accountid=${accid}$ where accountid=${accid}$
and acc_date = ${curdate}$ for update""" and acc_date = ${curdate}$ for update"""
recs = await sor.sqlExe(sql, {'accid':accid, 'curdate':self.curdate}) recs = await sor.sqlExe(sql, {'accid':accid, 'curdate':self.curdate})
new_balance = 0 new_balance = 0.0
if len(recs) == 0: if len(recs) == 0:
r = recs[0]
ns = { ns = {
'id':getID(), 'id':getID(),
'accountid':accid, 'accountid':accid,
'acc_date':self.curdate, 'acc_date':self.curdate,
'balance':leg['balance_amount'] 'balance':account.balance + leg['balance_amount']
} }
await sor.C('acc_balance', ns.copy()) await sor.C('acc_balance', ns.copy())
new_balance = leg['balance_amount'] new_balance = leg['balance_amount']
else: else:
ns = recs[0] ns = recs[0]
ns['balance'] += leg['balance_amount'] ns['balance'] += account.balance + leg['balance_amount']
await sor.U('acc_balance', ns.copy()) await sor.U('acc_balance', ns.copy())
new_balance = ns['balance'] new_balance = ns['balance']
@ -275,6 +276,6 @@ where accountid=${accid}$
await sor.U('account', { await sor.U('account', {
'id': accid, 'id': accid,
'max_detailno': account.max_detailno + 1, 'max_detailno': account.max_detailno + 1,
'balance': new_balance 'balance': account.balance + leg['balance_amount']
}) })