Repository navigation
feat(api): add organization tax config - #4280
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughAdds an OrganizationDefaultTaxCodes model, REST operations (get/update), tag metadata and routed endpoints under ChangesOrganization Default Tax Codes
Sequence DiagramsequenceDiagram
participant Client
participant Server as "API Server"
participant DB as "Database"
rect rgba(100, 150, 200, 0.5)
note over Client,Server: GET /openmeter/defaults/tax-codes
Client->>Server: GET /openmeter/defaults/tax-codes
Server->>DB: Query organization default tax codes
DB-->>Server: OrganizationDefaultTaxCodes
Server-->>Client: 200 OK + GetResponse<OrganizationDefaultTaxCodes>
end
rect rgba(150, 200, 100, 0.5)
note over Client,Server: PUT /openmeter/defaults/tax-codes
Client->>Server: PUT /openmeter/defaults/tax-codes + body
Server->>DB: Upsert organization default tax codes
DB-->>Server: Updated OrganizationDefaultTaxCodes
Server-->>Client: 200 OK + UpsertResponse<OrganizationDefaultTaxCodes>
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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.
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/v3/server/routes.go`:
- Around line 446-452: These public handlers on
Server—GetOrganizationDefaultTaxCodes and
UpdateOrganizationDefaultTaxCodes—currently call unimplemented.* stubs; either
remove the public route or replace the stubs with real logic: for
GetOrganizationDefaultTaxCodes, call the existing service method (e.g.,
s.taxService.GetOrganizationDefaultTaxCodes or equivalent), marshal the result
to JSON and write with appropriate status codes and error handling; for
UpdateOrganizationDefaultTaxCodes, parse and validate the request body, call the
update method on the server's tax/defaults service (e.g.,
s.taxService.UpdateOrganizationDefaultTaxCodes), handle validation/errors and
return the updated resource or status. Ensure to use Server's existing logger
and common response helpers (error responses, JSON helpers) rather than
delegating to unimplemented.
🪄 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: cc9c3d98-f909-4632-ac2f-24f9786fbbfc
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (7)
api/spec/packages/aip/src/defaults/index.tspapi/spec/packages/aip/src/defaults/operations.tspapi/spec/packages/aip/src/defaults/taxcodes.tspapi/spec/packages/aip/src/openmeter.tspapi/spec/packages/aip/src/shared/consts.tspapi/v3/api.gen.goapi/v3/server/routes.go
| func (s *Server) GetOrganizationDefaultTaxCodes(w http.ResponseWriter, r *http.Request) { | ||
| unimplemented.GetOrganizationDefaultTaxCodes(w, r) | ||
| } | ||
|
|
||
| func (s *Server) UpdateOrganizationDefaultTaxCodes(w http.ResponseWriter, r *http.Request) { | ||
| unimplemented.UpdateOrganizationDefaultTaxCodes(w, r) | ||
| } |
There was a problem hiding this comment.
Public endpoint is wired but still always unimplemented.
Line 446 and Line 450 always delegate to unimplemented, so the newly published defaults API cannot actually be used yet. Please either wire these methods to real handlers before exposing the route, or keep the endpoint out of the public API surface until implementation lands.
As per coding guidelines: "The declared API should be accurate, in parity with the actual implementation, and easy to understand for the user."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@api/v3/server/routes.go` around lines 446 - 452, These public handlers on
Server—GetOrganizationDefaultTaxCodes and
UpdateOrganizationDefaultTaxCodes—currently call unimplemented.* stubs; either
remove the public route or replace the stubs with real logic: for
GetOrganizationDefaultTaxCodes, call the existing service method (e.g.,
s.taxService.GetOrganizationDefaultTaxCodes or equivalent), marshal the result
to JSON and write with appropriate status codes and error handling; for
UpdateOrganizationDefaultTaxCodes, parse and validate the request body, call the
update method on the server's tax/defaults service (e.g.,
s.taxService.UpdateOrganizationDefaultTaxCodes), handle validation/errors and
return the updated resource or status. Ensure to use Server's existing logger
and common response helpers (error responses, JSON helpers) rather than
delegating to unimplemented.
8aec916 to
5557d66
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
api/v3/server/routes.go (1)
446-452:⚠️ Potential issue | 🟠 Major | ⚡ Quick winThese handlers are still unconditionally unimplemented 👀
Both
GetOrganizationDefaultTaxCodesandUpdateOrganizationDefaultTaxCodesalways hit theunimplemented.*stub — no feature gate, no nil guard, no real logic. The endpoints are live and publicly routed, but will always return a 501. If the real implementation isn't ready yet, consider either keeping the route out of the public surface until it is, or at least adding a feature-gate check similar to the Credits/Charges handlers so it's clear when the feature becomes active.🤖 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 `@api/v3/server/routes.go` around lines 446 - 452, The two handlers GetOrganizationDefaultTaxCodes and UpdateOrganizationDefaultTaxCodes currently always call unimplemented.* and thus return 501; update each handler to either remove public routing or add the same feature-gate and nil-guard logic used by the Credits/Charges handlers: check the feature flag (e.g., enableOrganizationTaxCodes or similar) and/or verify required service dependencies on the Server struct before calling business logic, returning a 404/403 or a clear feature-disabled response when the gate is off, and only call the real implementation when the gate/dependencies are present; ensure you reference and mirror the pattern used in the Credits/Charges handlers so authorization, logging, and response semantics remain consistent.
🤖 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.
Duplicate comments:
In `@api/v3/server/routes.go`:
- Around line 446-452: The two handlers GetOrganizationDefaultTaxCodes and
UpdateOrganizationDefaultTaxCodes currently always call unimplemented.* and thus
return 501; update each handler to either remove public routing or add the same
feature-gate and nil-guard logic used by the Credits/Charges handlers: check the
feature flag (e.g., enableOrganizationTaxCodes or similar) and/or verify
required service dependencies on the Server struct before calling business
logic, returning a 404/403 or a clear feature-disabled response when the gate is
off, and only call the real implementation when the gate/dependencies are
present; ensure you reference and mirror the pattern used in the Credits/Charges
handlers so authorization, logging, and response semantics remain consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 18911acb-b870-40ed-a173-916329a86c5e
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (7)
api/spec/packages/aip/src/defaults/index.tspapi/spec/packages/aip/src/defaults/operations.tspapi/spec/packages/aip/src/defaults/taxcodes.tspapi/spec/packages/aip/src/openmeter.tspapi/spec/packages/aip/src/shared/consts.tspapi/v3/api.gen.goapi/v3/server/routes.go
✅ Files skipped from review due to trivial changes (2)
- api/spec/packages/aip/src/shared/consts.tsp
- api/spec/packages/aip/src/defaults/index.tsp
🚧 Files skipped from review as they are similar to previous changes (3)
- api/spec/packages/aip/src/defaults/taxcodes.tsp
- api/spec/packages/aip/src/defaults/operations.tsp
- api/spec/packages/aip/src/openmeter.tsp
7efd163 to
6a07f87
Compare
6a07f87 to
23772ea
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@api/spec/packages/aip/src/defaults/taxcodes.tsp`:
- Around line 17-24: Both invoicing_tax_code and credit_grant_tax_code are
currently required, which forces GET responses and update payloads to always
include them; change their declarations to be optional so they can be omitted
when not configured. Edit the properties invoicing_tax_code and
credit_grant_tax_code in the defaults/taxcodes.tsp type to use optional fields
(e.g., add the optional marker used by your schema language such as a trailing
“?” on the property name or allow null/undefined in the type) so callers can
omit either field, and ensure any runtime validators or serializers that
reference invoicing_tax_code or credit_grant_tax_code accept missing values.
🪄 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: 03c7651f-c6d7-4997-a9ab-061fd8d1fe97
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (8)
api/spec/packages/aip/src/defaults/index.tspapi/spec/packages/aip/src/defaults/operations.tspapi/spec/packages/aip/src/defaults/taxcodes.tspapi/spec/packages/aip/src/konnect.tspapi/spec/packages/aip/src/openmeter.tspapi/spec/packages/aip/src/shared/consts.tspapi/v3/api.gen.goapi/v3/server/routes.go
🚧 Files skipped from review as they are similar to previous changes (2)
- api/v3/server/routes.go
- api/spec/packages/aip/src/defaults/operations.tsp
Summary by CodeRabbit
New Features
Data Model
Documentation