Skip to content

Fix charge-backed discount invoice edits#4603

Merged
turip merged 8 commits into
mainfrom
feat/billing-discount-charge-edits
Jun 29, 2026
Merged

Fix charge-backed discount invoice edits#4603
turip merged 8 commits into
mainfrom
feat/billing-discount-charge-edits

Conversation

@turip

@turip turip commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

This fixes discount edits for charge-backed invoice lines by making charge discount persistence use the billing discount envelope consistently.

  • Introduce billing.Discounts wrappers that preserve discount correlation IDs for percentage and usage discounts.
  • Store charge and override discounts in the same billing discount shape used by invoice lines.
  • Add the flat-fee override discounts field while leaving the previous percentage-only field deprecated.
  • Normalize missing discount correlation IDs when invoice-line overrides are applied, so API edits can omit them safely.
  • Route flat-fee manual discount edits through the charge line engine and persist the resulting override/current run totals.
  • Add a warning log from the v1 invoice edit endpoint with the rejected edit payload and rejection details.

Root Cause

Charge-backed invoice-line edits could introduce rate-card discounts without the billing correlation ID shape expected by detailed-line calculation. For flat-fee charge-managed lines, the edit path also needed the charge override storage to match the invoice-line discount envelope so recalculation could happen through the charge engine instead of trying to update managed invoice lines directly.

Validation

  • go vet -tags=dynamic ./...
  • env POSTGRES_HOST=127.0.0.1 go test -tags=dynamic -count=1 ./openmeter/billing/worker/subscriptionsync/service ./openmeter/billing/charges/flatfee/... ./openmeter/billing/charges/usagebased/... ./api/v3/handlers/customers/charges
  • env POSTGRES_HOST=127.0.0.1 go test -tags=dynamic -count=1 ./openmeter/billing/httpdriver
  • make test-nocache

Summary by CodeRabbit

  • New Features
    • Unified, billing-scoped discounts are now used across flat-fee and usage-based charge intents, overrides, pending lines, and subscription/charge syncing (including invoice editing).
    • Flat-fee charge overrides now persist discounts via the unified discounts structure.
    • Discount correlation IDs are automatically generated/upserted as discounts are converted and applied.
  • Bug Fixes
    • Improved discount preservation and correct propagation through credit-then-invoice and related workflows.
  • Observability
    • Added structured warning logs when invoice edits are rejected.
  • Tests / Documentation
    • Added new e2e flat-fee discount edit tests and updated related unit tests and testing guidance.

@coderabbitai

coderabbitai Bot commented Jun 29, 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

This PR switches discount handling to billing-scoped types across charge conversion, persistence, service, reconciliation, and invoice-edit flows. It also adds shared discount helpers, correlation-ID propagation, invoice logging, and new manual discount-edit test coverage.

Changes

Billing Discounts Migration

