feat(multi-entity): expose billing_entity_code on subscription, walle…#403
Merged
Conversation
…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.
toommz
approved these changes
Jun 22, 2026
aquinofb
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 onPOST /subscriptionsandPUT /subscriptions/:external_id.SubscriptionResponse.billing_entity_code— read back on every subscription response.Wallet.billing_entity_code— sent onPOST /walletsandPOST /customers/:external_id/wallets.WalletResponse.billing_entity_code— read back on every wallet response.OneOffInvoice.billing_entity_code— sent onPOST /invoices(one-off).InvoicePreview.billing_entity_code— sent onPOST /invoices/preview.CreditNoteResponse.billing_entity_code— read back on every credit-note response (InvoiceResponsealready had it).Notes
No list-endpoint changes were needed. The
FindAllCommandMixinalready takes a genericoptions: QueryPairsdict, andQueryPairsinservices/request.pyis typed asMapping[str, Union[int, str, list[str]]]— so callers can already passclient.subscriptions.find_all(options={"billing_entity_codes[]": ["EU", "US"]})againstGET /subscriptions,GET /wallets, andGET /payment_requestswithout any client refactor.Test plan
pytest tests/— 411 passedbilling_entity_codelands in__fields__forSubscription,SubscriptionResponse,Wallet,WalletResponse,OneOffInvoice,InvoicePreview,CreditNoteResponse.billing_entity_code, but a follow-up should add"billing_entity_code": "..."tosubscription.json,wallet.json,credit_note.jsonand corresponding assertions.