Skip to content

Commit 0cf7424

Browse files
committed
refactor(billing): consolidate billing duplication (Commit 2.4)
Creates billing-core.ts with shared billing logic: - getOrderedActiveGrantsForOwner: Generic grant fetching for user/org - calculateUsageAndBalanceFromGrants: Usage and balance calculation - GRANT_ORDER_BY: Consistent grant ordering constant - CreditBalance, CreditUsageAndBalance interfaces Fixes critical bug in consumeFromOrderedGrants: - Tracks effectiveBalances Map to prevent stale balance reads during multi-pass consumption Comprehensive tests with: - Simplified logger assertions (check calls, not specific messages) - Removed trivial edge cases (zero/empty/fractional tests) - Consolidated mock setup (shared beforeEach)
1 parent c9500a4 commit 0cf7424

File tree

5 files changed

+1449
-230
lines changed

5 files changed

+1449
-230
lines changed

0 commit comments

Comments
 (0)