32 lines
1.5 KiB
Plaintext
32 lines
1.5 KiB
Plaintext
async def supplier_accounts(ns):
|
|
"""供应商日结"""
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
try:
|
|
account_config = await sor.R('account_config',{'partytype':'供应商','del_flg':'0'})
|
|
provider = await sor.R('provider',{"del_flg":'0','settle_mode':'1'})
|
|
for i in provider:
|
|
org = await sor.R('organization', {"id": i['orgid'],'del_flg':'0'})
|
|
for j in account_config:
|
|
acc = await getAccountByName(sor, org[0]['parentid'], i['orgid'], j['subjectname'])
|
|
if acc != None:
|
|
accountid = await sor.R('acc_balance',{'accountid':acc})
|
|
if len(accountid) >= 1:
|
|
settle_log = {
|
|
'accounting_orgid': org[0]['parentid'],
|
|
'providerid': i['orgid'],
|
|
'settle_date': await get_business_date(sor=None),
|
|
'settle_mode': '1',
|
|
'sale_mode': '',
|
|
'settle_amt': accountid[0]['balance'],
|
|
'business_op': 'SETTLE'
|
|
}
|
|
ai = SettleAccounting(settle_log)
|
|
await ai.accounting(sor)
|
|
return {'status': True, 'msg': '成功'}
|
|
except Exception as e:
|
|
raise e
|
|
return {'status': False, 'msg': '失败'}
|
|
|
|
ret = await supplier_accounts(params_kw)
|
|
return ret |