From 996a8821e4172ec36d21b13a9364e9fe30597e50 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 15 Dec 2025 14:44:54 +0800 Subject: [PATCH] bugfix --- accounting/accounting_config.py | 11 ++++++++--- accounting/recharge.py | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index a98ac82..a605c6b 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -14,6 +14,11 @@ from datetime import datetime accounting_config = None +class PFBiz: + async def get_orgid_by_trans_role(self, sor, leg, role): + pass + + async def get_accounting_config(sor): global accounting_config if accounting_config: @@ -100,10 +105,10 @@ class Accounting: debug(f'do_accounting() ...{self.accounting_legs=}') self.check_accounting_balance(self.accounting_legs) for leg in self.accounting_legs: - accounting_orgid = await self.caller.get_orgid_by_trans_role(sor, leg.accounting_orgtype) - orgid = await self.caller.get_orgid_by_trans_role(sor, leg.orgtype) + accounting_orgid = await self.caller.get_orgid_by_trans_role(sor, leg, leg.accounting_orgtype) + orgid = await self.caller.get_orgid_by_trans_role(sor, leg, leg.orgtype) org1id = None if leg.org1type is None else \ - await self.caller.get_orgid_by_trans_role(sor, leg.org1type) + await self.caller.get_orgid_by_trans_role(sor, leg, leg.org1type) acc = await get_account(sor, accounting_orgid, orgid, leg.subjectid, org1id=org1id) if acc is None: debug(f'can not get accountid {accounting_orgid=}, {orgid=},{leg.subjectid=}, {org1id=}') diff --git a/accounting/recharge.py b/accounting/recharge.py index 7e1a61b..f8a9274 100644 --- a/accounting/recharge.py +++ b/accounting/recharge.py @@ -12,7 +12,7 @@ from .const import * from .excep import * from .getaccount import getAccountByName -class RechargeAccounting: +class RechargeBiz(PFBiz): def __init__(self, recharge_log): self.db = DBPools() self.recharge_log = recharge_log @@ -40,15 +40,23 @@ class RechargeAccounting: 'bill_date':self.curdate, 'bill_timestamp':self.timestamp } - - + + async def get_orgid_by_trans_role(self, sor, leg, role): + if role == 'owner': + return '0' + if role == 'customer': + return self.customerid + e = Exception(f'unknown role({role})') + exception(f'Exception:{e}') + raise e + async def accounting(self, sor): self.sor = sor bz_date = await get_business_date(sor=sor) if bz_date != self.curdate: raise AccountingDateNotInBusinessDate(self.curdate, bz_date) - ao = Accounting(self, "0", self.customerid) + ao = Accounting(self, self) await self.write_bill(sor) await ao.do_accounting(sor) print(f'recharge ok for {self.bill}, {nodes=}')