Commit Graph

2 Commits

Author SHA1 Message Date
Claude
84e44ee4e8 gitea-saas-core#16: billing core client API consistency (id, flat records, list_clients)
create_client now returns 'id' (was 'client_id'), get_client returns a flat
record with balance as a field (was nested under 'client'), and list_clients
is implemented returning {'clients': [...]} with the same flat shape. A
cross-method shape-consistency test (create/get/list key-set agreement)
plus a wire-shape test mirroring the server's _client_out allow-list guard
against future drift. server.py/test_server.py untouched (issue #2/!13).
2026-08-25 06:09:46 -05:00
pbwraith-worker
6d764d46f6 gitea-saas-core#1: billing ledger core (clients/ledger/holds, idempotent, fail-closed)
SQLite schema + ledger operations in gitea_saas/billing_core.py (+ db.py,
schema.sql). balance = credits + refunds - debits - active holds, never
negative; every mutation idempotent via UNIQUE idempotency_key; holds
expire (default 30 min) and auto-release on the next read/query. All ops
return (ok, details) with structured errors; never raise. Thread-safe via
single lock + WAL. 26 hermetic pytest tests (no network/Stripe/Gitea).
2026-08-25 04:16:35 -05:00