Repository navigation
feat(api): add tax id and tax behavior to charges list api - #4263
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a typed tax-code reference and surfaces per-charge tax configuration: introduces ChangesCharge tax config + tax-code reference
sequenceDiagram
participant Client as rgba(20,120,255,0.5) Client
participant API as rgba(0,200,120,0.5) HTTP Handler
participant Conv as rgba(255,180,0,0.5) Converter
participant Service as rgba(200,60,200,0.5) Billing Service / DB
Client->>API: request charge/list
API->>Conv: build API model (convertTaxCodeConfigToAPI / wrappers)
Conv->>Service: read/write intent with TaxCodeID/Behavior
Service-->>Conv: stored intent (may include TaxCodeID/Behavior)
Conv-->>API: API model with TaxConfig (TaxCode ref + Behavior)
API-->>Client: response includes tax_config
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/spec/packages/aip/src/customers/charges/charges.tsp (1)
157-185: 💤 Low valueCould we give the nested tax-code reference a name?
The inline
{ id: Shared.ULID }shape will show up as an anonymous nested type in generated schemas/clients, which makes this payload a bit harder to document and reuse. A tiny named model would keep the contract clearer if tax-code references pop up elsewhere later.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@api/spec/packages/aip/src/customers/charges/charges.tsp` around lines 157 - 185, The inline anonymous shape for tax_code should be replaced with a named model: add a new model (e.g., TaxCodeRef or Billing.TaxCodeRef) with a single id: Shared.ULID field and appropriate `@summary/`@friendlyName, then update ChargeTaxConfig.tax_code to reference that model instead of the inline `{ id: Shared.ULID }`; ensure the new model is declared in the same file or a shared models file so generated schemas/clients will use the named type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@api/spec/packages/aip/src/customers/charges/charges.tsp`:
- Around line 157-185: The inline anonymous shape for tax_code should be
replaced with a named model: add a new model (e.g., TaxCodeRef or
Billing.TaxCodeRef) with a single id: Shared.ULID field and appropriate
`@summary/`@friendlyName, then update ChargeTaxConfig.tax_code to reference that
model instead of the inline `{ id: Shared.ULID }`; ensure the new model is
declared in the same file or a shared models file so generated schemas/clients
will use the named type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cb426364-e022-41dd-ba09-07f6e537772d
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (5)
api/spec/packages/aip/src/customers/charges/charges.tspapi/v3/api.gen.goapi/v3/handlers/customers/charges/convert.goapi/v3/handlers/customers/charges/convert_test.goopenmeter/billing/charges/service/taxcode_test.go
65770c9 to
03c8ef9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/spec/packages/aip/src/billing/tax.tsp`:
- Around line 49-64: The docs are ambiguous about precedence between the
deprecated tax_code_id and the new tax_code; update the comments for tax_code
(and/or tax_code_id) to explicitly state which field wins when both are provided
(e.g., "When both tax_code and tax_code_id are provided, tax_code takes
precedence and tax_code_id is ignored"), and mirror the same precedence rule
already documented for stripe.code so generated docs match runtime conversion
behavior; locate the fields tax_code_id, tax_code, and the TaxCodeReference
comment in this file and add the single-sentence precedence clarification.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 26ecfd23-f497-4f03-92ff-1f2176595ee5
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (9)
api/spec/packages/aip/src/billing/tax.tspapi/spec/packages/aip/src/customers/charges/charges.tspapi/spec/packages/aip/src/customers/credits/grant.tspapi/v3/api.gen.goapi/v3/handlers/billingprofiles/convert.goapi/v3/handlers/customers/charges/convert.goapi/v3/handlers/customers/charges/convert_test.goapi/v3/handlers/customers/credits/convert.goopenmeter/billing/charges/service/taxcode_test.go
✅ Files skipped from review due to trivial changes (4)
- api/spec/packages/aip/src/customers/credits/grant.tsp
- openmeter/billing/charges/service/taxcode_test.go
- api/v3/handlers/customers/credits/convert.go
- api/v3/api.gen.go
🚧 Files skipped from review as they are similar to previous changes (2)
- api/v3/handlers/customers/charges/convert_test.go
- api/v3/handlers/customers/charges/convert.go
03c8ef9 to
d2c748f
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openmeter/billing/charges/service/taxcode_test.go (1)
785-792: 💤 Low valueTiny nit:
taxConfigFlatandtaxConfigUsageare structurally identicalBoth configs share the same
InclusiveTaxBehaviorand point to the sametcID. Using distinct behaviors (e.g.,ExclusiveTaxBehaviorfor the usage-based charge) would make the per-type assertions independently meaningful rather than both asserting the same expected value.✨ Suggested tweak
taxConfigFlat := &productcatalog.TaxCodeConfig{ Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), TaxCodeID: &tcID, } taxConfigUsage := &productcatalog.TaxCodeConfig{ - Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), + Behavior: lo.ToPtr(productcatalog.ExclusiveTaxBehavior), TaxCodeID: &tcID, }…and update the usage-based assertion at line 881:
-s.Equal(productcatalog.InclusiveTaxBehavior, *ub.Intent.TaxConfig.Behavior) +s.Equal(productcatalog.ExclusiveTaxBehavior, *ub.Intent.TaxConfig.Behavior)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openmeter/billing/charges/service/taxcode_test.go` around lines 785 - 792, taxConfigFlat and taxConfigUsage are identical; change taxConfigUsage to use a different behavior (e.g., set Behavior to lo.ToPtr(productcatalog.ExclusiveTaxBehavior) while keeping TaxCodeID as &tcID) so the two configs differ, and update the corresponding usage-based assertion that checks tax behavior (the assertion referencing taxConfigUsage) to expect ExclusiveTaxBehavior instead of InclusiveTaxBehavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@openmeter/billing/charges/service/taxcode_test.go`:
- Around line 785-792: taxConfigFlat and taxConfigUsage are identical; change
taxConfigUsage to use a different behavior (e.g., set Behavior to
lo.ToPtr(productcatalog.ExclusiveTaxBehavior) while keeping TaxCodeID as &tcID)
so the two configs differ, and update the corresponding usage-based assertion
that checks tax behavior (the assertion referencing taxConfigUsage) to expect
ExclusiveTaxBehavior instead of InclusiveTaxBehavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3fbc5012-7e79-4ab1-8c30-0a87b2699f5d
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (9)
api/spec/packages/aip/src/billing/tax.tspapi/spec/packages/aip/src/customers/charges/charges.tspapi/spec/packages/aip/src/customers/credits/grant.tspapi/v3/api.gen.goapi/v3/handlers/billingprofiles/convert.goapi/v3/handlers/customers/charges/convert.goapi/v3/handlers/customers/charges/convert_test.goapi/v3/handlers/customers/credits/convert.goopenmeter/billing/charges/service/taxcode_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
- api/spec/packages/aip/src/customers/credits/grant.tsp
- api/spec/packages/aip/src/customers/charges/charges.tsp
- api/v3/handlers/customers/charges/convert_test.go
- api/v3/handlers/customers/charges/convert.go
- api/spec/packages/aip/src/billing/tax.tsp
d2c748f to
bb5f6fc
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openmeter/billing/charges/service/taxcode_test.go (1)
784-792: 💤 Low valueMinor:
taxConfigFlatandtaxConfigUsageshare the same&tcIDpointerBoth configs point to the same underlying variable:
tcID := tc.ID taxConfigFlat := &productcatalog.TaxCodeConfig{TaxCodeID: &tcID, ...} taxConfigUsage := &productcatalog.TaxCodeConfig{TaxCodeID: &tcID, ...}Since
tcIDis never mutated after construction this is harmless, but if either config is ever extended with different values you'd have a surprise. Since both configs are identical here anyway, you can simplify with a helper or just one variable:✨ Optional cleanup
- tcID := tc.ID - taxConfigFlat := &productcatalog.TaxCodeConfig{ - Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), - TaxCodeID: &tcID, - } - taxConfigUsage := &productcatalog.TaxCodeConfig{ - Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), - TaxCodeID: &tcID, - } + newTaxConfig := func() *productcatalog.TaxCodeConfig { + id := tc.ID + return &productcatalog.TaxCodeConfig{ + Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), + TaxCodeID: &id, + } + } + taxConfigFlat := newTaxConfig() + taxConfigUsage := newTaxConfig()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@openmeter/billing/charges/service/taxcode_test.go` around lines 784 - 792, taxConfigFlat and taxConfigUsage both reference the same &tcID pointer which can cause surprises if one is later mutated; change the construction so each TaxCodeConfig gets its own pointer (or reuse a single config/ helper) by either creating separate local copies like tcIDFlat := tc.ID and tcIDUsage := tc.ID and using &tcIDFlat / &tcIDUsage for productcatalog.TaxCodeConfig, or collapse to a single shared config variable if they must remain identical; update references to taxConfigFlat and taxConfigUsage accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@openmeter/billing/charges/service/taxcode_test.go`:
- Around line 784-792: taxConfigFlat and taxConfigUsage both reference the same
&tcID pointer which can cause surprises if one is later mutated; change the
construction so each TaxCodeConfig gets its own pointer (or reuse a single
config/ helper) by either creating separate local copies like tcIDFlat := tc.ID
and tcIDUsage := tc.ID and using &tcIDFlat / &tcIDUsage for
productcatalog.TaxCodeConfig, or collapse to a single shared config variable if
they must remain identical; update references to taxConfigFlat and
taxConfigUsage accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 31f41027-40fe-4b59-9de9-b50bfcb94152
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (9)
api/spec/packages/aip/src/billing/tax.tspapi/spec/packages/aip/src/customers/charges/charges.tspapi/spec/packages/aip/src/customers/credits/grant.tspapi/v3/api.gen.goapi/v3/handlers/billingprofiles/convert.goapi/v3/handlers/customers/charges/convert.goapi/v3/handlers/customers/charges/convert_test.goapi/v3/handlers/customers/credits/convert.goopenmeter/billing/charges/service/taxcode_test.go
✅ Files skipped from review due to trivial changes (3)
- api/spec/packages/aip/src/customers/credits/grant.tsp
- api/v3/handlers/customers/credits/convert.go
- api/v3/handlers/billingprofiles/convert.go
🚧 Files skipped from review as they are similar to previous changes (1)
- api/spec/packages/aip/src/billing/tax.tsp
211d41c to
b7f8ad8
Compare
@CodeRabbit
Summary by CodeRabbit
New Features
Tests
Documentation