feat(api): Add tax_id and tax_behavior to charges list api#4262
feat(api): Add tax_id and tax_behavior to charges list api#4262mark-vass-konghq wants to merge 2 commits into
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds an optional charge-level tax configuration model and surfaces it through the API and conversion layer; updates generated Go types and adds unit/integration tests validating mapping and persistence for flat-fee and usage-based charges. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Handler as Handler
participant Converter
participant DB
participant API_Response as Response
Client->>API_Handler: Request charge(s) list or charge entity
API_Handler->>DB: Query charge records (include tax config fields)
DB-->>API_Handler: Return charge records (may include tax config)
API_Handler->>Converter: convert internal model -> API model (calls convertTaxCodeConfigToAPI)
Converter-->>API_Handler: API charge objects with optional BillingChargeTaxConfig
API_Handler-->>Response: Send JSON response to Client
Response-->>Client: JSON payload includes optional tax_config
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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 docstrings
🧪 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openmeter/billing/charges/service/taxcode_test.go (1)
784-819: ⚡ Quick winUse separate tax config values for each seeded charge.
Both intents currently share the same
taxConfigpointer. If any create/backfill path mutates it in place, the two assertions become coupled and this test can hide a bug. Duplicating the tiny struct per intent keeps the fixture isolated.Small fixture tweak
- taxConfig := &productcatalog.TaxCodeConfig{ - Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), - TaxCodeID: &tc.ID, - } + flatFeeTaxConfig := &productcatalog.TaxCodeConfig{ + Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), + TaxCodeID: &tc.ID, + } + usageBasedTaxConfig := &productcatalog.TaxCodeConfig{ + Behavior: lo.ToPtr(productcatalog.InclusiveTaxBehavior), + TaxCodeID: &tc.ID, + }🤖 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 - 819, The test currently reuses the same taxConfig pointer for both mock intents which couples their state; create a separate productcatalog.TaxCodeConfig instance for each intent (e.g., taxConfigFlat for "flat-fee-list-taxcode" and taxConfigUsage for "usage-based-list-taxcode") and pass those distinct pointers into the respective s.createMockChargeIntent calls so each seeded charge has its own independent taxConfig.
🤖 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-819: The test currently reuses the same taxConfig pointer for
both mock intents which couples their state; create a separate
productcatalog.TaxCodeConfig instance for each intent (e.g., taxConfigFlat for
"flat-fee-list-taxcode" and taxConfigUsage for "usage-based-list-taxcode") and
pass those distinct pointers into the respective s.createMockChargeIntent calls
so each seeded charge has its own independent taxConfig.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 63afa3b9-27bb-4332-8a08-2f83b470c64f
⛔ 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
@coderabbitai
Summary by CodeRabbit
New Features
Tests