Skip to content

feat(currencies): refactor currencies package#4585

Merged
mark-vass-konghq merged 2 commits into
mainfrom
feat/reactor-currencies-api
Jul 1, 2026
Merged

feat(currencies): refactor currencies package#4585
mark-vass-konghq merged 2 commits into
mainfrom
feat/reactor-currencies-api

Conversation

@mark-vass-konghq

@mark-vass-konghq mark-vass-konghq commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added effective_to support for cost-basis records across the API, models, and database migration flow.
  • Bug Fixes
    • Ensure cost-basis effective_to is correctly preserved, exposed, and validated (including open-ended ranges).
    • Use currency code consistently in billing intent/gathering line outputs.
    • Improve allocation and Stripe amount formatting to follow the configured currency precision/rounding rules.
  • Documentation
    • Updated/added Currencyx guidance covering fiat vs custom precision, rounding, deterministic allocation, and validation.
  • Tests
    • Expanded unit and migration tests for effective_to behavior, validation, and rounding/precision.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds optional effective_to support for cost bases across specs, models, migrations, services, API conversions, and handlers. It also introduces the currencyx currency-type and rounding API, updates allocation helpers, and switches billing worker code to CurrencyCode().

Changes

Currency and cost-basis flow

Layer / File(s) Summary
Currencyx docs and skill
pkg/currencyx/README.md, .agents/skills/currencyx/SKILL.md, .agents/skills/currencyx/agents/openai.yaml
The currencyx README, skill guide, and agent config describe fiat and custom usage, rounding, allocation behavior, and review commands.
Currency types, validation, and rounding
pkg/currencyx/currency.go, pkg/currencyx/validation.go, pkg/currencyx/fiat.go, pkg/currencyx/currency_test.go
currencyx adds currency types, validation helpers, fiat and custom constructors, a calculator abstraction, and tests for interface, constructor, validation, and rounding behavior.
Allocation helpers and coverage
pkg/currencyx/allocation.go, pkg/currencyx/allocation_test.go
Allocation helpers round through calculator methods, and the tests add custom-precision coverage.
Cost-basis storage
openmeter/ent/schema/custom_currencies.go, openmeter/currencies/models.go, openmeter/currencies/adapter.go, openmeter/currencies/adapter/adapter.go, openmeter/currencies/adapter/currencies.go, tools/migrate/currency_cost_basis_test.go, tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.*.sql
The cost-basis schema, models, adapter, migrations, and migration test rename the foreign key to currency_id, add optional effective_to, and keep queries and row mapping aligned with the new shape.
Cost-basis validation
openmeter/currencies/service/service.go, openmeter/currencies/service/service_test.go
The currency service preserves validation responses for list and create calls, and CreateCostBasis now rejects effective_to values that are not after effective_from; tests cover the new date-range cases.
Public API contract
api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp, api/spec/packages/aip-client-javascript/src/models/schemas.ts, api/spec/packages/aip-client-javascript/src/models/types.ts, api/v3/handlers/currencies/convert.go, api/v3/handlers/currencies/convert_test.go
The cost-basis API schemas and client types add effective_to, and billing currency conversion maps that field into v3.BillingCostBasis with test coverage for bounded and open-ended values.
Currency handlers
api/v3/handlers/currencies/handler.go, api/v3/handlers/currencies/create.go, api/v3/handlers/currencies/create_cost_basis.go, api/v3/handlers/currencies/get_cost_bases.go, api/v3/handlers/currencies/list.go, api/v3/server/server.go, openmeter/server/router/router.go
The currencies router, handler constructor, and create and list handlers now use a shared namespace resolver and direct body parsing while keeping page validation and request shaping consistent.
Currency code consumers
openmeter/app/stripe/calculator.go, openmeter/billing/rating/service/rate/tieredgraduated.go, openmeter/billing/worker/subscriptionsync/service/reconciler/*.go, openmeter/billing/worker/subscriptionsync/service/targetstate/*.go
Billing rating, subscription-sync reconciliation, and Stripe formatting now read currency values through calculator accessors such as CurrencyCode(), CurrencyPrecision(), and Definition().

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • openmeterio/openmeter#4135: Shares the currencies conversion layer and the ToAPIBillingCurrency / ToAPIBillingCostBasis helpers that this PR updates.

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.00% 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 is concise and accurately reflects the main theme: a broad refactor of the currencies package and related currency handling.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/reactor-currencies-api

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.

@mark-vass-konghq mark-vass-konghq added release-note/feature Release note: Exciting New Features area/billing labels Jun 26, 2026
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors currency handling and adds cost-basis range support. The main changes are:

  • Added effective_to to cost-basis API, models, generated clients, and migrations.
  • Reworked pkg/currencyx around shared fiat and custom currency interfaces.
  • Updated calculator, allocation, billing, and Stripe paths to use configured precision and rounding.
  • Added currencyx guidance and expanded tests for precision, rounding, allocation, and cost-basis behavior.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
pkg/currencyx/fiat.go Moves calculator state behind constructors and accessors for currency precision and rounding.
pkg/currencyx/currency.go Adds the shared currency interface and custom currency type used by calculator construction.
pkg/currencyx/allocation.go Updates allocation to use calculator precision helpers instead of fiat definition fields.
openmeter/app/stripe/calculator.go Updates Stripe amount conversion to use the calculator precision accessor.

Reviews (9): Last reviewed commit: "fix: rabbit comment and tests" | Re-trigger Greptile

Comment thread pkg/currencyx/fiat.go
@mark-vass-konghq mark-vass-konghq force-pushed the feat/reactor-currencies-api branch from 83d7f1f to 6a2acf8 Compare June 26, 2026 14:24
@mark-vass-konghq mark-vass-konghq marked this pull request as ready for review June 26, 2026 14:24
@mark-vass-konghq mark-vass-konghq requested a review from a team as a code owner June 26, 2026 14:24
@greptile-apps

greptile-apps Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@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: 5

🧹 Nitpick comments (1)
tools/migrate/currency_cost_basis_test.go (1)

11-23: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift

This only checks file text, not migration behavior.

A migration can still fail to execute or mishandle existing rows while these substring checks keep passing. Since this change renames a persisted column and adds effective_to, I'd back this with a DB-backed migration test that seeds a row, runs the up/down migrations, and verifies the row survives with the expected values. As per path instructions, **/*_test.go: "When appropriate, recommend e2e tests for critical changes" and "Suggest missing tests only when the PR introduces behavior without meaningful coverage, or when the current tests would pass despite a concrete regression in the changed code."

