bugfix
This commit is contained in:
commit
e10dcf9914
@ -41,20 +41,9 @@ class Accounting:
|
|||||||
if isinstance(caller, list):
|
if isinstance(caller, list):
|
||||||
self.callers = caller
|
self.callers = caller
|
||||||
caller = self.callers[0]
|
caller = self.callers[0]
|
||||||
|
else:
|
||||||
|
self.callers = [caller]
|
||||||
self.caller = caller
|
self.caller = caller
|
||||||
self.curdate = caller.curdate
|
|
||||||
self.realtimesettled = False
|
|
||||||
self.timestamp = caller.timestamp
|
|
||||||
self.billid = caller.billid
|
|
||||||
self.action = caller.action
|
|
||||||
self.summary = f'{self.caller.orderid}:{self.caller.billid}'
|
|
||||||
self.providerid = caller.providerid
|
|
||||||
self.productid = caller.productid
|
|
||||||
self.resellerid = caller.resellerid
|
|
||||||
self.customerid = caller.customerid
|
|
||||||
self.own_salemode = None
|
|
||||||
self.reseller_salemode = None
|
|
||||||
self.variable = caller.variable
|
|
||||||
|
|
||||||
async def setup_all_accounting_legs(self):
|
async def setup_all_accounting_legs(self):
|
||||||
self.accounting_legs = []
|
self.accounting_legs = []
|
||||||
@ -85,8 +74,9 @@ class Accounting:
|
|||||||
self.accounting_legs = legs
|
self.accounting_legs = legs
|
||||||
|
|
||||||
async def setup_accounting_legs(self):
|
async def setup_accounting_legs(self):
|
||||||
|
sor = self.sor
|
||||||
action = self.action.split('_')[0]
|
action = self.action.split('_')[0]
|
||||||
acfg = get_accounting_config(self.sor)
|
acfg = await get_accounting_config(self.sor)
|
||||||
legs = [r.copy() for r in acfg
|
legs = [r.copy() for r in acfg
|
||||||
if r.action == action ]
|
if r.action == action ]
|
||||||
debug(f'{legs=}')
|
debug(f'{legs=}')
|
||||||
@ -159,7 +149,7 @@ class Accounting:
|
|||||||
|
|
||||||
async def do_accounting(self, sor):
|
async def do_accounting(self, sor):
|
||||||
self.sor = sor
|
self.sor = sor
|
||||||
await self.setup_accounting_legs()
|
await self.setup_all_accounting_legs()
|
||||||
debug(f'do_accounting() ...{self.accounting_legs=}')
|
debug(f'do_accounting() ...{self.accounting_legs=}')
|
||||||
self.check_accounting_balance(self.accounting_legs)
|
self.check_accounting_balance(self.accounting_legs)
|
||||||
for leg in self.accounting_legs:
|
for leg in self.accounting_legs:
|
||||||
|
|||||||
@ -42,9 +42,12 @@ class ConsumeBiz(PFBiz):
|
|||||||
async def consume_accounting(sor, orderid, order_details):
|
async def consume_accounting(sor, orderid, order_details):
|
||||||
ods = []
|
ods = []
|
||||||
billid = getID()
|
billid = getID()
|
||||||
|
env = ServerEnv()
|
||||||
|
curdate = await env.get_business_date(sor)
|
||||||
for od in order_details:
|
for od in order_details:
|
||||||
od['billid'] = billid
|
od['billid'] = billid
|
||||||
od['orderid'] = orderid
|
od['orderid'] = orderid
|
||||||
|
od['curdate'] = curdate
|
||||||
ods.append(ConsumeBiz(od))
|
ods.append(ConsumeBiz(od))
|
||||||
ao = Accounting(ods)
|
ao = Accounting(ods)
|
||||||
bill = {
|
bill = {
|
||||||
@ -54,7 +57,7 @@ async def consume_accounting(sor, orderid, order_details):
|
|||||||
'orderid':self.orderid,
|
'orderid':self.orderid,
|
||||||
'business_op':self.action,
|
'business_op':self.action,
|
||||||
'amount':log['transamt'],
|
'amount':log['transamt'],
|
||||||
'bill_date':self.curdate,
|
'bill_date':curdate,
|
||||||
'bill_timestamp':self.timestamp
|
'bill_timestamp':self.timestamp
|
||||||
}
|
}
|
||||||
await sor.C('bill', bill.copy())
|
await sor.C('bill', bill.copy())
|
||||||
|
|||||||
@ -4,14 +4,16 @@ from ahserver.serverenv import ServerEnv, get_serverenv
|
|||||||
from .const import *
|
from .const import *
|
||||||
from accounting.accountingnode import get_parent_orgid
|
from accounting.accountingnode import get_parent_orgid
|
||||||
|
|
||||||
async def get_account(sor, accounting_orgid, orgid, subjectid, org1id=None):
|
async def get_account(sor, accounting_orgid, orgid, subjectid, org1id=None, update=False):
|
||||||
ss = "a.org1id is NULL"
|
ss = "a.org1id is NULL"
|
||||||
if org1id:
|
if org1id:
|
||||||
ss = "a.org1id = ${org1id}$"
|
ss = "a.org1id = ${org1id}$"
|
||||||
|
if update:
|
||||||
|
ss += " for update"
|
||||||
|
|
||||||
sql = """select
|
sql = """select
|
||||||
a.*,
|
a.*,
|
||||||
case when c.balance is null then 0.00 else c.balance end as balance
|
case when b.balance is null then 0.00 else b.balance end as balance
|
||||||
from account a left join acc_balance b
|
from account a left join acc_balance b
|
||||||
on a.id = b.accountid
|
on a.id = b.accountid
|
||||||
where
|
where
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user