Skip to content

feat(api): add organization tax config - #4280

Merged
borbelyr-kong merged 7 commits into
mainfrom
feat/org-tax-config
May 6, 2026
Merged

borbelyr-kong merged 7 commits into
mainfrom
feat/org-tax-config

Conversation

@borbelyr-kong

@borbelyr-kong borbelyr-kong commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added GET and PUT endpoints to retrieve and update organization-level default tax codes at /openmeter/defaults/tax-codes.
  • Data Model

    • Introduced an organization defaults model capturing invoicing and credit-grant tax code references plus created/updated timestamps (read-only).
  • Documentation

    • Added "OpenMeter Defaults" tag and description for API discovery and docs.

@coderabbitai

coderabbitai Bot commented May 4, 2026 •

Copy link
Copy Markdown
Contributor

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: 4f059e8d-fb06-456c-ad9b-5eb7dc7c4bb4

📥 Commits

Reviewing files that changed from the base of the PR and between b5be28c and 168027d.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (5)
  • api/spec/packages/aip/src/defaults/operations.tsp
  • api/spec/packages/aip/src/defaults/taxcodes.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/v3/api.gen.go

📝 Walkthrough

Walkthrough

Adds an OrganizationDefaultTaxCodes model, REST operations (get/update), tag metadata and routed endpoints under /openmeter/defaults/tax-codes, imports defaults into package indices, and adds Go handler stubs that delegate to unimplemented implementations.

Changes

Organization Default Tax Codes

Layer / File(s) Summary
Data Model
api/spec/packages/aip/src/defaults/taxcodes.tsp
Adds Defaults.OrganizationDefaultTaxCodes with invoicing_tax_code and credit_grant_tax_code (Shared.ResourceReference<Tax.TaxCode>) and read-only created_at/updated_at.
Operation Definitions
api/spec/packages/aip/src/defaults/operations.tsp
Adds Defaults.OrganizationDefaultTaxCodesOperations with get() (@get, operationId: get-organization-default-tax-codes) and update(@Body ...) (@put, operationId: update-organization-default-tax-codes); responses include Shared.GetResponse/Shared.UpsertResponse, Common.NotFound, Common.ErrorResponses; applies Shared.Private/Unstable/Internal extensions.
Defaults Aggregation
api/spec/packages/aip/src/defaults/index.tsp
Imports ./taxcodes.tsp and ./operations.tsp so the defaults index aggregates the new definitions.
API Metadata
api/spec/packages/aip/src/shared/consts.tsp
Adds Shared.DefaultsTag = "OpenMeter Defaults" and Shared.DefaultsDescription = "Organization-level default configuration.".
API Integration
api/spec/packages/aip/src/openmeter.tsp, api/spec/packages/aip/src/konnect.tsp
Import defaults index, register @tagMetadata(Shared.DefaultsTag, #{ description: Shared.DefaultsDescription }), and add routed interface OrganizationDefaultTaxCodesEndpoints at /openmeter/defaults/tax-codes that extends Defaults.OrganizationDefaultTaxCodesOperations.
Server Routing
api/v3/server/routes.go
Adds Server handler stubs GetOrganizationDefaultTaxCodes and UpdateOrganizationDefaultTaxCodes that delegate to unimplemented implementations.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • turip
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: adding organization-level tax code configuration APIs across the spec and server implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/org-tax-config

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 added area/api release-note/misc Miscellaneous changes labels May 4, 2026

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between bc11393 and 8aec916.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (7)
  • api/spec/packages/aip/src/defaults/index.tsp
  • api/spec/packages/aip/src/defaults/operations.tsp
  • api/spec/packages/aip/src/defaults/taxcodes.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/v3/api.gen.go
  • api/v3/server/routes.go

Comment thread api/v3/server/routes.go
Comment on lines +446 to +452
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)
}

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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

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.

@borbelyr-kong
borbelyr-kong marked this pull request as ready for review May 4, 2026 17:50
@borbelyr-kong
borbelyr-kong requested a review from a team as a code owner May 4, 2026 17:50
@borbelyr-kong
borbelyr-kong force-pushed the feat/org-tax-config branch from 8aec916 to 5557d66 Compare May 4, 2026 17:53

@coderabbitai coderabbitai Bot left a comment

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.

♻️ Duplicate comments (1)
api/v3/server/routes.go (1)

446-452: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

These handlers are still unconditionally unimplemented 👀

Both GetOrganizationDefaultTaxCodes and UpdateOrganizationDefaultTaxCodes always hit the unimplemented.* 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8aec916 and 5557d66.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (7)
  • api/spec/packages/aip/src/defaults/index.tsp
  • api/spec/packages/aip/src/defaults/operations.tsp
  • api/spec/packages/aip/src/defaults/taxcodes.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/v3/api.gen.go
  • api/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

Comment thread api/v3/openapi.yaml Resolved
turip
turip previously approved these changes May 5, 2026
Comment thread api/spec/packages/aip/src/openmeter.tsp Resolved

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7efd163 and b5be28c.

⛔ Files ignored due to path filters (1)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (8)
  • api/spec/packages/aip/src/defaults/index.tsp
  • api/spec/packages/aip/src/defaults/operations.tsp
  • api/spec/packages/aip/src/defaults/taxcodes.tsp
  • api/spec/packages/aip/src/konnect.tsp
  • api/spec/packages/aip/src/openmeter.tsp
  • api/spec/packages/aip/src/shared/consts.tsp
  • api/v3/api.gen.go
  • api/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

@borbelyr-kong
borbelyr-kong requested a review from tothandras May 5, 2026 20:53
@borbelyr-kong
borbelyr-kong requested a review from turip May 5, 2026 20:53

This branch was previously deployed

1 inactive deployment
dev — 168027d4 Deployed May 6, 2026 by borbelyr-kong via Migration Checks #14113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants