From 055463afc3757ed92f12d120c50c62348ed4354e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 11:30:41 +0800 Subject: [PATCH 1/7] bugfix --- accounting/consume.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/accounting/consume.py b/accounting/consume.py index 0c3af10..f722968 100644 --- a/accounting/consume.py +++ b/accounting/consume.py @@ -15,7 +15,6 @@ class ConsumeBiz(PFBiz): self.db = DBPools() self.action = od.action self.orderid = od['orderid'] - self.curdate = await get_business_date(sor) self.timestamp = timestampstr() self.action = od['action'] self.billid = getID() @@ -46,9 +45,12 @@ class ConsumeBiz(PFBiz): async def consume_accounting(sor, orderid, order_details): ods = [] billid = getID() + env = ServerEnv() + curdate = await env.get_business_date(sor) for od in order_details: od['billid'] = billid od['orderid'] = orderid + od['curdate'] = curdate ods.append(ConsumeBiz(od)) ao = Accounting(ods) bill = { @@ -58,7 +60,7 @@ async def consume_accounting(sor, orderid, order_details): 'orderid':self.orderid, 'business_op':self.action, 'amount':log['transamt'], - 'bill_date':self.curdate, + 'bill_date':curdate, 'bill_timestamp':self.timestamp } await sor.C('bill', bill.copy()) From e027352f3902c5dffa68a4d8482bf0cb65006c21 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 11:45:25 +0800 Subject: [PATCH 2/7] bugfix --- accounting/accounting_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index 610e3d3..c36a2e4 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -86,7 +86,7 @@ class Accounting: async def setup_accounting_legs(self): 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 if r.action == action ] debug(f'{legs=}') From b55a87c5288ec4cfafba3b6fba1cf8a241055001 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 11:49:37 +0800 Subject: [PATCH 3/7] bugfix --- accounting/accounting_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index c36a2e4..6ed0bd6 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -85,6 +85,7 @@ class Accounting: self.accounting_legs = legs async def setup_accounting_legs(self): + sor = self.sor action = self.action.split('_')[0] acfg = await get_accounting_config(self.sor) legs = [r.copy() for r in acfg From 59c632f223b704d691b63872d7ee2bdfddb3b9c2 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 11:52:48 +0800 Subject: [PATCH 4/7] bugfix --- accounting/getaccount.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounting/getaccount.py b/accounting/getaccount.py index a77cae2..d22f1c7 100644 --- a/accounting/getaccount.py +++ b/accounting/getaccount.py @@ -11,7 +11,7 @@ async def get_account(sor, accounting_orgid, orgid, subjectid, org1id=None): sql = """select 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 on a.id = b.accountid where From 0175d4181bef6b8e641c72f5b13ad0c8a77028e7 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 12:00:13 +0800 Subject: [PATCH 5/7] bugfix --- accounting/accounting_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index 6ed0bd6..3350e3f 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -160,7 +160,7 @@ class Accounting: async def do_accounting(self, sor): self.sor = sor - await self.setup_accounting_legs() + await self.setup_all_accounting_legs() debug(f'do_accounting() ...{self.accounting_legs=}') self.check_accounting_balance(self.accounting_legs) for leg in self.accounting_legs: From 5f5ddcd09a13106ca16bd325f1e95bdec41e0ec4 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 12:05:06 +0800 Subject: [PATCH 6/7] bugfix --- accounting/accounting_config.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index 3350e3f..901cb0d 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -41,20 +41,9 @@ class Accounting: if isinstance(caller, list): self.callers = caller caller = self.callers[0] - 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 + else: + self.callers = [caller] + self.caller = caller async def setup_all_accounting_legs(self): self.accounting_legs = [] From 16924ec6d381cf555f30d87cd13c69715e5a9d5e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 27 Dec 2025 12:07:03 +0800 Subject: [PATCH 7/7] bugfix --- accounting/getaccount.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/accounting/getaccount.py b/accounting/getaccount.py index d22f1c7..14b4d7e 100644 --- a/accounting/getaccount.py +++ b/accounting/getaccount.py @@ -4,10 +4,12 @@ from ahserver.serverenv import ServerEnv, get_serverenv from .const import * 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" if org1id: ss = "a.org1id = ${org1id}$" + if update: + ss += " for update" sql = """select a.*,