bugfix
This commit is contained in:
parent
4882b1f8a1
commit
cc8cb54a8a
@ -199,6 +199,13 @@ class Accounting:
|
||||
async def leg_accounting(self, sor, leg):
|
||||
# print(f'leg_accounting(), {leg=}')
|
||||
accid = leg['accid']
|
||||
sql = "select * from account where id=${accid}$ for update"
|
||||
accounts = await sor.sqlExe(sql, {'accid': accid})
|
||||
if len(accounts) == 0:
|
||||
e = Exception(f'{accid} account not exist')
|
||||
exception(f'{e}')
|
||||
raise e
|
||||
account = accounts[0]
|
||||
if leg['amount'] < 0.00001:
|
||||
return
|
||||
subjects = await sor.R('subject', {'id': leg['subjectid']})
|
||||
@ -255,6 +262,7 @@ where accountid=${accid}$
|
||||
ns = {
|
||||
'id':getID(),
|
||||
'accountid':accid,
|
||||
'acc_no': account.max_detailno + 1,
|
||||
'acc_date':self.curdate,
|
||||
'acc_timestamp':self.timestamp,
|
||||
'acc_dir':leg['acc_dir'],
|
||||
@ -264,5 +272,9 @@ where accountid=${accid}$
|
||||
'acclogid':logid
|
||||
}
|
||||
await sor.C('acc_detail', ns.copy())
|
||||
await sor.U('account', {'id': accid, 'balance': new_balance})
|
||||
await sor.U('account', {
|
||||
'id': accid,
|
||||
'max_detailno': account.max_detailno + 1,
|
||||
'balance': new_balance
|
||||
})
|
||||
|
||||
|
||||
@ -21,11 +21,13 @@ async def get_orgid_by_username(sor, username):
|
||||
|
||||
async def accounting(username):
|
||||
env = ServerEnv()
|
||||
async with get_sor_context(env, 'accounting') as sor:
|
||||
customerid = await get_orgid_by_username(sor, username)
|
||||
resellerid = '0'
|
||||
ais = []
|
||||
customerid = None
|
||||
for i in range(10):
|
||||
resellerid = '0'
|
||||
async with get_sor_context(env, 'accounting') as sor:
|
||||
ais = []
|
||||
if customerid is None:
|
||||
customerid = await get_orgid_by_username(sor, username)
|
||||
d = DictObject()
|
||||
d.customerid = customerid
|
||||
d.resellerid = '0'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user