Repository navigation
feat(flatfee): settle custom currency overage with fiat credits - #4935
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (17)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThe flat-fee billing flow now supports settlement-fiat overage allocation at invoice finalization. It centralizes rated-run reconciliation, adds allocation and correction handlers, updates invoice lines, simplifies realization-run APIs, and expands lifecycle tests for retries, rerating, deletion, and persistence. ChangesFlat-fee settlement-fiat flow
Estimated code review effort: 5 (Critical) | ~120 minutes Merge Risk: ⚪ Minimal · up to The PR adds fiat-credit settlement for custom-currency flat-fee overages while preserving allocation lineage and retry behavior; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant InvoiceFinalization
participant Realizations
participant FiatCreditHandler
participant LineMapper
InvoiceFinalization->>Realizations: AllocateFiatOverageCredits
Realizations->>FiatCreditHandler: OnAllocateFiatOverageCredits
FiatCreditHandler-->>Realizations: credit allocations
Realizations-->>InvoiceFinalization: updated charge and run
InvoiceFinalization->>LineMapper: populate invoice_finalizing line
LineMapper-->>InvoiceFinalization: updated invoice line
🚥 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 |
b32e4d1 to
633ccbd
Compare
Summary
Behavior
Custom-currency flat-fee
credit_then_invoiceruns now keep charge-currency and settlement-fiat credit facts separate. Draft invoice lines show the gross converted overage. At invoice finalization, eligible fiat credits are allocated once and applied to the existing line, leaving only the uncovered fiat total collectible. Mutable rerating settles the final charge-currency overage before fiat allocation, and pre-finalization deletion corrects charge-currency realizations while fiat history remains empty.Jira: OM-435
Validation
POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./openmeter/billing/charges/flatfee/...POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./openmeter/billing/charges/service -run 'TestInvoicableCharges/TestFlatFeeCustomCurrency' -count=1POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./openmeter/ledger/chargeadapternix develop --impure .#ci -c make lint-go-fastSummary by CodeRabbit
New Features
Bug Fixes
Greptile Summary
This PR separates charge-currency and settlement-fiat credit handling for custom-currency flat-fee charges, allocating fiat credits during invoice finalization while preserving realization lineage and retry behavior.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Sequence Diagram
Reviews (2): Last reviewed commit: "feat(flatfee): settle custom currency ov..." | Re-trigger Greptile
Context used: