Skip to content

feat(taxcode): add organization default tax codes HTTP handlers#4320

Merged
borbelyr-kong merged 2 commits into
mainfrom
feat/org-tax-config-handlers
May 11, 2026
Merged

feat(taxcode): add organization default tax codes HTTP handlers#4320
borbelyr-kong merged 2 commits into
mainfrom
feat/org-tax-config-handlers

Conversation

@borbelyr-kong
Copy link
Copy Markdown
Contributor

@borbelyr-kong borbelyr-kong commented May 7, 2026

@coderabbitai

Summary by CodeRabbit

New Features

  • Added ability to retrieve organization default tax code configuration
  • Added ability to update organization default tax code settings for invoicing and credit grants

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

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: 59f9f459-61b2-4f6a-bd3c-36c60f750c5c

📥 Commits

Reviewing files that changed from the base of the PR and between 1682b2c and 7398e04.

📒 Files selected for processing (6)
  • api/v3/handlers/taxcodes/convert.gen.go
  • api/v3/handlers/taxcodes/convert.go
  • api/v3/handlers/taxcodes/get_organization_default_tax_codes.go
  • api/v3/handlers/taxcodes/handler.go
  • api/v3/handlers/taxcodes/upsert_organization_default_tax_codes.go
  • api/v3/server/routes.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • api/v3/handlers/taxcodes/handler.go
  • api/v3/handlers/taxcodes/convert.gen.go
  • api/v3/handlers/taxcodes/upsert_organization_default_tax_codes.go
  • api/v3/handlers/taxcodes/get_organization_default_tax_codes.go

📝 Walkthrough

Walkthrough

This PR wires up two HTTP endpoints for managing organization default tax codes. It adds conversion helpers to translate between API tax code references and internal ID strings, generates bidirectional converters using goverter, implements GET and UPSERT handlers that coordinate with the service layer, and connects both endpoints to their route handlers.

Changes

Organization Default Tax Codes API Implementation

Layer / File(s) Summary
Conversion Infrastructure
api/v3/handlers/taxcodes/convert.go
Adds errors import, goverter extend directives, and three custom conversion helpers: IDStringToTaxCodeReference() wraps a string ID into a tax code reference, while InvoicingTaxCodeReferenceToIDString() and CreditGrantTaxCodeReferenceToIDString() validate non-nil references with non-empty IDs or return validation errors.
Generated Converters
api/v3/handlers/taxcodes/convert.go, api/v3/handlers/taxcodes/convert.gen.go
Goverter configuration maps taxcode.OrganizationDefaultTaxCodes to api.OrganizationDefaultTaxCodes with ID↔reference conversion helpers. FromAPIUpdateOrganizationDefaultTaxCodesRequest maps the API request into internal UpsertOrganizationDefaultTaxCodesInput and assigns the namespace. ToAPIOrganizationDefaultTaxCodes maps the stored model back to the API response with timestamps and reversed ID↔reference conversions.
Handler Interface Contract
api/v3/handlers/taxcodes/handler.go
Handler interface extended with GetOrganizationDefaultTaxCodes() and UpsertOrganizationDefaultTaxCodes() method signatures.
GET Handler
api/v3/handlers/taxcodes/get_organization_default_tax_codes.go
Type aliases define request, response, and handler types. Implementation resolves namespace from context, calls the service, converts the result via ToAPIOrganizationDefaultTaxCodes, and returns JSON with HTTP 200 OK.
UPSERT Handler
api/v3/handlers/taxcodes/upsert_organization_default_tax_codes.go
Type aliases define request, response, and handler types. Implementation decodes the JSON body, resolves namespace, converts the API request via FromAPIUpdateOrganizationDefaultTaxCodesRequest, calls the service, converts the result via ToAPIOrganizationDefaultTaxCodes, and returns JSON with HTTP 200 OK plus transport options for operation name and error encoding.
Route Wiring
api/v3/server/routes.go
GetOrganizationDefaultTaxCodes and UpdateOrganizationDefaultTaxCodes endpoints now delegate to the taxcodes handler implementations instead of returning unimplemented responses.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • openmeterio/openmeter#4280: Main PR implements the OrganizationDefaultTaxCodes API (converters, handlers, and routes) that directly correspond to and complete the spec/endpoint additions (operations, model, and stubbed routes) introduced in the retrieved PR #4280.
  • openmeterio/openmeter#4294: The retrieved PR adds the OrganizationDefaultTaxCodes ent schema and DB migration while the main PR implements API handlers and converters that map to that same organization-default-tax-codes model, so they are related.
  • openmeterio/openmeter#4263: Both PRs modify API tax-code reference types and add/adjust conversion logic between tax-code reference objects and internal ID fields (i.e., they touch the same tax-code conversion concerns across API converters), so they are related.

Suggested labels

release-note/feature, area/api, area/billing

Suggested reviewers

  • tothandras
  • turip
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding HTTP handlers for organization default tax codes operations in the taxcode API.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/org-tax-config-handlers

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
api/v3/handlers/taxcodes/convert.go (1)

