Repository navigation
test(payment-term): Cover structured payment_term requests - #106
Draft
annvelents wants to merge 1 commit into
Draft
annvelents wants to merge 1 commit into
annvelents wants to merge 1 commit into
Conversation
This was referenced Nov 9, 2026
Draft
Draft
annvelents
added a commit
to getlago/lago-openapi
that referenced
this pull request
Nov 10, 2026
Documents Lago's structured payment terms for everything already merged on lago-api `main` (#6201 customers and billing entities, #6195 invoices, #6234 subscriptions and invoice preview). - New `PaymentTermObject`: `term_type` (`due_on_receipt`, `net`, `end_of_month`, `net_end_of_month`, `days_end_of_month`, `day_of_month`), `days` 0..365, `day_of_month` 1..31, `month_offset` 0..12 (default 1), with the per-type rules and the `error_details.payment_term` codes (`invalid_format`, `invalid_term_type`, `unexpected_fields`, `invalid_days`, `invalid_day_of_month`, `invalid_month_offset`). - `payment_term` on: customer create and object; billing entity create, update and object; organization object (read-only — the default billing entity's term; `PUT /organizations` takes only `net_payment_term`); subscription create, update and object; invoice object; invoice preview (top-level). - Invoice preview: term resolution and the 422 `subscription_payment_terms_do_not_match`. - `net_payment_term` marked deprecated (`deprecated: true`, "**Deprecated.** Use `payment_term` instead.") on every input and response; on `PUT /organizations` it points to `payment_term` on the billing entity endpoints. Described as the legacy alias, nullable on billing entity, organization and invoice responses, with how it interacts with `payment_term`: 1. A non-null `payment_term` always wins. 2. `payment_term: null` with a non-null `net_payment_term`: the null is ignored and the term is `net N`. 3. `payment_term: null` with `net_payment_term` absent or null: clears both. 4. Only `net_payment_term` sent, equal to the stored value: no change. 5. Only `net_payment_term` sent, different value: the term is re-derived. Rules 2 and 4 depend on the lago-api PR below; merge this after it. Not included: one-off invoice and wallet `payment_term` (lago-api #6579, #6580, still open) — a follow-up PR once those merge. No v2 changes (the v2 endpoints don't expose payment terms). Overlap: #704 and #710 edit `net_payment_term` in the same three input schemas. No `src/` conflict; the bundled `openapi.yaml` will need `npm run build` after whichever merges second. Their `net_payment_term` wording should then be aligned to the legacy-alias description. `npm run test`: build OK, redocly and spectral warning counts identical to `main`, none on payment terms. ## Related - lago-api, keep the structured term on legacy nulls: getlago/lago-api#7097 - lago-openapi, payment terms: #716 - SDKs: Ruby getlago/lago-ruby-client#386 · Python getlago/lago-python-client#438 · Go getlago/lago-go-client#374 · JS getlago/lago-javascript-client#106 · Rust getlago/lago-rust-client#67 --------- Co-authored-by: annvelents <anna@getlago.com>
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.
The client types are generated from the published OpenAPI spec (
deno task build), soPaymentTermObjectandpayment_termon requests and responses arrive once the lago-openapi PR below is published. This PR adds the tests.tests/payment_term.test.ts:net_payment_termsends nopayment_termkey;payment_term: undefinedsends no key; an explicitnullis sent asnull;payment_termsends no key;payment_termfor customer, subscription create/update, billing entity create and invoice preview (top-level);payment_termand a nullnet_payment_termparsed on the customer response.Depends on the lago-openapi PR being published: until then the generated types don't have
PaymentTermObjectand this file doesn't type-check. Wallet and one-off invoice tests follow in a separate PR once getlago/lago-api#6579 and #6580 and their spec PR land.Checked locally against the regenerated spec:
deno check,deno fmt --checkanddeno linton the new file pass.Related