Layer / File(s) Summary
Discount helpers and correlation IDs
openmeter/billing/discount.go
Adds CloneOrNil, Validate, DiscountsFromProductCatalog, and UpsertCorrelationIDs on billing discount types.
Flat-fee discount types and persistence
openmeter/billing/charges/flatfee/charge.go, openmeter/billing/charges/flatfee/adapter/*, openmeter/ent/schema/chargesflatfee.go, tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.*
Flat-fee charge structs, ent schema, override persistence, and migration switch to billing.Discounts and the new override discounts column.
Usage-based discount mapping
openmeter/billing/charges/usagebased/charge.go, openmeter/billing/charges/usagebased/rating.go, openmeter/billing/charges/usagebased/service/create.go, openmeter/billing/charges/usagebased/adapter/intentoverride_test.go, openmeter/billing/charges/usagebased/service/rating/testutils/testutils.go
Usage-based charge types and helpers now use billing.Discounts and clone rate-card discounts directly.
Service-layer discount cloning
openmeter/billing/charges/flatfee/service/create.go, openmeter/billing/charges/flatfee/service/manualedit.go, openmeter/billing/charges/service/pendinglines.go, openmeter/billing/service/invoicecalc/discounts.go, openmeter/billing/stdinvoiceedit.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
Service paths now clone discount objects directly and delegate correlation-ID updates to shared UpsertCorrelationIDs() behavior.
API conversion and invoice logging
api/v3/handlers/customers/charges/convert.go, openmeter/billing/httpdriver/deprecations.go, openmeter/billing/httpdriver/handler.go, openmeter/billing/httpdriver/invoice.go
API conversion paths now use billing discount types and correlation IDs, and invoice edit rejections emit structured warnings when a logger is present.
Discount edit sync and e2e coverage
openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go, e2e/billinginvoice_discount_edit_test.go, e2e/creditsdisabled/billinginvoice_discount_edit_test.go
Adds coverage for manual percentage-discount edits on draft invoices and updates discount-related assertions.
Test guidance docs
AGENTS.md, .agents/skills/e2e/SKILL.md
Test guidance updates helper-function usage rules for e2e and general test code.

Sequence Diagram(s)

sequenceDiagram
  participant CustomerChargesHandler
  participant billing
  participant api
  CustomerChargesHandler->>billing: DiscountsFromProductCatalog / UpsertCorrelationIDs
  billing-->>CustomerChargesHandler: billing.Discounts
  CustomerChargesHandler->>api: map flat-fee or usage-based intent
  api-->>CustomerChargesHandler: charge intent with billing discounts
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

release-note/deprecation, kind/bug

Suggested reviewers

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

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% 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 matches the main change: fixing invoice edits for charge-backed discounts.
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/billing-discount-charge-edits

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.

@turip turip marked this pull request as ready for review June 29, 2026 15:35
@turip turip requested a review from a team as a code owner June 29, 2026 15:35
@turip turip added the release-note/bug-fix Release note: Bug Fixes label Jun 29, 2026
@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates charge-backed invoice discount editing to use the billing discount envelope. The main changes are:

  • Billing discount wrappers now preserve correlation IDs.
  • Flat-fee and usage-based charge discounts are stored in the billing discount shape.
  • Flat-fee override rows get a new discounts field.
  • Invoice edit paths normalize missing discount correlation IDs.
  • Flat-fee manual discount edits run through the charge line engine.
  • Rejected invoice edit requests now include warning logs.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
openmeter/billing/discount.go Adds billing-scoped discount wrappers, validation, cloning, catalog conversion, and correlation ID upsert helpers.
openmeter/billing/charges/flatfee/adapter/intentoverride.go Moves flat-fee override discount persistence to the new billing discount envelope.
openmeter/billing/charges/flatfee/service/manualedit.go Copies rate-card discount data from edited invoice lines into flat-fee charge override intents.
openmeter/ent/schema/chargesflatfee.go Adds the flat-fee override discounts column and updates charge discount fields to billing discount types.

Reviews (7): Last reviewed commit: "test(e2e): accept any standard invoice f..." | Re-trigger Greptile

Comment thread openmeter/billing/charges/flatfee/adapter/intentoverride.go

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

🤖 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 `@openmeter/billing/charges/flatfee/adapter/intentoverride_test.go`:
- Around line 129-134: The intent override test in requireOverrideMatches
currently verifies only Percentage, so a regression that changes
billing.PercentageDiscount.CorrelationID would still pass. Update the assertions
in intentoverride_test.go to also check the CorrelationID on the seeded
billing.PercentageDiscount, using the existing requireOverrideMatches path and
the test fixture that sets PercentageDiscounts, so both fields are covered.

In `@openmeter/billing/discount.go`:
- Around line 135-152: Discounts.Validate is wrapping the joined validation
errors with models.NewGenericValidationError and an extra “discounts:” prefix
instead of using the repo-standard nillable validation error. Update
Discounts.Validate to keep aggregating Percentage and Usage errors into errs,
then return models.NewNillableGenericValidationError(errors.Join(errs...))
directly so callers like usagebased.IntentMutableFields.Validate don’t
double-prefix the field name and the validation shape stays consistent.

In `@openmeter/billing/httpdriver/invoice.go`:
- Around line 533-538: The rejection log in invoice edit handling is leaking
sensitive tenant data by writing request.Input verbatim. Update the billing
invoice edit warning in the invoice edit path to omit the raw payload and
instead log only identifiers from request.InvoiceID plus invoiceType and a
redacted or summarized payload shape; keep the existing rejection error detail.
Use the logging call in the invoice edit rejection branch as the target for this
change.

In
`@openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go`:
- Around line 8922-8928: The assertTotals helper is using suite-based equality
for alpacadecimal.Decimal values instead of the repo’s preferred decimal
assertion style. Update the checks in CreditThenInvoiceTestSuite.assertTotals to
use require.Equal with s.T() and the InexactFloat64() values, matching the
existing test pattern for decimal comparisons and keeping the same expected
fields (Amount, DiscountsTotal, CreditsTotal, Total).
- Around line 4307-4308: The current test only checks the percentage value and
misses correlation ID propagation. Update the assertions around
editedInvoiceLine.RateCardDiscounts.Percentage to also verify a non-empty
CorrelationID, and extend assertFlatFeeIntent so it validates the propagated
charge intent discount CorrelationID as well. Use the existing edited invoice
line and discount helper paths to ensure the edit flow still preserves/backfills
the discount ID.

In
`@tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.up.sql`:
- Line 2: The migration for charge_flat_fee_overrides only adds the new
discounts column and leaves existing percentage_discounts data behind, so older
overrides will read as empty through billing.Discounts. Update the migration to
backfill existing rows by transforming percentage_discounts into the new
discounts JSON shape as part of the same change, using the
charge_flat_fee_overrides table and its legacy percentage_discounts column so
previously saved overrides remain visible after the schema switch.
🪄 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: b8f425b1-1938-465a-b24b-169b5e64a1fa

📥 Commits

Reviewing files that changed from the base of the PR and between eaeb4d5 and 2b673ed.

⛔ Files ignored due to path filters (25)
  • openmeter/ent/db/billinginvoiceline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoiceline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee/chargeflatfee.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride/chargeflatfeeoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased/chargeusagebased.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride/chargeusagebasedoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride_update.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/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (28)
  • api/v3/handlers/customers/charges/convert.go
  • openmeter/billing/charges/flatfee/adapter/charge.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride_test.go
  • openmeter/billing/charges/flatfee/adapter/mapper.go
  • openmeter/billing/charges/flatfee/charge.go
  • openmeter/billing/charges/flatfee/service/create.go
  • openmeter/billing/charges/flatfee/service/manualedit.go
  • openmeter/billing/charges/service/pendinglines.go
  • openmeter/billing/charges/usagebased/adapter/intentoverride_test.go
  • openmeter/billing/charges/usagebased/charge.go
  • openmeter/billing/charges/usagebased/rating.go
  • openmeter/billing/charges/usagebased/service/create.go
  • openmeter/billing/charges/usagebased/service/rating/testutils/testutils.go
  • openmeter/billing/discount.go
  • openmeter/billing/httpdriver/deprecations.go
  • openmeter/billing/httpdriver/handler.go
  • openmeter/billing/httpdriver/invoice.go
  • openmeter/billing/service/invoicecalc/discounts.go
  • openmeter/billing/stdinvoiceedit.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/ent/schema/chargesflatfee.go
  • openmeter/ent/schema/chargesusagebased.go
  • tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.down.sql
  • tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.up.sql

Comment thread openmeter/billing/charges/flatfee/adapter/intentoverride_test.go
Comment thread openmeter/billing/discount.go Outdated
Comment thread openmeter/billing/httpdriver/invoice.go
Comment thread openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go Outdated
Comment thread openmeter/billing/charges/flatfee/adapter/intentoverride.go
@turip turip force-pushed the feat/billing-discount-charge-edits branch from f312cd5 to 2d347a2 Compare June 29, 2026 16:57

@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 `@e2e/billinginvoice_discount_edit_test.go`:
- Around line 238-285: The current test in billinginvoice_discount_edit_test
only exercises the update endpoint and still hard-codes the discount
CorrelationId, so it won’t catch regressions in the new discount normalization
flow. Update the test around the invoice edit path to send the percentage
discount without CorrelationId, then verify the returned invoice or a subsequent
GetInvoice shows the edited line persisted with a generated correlation ID and
the expected 50% discount. Keep the assertions focused on the update flow in
UpdateInvoiceWithResponse and the line discount data in the invoice response.

In `@e2e/creditsdisabled/billinginvoice_discount_edit_test.go`:
- Around line 238-285: The credits-disabled invoice edit test still sets a
CorrelationId and only checks for a 200 response, so it can miss regressions in
discount ID backfilling or persistence. Update the test around the invoice line
update in billinginvoice_discount_edit_test.go to omit the CorrelationId when
building the BillingDiscounts/ BillingDiscountPercentage for the edited line,
then assert the response from UpdateInvoiceWithResponse returns the line with a
generated ID and the expected 50% percentage discount. Use the existing invoice
update flow and response assertions near replacementLines and updateResp to
locate the change.
🪄 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: 8a6333f7-8ef4-4f5e-a7d9-6791a80b4b3d

📥 Commits

Reviewing files that changed from the base of the PR and between f312cd5 and 2d347a2.

⛔ Files ignored due to path filters (25)
  • openmeter/ent/db/billinginvoiceline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoiceline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee/chargeflatfee.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride/chargeflatfeeoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeeoverride_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased/chargeusagebased.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride/chargeusagebasedoverride.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedoverride_update.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/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (32)
  • .agents/skills/e2e/SKILL.md
  • AGENTS.md
  • api/v3/handlers/customers/charges/convert.go
  • e2e/billinginvoice_discount_edit_test.go
  • e2e/creditsdisabled/billinginvoice_discount_edit_test.go
  • openmeter/billing/charges/flatfee/adapter/charge.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride_test.go
  • openmeter/billing/charges/flatfee/adapter/mapper.go
  • openmeter/billing/charges/flatfee/charge.go
  • openmeter/billing/charges/flatfee/service/create.go
  • openmeter/billing/charges/flatfee/service/manualedit.go
  • openmeter/billing/charges/service/pendinglines.go
  • openmeter/billing/charges/usagebased/adapter/intentoverride_test.go
  • openmeter/billing/charges/usagebased/charge.go
  • openmeter/billing/charges/usagebased/rating.go
  • openmeter/billing/charges/usagebased/service/create.go
  • openmeter/billing/charges/usagebased/service/rating/testutils/testutils.go
  • openmeter/billing/discount.go
  • openmeter/billing/httpdriver/deprecations.go
  • openmeter/billing/httpdriver/handler.go
  • openmeter/billing/httpdriver/invoice.go
  • openmeter/billing/service/invoicecalc/discounts.go
  • openmeter/billing/stdinvoiceedit.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/ent/schema/chargesflatfee.go
  • openmeter/ent/schema/chargesusagebased.go
  • tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.down.sql
  • tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.up.sql
✅ Files skipped from review due to trivial changes (2)
  • .agents/skills/e2e/SKILL.md
  • AGENTS.md
🚧 Files skipped from review as they are similar to previous changes (28)
  • tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.down.sql
  • openmeter/billing/service/invoicecalc/discounts.go
  • openmeter/billing/httpdriver/deprecations.go
  • openmeter/billing/charges/flatfee/service/create.go
  • openmeter/billing/stdinvoiceedit.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.go
  • openmeter/billing/charges/usagebased/rating.go
  • openmeter/billing/charges/usagebased/service/rating/testutils/testutils.go
  • tools/migrate/migrations/20260629144435_add_charge_flat_fee_override_discounts.up.sql
  • openmeter/ent/schema/chargesusagebased.go
  • openmeter/billing/charges/flatfee/adapter/mapper.go
  • openmeter/billing/charges/usagebased/adapter/intentoverride_test.go
  • openmeter/billing/charges/usagebased/service/create.go
  • openmeter/billing/worker/subscriptionsync/service/targetstate/targetstateitem.go
  • openmeter/billing/charges/flatfee/adapter/charge.go
  • openmeter/billing/charges/flatfee/service/manualedit.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride.go
  • openmeter/billing/httpdriver/handler.go
  • openmeter/ent/schema/chargesflatfee.go
  • openmeter/billing/charges/usagebased/charge.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride_test.go
  • api/v3/handlers/customers/charges/convert.go
  • openmeter/billing/discount.go
  • openmeter/billing/charges/service/pendinglines.go
  • openmeter/billing/httpdriver/invoice.go
  • openmeter/billing/charges/flatfee/charge.go
  • openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go

Comment thread e2e/billinginvoice_discount_edit_test.go
Comment thread e2e/creditsdisabled/billinginvoice_discount_edit_test.go

@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/legacy/src/billing/invoices/invoice.tsp`:
- Around line 659-661: The shared discounts property on the invoice model is
being deprecated even though it is still valid for create and update inputs,
which will incorrectly mark writable SDK fields as deprecated. Remove the
`#deprecated` annotation from the discounts member in the invoice.tsp definition
and keep the V1 read-only limitation in the description, or move the deprecation
to a response-only projection if the intent is read-only. Use the discounts
property and the invoice shape definition to locate the change.
🪄 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: 62104875-aa67-44c1-85a9-3e82b1e01498

📥 Commits

Reviewing files that changed from the base of the PR and between 70a9e71 and 1c6b983.

⛔ Files ignored due to path filters (4)
  • api/client/go/client.gen.go is excluded by !api/client/**
  • api/client/javascript/src/client/schemas.ts is excluded by !api/client/**
  • api/openapi.cloud.yaml is excluded by !**/openapi.cloud.yaml
  • api/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (4)
  • api/api.gen.go
  • api/spec/packages/legacy/src/billing/invoices/invoice.tsp
  • e2e/billinginvoice_discount_edit_test.go
  • e2e/creditsdisabled/billinginvoice_discount_edit_test.go
💤 Files with no reviewable changes (2)
  • e2e/billinginvoice_discount_edit_test.go
  • e2e/creditsdisabled/billinginvoice_discount_edit_test.go

Comment thread api/spec/packages/legacy/src/billing/invoices/invoice.tsp
tothandras
tothandras previously approved these changes Jun 29, 2026
@turip turip merged commit d10745e into main Jun 29, 2026
29 checks passed
@turip turip deleted the feat/billing-discount-charge-edits branch June 29, 2026 18:32
@tothandras

Copy link
Copy Markdown
Contributor

approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants