bugfix
This commit is contained in:
parent
231403885d
commit
7c77aa7bd6
@ -130,9 +130,9 @@ where a.id = b.protocolid
|
||||
rev = self.action.endswith('_REVERSE')
|
||||
for l in self.accounting_legs:
|
||||
if rev:
|
||||
l['acc_dir'] = '0' if l['accounting_dir'] == CREDIT else '1'
|
||||
l['acc_dir'] = DEBT if l['accounting_dir'] == CREDIT else CREDIT
|
||||
else:
|
||||
l['acc_dir'] = '0' if l['accounting_dir'] == DEBT else '1'
|
||||
l['acc_dir'] = l['accounting_dir']
|
||||
ac = ArgsConvert('${', '}$')
|
||||
print(f'{l["id"]},{l["amt_pattern"]=}')
|
||||
try:
|
||||
@ -239,11 +239,25 @@ where a.id = b.protocolid
|
||||
|
||||
print(f'{name} not found')
|
||||
|
||||
def check_accounting_balance(self, legs):
|
||||
debt_balance = 0.0
|
||||
credit_balance = 0.0
|
||||
for l in legs:
|
||||
if l['acc_dir'] == DEBT:
|
||||
debt_balance += legs['amount']
|
||||
else:
|
||||
credit_balance += legs['amount']
|
||||
if abs(credit_balance - debt_balance) >= 0.01:
|
||||
e = Exception('accounting legs not balance')
|
||||
exception(f'{legs=}, {e=}')
|
||||
raise e
|
||||
|
||||
async def do_accounting(self, sor):
|
||||
self.sor = sor
|
||||
|
||||
await self.setup_accounting_legs()
|
||||
print('do_accounting() ...', self.accounting_legs)
|
||||
self.check_accounting_balance(self.accounting_legs)
|
||||
for leg in self.accounting_legs:
|
||||
orgid = self.accounting_orgid
|
||||
if leg['orgtype'] == '客户':
|
||||
@ -312,9 +326,9 @@ where accountid=${accid}$
|
||||
|
||||
if acc.get('balance') is None:
|
||||
acc['balance'] = 0
|
||||
if acc['balance_at'] == '0' and leg['acc_dir'] == '1' \
|
||||
or acc['balance_at'] == '1' and leg['acc_dir'] == '0':
|
||||
if int(acc['balance']*100) - int(leg['amount']*100) < 0:
|
||||
if acc['balance_at'] == DEBT and leg['acc_dir'] == CREDIT \
|
||||
or acc['balance_at'] == CREDIT and leg['acc_dir'] == DEBT:
|
||||
if int(acc['balance']*10000) - int(leg['amount']*10000) < 0:
|
||||
if tryAgain:
|
||||
await asyncio.sleep(1.5);
|
||||
return await self.overdraw_check(sor, accid, leg, tryAgain=False)
|
||||
@ -327,6 +341,8 @@ where accountid=${accid}$
|
||||
|
||||
async def leg_accounting(self, sor, accid, leg):
|
||||
# print(f'leg_accounting(), {accid=}, {leg=}')
|
||||
if leg['amount'] < 0.0001:
|
||||
return
|
||||
await self.overdraw_check(sor, accid, leg)
|
||||
# write acc_balance
|
||||
sql = """select * from acc_balance
|
||||
|
@ -23,7 +23,7 @@ PARTY_PROVIDER = '供应商'
|
||||
DEBT = '0'
|
||||
CREDIT = '1'
|
||||
|
||||
ACTNAME_BUY = 'sonsume'
|
||||
ACTNAME_BUY = 'consume'
|
||||
ACTNAME_RECHARGE = 'recharge'
|
||||
ACTNAME_RECHARGE_ALIPAY = 'rechange_alipay'
|
||||
ACTNAME_SETTLE = '结算'
|
||||
|
BIN
docs/平台类系统记账子系统.docx
Normal file
BIN
docs/平台类系统记账子系统.docx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user