Skip to content

feat(multi-entity): expose billing_entity_code on subscription, walle…#403

Merged
mariohd merged 1 commit into
mainfrom
ING-70-multi-billing-entity
Jun 26, 2026
Merged

feat(multi-entity): expose billing_entity_code on subscription, walle…#403
mariohd merged 1 commit into
mainfrom
ING-70-multi-billing-entity

Conversation

@mariohd

@mariohd mariohd commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Multi-entity additions to the Python client: callers can now pin a subscription, wallet, or one-off invoice to a specific billing entity at create/update time, and read the resolved entity back from subscription, wallet, invoice, and credit-note responses.

Changes

  • Subscription.billing_entity_code — sent on POST /subscriptions and PUT /subscriptions/:external_id.
  • SubscriptionResponse.billing_entity_code — read back on every subscription response.
  • Wallet.billing_entity_code — sent on POST /wallets and POST /customers/:external_id/wallets.
  • WalletResponse.billing_entity_code — read back on every wallet response.
  • OneOffInvoice.billing_entity_code — sent on POST /invoices (one-off).
  • InvoicePreview.billing_entity_code — sent on POST /invoices/preview.
  • CreditNoteResponse.billing_entity_code — read back on every credit-note response (InvoiceResponse already had it).

Notes

No list-endpoint changes were needed. The FindAllCommandMixin already takes a generic options: QueryPairs dict, and QueryPairs in services/request.py is typed as Mapping[str, Union[int, str, list[str]]] — so callers can already pass client.subscriptions.find_all(options={"billing_entity_codes[]": ["EU", "US"]}) against GET /subscriptions, GET /wallets, and GET /payment_requests without any client refactor.

Test plan

  • pytest tests/ — 411 passed
  • Smoke-checked that billing_entity_code lands in __fields__ for Subscription, SubscriptionResponse, Wallet, WalletResponse, OneOffInvoice, InvoicePreview, CreditNoteResponse.
  • (Not added in this PR) Fixture/assertion coverage for the new fields on the response side and for the request-body serialization. Existing tests don't break because their fixtures and expected payloads don't reference billing_entity_code, but a follow-up should add "billing_entity_code": "..." to subscription.json, wallet.json, credit_note.json and corresponding assertions.

…t, invoice, and credit-note models

## Context

The Lago API lets callers pin a subscription, wallet, or one-off
invoice to a specific billing entity within a multi-entity
organization, and returns the resolved entity on every resource
response (subscription, wallet, invoice, credit note). The Python
client's models did not carry the field, so callers couldn't set
it on create/update or read it back from the parsed responses.

## Description

Adds `billing_entity_code: Optional[str]` to the `Subscription` and
`Wallet` request models (POST + PUT) and to their response models,
to the `OneOffInvoice` and `InvoicePreview` request models for
`POST /invoices` and `POST /invoices/preview`, and to
`CreditNoteResponse` so the field is parsed from credit-note
payloads. No changes are needed for the list endpoints: the
`find_all` mixin already takes a generic `options: QueryPairs`
dict that natively carries `billing_entity_codes[]` as a list
value.
@mariohd mariohd requested review from a team, toommz and vincent-pochet and removed request for a team June 22, 2026 13:30
@mariohd mariohd merged commit bb9866d into main Jun 26, 2026
7 checks passed
@mariohd mariohd deleted the ING-70-multi-billing-entity branch June 26, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants