diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index 59899ea..ac6f26a 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -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}) diff --git a/wwwroot/myaccounts.ui b/wwwroot/myaccounts.ui index a0ab4e3..ee5600c 100644 --- a/wwwroot/myaccounts.ui +++ b/wwwroot/myaccounts.ui @@ -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%"