🤖 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 `@tools/migrate/currency_cost_basis_test.go` around lines 11 - 23, The current
test only validates migration SQL text, so it can miss real execution failures
or row-loss regressions. Add a DB-backed migration test around the currency cost
basis migration that uses the existing migration helpers for
20260626133809_add_currency_cost_basis_effective_to.up.sql and .down.sql, seeds
a representative row, runs the up/down path, and asserts the row still exists
with the expected renamed currency_id and effective_to values. Keep the current
substring assertions if useful, but back them with behavior coverage in
TestCurrencyCostBasisEffectiveToMigrationPreservesRows or a new migration test.

Source: Path instructions

🤖 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/currencies/cost-bases/cost-basis.tsp`:
- Around line 34-39: The `effective_to` field documentation in `cost-basis.tsp`
only mentions the open-ended case and should also document the ordering
constraint enforced by the service. Update the doc comment on `effective_to`
near the `@visibility(Lifecycle.Create, Lifecycle.Read)` declaration so it
clearly states that, when provided, it must be later than `effective_from`,
while still noting that it is otherwise open-ended until superseded. Keep the
wording aligned with the existing `effective_from`/`effective_to` contract so
generated client docs match the actual behavior.

In `@api/v3/handlers/currencies/convert_test.go`:
- Around line 14-42: The ToAPIBillingCostBasis test only covers a populated
EffectiveTo pointer, so add a second case in
TestToAPIBillingCostBasisExposesIDAndEffectiveTo that passes a
currencies.CostBasis with EffectiveTo set to nil and asserts the API model keeps
EffectiveTo nil. Keep the existing checks for Id, FiatCode, Rate, EffectiveFrom,
and CreatedAt, and use the same ToAPIBillingCostBasis conversion path to verify
both the open-ended and bounded cost basis behaviors.

In `@openmeter/currencies/service/service_test.go`:
- Around line 317-319: In the validation test for the effective_to case in
service_test.go, tighten the assertion so it checks the returned error still
uses the validation-error wrapper, not just the message substrings. Update the
test around the existing assertions on err to verify the error type/contract
exposed by the currencies service validation path, alongside the current
effective_to message checks.

In `@pkg/currencyx/currency.go`:
- Around line 78-87: NewFiatCurrency is currently treating any currency returned
by currency.Get as fiat, including non-ISO definitions. Update NewFiatCurrency
to only accept currencies whose definition has a non-empty ISONumeric field,
using the existing currency.Get lookup and the currency.Code/code symbols to
locate the definition. If the lookup is missing or ISONumeric is empty, return
the fiat currency definition error; otherwise keep the current validation and
return the code as fiat.

In `@pkg/currencyx/validation.go`:
- Around line 68-84: Wrap the aggregated result from CustomCurrency.Validate
with the repo’s standard validation wrapper instead of returning raw
errors.Join(errs...). Keep collecting all issues in errs, then return
models.NewNillableGenericValidationError(errors.Join(errs...)) so this
Validate() method matches the shared validation-error contract; apply the same
pattern to the other new Validate() methods in currencyx.

---

Nitpick comments:
In `@tools/migrate/currency_cost_basis_test.go`:
- Around line 11-23: The current test only validates migration SQL text, so it
can miss real execution failures or row-loss regressions. Add a DB-backed
migration test around the currency cost basis migration that uses the existing
migration helpers for 20260626133809_add_currency_cost_basis_effective_to.up.sql
and .down.sql, seeds a representative row, runs the up/down path, and asserts
the row still exists with the expected renamed currency_id and effective_to
values. Keep the current substring assertions if useful, but back them with
behavior coverage in TestCurrencyCostBasisEffectiveToMigrationPreservesRows or a
new migration test.
🪄 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: adacf1c3-2ec4-4080-a380-6f82599c71f4

📥 Commits

Reviewing files that changed from the base of the PR and between a693618 and 6a2acf8.

⛔ Files ignored due to path filters (12)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
  • openmeter/ent/db/currencycostbasis.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis/currencycostbasis.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/customcurrency/customcurrency.go is excluded by !**/ent/db/**
  • openmeter/ent/db/customcurrency_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (34)
  • .agents/skills/currencyx/SKILL.md
  • .agents/skills/currencyx/agents/openai.yaml
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/currencies/convert.go
  • api/v3/handlers/currencies/convert_test.go
  • api/v3/handlers/currencies/create.go
  • api/v3/handlers/currencies/create_cost_basis.go
  • api/v3/handlers/currencies/get_cost_bases.go
  • api/v3/handlers/currencies/list.go
  • api/v3/handlers/currencies/request.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchcharge_test.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/currencies/adapter.go
  • openmeter/currencies/adapter/adapter.go
  • openmeter/currencies/adapter/currencies.go
  • openmeter/currencies/models.go
  • openmeter/currencies/service/service.go
  • openmeter/currencies/service/service_test.go
  • openmeter/ent/schema/custom_currencies.go
  • pkg/currencyx/README.md
  • pkg/currencyx/allocation.go
  • pkg/currencyx/allocation_test.go
  • pkg/currencyx/currency.go
  • pkg/currencyx/currency_test.go
  • pkg/currencyx/fiat.go
  • pkg/currencyx/validation.go
  • tools/migrate/currency_cost_basis_test.go
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.down.sql
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.up.sql
💤 Files with no reviewable changes (1)
  • openmeter/currencies/adapter.go

Comment thread api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp
Comment thread api/v3/handlers/currencies/convert_test.go
Comment thread openmeter/currencies/service/service_test.go
Comment thread pkg/currencyx/currency.go
Comment thread pkg/currencyx/validation.go
@mark-vass-konghq mark-vass-konghq force-pushed the feat/reactor-currencies-api branch from 6a2acf8 to d7e9b9a Compare June 26, 2026 15:25

@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

🧹 Nitpick comments (1)
openmeter/billing/rating/service/rate/tieredgraduated.go (1)

112-137: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Fold the new currency check into aggregated validation.

Since this Validate() error was touched, please collect all validation failures in errs []error instead of adding another fail-fast return, so callers can see every invalid input at once. As per coding guidelines, "**/*.go: For Go Validate() error methods, collect all validation issues into var errs []error and return models.NewNillableGenericValidationError(errors.Join(errs...)) instead of failing fast."

🤖 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 `@openmeter/billing/rating/service/rate/tieredgraduated.go` around lines 112 -
137, The TieredPriceCalculatorInput.Validate method currently returns on the
first error, but it should aggregate all validation failures. Change the
validation flow to collect issues in a var errs []error, keep the existing
checks for TieredPrice.Validate, GraduatedTieredPrice mode, FromQty, ToQty, and
Currency, append each failure instead of returning immediately, and finish by
returning models.NewNillableGenericValidationError(errors.Join(errs...)) when
any errors are present.

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.

Inline comments:
In `@pkg/currencyx/fiat.go`:
- Around line 59-62: NewCalculator and Calculator.Validate() are accepting
non-ISO currency definitions, unlike NewFiatCurrency. Update the fiat checks in
those paths to require a valid definition with a non-empty ISONumeric before
treating a currency as fiat, using the existing currency.Get/currency.Code
lookup in NewCalculator and the validation logic in Calculator.Validate(). Keep
the same error style as the current fiat validation messages so all fiat
creation and validation paths enforce the same contract.

---

Nitpick comments:
In `@openmeter/billing/rating/service/rate/tieredgraduated.go`:
- Around line 112-137: The TieredPriceCalculatorInput.Validate method currently
returns on the first error, but it should aggregate all validation failures.
Change the validation flow to collect issues in a var errs []error, keep the
existing checks for TieredPrice.Validate, GraduatedTieredPrice mode, FromQty,
ToQty, and Currency, append each failure instead of returning immediately, and
finish by returning
models.NewNillableGenericValidationError(errors.Join(errs...)) when any errors
are present.
🪄 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: 4b2e0dba-69b7-4eab-9804-a35a4479b851

📥 Commits

Reviewing files that changed from the base of the PR and between 6a2acf8 and d7e9b9a.

⛔ Files ignored due to path filters (12)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
  • openmeter/ent/db/currencycostbasis.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis/currencycostbasis.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/customcurrency/customcurrency.go is excluded by !**/ent/db/**
  • openmeter/ent/db/customcurrency_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (38)
  • .agents/skills/currencyx/SKILL.md
  • .agents/skills/currencyx/agents/openai.yaml
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/currencies/convert.go
  • api/v3/handlers/currencies/convert_test.go
  • api/v3/handlers/currencies/create.go
  • api/v3/handlers/currencies/create_cost_basis.go
  • api/v3/handlers/currencies/get_cost_bases.go
  • api/v3/handlers/currencies/handler.go
  • api/v3/handlers/currencies/list.go
  • api/v3/server/server.go
  • openmeter/app/stripe/calculator.go
  • openmeter/billing/rating/service/rate/tieredgraduated.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchcharge_test.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/currencies/adapter.go
  • openmeter/currencies/adapter/adapter.go
  • openmeter/currencies/adapter/currencies.go
  • openmeter/currencies/models.go
  • openmeter/currencies/service/service.go
  • openmeter/currencies/service/service_test.go
  • openmeter/ent/schema/custom_currencies.go
  • openmeter/server/router/router.go
  • pkg/currencyx/README.md
  • pkg/currencyx/allocation.go
  • pkg/currencyx/allocation_test.go
  • pkg/currencyx/currency.go
  • pkg/currencyx/currency_test.go
  • pkg/currencyx/fiat.go
  • pkg/currencyx/validation.go
  • tools/migrate/currency_cost_basis_test.go
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.down.sql
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.up.sql
💤 Files with no reviewable changes (1)
  • openmeter/currencies/adapter.go
✅ Files skipped from review due to trivial changes (2)
  • .agents/skills/currencyx/SKILL.md
  • pkg/currencyx/README.md
🚧 Files skipped from review as they are similar to previous changes (24)
  • api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • api/v3/handlers/currencies/create.go
  • api/v3/handlers/currencies/convert_test.go
  • .agents/skills/currencyx/agents/openai.yaml
  • openmeter/currencies/models.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchcharge_test.go
  • api/v3/handlers/currencies/create_cost_basis.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/currencies/service/service.go
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.down.sql
  • openmeter/currencies/adapter/adapter.go
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.up.sql
  • api/v3/handlers/currencies/convert.go
  • pkg/currencyx/allocation_test.go
  • openmeter/ent/schema/custom_currencies.go
  • pkg/currencyx/allocation.go
  • openmeter/currencies/adapter/currencies.go
  • openmeter/currencies/service/service_test.go
  • pkg/currencyx/validation.go
  • pkg/currencyx/currency_test.go

Comment thread pkg/currencyx/fiat.go
@mark-vass-konghq mark-vass-konghq force-pushed the feat/reactor-currencies-api branch from d7e9b9a to ca7eb79 Compare June 26, 2026 17:21

@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: 2

🤖 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 `@pkg/currencyx/currency.go`:
- Around line 16-23: CurrencyType.Validate currently returns a raw fmt.Errorf on
invalid values, which breaks the package’s standard validation contract. Update
CurrencyType.Validate to follow the usual validation pattern used elsewhere in
the repo: collect issues in a var errs []error, append the invalid-type error
for the default case, and return
models.NewNillableGenericValidationError(errors.Join(errs...)). Keep the
existing CurrencyType.Validate symbol and make sure it matches the repo’s
validation shape consistently.

In `@pkg/currencyx/fiat.go`:
- Around line 20-27: The RoundingMode.Validate method currently returns a raw
fmt.Errorf on invalid input, unlike the package’s standard aggregated validation
pattern. Update RoundingMode.Validate to collect issues in a var errs []error,
append the invalid-mode error when needed, and return
models.NewNillableGenericValidationError(errors.Join(errs...)) instead of
returning a direct error; keep the valid cases returning nil.
🪄 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: 357f10e1-b7d8-4370-a718-6ced72938f7a

📥 Commits

Reviewing files that changed from the base of the PR and between d7e9b9a and ca7eb79.

⛔ Files ignored due to path filters (12)
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
  • openmeter/ent/db/currencycostbasis.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis/currencycostbasis.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/currencycostbasis_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/customcurrency/customcurrency.go is excluded by !**/ent/db/**
  • openmeter/ent/db/customcurrency_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (38)
  • .agents/skills/currencyx/SKILL.md
  • .agents/skills/currencyx/agents/openai.yaml
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/currencies/convert.go
  • api/v3/handlers/currencies/convert_test.go
  • api/v3/handlers/currencies/create.go
  • api/v3/handlers/currencies/create_cost_basis.go
  • api/v3/handlers/currencies/get_cost_bases.go
  • api/v3/handlers/currencies/handler.go
  • api/v3/handlers/currencies/list.go
  • api/v3/server/server.go
  • openmeter/app/stripe/calculator.go
  • openmeter/billing/rating/service/rate/tieredgraduated.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchcharge_test.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/currencies/adapter.go
  • openmeter/currencies/adapter/adapter.go
  • openmeter/currencies/adapter/currencies.go
  • openmeter/currencies/models.go
  • openmeter/currencies/service/service.go
  • openmeter/currencies/service/service_test.go
  • openmeter/ent/schema/custom_currencies.go
  • openmeter/server/router/router.go
  • pkg/currencyx/README.md
  • pkg/currencyx/allocation.go
  • pkg/currencyx/allocation_test.go
  • pkg/currencyx/currency.go
  • pkg/currencyx/currency_test.go
  • pkg/currencyx/fiat.go
  • pkg/currencyx/validation.go
  • tools/migrate/currency_cost_basis_test.go
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.down.sql
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.up.sql
💤 Files with no reviewable changes (1)
  • openmeter/currencies/adapter.go
✅ Files skipped from review due to trivial changes (3)
  • .agents/skills/currencyx/SKILL.md
  • pkg/currencyx/README.md
  • openmeter/billing/rating/service/rate/tieredgraduated.go
🚧 Files skipped from review as they are similar to previous changes (30)
  • api/spec/packages/aip-client-javascript/src/models/schemas.ts
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/server/router/router.go
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.down.sql
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • api/spec/packages/aip-client-javascript/src/models/types.ts
  • .agents/skills/currencyx/agents/openai.yaml
  • api/v3/server/server.go
  • api/v3/handlers/currencies/create.go
  • api/v3/handlers/currencies/handler.go
  • api/v3/handlers/currencies/list.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchcharge_test.go
  • tools/migrate/migrations/20260626133809_add_currency_cost_basis_effective_to.up.sql
  • api/spec/packages/aip/src/currencies/cost-bases/cost-basis.tsp
  • pkg/currencyx/allocation_test.go
  • api/v3/handlers/currencies/convert_test.go
  • pkg/currencyx/allocation.go
  • tools/migrate/currency_cost_basis_test.go
  • openmeter/currencies/service/service.go
  • api/v3/handlers/currencies/convert.go
  • api/v3/handlers/currencies/create_cost_basis.go
  • api/v3/handlers/currencies/get_cost_bases.go
  • openmeter/currencies/models.go
  • pkg/currencyx/validation.go
  • openmeter/currencies/adapter/adapter.go
  • openmeter/ent/schema/custom_currencies.go
  • openmeter/currencies/service/service_test.go
  • pkg/currencyx/currency_test.go
  • openmeter/currencies/adapter/currencies.go

Comment thread pkg/currencyx/currency.go
Comment thread pkg/currencyx/fiat.go
@mark-vass-konghq mark-vass-konghq force-pushed the feat/reactor-currencies-api branch 4 times, most recently from bb0b786 to 38a4902 Compare July 1, 2026 08:46
@mark-vass-konghq mark-vass-konghq force-pushed the feat/reactor-currencies-api branch from 38a4902 to d833b2d Compare July 1, 2026 08:47
@mark-vass-konghq mark-vass-konghq enabled auto-merge (squash) July 1, 2026 08:55
@mark-vass-konghq mark-vass-konghq merged commit c0a5530 into main Jul 1, 2026
28 checks passed
@mark-vass-konghq mark-vass-konghq deleted the feat/reactor-currencies-api branch July 1, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing release-note/feature Release note: Exciting New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants