feat: expose unit_config on the v3 invoice line rate card#4730
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (9)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughInvoice line rate-card contracts now expose optional unit configuration snapshots across the API specification, generated clients, and JavaScript SDK. Billing conversion populates the snapshot, tests cover both presence and absence, and update payloads use dedicated input types. ChangesInvoice unit configuration propagation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant BillingStandardLine
participant mapRateCard
participant BillingInvoiceLineRateCard
participant APIClient
BillingStandardLine->>mapRateCard: provide unit configuration snapshot
mapRateCard->>BillingInvoiceLineRateCard: populate UnitConfig
BillingInvoiceLineRateCard->>APIClient: expose unit_config in invoice response
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4121b30 to
d55d33f
Compare
What
Surfaces the OM-398
unit_configsnapshot on the v3 invoice API's per-linerate card (read-only). The config that was applied when a usage-based line was
billed — the conversion rule that turned raw metered units into billed units —
is now readable on
BillingInvoiceLineRateCard. Pure exposure: no schema, nomigration, nil snapshot is omitted, so invoices without a unit_config are
byte-identical to today.
Why
unit_config was fully persisted on invoice lines (OM-398,
BillingInvoiceUsageBasedLineConfig.unit_config) and reached the billing domain(
StandardLine.GetUnitConfig), but stopped at the v3 invoice converter —mapRateCardnever read it and no v3 invoice type had a field to hold it, sothe applied conversion was invisible over the API (v1 or v3). This is the first
of the invoice-read exposure fast-follows the epic deferred behind the v3
invoice API track; billed amounts were already correct, this just makes the
applied config auditable to API consumers.
How
unit_configfield toInvoiceLineRateCard(
invoices/invoice.tsp), reusing the existing productcatalogUnitConfigmodel; regenerate OpenAPI + the Go/JS SDKs.
mapRateCardmaps the snapshot via the existingplans.ToAPIBillingUnitConfig(reused, not hand-rolled); a nil snapshot isomitted, so the field is naturally identity when no config was applied.
@visibility(Lifecycle.Read)forks the SDK's update projection into adistinct
UpdateInvoiceLineRateCard. This is correct: unit_config is awrite-once billing-time snapshot and must not be settable via invoice update.
The one e2e literal that built an update line is moved to the new type.
type, and a nil snapshot is omitted. No e2e: the v3 invoice API only serves
standard invoices, but a pure-usage subscription line stays on a gathering
invoice until its period closes in the past (v3
SubscriptionCreatecan'tstart a subscription in the past), so an end-to-end fixture would need a
v1 past-dated subscription — deferred as not worth the fragility since the
mapping is unit-tested.
No schema/migration. Gated implicitly by the same
unitConfig.enabledauthoringflag — an absent snapshot reads as omitted.
Summary by CodeRabbit
unit_configsnapshot that shows how metered quantity is converted at billing time.unit_configwhen creating or updating invoice line rate cards via the new input payload type.unit_configfield.unit_configis mapped when present and omitted when absent, and updated e2e request helpers for the new rate-card update type.Greptile Summary
This PR exposes the billing-time unit conversion snapshot on v3 invoice line rate cards. The main changes are:
unit_configfield to the TypeSpec and OpenAPI models.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
unit_configas an optional read-only API property.Reviews (2): Last reviewed commit: "feat: expose unit_config on the v3 invoi..." | Re-trigger Greptile
Context used (3)