Repository navigation
fix(billing): resolve persisted split history during invoice simulation - #5360
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Resolve hierarchies during standard-line rating openmeter/billing/lineengine/rating.go, openmeter/billing/lineengine/rating_test.go |
RateStandardLines now accepts a context, namespace, and lines. It resolves hierarchies before rating and returns resolution errors. Tests use the new API and internal hierarchy pairs. |
Use persisted history in invoice simulation openmeter/billing/stdinvoice.go, openmeter/billing/service/invoice.go, openmeter/billing/README.md, openmeter/billing/httpdriver/invoiceline_test.go, test/billing/invoice_test.go, test/billing/legacycalculation_test.go |
SimulateInvoiceInput no longer includes SplitLineHierarchies. Simulation calls RateStandardLines; tests verify supplied snapshots, persisted history, missing-group errors, and input preservation. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant SimulateInvoice
participant RateStandardLines
participant PersistedSplitGroupHistory
participant LineRating
SimulateInvoice->>RateStandardLines: namespace and grouped lines
RateStandardLines->>PersistedSplitGroupHistory: resolve hierarchies
PersistedSplitGroupHistory-->>RateStandardLines: hierarchy or error
RateStandardLines->>LineRating: rate resolved lines
LineRating-->>RateStandardLines: rated lines
RateStandardLines-->>SimulateInvoice: rated lines or error
Possibly related PRs
- openmeterio/openmeter#5341: Introduced the split-line hierarchy resolver and the rating API that this change replaces.
- openmeterio/openmeter#5333: Added the persisted split-line history path used by the updated rating method.
- openmeterio/openmeter#5356: Added transient hierarchy input to invoice simulation, which this change removes.
Suggested labels: area/billing, kind/bug, release-note/bug-fix
Suggested reviewers: borosr
Merge Risk: 
Minimal · up to dbc97
-
The supplied evidence identifies no actionable issue blocking the simulation change. Merge after normal checks.
Pre-merge checks: 
4
Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
Overview
Invoice simulation with a split-group ID currently requires a separate supplied hierarchy even when the group's history is persisted. Resolve referenced groups through the legacy engine's existing namespaced history resolver, preserving supplied quantities and pending line edits without persisting the simulated invoice.
Remove the simulation-specific hierarchy map and explicit-history rating facade. Ordinary simulation retains prior-usage offsets, clone isolation, and validation results.
Notes for reviewer
The public HTTP simulation input is unchanged. Missing groups fail explicitly through the existing resolver.
Validated with targeted billing, rating, and HTTP tests; PostgreSQL simulation and persisted legacy-calculation invariants; affected-consumer vet; and scoped
make lint-go-fast.Summary by CodeRabbit


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Invoice simulation now resolves persisted split-group history through the legacy engine.
turipexplicitly describes removing the transient hierarchy map as intentional. No actionable issues were found. Tests were inspected, not run.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Supplied simulation lines] --> B[Clone and set namespace] B --> C[RateStandardLines] C --> D{Split-group IDs?} D -->|No| F[Rate cloned snapshots] D -->|Yes| E[Resolve persisted history in namespace] E -->|Found| F E -->|Missing| G[Return error] F --> H[Calculate invoice totals] H --> I[Return invoice without saving]Reviews (1) · Last reviewed commit: "fix(billing): resolve persisted split hi..." · Reviewed by Greptile