This commit is contained in:
yumoqing 2026-04-10 20:45:55 +08:00
parent 78ef190c9d
commit 8613abf6c0
2 changed files with 11 additions and 6 deletions

View File

@ -151,13 +151,14 @@ class Accounting:
acc_balance = l['acc'].balance
if l['acc_dir'] != l['balance_at']:
acc_balance -= l['amount']
l['balance_amount'] = -l['amount']
else:
acc_balance += l['amount']
l['balance_amount'] = l['amount']
if acc_balance < 0.000001:
e = AccountOverDraw(curacc, l['acc'].balance, l['amount'])
exception(f'{e},{legs=}')
raise e
l['new_balance'] = acc_balance
if l['acc_dir'] == DEBT:
debt_balance += l['amount']
else:
@ -206,20 +207,23 @@ class Accounting:
# write acc_balance
sql = """select * from acc_balance
where accountid=${accid}$
and acc_date = ${curdate}$"""
and acc_date = ${curdate}$ for update"""
recs = await sor.sqlExe(sql, {'accid':accid, 'curdate':self.curdate})
new_balance = 0
if len(recs) == 0:
ns = {
'id':getID(),
'accountid':accid,
'acc_date':self.curdate,
'balance':leg['new_balance']
'balance':leg['balance_amount']
}
await sor.C('acc_balance', ns.copy())
new_balance = leg['balance_amount']
else:
ns = recs[0]
ns['balance'] = leg['new_balance']
ns['balance'] += leg['balance_amount']
await sor.U('acc_balance', ns.copy())
new_balance = ns['balance']
# summary = self.summary
ns = {
@ -256,8 +260,9 @@ where accountid=${accid}$
'acc_dir':leg['acc_dir'],
'summary':self.summary,
'amount':leg['amount'],
'balance':leg['new_balance'],
'balance':new_balance,
'acclogid':logid
}
await sor.C('acc_detail', ns.copy())
await sor.U('account', {id: accid, 'balance': new_balance})

View File

@ -89,7 +89,7 @@
"target":"PopupWindow",
"popup_options":{
"icon":"{{entire_url('imgs/accdetail.svg')}}",
"title":"充值",
"title":"明细",
{% if params_kw._is_mobile %}
"width":"100%",
"height":"95%"