Repository navigation
fix(billing): handle custom currency gathering previews - #5167
Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openmeterio/openmeter/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughPreview generation now resolves dynamic cost bases for credit-purchase projections without persisting them. Custom-currency gathering placeholders are omitted from previews. Tests cover resolver behavior, projected totals, and unresolved charge state. ChangesPreview cost-basis handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant GatheringPreview
participant CreditPurchaseLineEngine
participant CostBasisResolver
participant Charge
GatheringPreview->>CreditPurchaseLineEngine: Build preview lines
CreditPurchaseLineEngine->>CostBasisResolver: Resolve dynamic cost basis
CostBasisResolver-->>CreditPurchaseLineEngine: Return projected state
CreditPurchaseLineEngine->>Charge: Apply state for line construction
CreditPurchaseLineEngine-->>GatheringPreview: Return projected invoice lines
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Overview
Notes for reviewer
Credit-purchase invoice amounts are directly determined by purchased quantity and cost basis, so they can be projected safely. Flat-fee and usage-based invoice amounts depend on post-allocation overage and are intentionally omitted.
Validation:
Summary by CodeRabbit
New Features
Bug Fixes
Tests
The PR appears safe to merge; the changed preview paths preserve read-only behavior and correctly separate projectable credit purchases from unresolved overage placeholders.
Summary
This PR changes custom-currency gathering previews to project credit purchases from their persisted or dynamically resolved cost basis while omitting flat-fee and usage-based placeholders whose fiat overage is not known before credit allocation.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD G[Custom-currency gathering line] --> T{Charge type} T -->|Credit purchase| C{Persisted cost basis?} C -->|Yes| P[Use persisted snapshot] C -->|No, dynamic| R[Resolve rate at service-period start] P --> L[Build projected fiat line] R --> L T -->|Flat fee or usage based| O[Mark placeholder deleted in preview copy] O --> F[Preview filtering omits line] L --> V[Return read-only gathering preview] F --> VReviews (1) · Last reviewed commit: "fix(billing): handle custom currency gat..."