fix: correct indentation in leg_accounting credit limit block

Two bugs fixed:
1. FATAL: lines 213-278 were indented inside the 'if new_balance < 0' block,
   causing all normal (positive balance) accounting operations to be skipped.
   All post-credit-check code now correctly at method body level (2 tabs).

2. LOGIC: added else clause to reset used_credit to 0 when balance returns
   to non-negative (e.g. after recharge). Previously used_credit stayed
   stale after account recovered from overdraft.
This commit is contained in:
yumoqing 2026-05-28 23:05:23 +08:00
parent 5da6ddd7d5
commit 5fa058add9

View File

@ -209,6 +209,9 @@ class Accounting:
raise e raise e
# Update used credit # Update used credit
await update_used_credit(sor, accid, abs(new_balance)) await update_used_credit(sor, accid, abs(new_balance))
else:
# Balance is non-negative, reset used credit if any
await update_used_credit(sor, accid, 0)
subjects = await sor.R('subject', {'id': leg['subjectid']}) subjects = await sor.R('subject', {'id': leg['subjectid']})
if len(subjects) > 0: if len(subjects) > 0: