Repository navigation
feat(billing): depraracate tax code setting on billing profile - #4504
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:
📝 WalkthroughWalkthroughThis PR enforces deprecation of tax code field assignments on billing profile default tax configurations. It adds validation logic that rejects create/update attempts to add or modify ChangesTax Code Deprecation Enforcement
Sequence DiagramssequenceDiagram
participant CreateProfile
participant UpdateProfile
participant WithDeprecatedTaxCodeEnforced
participant BillingAdapter
CreateProfile->>WithDeprecatedTaxCodeEnforced: Validate incoming config vs zero-value
alt Add or Change Attempted
WithDeprecatedTaxCodeEnforced-->>CreateProfile: Return ValidationError
else Removal or No-op
WithDeprecatedTaxCodeEnforced-->>CreateProfile: Allow (possibly normalized)
CreateProfile->>BillingAdapter: Persist profile
end
UpdateProfile->>WithDeprecatedTaxCodeEnforced: Validate incoming vs existing profile config
alt Add or Change Attempted
WithDeprecatedTaxCodeEnforced-->>UpdateProfile: Return ValidationError
else Removal or No-op
WithDeprecatedTaxCodeEnforced-->>UpdateProfile: Allow (possibly normalized)
UpdateProfile->>BillingAdapter: Persist updated profile
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes The PR introduces a new validation checkpoint with solid test coverage and integrates it cleanly into existing handler flows. The test refactoring spans multiple files and shifts intent from preservation to deprecation enforcement, requiring careful review of each test change to confirm intent alignment and assertion correctness. Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
aebd198 to
ee12371
Compare
|
@greptileai review this draft |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/billing/taxcode_dual_write_test.go (1)
95-155: ⚡ Quick winCover the
taxCodeIdservice path too.These new rejection tests only exercise
DefaultTaxConfig.Stripe.Code, but the deprecation rule here blocks bothstripe.codeandtaxCodeId. Right now a service-level regression in theTaxCodeIDbranch would still leave this suite green. Adding one create case and one update case withDefaultTaxConfig.TaxCodeIDwould close that gap nicely.As per coding guidelines,
**/*_test.go: "Make sure the tests are comprehensive and cover the changes."🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/billing/taxcode_dual_write_test.go` around lines 95 - 155, Add parallel assertions that exercise the taxCodeId path by creating new cases (or extending the existing tests TestProfileCreateWithTaxCodeRejected and TestProfileUpdateAddTaxCodeRejected) which set input.WorkflowConfig.Invoicing.DefaultTaxConfig.TaxCodeID (instead of/in addition to Stripe.Code) when calling BillingService.CreateProfile and BillingService.UpdateProfile; ensure you assert the returned error is a billing.ValidationError and that no default profile or TaxCode entity is persisted (same GetDefaultProfile and DBClient.TaxCode.Query() checks) after the rejected create/update.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/billing/taxcode_dual_write_test.go`:
- Around line 95-155: Add parallel assertions that exercise the taxCodeId path
by creating new cases (or extending the existing tests
TestProfileCreateWithTaxCodeRejected and TestProfileUpdateAddTaxCodeRejected)
which set input.WorkflowConfig.Invoicing.DefaultTaxConfig.TaxCodeID (instead
of/in addition to Stripe.Code) when calling BillingService.CreateProfile and
BillingService.UpdateProfile; ensure you assert the returned error is a
billing.ValidationError and that no default profile or TaxCode entity is
persisted (same GetDefaultProfile and DBClient.TaxCode.Query() checks) after the
rejected create/update.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3ebc3605-db37-47aa-8d42-1d0363eb2aab
📒 Files selected for processing (7)
openmeter/billing/profile.goopenmeter/billing/profile_test.goopenmeter/billing/service/profile.goopenmeter/productcatalog/tax.gotest/billing/suite.gotest/billing/tax_test.gotest/billing/taxcode_dual_write_test.go
✅ Files skipped from review due to trivial changes (1)
- openmeter/productcatalog/tax.go
Greptile SummaryEnforces deprecation of
Confidence Score: 5/5Safe to merge; the gate logic is straightforward and backed by 20+ unit tests plus updated integration tests. The core gate function is well-structured, covered by a comprehensive table-driven test, and the two-pass ordering (gate → resolver) is preserved in UpdateProfile with a clear comment. The only finding is a stale method name in a doc comment. No logic regressions were identified. No files require special attention; the suite.go doc comment stale reference is cosmetic only. Important Files Changed
|
26ef38e to
8083bef
Compare
4879485 to
0a39d58
Compare
- Delete profiletaxdeprecation.go (CheckProfileTaxConfigDeprecation) and remove the duplicate handler-layer calls from httpdriver/profile.go and both api/v3/handlers/billingprofiles handlers. The gate now lives exclusively in InvoicingConfig.EnforceTaxCodeDeprecation called from the service. - Rename profiletaxdeprecation_test.go → profile_test.go to match the method's new home on InvoicingConfig. - Add missing TaxCode entity assertion in TestProfileUpdateAddTaxCodeRejected (parity with the analogous create test). - Add 'create: both stripe.code and taxCodeId set is rejected' test case. - Clarify the zero-value stored argument on the CreateProfile call site.
0a39d58 to
daa27cd
Compare
@coderabbitai
Summary by CodeRabbit
Release Notes
New Features
stripe.code/taxCodeIdcan no longer be added or changed. The organization default tax code is used instead;behaviorremains supported. Existing deprecated values may be removed.Documentation
Tests