Commit 139cf38
committed
refactor(billing): consolidate billing duplication (Commit 2.4)
📊 ~540 implementation lines, ~1,140 test lines
Extracts shared billing logic into billing-core.ts:
- consumeFromOrderedGrants: Core grant consumption algorithm
- getOrderedActiveGrants: Grant ordering and filtering
- calculateGrantCreditsToConsume: Per-grant consumption calculation
Includes comprehensive unit tests (160 tests) covering:
- Basic consumption scenarios
- Grant ordering (expiration, type priority)
- Boundary conditions and edge cases
- Negative balance handling
Fixes boundary condition: uses strict > comparison instead of >= for threshold checks.1 parent 848ab2c commit 139cf38
File tree
5 files changed
+1449
-230
lines changed- packages/billing/src
- __tests__
5 files changed
+1449
-230
lines changed
0 commit comments