Skip to content

feat(taxcode): seed default Stripe tax codes at server startup#4039

Draft
borbelyr-kong wants to merge 1 commit intomainfrom
feat/tax-code-seeds
Draft

feat(taxcode): seed default Stripe tax codes at server startup#4039
borbelyr-kong wants to merge 1 commit intomainfrom
feat/tax-code-seeds

Conversation

@borbelyr-kong
Copy link
Copy Markdown
Contributor

@borbelyr-kong borbelyr-kong commented Mar 30, 2026

Summary by CodeRabbit

  • New Features
    • Default tax codes are now automatically provisioned during server startup, making a curated set of Stripe tax codes immediately available for use in your system.

@borbelyr-kong borbelyr-kong requested a review from a team as a code owner March 30, 2026 18:39
@borbelyr-kong borbelyr-kong added the release-note/ignore Ignore this change when generating release notes label Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6c2ffab7-a5d7-41b3-b615-82d1fffe54a8

📥 Commits

Reviewing files that changed from the base of the PR and between e1aef59 and 8382186.

📒 Files selected for processing (5)
  • cmd/server/main.go
  • openmeter/server/server_test.go
  • openmeter/taxcode/defaults.go
  • openmeter/taxcode/service.go
  • openmeter/taxcode/service/taxcode.go

📝 Walkthrough

Walkthrough

This PR adds default tax code provisioning to the server startup sequence. It introduces a new interface method to the TaxCodeService for seeding predefined Stripe tax codes, implements the method with idempotent conflict handling, defines the default tax code seeds, and wires the provisioning call into server initialization before meter setup.

Changes

Cohort / File(s) Summary
Server startup integration
cmd/server/main.go
Wires ProvisionDefaultTaxCodes into server startup after namespace and sandbox initialization but before meter setup; logs and exits on failure.
Service interface & implementation
openmeter/taxcode/service.go, openmeter/taxcode/service/taxcode.go
Adds ProvisionDefaultTaxCodes method to the Service interface and implements it with transactional seeding of default Stripe tax codes, skipping conflicts by treating existing keys as non-fatal.
Default tax code seeds
openmeter/taxcode/defaults.go
New file defining DefaultTaxCodeSeed struct and DefaultStripeTaxCodes slice containing curated Stripe tax code entries with keys, names, optional descriptions, and Stripe identifiers.
Test utilities
openmeter/server/server_test.go
Adds no-op ProvisionDefaultTaxCodes method to NoopTaxCodeService for test support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • tothandras
  • turip
  • GAlexIHU
  • hekike
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding default Stripe tax code provisioning at server startup, which is reflected across multiple files in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/tax-code-seeds

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 and usage tips.

@borbelyr-kong borbelyr-kong marked this pull request as draft March 30, 2026 18:55
// seed CreateTaxCode call will hit the unique constraint and be silently skipped.
var DefaultStripeTaxCodes = []DefaultTaxCodeSeed{
{
Key: "stripe_txcd_00000000",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd choose a key that's specific to our platform. When we support other providers, the same tax code will map between providers.

Suggested change
Key: "stripe_txcd_00000000",
Key: "non_taxable",

or we can define a format for OM

Suggested change
Key: "stripe_txcd_00000000",
Key: "om_......",

import "github.com/samber/lo"

// DefaultTaxCodeSeed holds the minimal inputs needed to seed one well-known tax code.
type DefaultTaxCodeSeed struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we reuse the CreateTaxCodeInput type?

// Keys follow the same convention used by GetOrCreateByAppMapping: "stripe_<code>".
// This ensures that if a code was already auto-created by the billing flow, the
// seed CreateTaxCode call will hit the unique constraint and be silently skipped.
var DefaultStripeTaxCodes = []DefaultTaxCodeSeed{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should come from config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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