Add lifetime income/expense totals to UserBalance
New get_user_lifetime_totals_bql() runs tag-filtered BQL queries
(Payable + expense-entry, Receivable + income-entry) to compute
per-user lifetime totals separately from the net balance. Plumbed
through /api/v1/balance and /api/v1/balance/{user_id}; existing
clients keep working (fields default to zero / empty dict).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
483e89163e
commit
deeec7e2c5
3 changed files with 82 additions and 0 deletions
|
|
@ -90,6 +90,11 @@ class UserBalance(BaseModel):
|
|||
balance: int # positive = libra owes user, negative = user owes libra
|
||||
accounts: list[Account] = []
|
||||
fiat_balances: dict[str, Decimal] = {} # e.g. {"EUR": Decimal("250.0"), "USD": Decimal("100.0")}
|
||||
# Lifetime totals (original entries only; not net of reconciliation)
|
||||
total_expenses_sats: int = 0
|
||||
total_expenses_fiat: dict[str, Decimal] = {}
|
||||
total_income_sats: int = 0
|
||||
total_income_fiat: dict[str, Decimal] = {}
|
||||
|
||||
|
||||
class ExpenseEntry(BaseModel):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue