bugfix
This commit is contained in:
parent
41661535ba
commit
ba5b74b447
@ -5,7 +5,7 @@ from appPublic.registerfunction import RegisterFunction
|
|||||||
from appPublic.log import debug, exception
|
from appPublic.log import debug, exception
|
||||||
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, org1id=None):
|
||||||
ns = {
|
ns = {
|
||||||
'id':getID(),
|
'id':getID(),
|
||||||
'accounting_orgid':accounting_orgid,
|
'accounting_orgid':accounting_orgid,
|
||||||
@ -14,18 +14,27 @@ 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
|
||||||
}
|
}
|
||||||
|
if org1id:
|
||||||
|
ns['org1id'] = org1id;
|
||||||
debug(f'openAccount(), {ns=}')
|
debug(f'openAccount(), {ns=}')
|
||||||
await sor.C('account', ns.copy())
|
await sor.C('account', ns.copy())
|
||||||
print(ns, 'opened')
|
print(ns, 'opened')
|
||||||
|
|
||||||
async def openPartyAccounts(sor, accounting_orgid, orgid, party_type):
|
async def openPartyAccounts(sor, accounting_orgid, orgid, party_type, org1id=None, party1_type=None):
|
||||||
|
addon_cond = " and a.party1type is NULL "
|
||||||
|
ns = {'partytype':party_type}
|
||||||
|
if party1_type:
|
||||||
|
addon_cond = " and a.party1type = ${party1type}$ "
|
||||||
|
ns['party1type'] = party1_type
|
||||||
|
|
||||||
sql = """select a.*, b.id as subjectid, b.balance_side from account_config a, subject b
|
sql = """select a.*, b.id as subjectid, b.balance_side from account_config a, subject b
|
||||||
where a.subjectname = b.name
|
where a.subjectname = b.name """
|
||||||
|
+ addon_cond + """
|
||||||
and a.partytype=${partytype}$ """
|
and a.partytype=${partytype}$ """
|
||||||
recs = await sor.sqlExe(sql, {'partytype':party_type})
|
recs = await sor.sqlExe(sql, ns)
|
||||||
# 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, org1id=org1id)
|
||||||
|
|
||||||
async def _openPartyAccounts(accounting_orgid, orgid, party_type):
|
async def _openPartyAccounts(accounting_orgid, orgid, party_type):
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
@ -78,4 +87,13 @@ async def openAllProviderAccounts(sor, accounting_orgid):
|
|||||||
for r in recs:
|
for r in recs:
|
||||||
await openProviderAccounts(sor, accounting_orgid, r['id'])
|
await openProviderAccounts(sor, accounting_orgid, r['id'])
|
||||||
|
|
||||||
|
async def openRetailRelationshipAccounts(sor, accounting_orgid, providerid, resellerid):
|
||||||
|
db = DBPools()
|
||||||
|
async with db.sqlorContext(DBNAME()) as sor:
|
||||||
|
await openPartyAccounts(sor, accounting_orgid, providerid, PARTY_PROVIDER,
|
||||||
|
org1id=resellerid,
|
||||||
|
party1_type=PARTY_RESELLER)
|
||||||
|
await openPartyAccounts(sor, accounting_orgid, resellerid, PARTY_RESELLER,
|
||||||
|
org1id=providerid,
|
||||||
|
party1_type=PARTY_PROVIDER)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user