Skip to content

refactor: move billing sequence service - #4676

Merged
turip merged 1 commit into
mainfrom
feat/billing-sequence-service
Jul 10, 2026
Merged

turip merged 1 commit into
mainfrom
feat/billing-sequence-service

Conversation

@turip

@turip turip commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Move billing sequence types, service, and adapter into openmeter/billing/sequence using the service/adapter package pattern.
  • Remove the old billing/seq.go compatibility facade and update callers to depend on the sequence package directly.
  • Wire the sequence service through common app/billing setup, sandbox/custom invoicing apps, and test harnesses.

Validation

  • go test -tags=dynamic ./openmeter/billing/sequence/... ./openmeter/billing/service/... ./openmeter/app/sandbox/... ./openmeter/app/custominvoicing/... ./app/common/... ./test/app/... ./test/billing/... ./test/customer/... ./test/subscription/...
  • go vet -tags=dynamic ./openmeter/billing/sequence/... ./openmeter/billing/service/... ./openmeter/app/sandbox/... ./openmeter/app/custominvoicing/... ./app/common/... ./test/app/... ./test/billing/... ./test/customer/... ./test/subscription/...
  • go test -tags=dynamic ./cmd/server ./cmd/billing-worker ./cmd/jobs/internal

Summary by CodeRabbit

  • New Features
    • Added dedicated invoice sequence management for generating draft and gathering invoice numbers.
    • Invoice numbering is now available through a focused sequence service across billing, sandbox, and custom invoicing workflows.
  • Bug Fixes
    • Improved invoice finalization and creation flows by consistently using the dedicated sequence generation process.
  • Refactor
    • Separated invoice sequence handling from the broader billing service for clearer service responsibilities.

Greptile Summary

This PR moves billing sequence generation into its own package. The main changes are:

  • Adds a dedicated sequence service and adapter under openmeter/billing/sequence.
  • Removes sequence generation from the broader billing service and adapter interfaces.
  • Updates billing, sandbox, custom invoicing, and test wiring to inject sequence.Service directly.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
app/common/billing.go Creates and stores the dedicated sequence service in the shared billing registry.
openmeter/billing/sequence/service/service.go Moves invoice sequence number rendering into the new sequence service.
openmeter/billing/sequence/adapter/adapter.go Adds the sequence adapter wrapper and transaction support.
openmeter/app/sandbox/app.go Updates sandbox invoice numbering to use the injected sequence service.
openmeter/app/custominvoicing/factory.go Updates custom invoicing factory validation and app construction for the sequence service.

Reviews (2): Last reviewed commit: "refactor: move billing sequence service" | Re-trigger Greptile

Context used (3)

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)
  • Context used - api/spec/AGENTS.md (source)

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extracts invoice sequence generation into a dedicated billing/sequence package, updates billing and application dependencies to use it, adds registry construction and exposure, and rewires test environments with the new sequence adapter and service.

Changes

Billing sequence extraction

Layer / File(s) Summary
Sequence contracts and adapter implementation
openmeter/billing/sequence/..., openmeter/billing/adapter.go, openmeter/billing/service.go
Sequence definitions, inputs, interfaces, adapter transactions, and service signatures move into the dedicated sequence package.
Billing service sequence dependency
openmeter/billing/service/...
Billing service configuration requires a sequence service and uses it for draft and gathering invoice number generation.
Application factories and registry wiring
app/common/..., openmeter/app/sandbox/..., openmeter/app/custominvoicing/...
The billing registry constructs and exposes the sequence service, and application factories inject it instead of the billing service.
Test environment wiring
test/..., openmeter/server/server_test.go
Test setups construct sequence adapters and services, pass them into billing and application factories, and remove the old billing sequence stub.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: tothandras, chrisgacsal

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: moving billing sequence logic into a dedicated sequence service package.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/billing-sequence-service

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@turip turip added release-note/ignore Ignore this change when generating release notes area/billing labels Jul 10, 2026
@turip
turip force-pushed the feat/billing-sequence-service branch from a686bd0 to 3317677 Compare July 10, 2026 06:12
@turip
turip marked this pull request as ready for review July 10, 2026 06:12
@turip
turip requested a review from a team as a code owner July 10, 2026 06:12
@turip
turip merged commit 121f290 into main Jul 10, 2026
25 of 26 checks passed
@turip
turip deleted the feat/billing-sequence-service branch July 10, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants