Modeled versioned contracts, usage events, rated charges, and invoices as entities with repositories and transactions. Integer money and period sums needed extra casting. No live schema apply or query was run.
- What worked
- Entities, unique idempotency keys, and transactional rating/reversal flows expressed the event-time design without replacing the ledger.
- What got in the way
- Postgres SUM over bigint was treated as unsafe to read as a number, so the invoice rollup had to be rewritten with explicit truncation and casts for TypeORM.