bugfix
This commit is contained in:
parent
1d8f368223
commit
77c2c31961
@ -5,6 +5,7 @@ from .accountingnode import get_parent_orgid
|
|||||||
from .excep import *
|
from .excep import *
|
||||||
from .getaccount import getAccountByName
|
from .getaccount import getAccountByName
|
||||||
from appPublic.uniqueID import getID
|
from appPublic.uniqueID import getID
|
||||||
|
from appPublic.log import debug
|
||||||
from sqlor.dbpools import DBPools
|
from sqlor.dbpools import DBPools
|
||||||
from appPublic.timeUtils import curDateString
|
from appPublic.timeUtils import curDateString
|
||||||
from .argsconvert import ArgsConvert
|
from .argsconvert import ArgsConvert
|
||||||
@ -108,6 +109,7 @@ where a.id = b.protocolid
|
|||||||
aorgtype = '客户所在机构'
|
aorgtype = '客户所在机构'
|
||||||
if self.resellerid:
|
if self.resellerid:
|
||||||
aorgtype = '分销商机构'
|
aorgtype = '分销商机构'
|
||||||
|
debug(f'{accounting_config=}, {aorgtype=}')
|
||||||
if self.specstr.startswith(ACTNAME_SETTLE):
|
if self.specstr.startswith(ACTNAME_SETTLE):
|
||||||
self.accounting_legs = [r.copy() for r in accounting_config
|
self.accounting_legs = [r.copy() for r in accounting_config
|
||||||
if r['specstr'] == specstr ]
|
if r['specstr'] == specstr ]
|
||||||
@ -115,6 +117,7 @@ where a.id = b.protocolid
|
|||||||
self.accounting_legs = [r.copy() for r in accounting_config
|
self.accounting_legs = [r.copy() for r in accounting_config
|
||||||
if r['specstr'] == specstr
|
if r['specstr'] == specstr
|
||||||
and r['accounting_orgtype'] == aorgtype]
|
and r['accounting_orgtype'] == aorgtype]
|
||||||
|
debug(f'{self.accounting_legs=}')
|
||||||
for l in self.accounting_legs:
|
for l in self.accounting_legs:
|
||||||
l['summary'] = self.action
|
l['summary'] = self.action
|
||||||
|
|
||||||
@ -396,7 +399,9 @@ where accountid=${accid}$
|
|||||||
|
|
||||||
async def get_act_specstr(self):
|
async def get_act_specstr(self):
|
||||||
sor = self.sor
|
sor = self.sor
|
||||||
|
debug(f'{self.action=} ---')
|
||||||
if self.action in [ ACTION_RECHARGE, ACTION_RECHARGE_REVERSE ]:
|
if self.action in [ ACTION_RECHARGE, ACTION_RECHARGE_REVERSE ]:
|
||||||
|
debug(f'{self.action=}, {ACTNAME_RECHARGE=}')
|
||||||
return ACTNAME_RECHARGE
|
return ACTNAME_RECHARGE
|
||||||
|
|
||||||
if self.action in [ ACTION_SETTLE, ACTION_SETTLE_REVERSE ]:
|
if self.action in [ ACTION_SETTLE, ACTION_SETTLE_REVERSE ]:
|
||||||
@ -407,6 +412,7 @@ where accountid=${accid}$
|
|||||||
spec = f'{ACTNAME_SETTLE}-{SALEMODE_REBATE}'
|
spec = f'{ACTNAME_SETTLE}-{SALEMODE_REBATE}'
|
||||||
else:
|
else:
|
||||||
spec = f'{ACTNAME_SETTLE}-{SALEMODE_FLOORPRICE}'
|
spec = f'{ACTNAME_SETTLE}-{SALEMODE_FLOORPRICE}'
|
||||||
|
debug(f'{self.action=} {spec=}')
|
||||||
return spec
|
return spec
|
||||||
|
|
||||||
|
|
||||||
@ -428,6 +434,7 @@ where accountid=${accid}$
|
|||||||
else:
|
else:
|
||||||
self.reseller_salemode = sale_mode
|
self.reseller_salemode = sale_mode
|
||||||
await self.setup_bill_variable()
|
await self.setup_bill_variable()
|
||||||
|
debug(f'{ret=}')
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DBNAME = 'kboss'
|
DBNAME = 'sage'
|
||||||
RESELLER_ORG = '1'
|
RESELLER_ORG = '1'
|
||||||
OWNER_OGR = '0'
|
OWNER_OGR = '0'
|
||||||
CORP_CUSTOMER = '2'
|
CORP_CUSTOMER = '2'
|
||||||
@ -10,12 +10,12 @@ PARTY_CUSTOMER = '客户'
|
|||||||
PARTY_RESELLER = '分销商'
|
PARTY_RESELLER = '分销商'
|
||||||
PARTY_PROVIDER = '供应商'
|
PARTY_PROVIDER = '供应商'
|
||||||
|
|
||||||
DEBT = '借'
|
DEBT = '0'
|
||||||
CREDIT = '贷'
|
CREDIT = '1'
|
||||||
|
|
||||||
ACTNAME_BUY = '付费'
|
ACTNAME_BUY = 'sonsume'
|
||||||
ACTNAME_RECHARGE = '充值'
|
ACTNAME_RECHARGE = 'recharge'
|
||||||
ACTNAME_RECHARGE_ALIPAY = '支付宝充值'
|
ACTNAME_RECHARGE_ALIPAY = 'rechange_alipay'
|
||||||
ACTNAME_SETTLE = '结算'
|
ACTNAME_SETTLE = '结算'
|
||||||
|
|
||||||
SALEMODE_DISCOUNT = '折扣'
|
SALEMODE_DISCOUNT = '折扣'
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from sqlor.dbpools import DBPools
|
from sqlor.dbpools import DBPools
|
||||||
from .const import *
|
from .const import *
|
||||||
from appPublic.uniqueID import getID
|
from appPublic.uniqueID import getID
|
||||||
|
from appPublic.log import debug
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
async def openAccount(sor, accounting_orgid, orgid, account_config):
|
async def openAccount(sor, accounting_orgid, orgid, account_config):
|
||||||
@ -12,6 +13,7 @@ async def openAccount(sor, accounting_orgid, orgid, account_config):
|
|||||||
'balance_at':account_config['balance_side'],
|
'balance_at':account_config['balance_side'],
|
||||||
'max_detailno':0
|
'max_detailno':0
|
||||||
}
|
}
|
||||||
|
debug(f'openAccount(), {ns=}')
|
||||||
await sor.C('account', ns.copy())
|
await sor.C('account', ns.copy())
|
||||||
print(ns, 'opened')
|
print(ns, 'opened')
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ async def openPartyAccounts(sor, accounting_orgid, orgid, party_type):
|
|||||||
where a.subjectname = b.name
|
where a.subjectname = b.name
|
||||||
and a.partytype=${partytype}$ """
|
and a.partytype=${partytype}$ """
|
||||||
recs = await sor.sqlExe(sql, {'partytype':party_type})
|
recs = await sor.sqlExe(sql, {'partytype':party_type})
|
||||||
print(f'select account_config {recs=}', party_type)
|
# print(f'select account_config {recs=}', party_type)
|
||||||
for r in recs:
|
for r in recs:
|
||||||
await openAccount(sor, accounting_orgid, orgid, r)
|
await openAccount(sor, accounting_orgid, orgid, r)
|
||||||
|
|
||||||
@ -43,9 +45,16 @@ async def openProviderAccounts(sor, accounting_orgid, orgid):
|
|||||||
return await _openPartyAccounts(accounting_orgid, orgid, PARTY_PROVIDER)
|
return await _openPartyAccounts(accounting_orgid, orgid, PARTY_PROVIDER)
|
||||||
|
|
||||||
async def openAllCustomerAccounts(sor, accounting_orgid):
|
async def openAllCustomerAccounts(sor, accounting_orgid):
|
||||||
sql = """select * from organization
|
sql = """select * from organization a,
|
||||||
where parentid=${accounting_orgid}$ and
|
(select orgid, count(*) cnt
|
||||||
org_type in ('2', '3' )"""
|
from orgtypes
|
||||||
|
where orgtypeid in ('customer', 'personalcustomer', 'agencycustomer')
|
||||||
|
group by orgid
|
||||||
|
) b
|
||||||
|
where a.parentid=${accounting_orgid}$ and
|
||||||
|
a.id = b.orgid and
|
||||||
|
b.cnt > 0
|
||||||
|
"""
|
||||||
recs = await sor.sqlExe(sql, {'accounting_orgid':accounting_orgid})
|
recs = await sor.sqlExe(sql, {'accounting_orgid':accounting_orgid})
|
||||||
print(f'{recs=}')
|
print(f'{recs=}')
|
||||||
for r in recs:
|
for r in recs:
|
||||||
|
29
test/open_account.py
Normal file
29
test/open_account.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
from run_test import run
|
||||||
|
from appPublic.log import debug
|
||||||
|
from sqlor.dbpools import DBPools
|
||||||
|
from accounting.openaccount import openAllCustomerAccounts, \
|
||||||
|
openOwnerAccounts, openAllProviderAccounts, openAllResellerAccounts
|
||||||
|
|
||||||
|
async def OpenAccount():
|
||||||
|
orgid = '_VaV5trl8faujgr7xaE3D'
|
||||||
|
db = DBPools()
|
||||||
|
async with db.sqlorContext('sage') as sor:
|
||||||
|
try:
|
||||||
|
await openAllCustomerAccounts(sor, orgid)
|
||||||
|
except Exception as e:
|
||||||
|
debug(f'{e}')
|
||||||
|
try:
|
||||||
|
await openOwnerAccounts(sor, orgid)
|
||||||
|
except Exception as e:
|
||||||
|
debug(f'{e}')
|
||||||
|
try:
|
||||||
|
await openAllProviderAccounts(sor, orgid)
|
||||||
|
except Exception as e:
|
||||||
|
debug(f'{e}')
|
||||||
|
try:
|
||||||
|
await openAllResellerAccounts(sor, orgid)
|
||||||
|
except Exception as e:
|
||||||
|
debug(f'{e}')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run(OpenAccount)
|
Loading…
Reference in New Issue
Block a user