diff --git a/accounting/accounting_config.py b/accounting/accounting_config.py index 77dea9d..12f654c 100644 --- a/accounting/accounting_config.py +++ b/accounting/accounting_config.py @@ -65,16 +65,20 @@ class Accounting: self.reseller_salemode = None self.variable = caller.variable await self.setup_accounting_legs(i) - legs = sorted( - self.accounting_legs, - key=lambda x: ( - x.get('accounting_orgid','0'), - x.get('orgid', ''), - x.get('subjectid', ''), - 0 if x.get('acc_dir', '0') == x.get('balance_at', '0') else 1 + try: + legs = sorted( + self.accounting_legs, + key=lambda x: ( + x.get('accounting_orgid','0'), + x.get('orgid', ''), + x.get('subjectid', ''), + 0 if x.get('acc_dir', '0') == x.get('balance_at', '0') else 1 + ) ) - ) - self.accounting_legs = legs + self.accounting_legs = legs + except Exception as e: + exception(f'{self.accounting_legs=}, {e=}\n{format_exec()}') + await self.get_legs_account() async def setup_accounting_legs(self, pos):