Repository navigation
refactor(billing): remove embedded split-line history - #5356
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Invoice-line history contract openmeter/billing/stdinvoiceline.go, openmeter/billing/gatheringinvoice.go, openmeter/billing/lineengine/*, openmeter/billing/rating/*, openmeter/billing/README.md |
Standard and gathering lines no longer store split-line hierarchies. Rating tests provide history separately. The README describes changes to event and public representations. |
Invoice reads and explicit history lookup openmeter/billing/adapter/*, openmeter/billing/service/invoice.go, openmeter/billing/worker/subscriptionsync/*, test/billing/*, test/credits/* |
Invoice read paths no longer expand split-line history. Subscription-sync and test paths retrieve persisted groups by split-group ID when needed. Tests check that ordinary reads do not query history. |
Transient simulation history openmeter/billing/stdinvoice.go, openmeter/billing/service/invoice.go, test/billing/invoice_test.go |
SimulateInvoiceInput accepts hierarchies keyed by split-group ID. Tests verify simulation behavior without persisted-history queries or invoice writes. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Possibly related PRs
- openmeterio/openmeter#5333: Changes persisted split-line history records and hierarchy mapping used by explicit history reads.
- openmeterio/openmeter#5341: Adds legacy rating support for supplied split-line history, which this change continues through simulation input.
Suggested reviewers: galexihu, borosr
Merge Risk: 
Minimal · up to 0ec83
-
No actionable issue is established in the supplied changes; the PR appears mergeable after normal checks.
Pre-merge checks: 
4
Finishing Touches
-
📝 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
Ordinary invoice reads still attach split-line history to every line even though the legacy engine resolves that history explicitly. Remove the embedded hierarchy fields, automatic adapter expansion, and the gathering-preview reload that existed solely to obtain history. Lines retain their split-group IDs, and calculation continues to use the engine-owned full-history resolver.
Simulation now accepts supplied transient histories on the Go service input, keyed by split-group ID, so association survives generated line IDs and namespace normalization without group reads or persistence.
Notes for reviewer
Follows #5341. The public HTTP simulation contract is unchanged; complete supplied-history simulation remains an internal Go service capability. Internal invoice event snapshots omit the former optional hierarchy expansions. No schema changes or changes to the documented legacy cancellation-ordering limitation.
Validation: PostgreSQL billing and subscription-sync suites; billing domain, legacy engine, rating, HTTP, and notification-event contract tests; affected-consumer and e2e-module vet; scoped fast Go lint.
Summary by CodeRabbit


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues were found.Summary
Removes embedded split history from invoice lines while keeping
SplitLineGroupID.Review was based on code and tests; no tests were executed.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Ordinary invoice read] --> B[Line snapshots with split-group IDs] C[Persisted calculation or gathering preview] --> D[Legacy engine] D --> E[Load persisted split history] E --> F[Snapshot quantities and rate] G[Go simulation input] --> H[Normalize line IDs and namespaces] H --> I[Find supplied history by split-group ID] I --> J[Rate cloned lines without group reads]Reviews (1) · Last reviewed commit: "refactor(billing): remove embedded split..." · Reviewed by Greptile