101-113: 💤 Low value

Easy DRY win: shared private helper for the reference converters.

InvoicingTaxCodeReferenceToIDString and CreditGrantTaxCodeReferenceToIDString are character-for-character identical except for the error string. A small private helper cleans this up nicely.

♻️ Proposed refactor
+func taxCodeReferenceToIDString(ref *api.TaxCodeReference, field string) (string, error) {
+	if ref == nil || ref.Id == "" {
+		return "", models.NewGenericValidationError(fmt.Errorf("%s is required", field))
+	}
+	return ref.Id, nil
+}
+
 func InvoicingTaxCodeReferenceToIDString(ref *api.TaxCodeReference) (string, error) {
-	if ref == nil || ref.Id == "" {
-		return "", models.NewGenericValidationError(errors.New("invoicing_tax_code.id is required"))
-	}
-	return ref.Id, nil
+	return taxCodeReferenceToIDString(ref, "invoicing_tax_code.id")
 }
 
 func CreditGrantTaxCodeReferenceToIDString(ref *api.TaxCodeReference) (string, error) {
-	if ref == nil || ref.Id == "" {
-		return "", models.NewGenericValidationError(errors.New("credit_grant_tax_code.id is required"))
-	}
-	return ref.Id, nil
+	return taxCodeReferenceToIDString(ref, "credit_grant_tax_code.id")
 }

(You'd swap errors.New for fmt.Errorf, or keep the errors import and use errors.New(field + " is required") — whatever style fits the file best.)

🤖 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/handlers/taxcodes/convert.go` around lines 101 - 113, The two
functions InvoicingTaxCodeReferenceToIDString and
CreditGrantTaxCodeReferenceToIDString are identical except for the error
message; create a small private helper (e.g., taxCodeRefToIDString(ref
*api.TaxCodeReference, fieldName string) (string, error)) that checks ref and
ref.Id and returns the id or a models.NewGenericValidationError with a
constructed message like "<fieldName> is required", then replace both
InvoicingTaxCodeReferenceToIDString and CreditGrantTaxCodeReferenceToIDString to
call this helper with the appropriate field name; use fmt.Errorf or errors.New
for building the message consistent with the file's imports.
🤖 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/v3/handlers/taxcodes/upsert_organization_default_tax_codes.go`:
- Around line 3-13: The import block in upsert_organization_default_tax_codes.go
is misordered causing gci formatting errors; run the project's import formatter
(e.g., gci write on this file or the repo make target that formats imports) to
reorder/group imports correctly so the file passes CI. Ensure the imports around
symbols context, net/http, api (github.com/openmeterio/openmeter/api/v3),
apierrors, request, taxcode, commonhttp, and httptransport are formatted by the
tool and then commit the updated file.

---

Nitpick comments:
In `@api/v3/handlers/taxcodes/convert.go`:
- Around line 101-113: The two functions InvoicingTaxCodeReferenceToIDString and
CreditGrantTaxCodeReferenceToIDString are identical except for the error
message; create a small private helper (e.g., taxCodeRefToIDString(ref
*api.TaxCodeReference, fieldName string) (string, error)) that checks ref and
ref.Id and returns the id or a models.NewGenericValidationError with a
constructed message like "<fieldName> is required", then replace both
InvoicingTaxCodeReferenceToIDString and CreditGrantTaxCodeReferenceToIDString to
call this helper with the appropriate field name; use fmt.Errorf or errors.New
for building the message consistent with the file's imports.
🪄 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: 8eb19632-eedb-4b9b-ac67-bef43cd016c4

📥 Commits

Reviewing files that changed from the base of the PR and between 231ba12 and 74c90dd.

📒 Files selected for processing (6)
  • api/v3/handlers/taxcodes/convert.gen.go
  • api/v3/handlers/taxcodes/convert.go
  • api/v3/handlers/taxcodes/get_organization_default_tax_codes.go
  • api/v3/handlers/taxcodes/handler.go
  • api/v3/handlers/taxcodes/upsert_organization_default_tax_codes.go
  • api/v3/server/routes.go

Comment thread api/v3/handlers/taxcodes/upsert_organization_default_tax_codes.go
Base automatically changed from feat/org-tax-config-service to main May 11, 2026 10:53
@borbelyr-kong borbelyr-kong force-pushed the feat/org-tax-config-handlers branch from df81cec to 1682b2c Compare May 11, 2026 11:37
@borbelyr-kong borbelyr-kong marked this pull request as ready for review May 11, 2026 11:37
@borbelyr-kong borbelyr-kong requested a review from a team as a code owner May 11, 2026 11:37
@borbelyr-kong borbelyr-kong requested review from tothandras and turip May 11, 2026 11:59
@borbelyr-kong borbelyr-kong merged commit 23d9f70 into main May 11, 2026
41 of 42 checks passed
@borbelyr-kong borbelyr-kong deleted the feat/org-tax-config-handlers branch May 11, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/misc Miscellaneous changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants