@vitrina/api 11.40.0 → 11.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.cts +1333 -15
  2. package/dist/index.d.ts +1333 -15
  3. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -14834,6 +14834,8 @@ interface paths {
14834
14834
  * ⚠ `tenencia=propio` IS THE COLUMN DEFAULT, not a recorded decision: that cohort includes every unit nobody has classified yet. Do not word it as "comprado".
14835
14835
  *
14836
14836
  * Phase 2 (tenencia_source): `tenencia_source` COMPOSES with `tenencia` rather than narrowing it — `?tenencia=propio&tenencia_source=decided` is "propio, and a person or a document actually settled that" (`decided` ⇒ `tenencia_source <> 'default'`); `document` / `declared` / `default` match the column exactly. See `POST /vehicles/tenencia` for how a `declared` row is produced.
14837
+ *
14838
+ * SIN COSTO (ADR 0114 §8). A car that entered without a compra (nota de compra), a consignación (contrato) or a parte de pago (nota de venta) has no acquisition, so nothing records what it cost. Every row carries `sin_costo: true` for such a unit (any status), and `view=sin_costo` lists the pile still on the floor — active, not vendido, no acquisition; the SAME predicate as the `sin_costo` count on `GET /vehicles/stats` and the `stock_without_cost` dealer alert. It is never a gate: bulk imports and migrations land cars here on purpose. `sin_costo` is a statement about the cost basis and follows the cost omission above: ABSENT without `dealership_economics:read`.
14837
14839
  */
14838
14840
  get: {
14839
14841
  parameters: {
@@ -14860,7 +14862,7 @@ interface paths {
14860
14862
  consignacion_modalidad?: "en_local" | "virtual" | "sin_contrato";
14861
14863
  tenencia_source?: "document" | "declared" | "default" | "decided";
14862
14864
  without_acquisition?: boolean | string;
14863
- view?: "published" | "unpublished" | "error" | "stale" | "source_deactivated";
14865
+ view?: "published" | "unpublished" | "error" | "stale" | "source_deactivated" | "sin_costo";
14864
14866
  active?: boolean | string;
14865
14867
  sort?: "price_asc" | "price_desc" | "year_desc" | "recent" | "days_desc" | "interest_desc" | "estacionamiento";
14866
14868
  limit?: number;
@@ -14951,6 +14953,7 @@ interface paths {
14951
14953
  * "updated_at": "2026-09-15T18:34:48.575Z",
14952
14954
  * "live_sale_note": null,
14953
14955
  * "active_reservation": null,
14956
+ * "sin_costo": true,
14954
14957
  * "not_on_lot": false
14955
14958
  * }
14956
14959
  * ],
@@ -15212,6 +15215,7 @@ interface paths {
15212
15215
  * "updated_at": "2026-09-15T18:34:48.575Z",
15213
15216
  * "live_sale_note": null,
15214
15217
  * "active_reservation": null,
15218
+ * "sin_costo": true,
15215
15219
  * "not_on_lot": false,
15216
15220
  * "publications": [
15217
15221
  * {
@@ -15353,7 +15357,7 @@ interface paths {
15353
15357
  query?: {
15354
15358
  format?: "xlsx" | "pdf";
15355
15359
  q?: string;
15356
- view?: "published" | "unpublished" | "error" | "stale" | "source_deactivated";
15360
+ view?: "published" | "unpublished" | "error" | "stale" | "source_deactivated" | "sin_costo";
15357
15361
  location_id?: string;
15358
15362
  status?: "disponible" | "reservado" | "vendido";
15359
15363
  vehicle_type?: "auto" | "camion" | "maquinaria" | "nautico";
@@ -15562,6 +15566,7 @@ interface paths {
15562
15566
  * "updated_at": "2026-09-15T18:34:48.575Z",
15563
15567
  * "live_sale_note": null,
15564
15568
  * "active_reservation": null,
15569
+ * "sin_costo": true,
15565
15570
  * "not_on_lot": false
15566
15571
  * }
15567
15572
  * }
@@ -15795,6 +15800,7 @@ interface paths {
15795
15800
  * "updated_at": "2026-09-15T18:34:48.575Z",
15796
15801
  * "live_sale_note": null,
15797
15802
  * "active_reservation": null,
15803
+ * "sin_costo": true,
15798
15804
  * "not_on_lot": false
15799
15805
  * }
15800
15806
  * }
@@ -16065,6 +16071,7 @@ interface paths {
16065
16071
  * "updated_at": "2026-09-15T18:34:48.575Z",
16066
16072
  * "live_sale_note": null,
16067
16073
  * "active_reservation": null,
16074
+ * "sin_costo": true,
16068
16075
  * "not_on_lot": false
16069
16076
  * }
16070
16077
  * }
@@ -16257,6 +16264,7 @@ interface paths {
16257
16264
  * "updated_at": "2026-09-15T18:34:48.575Z",
16258
16265
  * "live_sale_note": null,
16259
16266
  * "active_reservation": null,
16267
+ * "sin_costo": true,
16260
16268
  * "not_on_lot": false
16261
16269
  * }
16262
16270
  * }
@@ -19958,6 +19966,28 @@ interface paths {
19958
19966
  * "lost_reason": null,
19959
19967
  * "lost_reason_source": null,
19960
19968
  * "lost_reason_at": null,
19969
+ * "payment_method": "financing",
19970
+ * "down_payment_amount": 4000000,
19971
+ * "budget_max_amount": 11500000,
19972
+ * "has_trade_in": false,
19973
+ * "trade_in_description": null,
19974
+ * "offer_amount": null,
19975
+ * "offer_note": null,
19976
+ * "deal_terms_meta": {
19977
+ * "payment_method": {
19978
+ * "source": "ai",
19979
+ * "actor_id": null,
19980
+ * "actor_label": null,
19981
+ * "at": "2026-09-21T14:02:11.000Z"
19982
+ * },
19983
+ * "down_payment_amount": {
19984
+ * "source": "human",
19985
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
19986
+ * "actor_label": "Camila Rojas",
19987
+ * "at": "2026-09-21T15:10:00.000Z"
19988
+ * }
19989
+ * },
19990
+ * "deal_terms_suggestions": {},
19961
19991
  * "closed_at": null,
19962
19992
  * "created_by": "11111111-0000-4000-8000-000000000001",
19963
19993
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -20015,6 +20045,28 @@ interface paths {
20015
20045
  * "lost_reason": null,
20016
20046
  * "lost_reason_source": null,
20017
20047
  * "lost_reason_at": null,
20048
+ * "payment_method": "financing",
20049
+ * "down_payment_amount": 4000000,
20050
+ * "budget_max_amount": 11500000,
20051
+ * "has_trade_in": false,
20052
+ * "trade_in_description": null,
20053
+ * "offer_amount": null,
20054
+ * "offer_note": null,
20055
+ * "deal_terms_meta": {
20056
+ * "payment_method": {
20057
+ * "source": "ai",
20058
+ * "actor_id": null,
20059
+ * "actor_label": null,
20060
+ * "at": "2026-09-21T14:02:11.000Z"
20061
+ * },
20062
+ * "down_payment_amount": {
20063
+ * "source": "human",
20064
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
20065
+ * "actor_label": "Camila Rojas",
20066
+ * "at": "2026-09-21T15:10:00.000Z"
20067
+ * }
20068
+ * },
20069
+ * "deal_terms_suggestions": {},
20018
20070
  * "closed_at": null,
20019
20071
  * "created_by": null,
20020
20072
  * "created_at": "2026-09-19T09:12:44.000Z",
@@ -20212,6 +20264,28 @@ interface paths {
20212
20264
  * "lost_reason": null,
20213
20265
  * "lost_reason_source": null,
20214
20266
  * "lost_reason_at": null,
20267
+ * "payment_method": "financing",
20268
+ * "down_payment_amount": 4000000,
20269
+ * "budget_max_amount": 11500000,
20270
+ * "has_trade_in": false,
20271
+ * "trade_in_description": null,
20272
+ * "offer_amount": null,
20273
+ * "offer_note": null,
20274
+ * "deal_terms_meta": {
20275
+ * "payment_method": {
20276
+ * "source": "ai",
20277
+ * "actor_id": null,
20278
+ * "actor_label": null,
20279
+ * "at": "2026-09-21T14:02:11.000Z"
20280
+ * },
20281
+ * "down_payment_amount": {
20282
+ * "source": "human",
20283
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
20284
+ * "actor_label": "Camila Rojas",
20285
+ * "at": "2026-09-21T15:10:00.000Z"
20286
+ * }
20287
+ * },
20288
+ * "deal_terms_suggestions": {},
20215
20289
  * "closed_at": null,
20216
20290
  * "created_by": "11111111-0000-4000-8000-000000000001",
20217
20291
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -20395,6 +20469,28 @@ interface paths {
20395
20469
  * "lost_reason": null,
20396
20470
  * "lost_reason_source": null,
20397
20471
  * "lost_reason_at": null,
20472
+ * "payment_method": "financing",
20473
+ * "down_payment_amount": 4000000,
20474
+ * "budget_max_amount": 11500000,
20475
+ * "has_trade_in": false,
20476
+ * "trade_in_description": null,
20477
+ * "offer_amount": null,
20478
+ * "offer_note": null,
20479
+ * "deal_terms_meta": {
20480
+ * "payment_method": {
20481
+ * "source": "ai",
20482
+ * "actor_id": null,
20483
+ * "actor_label": null,
20484
+ * "at": "2026-09-21T14:02:11.000Z"
20485
+ * },
20486
+ * "down_payment_amount": {
20487
+ * "source": "human",
20488
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
20489
+ * "actor_label": "Camila Rojas",
20490
+ * "at": "2026-09-21T15:10:00.000Z"
20491
+ * }
20492
+ * },
20493
+ * "deal_terms_suggestions": {},
20398
20494
  * "closed_at": null,
20399
20495
  * "created_by": "11111111-0000-4000-8000-000000000001",
20400
20496
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -21088,6 +21184,28 @@ interface paths {
21088
21184
  * "lost_reason": null,
21089
21185
  * "lost_reason_source": null,
21090
21186
  * "lost_reason_at": null,
21187
+ * "payment_method": "financing",
21188
+ * "down_payment_amount": 4000000,
21189
+ * "budget_max_amount": 11500000,
21190
+ * "has_trade_in": false,
21191
+ * "trade_in_description": null,
21192
+ * "offer_amount": null,
21193
+ * "offer_note": null,
21194
+ * "deal_terms_meta": {
21195
+ * "payment_method": {
21196
+ * "source": "ai",
21197
+ * "actor_id": null,
21198
+ * "actor_label": null,
21199
+ * "at": "2026-09-21T14:02:11.000Z"
21200
+ * },
21201
+ * "down_payment_amount": {
21202
+ * "source": "human",
21203
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
21204
+ * "actor_label": "Camila Rojas",
21205
+ * "at": "2026-09-21T15:10:00.000Z"
21206
+ * }
21207
+ * },
21208
+ * "deal_terms_suggestions": {},
21091
21209
  * "closed_at": null,
21092
21210
  * "created_by": "11111111-0000-4000-8000-000000000001",
21093
21211
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -21155,6 +21273,28 @@ interface paths {
21155
21273
  * "lost_reason": null,
21156
21274
  * "lost_reason_source": null,
21157
21275
  * "lost_reason_at": null,
21276
+ * "payment_method": "financing",
21277
+ * "down_payment_amount": 4000000,
21278
+ * "budget_max_amount": 11500000,
21279
+ * "has_trade_in": false,
21280
+ * "trade_in_description": null,
21281
+ * "offer_amount": null,
21282
+ * "offer_note": null,
21283
+ * "deal_terms_meta": {
21284
+ * "payment_method": {
21285
+ * "source": "ai",
21286
+ * "actor_id": null,
21287
+ * "actor_label": null,
21288
+ * "at": "2026-09-21T14:02:11.000Z"
21289
+ * },
21290
+ * "down_payment_amount": {
21291
+ * "source": "human",
21292
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
21293
+ * "actor_label": "Camila Rojas",
21294
+ * "at": "2026-09-21T15:10:00.000Z"
21295
+ * }
21296
+ * },
21297
+ * "deal_terms_suggestions": {},
21158
21298
  * "closed_at": null,
21159
21299
  * "created_by": null,
21160
21300
  * "created_at": "2026-09-19T09:12:44.000Z",
@@ -21435,6 +21575,28 @@ interface paths {
21435
21575
  * "lost_reason": null,
21436
21576
  * "lost_reason_source": null,
21437
21577
  * "lost_reason_at": null,
21578
+ * "payment_method": "financing",
21579
+ * "down_payment_amount": 4000000,
21580
+ * "budget_max_amount": 11500000,
21581
+ * "has_trade_in": false,
21582
+ * "trade_in_description": null,
21583
+ * "offer_amount": null,
21584
+ * "offer_note": null,
21585
+ * "deal_terms_meta": {
21586
+ * "payment_method": {
21587
+ * "source": "ai",
21588
+ * "actor_id": null,
21589
+ * "actor_label": null,
21590
+ * "at": "2026-09-21T14:02:11.000Z"
21591
+ * },
21592
+ * "down_payment_amount": {
21593
+ * "source": "human",
21594
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
21595
+ * "actor_label": "Camila Rojas",
21596
+ * "at": "2026-09-21T15:10:00.000Z"
21597
+ * }
21598
+ * },
21599
+ * "deal_terms_suggestions": {},
21438
21600
  * "closed_at": null,
21439
21601
  * "created_by": "11111111-0000-4000-8000-000000000001",
21440
21602
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -21610,6 +21772,28 @@ interface paths {
21610
21772
  * "lost_reason": null,
21611
21773
  * "lost_reason_source": null,
21612
21774
  * "lost_reason_at": null,
21775
+ * "payment_method": "financing",
21776
+ * "down_payment_amount": 4000000,
21777
+ * "budget_max_amount": 11500000,
21778
+ * "has_trade_in": false,
21779
+ * "trade_in_description": null,
21780
+ * "offer_amount": null,
21781
+ * "offer_note": null,
21782
+ * "deal_terms_meta": {
21783
+ * "payment_method": {
21784
+ * "source": "ai",
21785
+ * "actor_id": null,
21786
+ * "actor_label": null,
21787
+ * "at": "2026-09-21T14:02:11.000Z"
21788
+ * },
21789
+ * "down_payment_amount": {
21790
+ * "source": "human",
21791
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
21792
+ * "actor_label": "Camila Rojas",
21793
+ * "at": "2026-09-21T15:10:00.000Z"
21794
+ * }
21795
+ * },
21796
+ * "deal_terms_suggestions": {},
21613
21797
  * "closed_at": null,
21614
21798
  * "created_by": "11111111-0000-4000-8000-000000000001",
21615
21799
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -21952,6 +22136,485 @@ interface paths {
21952
22136
  patch?: never;
21953
22137
  trace?: never;
21954
22138
  };
22139
+ "/leads/{id}/deal-terms": {
22140
+ parameters: {
22141
+ query?: never;
22142
+ header?: never;
22143
+ path?: never;
22144
+ cookie?: never;
22145
+ };
22146
+ get?: never;
22147
+ /**
22148
+ * Set a lead's deal terms (human)
22149
+ * @description Deal terms are seven nullable, vertical-neutral facts: `payment_method` (`cash` | `financing` | `credit_card` | `debit_card` | `mixed`), `down_payment_amount`, `budget_max_amount`, `offer_amount` (in the lead's `value_currency`), `has_trade_in` (null = unknown, false = none), `trade_in_description`, `offer_note`. Each carries provenance in `deal_terms_meta` (`ai` | `human`); an AI writer never overwrites a human-owned field — a disagreeing AI reading is kept in `deal_terms_suggestions` instead. Every field in the body becomes human-owned (`source: human`, the caller as actor) and its pending suggestion is removed; `null` clears a value but keeps it human-owned, so the next AI read proposes instead of re-filling it. Accepting a suggestion is this call with the suggested value. Changes land on the lead's timeline as `deal_terms_changed`. Returns the Oportunidad `lead` object. `{id}` accepts the lead uuid or its ID visible (`L-89`) — the label is a lookup shortcut on the path only, never a value to store.
22150
+ */
22151
+ put: {
22152
+ parameters: {
22153
+ query?: never;
22154
+ header?: never;
22155
+ path: {
22156
+ id: string;
22157
+ };
22158
+ cookie?: never;
22159
+ };
22160
+ requestBody?: {
22161
+ content: {
22162
+ /**
22163
+ * @example {
22164
+ * "payment_method": "cash",
22165
+ * "offer_amount": 10800000
22166
+ * }
22167
+ */
22168
+ "application/json": {
22169
+ /** @enum {string|null} */
22170
+ payment_method?: "cash" | "financing" | "credit_card" | "debit_card" | "mixed" | null;
22171
+ down_payment_amount?: number | null;
22172
+ budget_max_amount?: number | null;
22173
+ has_trade_in?: boolean | null;
22174
+ trade_in_description?: string | null;
22175
+ offer_amount?: number | null;
22176
+ offer_note?: string | null;
22177
+ };
22178
+ };
22179
+ };
22180
+ responses: {
22181
+ /** @description Oportunidad lead */
22182
+ 200: {
22183
+ headers: {
22184
+ [name: string]: unknown;
22185
+ };
22186
+ content: {
22187
+ /**
22188
+ * @example {
22189
+ * "id": "99999999-0000-4000-8000-000000000001",
22190
+ * "display_id": "L-89",
22191
+ * "title": "María — prueba de manejo Corolla 2022",
22192
+ * "status": "open",
22193
+ * "source": "mercadolibre",
22194
+ * "stage": {
22195
+ * "id": "55555555-0000-4000-8000-000000000001",
22196
+ * "name": "Contactado"
22197
+ * },
22198
+ * "pipeline": {
22199
+ * "id": "44444444-0000-4000-8000-000000000001",
22200
+ * "name": "Venta de vehículos"
22201
+ * },
22202
+ * "score": 72,
22203
+ * "score_reason": "pidió hora para probar el auto y confirmó día",
22204
+ * "scored_at": "2026-09-21T14:02:11.000Z",
22205
+ * "temperature": "warm",
22206
+ * "value_currency": "CLP",
22207
+ * "deal_terms": {
22208
+ * "payment_method": "financing",
22209
+ * "down_payment_amount": 4000000,
22210
+ * "budget_max_amount": 11500000,
22211
+ * "has_trade_in": true,
22212
+ * "trade_in_description": "Chery Tiggo 2 Pro 2023, 32.000 km",
22213
+ * "offer_amount": 10500000,
22214
+ * "offer_note": "Financiado · pendiente de aprobación"
22215
+ * },
22216
+ * "deal_terms_meta": {
22217
+ * "payment_method": {
22218
+ * "source": "ai",
22219
+ * "actor_id": null,
22220
+ * "actor_label": null,
22221
+ * "at": "2026-09-21T14:02:11.000Z"
22222
+ * },
22223
+ * "offer_amount": {
22224
+ * "source": "human",
22225
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
22226
+ * "actor_label": "Camila Rojas",
22227
+ * "at": "2026-09-21T15:10:00.000Z"
22228
+ * }
22229
+ * },
22230
+ * "deal_terms_suggestions": {
22231
+ * "offer_amount": {
22232
+ * "value": 10800000,
22233
+ * "reason": "subió la oferta a 10,8 millones",
22234
+ * "at": "2026-09-22T10:00:00.000Z"
22235
+ * }
22236
+ * }
22237
+ * }
22238
+ */
22239
+ "application/json": {
22240
+ data?: unknown;
22241
+ meta?: {
22242
+ [key: string]: unknown;
22243
+ };
22244
+ };
22245
+ };
22246
+ };
22247
+ /** @description Validation error */
22248
+ 400: {
22249
+ headers: {
22250
+ [name: string]: unknown;
22251
+ };
22252
+ content: {
22253
+ "application/json": components["schemas"]["Error"];
22254
+ };
22255
+ };
22256
+ /** @description Unauthorized */
22257
+ 401: {
22258
+ headers: {
22259
+ [name: string]: unknown;
22260
+ };
22261
+ content: {
22262
+ "application/json": components["schemas"]["Error"];
22263
+ };
22264
+ };
22265
+ /** @description Forbidden */
22266
+ 403: {
22267
+ headers: {
22268
+ [name: string]: unknown;
22269
+ };
22270
+ content: {
22271
+ "application/json": components["schemas"]["Error"];
22272
+ };
22273
+ };
22274
+ /** @description Not found */
22275
+ 404: {
22276
+ headers: {
22277
+ [name: string]: unknown;
22278
+ };
22279
+ content: {
22280
+ "application/json": components["schemas"]["Error"];
22281
+ };
22282
+ };
22283
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
22284
+ 409: {
22285
+ headers: {
22286
+ [name: string]: unknown;
22287
+ };
22288
+ content: {
22289
+ "application/json": components["schemas"]["Error"];
22290
+ };
22291
+ };
22292
+ /** @description Rate limited */
22293
+ 429: {
22294
+ headers: {
22295
+ [name: string]: unknown;
22296
+ };
22297
+ content: {
22298
+ "application/json": components["schemas"]["Error"];
22299
+ };
22300
+ };
22301
+ };
22302
+ };
22303
+ post?: never;
22304
+ delete?: never;
22305
+ options?: never;
22306
+ head?: never;
22307
+ patch?: never;
22308
+ trace?: never;
22309
+ };
22310
+ "/leads/{id}/deal-terms/suggestions/{field}": {
22311
+ parameters: {
22312
+ query?: never;
22313
+ header?: never;
22314
+ path?: never;
22315
+ cookie?: never;
22316
+ };
22317
+ get?: never;
22318
+ put?: never;
22319
+ post?: never;
22320
+ /**
22321
+ * Dismiss an AI deal-term suggestion (keep the human value)
22322
+ * @description «Mantener la mía»: removes the pending AI suggestion for one field and leaves the human value as it is. Idempotent — no suggestion is a no-op. Returns the Oportunidad `lead` object. `{id}` accepts the lead uuid or its ID visible (`L-89`) — the label is a lookup shortcut on the path only, never a value to store.
22323
+ */
22324
+ delete: {
22325
+ parameters: {
22326
+ query?: never;
22327
+ header?: never;
22328
+ path: {
22329
+ id: string;
22330
+ field: "payment_method" | "down_payment_amount" | "budget_max_amount" | "has_trade_in" | "trade_in_description" | "offer_amount" | "offer_note";
22331
+ };
22332
+ cookie?: never;
22333
+ };
22334
+ requestBody?: never;
22335
+ responses: {
22336
+ /** @description Oportunidad lead */
22337
+ 200: {
22338
+ headers: {
22339
+ [name: string]: unknown;
22340
+ };
22341
+ content: {
22342
+ /**
22343
+ * @example {
22344
+ * "id": "99999999-0000-4000-8000-000000000001",
22345
+ * "display_id": "L-89",
22346
+ * "title": "María — prueba de manejo Corolla 2022",
22347
+ * "status": "open",
22348
+ * "source": "mercadolibre",
22349
+ * "stage": {
22350
+ * "id": "55555555-0000-4000-8000-000000000001",
22351
+ * "name": "Contactado"
22352
+ * },
22353
+ * "pipeline": {
22354
+ * "id": "44444444-0000-4000-8000-000000000001",
22355
+ * "name": "Venta de vehículos"
22356
+ * },
22357
+ * "score": 72,
22358
+ * "score_reason": "pidió hora para probar el auto y confirmó día",
22359
+ * "scored_at": "2026-09-21T14:02:11.000Z",
22360
+ * "temperature": "warm",
22361
+ * "value_currency": "CLP",
22362
+ * "deal_terms": {
22363
+ * "payment_method": "financing",
22364
+ * "down_payment_amount": 4000000,
22365
+ * "budget_max_amount": 11500000,
22366
+ * "has_trade_in": true,
22367
+ * "trade_in_description": "Chery Tiggo 2 Pro 2023, 32.000 km",
22368
+ * "offer_amount": 10500000,
22369
+ * "offer_note": "Financiado · pendiente de aprobación"
22370
+ * },
22371
+ * "deal_terms_meta": {
22372
+ * "payment_method": {
22373
+ * "source": "ai",
22374
+ * "actor_id": null,
22375
+ * "actor_label": null,
22376
+ * "at": "2026-09-21T14:02:11.000Z"
22377
+ * },
22378
+ * "offer_amount": {
22379
+ * "source": "human",
22380
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
22381
+ * "actor_label": "Camila Rojas",
22382
+ * "at": "2026-09-21T15:10:00.000Z"
22383
+ * }
22384
+ * },
22385
+ * "deal_terms_suggestions": {
22386
+ * "offer_amount": {
22387
+ * "value": 10800000,
22388
+ * "reason": "subió la oferta a 10,8 millones",
22389
+ * "at": "2026-09-22T10:00:00.000Z"
22390
+ * }
22391
+ * }
22392
+ * }
22393
+ */
22394
+ "application/json": {
22395
+ data?: unknown;
22396
+ meta?: {
22397
+ [key: string]: unknown;
22398
+ };
22399
+ };
22400
+ };
22401
+ };
22402
+ /** @description Validation error */
22403
+ 400: {
22404
+ headers: {
22405
+ [name: string]: unknown;
22406
+ };
22407
+ content: {
22408
+ "application/json": components["schemas"]["Error"];
22409
+ };
22410
+ };
22411
+ /** @description Unauthorized */
22412
+ 401: {
22413
+ headers: {
22414
+ [name: string]: unknown;
22415
+ };
22416
+ content: {
22417
+ "application/json": components["schemas"]["Error"];
22418
+ };
22419
+ };
22420
+ /** @description Forbidden */
22421
+ 403: {
22422
+ headers: {
22423
+ [name: string]: unknown;
22424
+ };
22425
+ content: {
22426
+ "application/json": components["schemas"]["Error"];
22427
+ };
22428
+ };
22429
+ /** @description Not found */
22430
+ 404: {
22431
+ headers: {
22432
+ [name: string]: unknown;
22433
+ };
22434
+ content: {
22435
+ "application/json": components["schemas"]["Error"];
22436
+ };
22437
+ };
22438
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
22439
+ 409: {
22440
+ headers: {
22441
+ [name: string]: unknown;
22442
+ };
22443
+ content: {
22444
+ "application/json": components["schemas"]["Error"];
22445
+ };
22446
+ };
22447
+ /** @description Rate limited */
22448
+ 429: {
22449
+ headers: {
22450
+ [name: string]: unknown;
22451
+ };
22452
+ content: {
22453
+ "application/json": components["schemas"]["Error"];
22454
+ };
22455
+ };
22456
+ };
22457
+ };
22458
+ options?: never;
22459
+ head?: never;
22460
+ patch?: never;
22461
+ trace?: never;
22462
+ };
22463
+ "/leads/{id}/review": {
22464
+ parameters: {
22465
+ query?: never;
22466
+ header?: never;
22467
+ path?: never;
22468
+ cookie?: never;
22469
+ };
22470
+ get?: never;
22471
+ put?: never;
22472
+ /**
22473
+ * Run the lead reviewer on this lead now
22474
+ * @description Synchronous (typically 5–20 s): the same lead-reviewer pass the background worker runs — score, temperature, the stage ladder (auto move or suggestion) and the deal terms the conversation states. Returns the Oportunidad `lead` object. At most once per lead per 60 s: a repeat answers 429 with `error.retry_after_seconds` (and a `Retry-After` header). 409 when lead review is off for the workspace or the lead is closed; 502 when the review could not complete. `{id}` accepts the lead uuid or its ID visible (`L-89`) — the label is a lookup shortcut on the path only, never a value to store.
22475
+ */
22476
+ post: {
22477
+ parameters: {
22478
+ query?: never;
22479
+ header?: {
22480
+ /** @description Replay-safe retries: resending the SAME key with the SAME body returns the original response (`X-Idempotent-Replay: 1`) instead of creating a second copy — safe to send whenever a response might not have arrived. The same key with a DIFFERENT body answers `409 IDEMPOTENCY_KEY_CONFLICT`; use a fresh key per operation. */
22481
+ "Idempotency-Key"?: string;
22482
+ };
22483
+ path: {
22484
+ id: string;
22485
+ };
22486
+ cookie?: never;
22487
+ };
22488
+ requestBody?: never;
22489
+ responses: {
22490
+ /** @description Oportunidad lead */
22491
+ 200: {
22492
+ headers: {
22493
+ [name: string]: unknown;
22494
+ };
22495
+ content: {
22496
+ /**
22497
+ * @example {
22498
+ * "id": "99999999-0000-4000-8000-000000000001",
22499
+ * "display_id": "L-89",
22500
+ * "title": "María — prueba de manejo Corolla 2022",
22501
+ * "status": "open",
22502
+ * "source": "mercadolibre",
22503
+ * "stage": {
22504
+ * "id": "55555555-0000-4000-8000-000000000001",
22505
+ * "name": "Contactado"
22506
+ * },
22507
+ * "pipeline": {
22508
+ * "id": "44444444-0000-4000-8000-000000000001",
22509
+ * "name": "Venta de vehículos"
22510
+ * },
22511
+ * "score": 72,
22512
+ * "score_reason": "pidió hora para probar el auto y confirmó día",
22513
+ * "scored_at": "2026-09-21T14:02:11.000Z",
22514
+ * "temperature": "warm",
22515
+ * "value_currency": "CLP",
22516
+ * "deal_terms": {
22517
+ * "payment_method": "financing",
22518
+ * "down_payment_amount": 4000000,
22519
+ * "budget_max_amount": 11500000,
22520
+ * "has_trade_in": true,
22521
+ * "trade_in_description": "Chery Tiggo 2 Pro 2023, 32.000 km",
22522
+ * "offer_amount": 10500000,
22523
+ * "offer_note": "Financiado · pendiente de aprobación"
22524
+ * },
22525
+ * "deal_terms_meta": {
22526
+ * "payment_method": {
22527
+ * "source": "ai",
22528
+ * "actor_id": null,
22529
+ * "actor_label": null,
22530
+ * "at": "2026-09-21T14:02:11.000Z"
22531
+ * },
22532
+ * "offer_amount": {
22533
+ * "source": "human",
22534
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
22535
+ * "actor_label": "Camila Rojas",
22536
+ * "at": "2026-09-21T15:10:00.000Z"
22537
+ * }
22538
+ * },
22539
+ * "deal_terms_suggestions": {
22540
+ * "offer_amount": {
22541
+ * "value": 10800000,
22542
+ * "reason": "subió la oferta a 10,8 millones",
22543
+ * "at": "2026-09-22T10:00:00.000Z"
22544
+ * }
22545
+ * }
22546
+ * }
22547
+ */
22548
+ "application/json": {
22549
+ data?: unknown;
22550
+ meta?: {
22551
+ [key: string]: unknown;
22552
+ };
22553
+ };
22554
+ };
22555
+ };
22556
+ /** @description Validation error */
22557
+ 400: {
22558
+ headers: {
22559
+ [name: string]: unknown;
22560
+ };
22561
+ content: {
22562
+ "application/json": components["schemas"]["Error"];
22563
+ };
22564
+ };
22565
+ /** @description Unauthorized */
22566
+ 401: {
22567
+ headers: {
22568
+ [name: string]: unknown;
22569
+ };
22570
+ content: {
22571
+ "application/json": components["schemas"]["Error"];
22572
+ };
22573
+ };
22574
+ /** @description Forbidden */
22575
+ 403: {
22576
+ headers: {
22577
+ [name: string]: unknown;
22578
+ };
22579
+ content: {
22580
+ "application/json": components["schemas"]["Error"];
22581
+ };
22582
+ };
22583
+ /** @description Not found */
22584
+ 404: {
22585
+ headers: {
22586
+ [name: string]: unknown;
22587
+ };
22588
+ content: {
22589
+ "application/json": components["schemas"]["Error"];
22590
+ };
22591
+ };
22592
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
22593
+ 409: {
22594
+ headers: {
22595
+ [name: string]: unknown;
22596
+ };
22597
+ content: {
22598
+ "application/json": components["schemas"]["Error"];
22599
+ };
22600
+ };
22601
+ /** @description Rate limited */
22602
+ 429: {
22603
+ headers: {
22604
+ [name: string]: unknown;
22605
+ };
22606
+ content: {
22607
+ "application/json": components["schemas"]["Error"];
22608
+ };
22609
+ };
22610
+ };
22611
+ };
22612
+ delete?: never;
22613
+ options?: never;
22614
+ head?: never;
22615
+ patch?: never;
22616
+ trace?: never;
22617
+ };
21955
22618
  "/leads/{id}/stage": {
21956
22619
  parameters: {
21957
22620
  query?: never;
@@ -22031,6 +22694,28 @@ interface paths {
22031
22694
  * "lost_reason": null,
22032
22695
  * "lost_reason_source": null,
22033
22696
  * "lost_reason_at": null,
22697
+ * "payment_method": "financing",
22698
+ * "down_payment_amount": 4000000,
22699
+ * "budget_max_amount": 11500000,
22700
+ * "has_trade_in": false,
22701
+ * "trade_in_description": null,
22702
+ * "offer_amount": null,
22703
+ * "offer_note": null,
22704
+ * "deal_terms_meta": {
22705
+ * "payment_method": {
22706
+ * "source": "ai",
22707
+ * "actor_id": null,
22708
+ * "actor_label": null,
22709
+ * "at": "2026-09-21T14:02:11.000Z"
22710
+ * },
22711
+ * "down_payment_amount": {
22712
+ * "source": "human",
22713
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
22714
+ * "actor_label": "Camila Rojas",
22715
+ * "at": "2026-09-21T15:10:00.000Z"
22716
+ * }
22717
+ * },
22718
+ * "deal_terms_suggestions": {},
22034
22719
  * "closed_at": null,
22035
22720
  * "created_by": "11111111-0000-4000-8000-000000000001",
22036
22721
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -22206,6 +22891,28 @@ interface paths {
22206
22891
  * "lost_reason": null,
22207
22892
  * "lost_reason_source": null,
22208
22893
  * "lost_reason_at": null,
22894
+ * "payment_method": "financing",
22895
+ * "down_payment_amount": 4000000,
22896
+ * "budget_max_amount": 11500000,
22897
+ * "has_trade_in": false,
22898
+ * "trade_in_description": null,
22899
+ * "offer_amount": null,
22900
+ * "offer_note": null,
22901
+ * "deal_terms_meta": {
22902
+ * "payment_method": {
22903
+ * "source": "ai",
22904
+ * "actor_id": null,
22905
+ * "actor_label": null,
22906
+ * "at": "2026-09-21T14:02:11.000Z"
22907
+ * },
22908
+ * "down_payment_amount": {
22909
+ * "source": "human",
22910
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
22911
+ * "actor_label": "Camila Rojas",
22912
+ * "at": "2026-09-21T15:10:00.000Z"
22913
+ * }
22914
+ * },
22915
+ * "deal_terms_suggestions": {},
22209
22916
  * "closed_at": null,
22210
22917
  * "created_by": "11111111-0000-4000-8000-000000000001",
22211
22918
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -22382,6 +23089,28 @@ interface paths {
22382
23089
  * "lost_reason": null,
22383
23090
  * "lost_reason_source": null,
22384
23091
  * "lost_reason_at": null,
23092
+ * "payment_method": "financing",
23093
+ * "down_payment_amount": 4000000,
23094
+ * "budget_max_amount": 11500000,
23095
+ * "has_trade_in": false,
23096
+ * "trade_in_description": null,
23097
+ * "offer_amount": null,
23098
+ * "offer_note": null,
23099
+ * "deal_terms_meta": {
23100
+ * "payment_method": {
23101
+ * "source": "ai",
23102
+ * "actor_id": null,
23103
+ * "actor_label": null,
23104
+ * "at": "2026-09-21T14:02:11.000Z"
23105
+ * },
23106
+ * "down_payment_amount": {
23107
+ * "source": "human",
23108
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
23109
+ * "actor_label": "Camila Rojas",
23110
+ * "at": "2026-09-21T15:10:00.000Z"
23111
+ * }
23112
+ * },
23113
+ * "deal_terms_suggestions": {},
22385
23114
  * "closed_at": null,
22386
23115
  * "created_by": "11111111-0000-4000-8000-000000000001",
22387
23116
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -22560,6 +23289,28 @@ interface paths {
22560
23289
  * "lost_reason": null,
22561
23290
  * "lost_reason_source": null,
22562
23291
  * "lost_reason_at": null,
23292
+ * "payment_method": "financing",
23293
+ * "down_payment_amount": 4000000,
23294
+ * "budget_max_amount": 11500000,
23295
+ * "has_trade_in": false,
23296
+ * "trade_in_description": null,
23297
+ * "offer_amount": null,
23298
+ * "offer_note": null,
23299
+ * "deal_terms_meta": {
23300
+ * "payment_method": {
23301
+ * "source": "ai",
23302
+ * "actor_id": null,
23303
+ * "actor_label": null,
23304
+ * "at": "2026-09-21T14:02:11.000Z"
23305
+ * },
23306
+ * "down_payment_amount": {
23307
+ * "source": "human",
23308
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
23309
+ * "actor_label": "Camila Rojas",
23310
+ * "at": "2026-09-21T15:10:00.000Z"
23311
+ * }
23312
+ * },
23313
+ * "deal_terms_suggestions": {},
22563
23314
  * "closed_at": "2026-09-22T08:41:32.977Z",
22564
23315
  * "created_by": "11111111-0000-4000-8000-000000000001",
22565
23316
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -22736,6 +23487,28 @@ interface paths {
22736
23487
  * "lost_reason": "bought_elsewhere",
22737
23488
  * "lost_reason_source": "jev",
22738
23489
  * "lost_reason_at": "2026-09-22T08:44:12.501Z",
23490
+ * "payment_method": "financing",
23491
+ * "down_payment_amount": 4000000,
23492
+ * "budget_max_amount": 11500000,
23493
+ * "has_trade_in": false,
23494
+ * "trade_in_description": null,
23495
+ * "offer_amount": null,
23496
+ * "offer_note": null,
23497
+ * "deal_terms_meta": {
23498
+ * "payment_method": {
23499
+ * "source": "ai",
23500
+ * "actor_id": null,
23501
+ * "actor_label": null,
23502
+ * "at": "2026-09-21T14:02:11.000Z"
23503
+ * },
23504
+ * "down_payment_amount": {
23505
+ * "source": "human",
23506
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
23507
+ * "actor_label": "Camila Rojas",
23508
+ * "at": "2026-09-21T15:10:00.000Z"
23509
+ * }
23510
+ * },
23511
+ * "deal_terms_suggestions": {},
22739
23512
  * "closed_at": "2026-09-22T08:44:10.331Z",
22740
23513
  * "created_by": "11111111-0000-4000-8000-000000000001",
22741
23514
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -22912,6 +23685,28 @@ interface paths {
22912
23685
  * "lost_reason": null,
22913
23686
  * "lost_reason_source": null,
22914
23687
  * "lost_reason_at": null,
23688
+ * "payment_method": "financing",
23689
+ * "down_payment_amount": 4000000,
23690
+ * "budget_max_amount": 11500000,
23691
+ * "has_trade_in": false,
23692
+ * "trade_in_description": null,
23693
+ * "offer_amount": null,
23694
+ * "offer_note": null,
23695
+ * "deal_terms_meta": {
23696
+ * "payment_method": {
23697
+ * "source": "ai",
23698
+ * "actor_id": null,
23699
+ * "actor_label": null,
23700
+ * "at": "2026-09-21T14:02:11.000Z"
23701
+ * },
23702
+ * "down_payment_amount": {
23703
+ * "source": "human",
23704
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
23705
+ * "actor_label": "Camila Rojas",
23706
+ * "at": "2026-09-21T15:10:00.000Z"
23707
+ * }
23708
+ * },
23709
+ * "deal_terms_suggestions": {},
22915
23710
  * "closed_at": "2026-09-22T08:44:10.331Z",
22916
23711
  * "created_by": "11111111-0000-4000-8000-000000000001",
22917
23712
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -23073,6 +23868,28 @@ interface paths {
23073
23868
  * "lost_reason": null,
23074
23869
  * "lost_reason_source": null,
23075
23870
  * "lost_reason_at": null,
23871
+ * "payment_method": "financing",
23872
+ * "down_payment_amount": 4000000,
23873
+ * "budget_max_amount": 11500000,
23874
+ * "has_trade_in": false,
23875
+ * "trade_in_description": null,
23876
+ * "offer_amount": null,
23877
+ * "offer_note": null,
23878
+ * "deal_terms_meta": {
23879
+ * "payment_method": {
23880
+ * "source": "ai",
23881
+ * "actor_id": null,
23882
+ * "actor_label": null,
23883
+ * "at": "2026-09-21T14:02:11.000Z"
23884
+ * },
23885
+ * "down_payment_amount": {
23886
+ * "source": "human",
23887
+ * "actor_id": "11111111-0000-4000-8000-000000000001",
23888
+ * "actor_label": "Camila Rojas",
23889
+ * "at": "2026-09-21T15:10:00.000Z"
23890
+ * }
23891
+ * },
23892
+ * "deal_terms_suggestions": {},
23076
23893
  * "closed_at": null,
23077
23894
  * "created_by": "11111111-0000-4000-8000-000000000001",
23078
23895
  * "created_at": "2026-09-18T13:44:02.115Z",
@@ -30275,6 +31092,10 @@ interface paths {
30275
31092
  *
30276
31093
  * **Every row carries `totals`** — the SAME object `GET /sale-notes/{id}` embeds, computed by the same roll-up: `total_a_pagar_clp` (price + IVA + Σ statutory add-ons), `total_pagos_clp`, `saldo_clp`, `payment_count`, `complete` and `gaps`. ⚠ **A POSITIVE `saldo_clp` means the customer has OVERPAID; a NEGATIVE one is what they still owe** (BR-245 — it is the sign the printed document uses). `total_a_pagar_clp` and `saldo_clp` are both **`null`** when `tax_clp` was never recorded, with `gaps` naming it: that is "not computable", never zero, and a client must render it as such rather than treating the unrecorded IVA as 0. Voided rows are totalled like any other — the money against them was really taken, and `status` is what says the document is dead. Do not sum the payments client-side; there is one definition of this balance and this is it.
30277
31094
  *
31095
+ * **`economics` — only for callers holding `dealership_economics:read`** (absent, not null, for everyone else): `margen_bruto_clp` (Margen bruto), `margen_neto_clp` (Utilidad del negocio), `comisiones_vendedores_clp` (Comisión) and `canal` (where the buyer came from), each the SAME figure `GET /margin` serves — one definition, computed in batch for the page. A figure that is not computable is `null`, never zero, and `gaps` names the missing input (`cost_rollup` = Sin costo, `seller_commission` = Sin comisión, `liquidacion` = Sin liquidación). A voided row has `economics: null`.
31096
+ *
31097
+ * **`status`** narrows to one derived status; `status=issued` is the «Por aprobar» list (emitted, waiting for its approval — ADR 0114 §4).
31098
+ *
30278
31099
  * Unknown query parameters are a **400**, not a silent drop: a filter the caller believes is being applied, returning a full unfiltered list with a 200, is a worse answer than a refusal.
30279
31100
  */
30280
31101
  get: {
@@ -30283,6 +31104,7 @@ interface paths {
30283
31104
  exclude_voided?: boolean | null;
30284
31105
  vehicle_id?: string;
30285
31106
  lead_id?: string;
31107
+ status?: "issued" | "approved" | "voided";
30286
31108
  limit?: number;
30287
31109
  };
30288
31110
  header?: never;
@@ -30318,6 +31140,7 @@ interface paths {
30318
31140
  * "tax_treatment": "afecto",
30319
31141
  * "status": "issued",
30320
31142
  * "issued_at": "2026-09-19T13:00:00.000Z",
31143
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
30321
31144
  * "approved_by": null,
30322
31145
  * "approved_at": null,
30323
31146
  * "voided_at": null,
@@ -30401,6 +31224,8 @@ interface paths {
30401
31224
  * Issue a nota de venta
30402
31225
  * @description Issues the document and allocates its folio (`V-1`, `V-2`, …) inside the inserting transaction, so a failed issue RELEASES the number rather than burning it out of a legally accountable series.
30403
31226
  *
31227
+ * **`emitted_by` is the caller** (ADR 0114 §4): the member (also behind a personal token) or the API key that issued it, stamped from the credential — there is no body field for it.
31228
+ *
30404
31229
  * **Money is whole CLP pesos** (`bigint`, never minor units, never decimals) and the triple is `net_clp` + `tax_clp` + `tax_treatment`. Omit `tax_clp` to record "not recorded"; pass `0` to record "no tax" — ADR 0058 §2 makes those two different claims and nothing collapses them. `tax_treatment` is REQUIRED and has no default: the same peso falls inside or outside the IVA base depending on how the deal is structured, so a default would be a guess stored as a determination.
30405
31230
  *
30406
31231
  * `vehicle_id`, `buyer_contact_id` and `lead_id` must belong to the calling workspace — no foreign key carries a tenant, so this is checked before the insert. A foreign id and a nonexistent one answer identically (404), deliberately: a difference between them is an existence oracle. A soft-deleted or merged vehicle is also refused.
@@ -30533,6 +31358,7 @@ interface paths {
30533
31358
  * "tax_treatment": "afecto",
30534
31359
  * "status": "issued",
30535
31360
  * "issued_at": "2026-09-19T13:00:00.000Z",
31361
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
30536
31362
  * "approved_by": null,
30537
31363
  * "approved_at": null,
30538
31364
  * "voided_at": null,
@@ -30627,6 +31453,8 @@ interface paths {
30627
31453
  *
30628
31454
  * Nothing here is stored: the standing is DERIVED from the rows on every read, there is no `funding_standing` column, and there is nothing to write. A document issued without a funding plan reads `short`, which is the honest state and not an error.
30629
31455
  *
31456
+ * **`timeline` says who did what, by name** (ADR 0114 §4): one entry per step that happened, in the order the document lives them — `emitted` (`issued_at`, `emitted_by`), `approved`, `printed` (the compraventa in force) and `voided` — each with its instant and its `actor` (`{ id, name, kind }`, `kind` = `member` or `api_key`). `actor` is `null` when the document does not record who did it (a note emitted before `emitted_by` existed); `actor.name` is `null` when that person has no name on file. Show either in words — never as an anonymous teammate. Approval is a separate step under `sale_notes:write`, so the emitter and the approver are often different people.
31457
+ *
30630
31458
  * **`trade_ins` names the cars taken in part-exchange** (ERP S9-6) — one entry per car with the line’s own id (never the vehicle’s: BR-457), the `vehicle_id`, the `precio_toma_clp` allowed for it, and the `acquisition_id` of the `vehicle_acquisition` that arrival created. That is the SALE → UNIT direction; the UNIT → SALE direction needs no surface here, because `vehicle_acquisition.sale_note_id` is projected on every read of `GET /vehicle-acquisitions?vehicle_id=`. `acquisition_id` is `null` once the document has been VOIDED — a void retracts the arrival and keeps the line, so the null says exactly what happened: this credit was agreed, and the arrival it caused has been withdrawn.
30631
31459
  *
30632
31460
  * **`credit` is the LIVE brokered credit, or `null`** (ERP S9-7) — the `institution` that is lending (BR-464 makes the financiera the credit’s identity on the document), the `amount_clp`, and its OWN `state`: `committed` (the bank has promised) or `disbursed` (the money has arrived, with `disbursed_at` / `disbursed_by` beside it). ⚠ **Both count the same in `funding`** (BR-463), so never read `funded` as "the cash is in" — read `credit.state` for that. The committed-vs-collected gap is exactly this pair of fields read side by side. ⚠ **The credit’s state is INDEPENDENT of the document’s `status`**: a voided nota de venta keeps its credit row untouched, and a disbursed credit does not make the document anything. Credits that were REPLACED or REMOVED are tombstoned and are deliberately not served here — they are history, not funding, and listing them beside the live one would invite a client to add them up.
@@ -30668,6 +31496,7 @@ interface paths {
30668
31496
  * "tax_treatment": "afecto",
30669
31497
  * "status": "issued",
30670
31498
  * "issued_at": "2026-09-19T13:00:00.000Z",
31499
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
30671
31500
  * "approved_by": null,
30672
31501
  * "approved_at": null,
30673
31502
  * "voided_at": null,
@@ -30725,7 +31554,18 @@ interface paths {
30725
31554
  * "gaps": []
30726
31555
  * },
30727
31556
  * "trade_ins": [],
30728
- * "credit": null
31557
+ * "credit": null,
31558
+ * "timeline": [
31559
+ * {
31560
+ * "step": "emitted",
31561
+ * "at": "2026-09-19T13:00:00.000Z",
31562
+ * "actor": {
31563
+ * "id": "11111111-0000-4000-8000-000000000001",
31564
+ * "name": "Martina Reyes",
31565
+ * "kind": "member"
31566
+ * }
31567
+ * }
31568
+ * ]
30729
31569
  * }
30730
31570
  * }
30731
31571
  */
@@ -30869,6 +31709,7 @@ interface paths {
30869
31709
  * "tax_treatment": "afecto",
30870
31710
  * "status": "issued",
30871
31711
  * "issued_at": "2026-09-19T13:00:00.000Z",
31712
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
30872
31713
  * "approved_by": null,
30873
31714
  * "approved_at": null,
30874
31715
  * "voided_at": null,
@@ -30926,7 +31767,18 @@ interface paths {
30926
31767
  * "gaps": []
30927
31768
  * },
30928
31769
  * "trade_ins": [],
30929
- * "credit": null
31770
+ * "credit": null,
31771
+ * "timeline": [
31772
+ * {
31773
+ * "step": "emitted",
31774
+ * "at": "2026-09-19T13:00:00.000Z",
31775
+ * "actor": {
31776
+ * "id": "11111111-0000-4000-8000-000000000001",
31777
+ * "name": "Martina Reyes",
31778
+ * "kind": "member"
31779
+ * }
31780
+ * }
31781
+ * ]
30930
31782
  * }
30931
31783
  * }
30932
31784
  */
@@ -31208,6 +32060,7 @@ interface paths {
31208
32060
  * "tax_treatment": "afecto",
31209
32061
  * "status": "approved",
31210
32062
  * "issued_at": "2026-09-19T13:00:00.000Z",
32063
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
31211
32064
  * "approved_by": "11111111-0000-4000-8000-000000000001",
31212
32065
  * "approved_at": "2026-09-19T14:10:00.000Z",
31213
32066
  * "voided_at": null,
@@ -31358,6 +32211,7 @@ interface paths {
31358
32211
  * "tax_treatment": "afecto",
31359
32212
  * "status": "voided",
31360
32213
  * "issued_at": "2026-09-19T13:00:00.000Z",
32214
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
31361
32215
  * "approved_by": null,
31362
32216
  * "approved_at": null,
31363
32217
  * "voided_at": "2026-09-20T09:00:00.000Z",
@@ -32956,6 +33810,101 @@ interface paths {
32956
33810
  };
32957
33811
  trace?: never;
32958
33812
  };
33813
+ "/purchase-notes/{id}/pdf": {
33814
+ parameters: {
33815
+ query?: never;
33816
+ header?: never;
33817
+ path?: never;
33818
+ cookie?: never;
33819
+ };
33820
+ /**
33821
+ * Print the nota de compra
33822
+ * @description The nota de compra as a printable PDF (`application/pdf`, served `inline`) on the dealership’s paper: folio, seller, vehicle, lines and totals. Rendered on demand and not stored. Any status prints; a voided note says «Anulada». Accepts the UUID or the folio (`P-47`). Requires `purchase_notes:read`.
33823
+ */
33824
+ get: {
33825
+ parameters: {
33826
+ query?: never;
33827
+ header?: never;
33828
+ path: {
33829
+ id: string;
33830
+ };
33831
+ cookie?: never;
33832
+ };
33833
+ requestBody?: never;
33834
+ responses: {
33835
+ /** @description The printable nota de compra */
33836
+ 200: {
33837
+ headers: {
33838
+ [name: string]: unknown;
33839
+ };
33840
+ content: {
33841
+ "application/pdf": string;
33842
+ };
33843
+ };
33844
+ /** @description Validation error */
33845
+ 400: {
33846
+ headers: {
33847
+ [name: string]: unknown;
33848
+ };
33849
+ content: {
33850
+ "application/json": components["schemas"]["Error"];
33851
+ };
33852
+ };
33853
+ /** @description Unauthorized */
33854
+ 401: {
33855
+ headers: {
33856
+ [name: string]: unknown;
33857
+ };
33858
+ content: {
33859
+ "application/json": components["schemas"]["Error"];
33860
+ };
33861
+ };
33862
+ /** @description Forbidden */
33863
+ 403: {
33864
+ headers: {
33865
+ [name: string]: unknown;
33866
+ };
33867
+ content: {
33868
+ "application/json": components["schemas"]["Error"];
33869
+ };
33870
+ };
33871
+ /** @description Not found */
33872
+ 404: {
33873
+ headers: {
33874
+ [name: string]: unknown;
33875
+ };
33876
+ content: {
33877
+ "application/json": components["schemas"]["Error"];
33878
+ };
33879
+ };
33880
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
33881
+ 409: {
33882
+ headers: {
33883
+ [name: string]: unknown;
33884
+ };
33885
+ content: {
33886
+ "application/json": components["schemas"]["Error"];
33887
+ };
33888
+ };
33889
+ /** @description Rate limited */
33890
+ 429: {
33891
+ headers: {
33892
+ [name: string]: unknown;
33893
+ };
33894
+ content: {
33895
+ "application/json": components["schemas"]["Error"];
33896
+ };
33897
+ };
33898
+ };
33899
+ };
33900
+ put?: never;
33901
+ post?: never;
33902
+ delete?: never;
33903
+ options?: never;
33904
+ head?: never;
33905
+ patch?: never;
33906
+ trace?: never;
33907
+ };
32959
33908
  "/purchase-notes/{id}/void": {
32960
33909
  parameters: {
32961
33910
  query?: never;
@@ -35216,6 +36165,135 @@ interface paths {
35216
36165
  patch?: never;
35217
36166
  trace?: never;
35218
36167
  };
36168
+ "/sale-notes/{id}/participations/{participationId}": {
36169
+ parameters: {
36170
+ query?: never;
36171
+ header?: never;
36172
+ path?: never;
36173
+ cookie?: never;
36174
+ };
36175
+ get?: never;
36176
+ put?: never;
36177
+ post?: never;
36178
+ delete?: never;
36179
+ options?: never;
36180
+ head?: never;
36181
+ /**
36182
+ * Record the missing commission on a participation
36183
+ * @description Fixes a «Sin comisión» sale: a participation written with no commission — its Vendedor had no compensation scheme when the nota de venta was emitted, or the car had no recorded cost (no computable Margen bruto to apply a rate to) — gets one. `commission_rate_bp` defaults to the member’s scheme as of the SALE’s day; `commission_basis_clp` defaults to the sale’s Margen bruto as it stands now (so: record the cost, then the commission). **409** when the participation already has a commission — a recorded commission is frozen and never restated — when the Margen bruto is still not computable and no basis is stated, or on a voided nota de venta. **400** when no rate is stated and the member had no scheme on that day. Once every participation has its commission, the sale’s Utilidad del negocio is computable and it enters Margen y rentabilidad’s totals.
36184
+ */
36185
+ patch: {
36186
+ parameters: {
36187
+ query?: never;
36188
+ header?: never;
36189
+ path: {
36190
+ id: string;
36191
+ participationId: string;
36192
+ };
36193
+ cookie?: never;
36194
+ };
36195
+ requestBody?: {
36196
+ content: {
36197
+ /**
36198
+ * @example {
36199
+ * "commission_rate_bp": 250
36200
+ * }
36201
+ */
36202
+ "application/json": {
36203
+ commission_rate_bp?: number;
36204
+ commission_basis_clp?: number;
36205
+ };
36206
+ };
36207
+ };
36208
+ responses: {
36209
+ /** @description The participation, with its commission recorded */
36210
+ 200: {
36211
+ headers: {
36212
+ [name: string]: unknown;
36213
+ };
36214
+ content: {
36215
+ /**
36216
+ * @example {
36217
+ * "data": {
36218
+ * "id": "5d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
36219
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
36220
+ * "sale_note_id": "d4d4d4d4-0000-4000-8000-000000000001",
36221
+ * "user_id": "11111111-0000-4000-8000-000000000001",
36222
+ * "role": "closer",
36223
+ * "commission_rate_bp": 250,
36224
+ * "commission_basis_clp": 1800000,
36225
+ * "commission_clp": 45000,
36226
+ * "created_at": "2026-09-14T11:30:00.000Z",
36227
+ * "updated_at": "2026-09-29T10:05:00.000Z"
36228
+ * }
36229
+ * }
36230
+ */
36231
+ "application/json": {
36232
+ data?: unknown;
36233
+ meta?: {
36234
+ [key: string]: unknown;
36235
+ };
36236
+ };
36237
+ };
36238
+ };
36239
+ /** @description Validation error */
36240
+ 400: {
36241
+ headers: {
36242
+ [name: string]: unknown;
36243
+ };
36244
+ content: {
36245
+ "application/json": components["schemas"]["Error"];
36246
+ };
36247
+ };
36248
+ /** @description Unauthorized */
36249
+ 401: {
36250
+ headers: {
36251
+ [name: string]: unknown;
36252
+ };
36253
+ content: {
36254
+ "application/json": components["schemas"]["Error"];
36255
+ };
36256
+ };
36257
+ /** @description Forbidden */
36258
+ 403: {
36259
+ headers: {
36260
+ [name: string]: unknown;
36261
+ };
36262
+ content: {
36263
+ "application/json": components["schemas"]["Error"];
36264
+ };
36265
+ };
36266
+ /** @description Not found */
36267
+ 404: {
36268
+ headers: {
36269
+ [name: string]: unknown;
36270
+ };
36271
+ content: {
36272
+ "application/json": components["schemas"]["Error"];
36273
+ };
36274
+ };
36275
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
36276
+ 409: {
36277
+ headers: {
36278
+ [name: string]: unknown;
36279
+ };
36280
+ content: {
36281
+ "application/json": components["schemas"]["Error"];
36282
+ };
36283
+ };
36284
+ /** @description Rate limited */
36285
+ 429: {
36286
+ headers: {
36287
+ [name: string]: unknown;
36288
+ };
36289
+ content: {
36290
+ "application/json": components["schemas"]["Error"];
36291
+ };
36292
+ };
36293
+ };
36294
+ };
36295
+ trace?: never;
36296
+ };
35219
36297
  "/reservations": {
35220
36298
  parameters: {
35221
36299
  query?: never;
@@ -36049,6 +37127,7 @@ interface paths {
36049
37127
  * "tax_treatment": "afecto",
36050
37128
  * "status": "issued",
36051
37129
  * "issued_at": "2026-09-19T13:00:00.000Z",
37130
+ * "emitted_by": "11111111-0000-4000-8000-000000000001",
36052
37131
  * "approved_by": null,
36053
37132
  * "approved_at": null,
36054
37133
  * "voided_at": null,
@@ -36550,7 +37629,7 @@ interface paths {
36550
37629
  put?: never;
36551
37630
  /**
36552
37631
  * Request approval for a below-reference price
36553
- * @description Names exactly one of `quote_id` / `reservation_id` / `sale_note_id`. The requester is the authenticated principal, never a body field.
37632
+ * @description Names exactly one of `quote_id` / `reservation_id` / `sale_note_id`. `requested_price_clp` is the price the buyer pays for the car — IVA included on an afecto sale — the same terms as the published price and the precio piso it is measured against (ADR 0114 §2.2). A sale note is approved when what its buyer pays is at or above an approved request. The requester is the authenticated principal, never a body field.
36554
37633
  */
36555
37634
  post: {
36556
37635
  parameters: {
@@ -36682,7 +37761,7 @@ interface paths {
36682
37761
  };
36683
37762
  /**
36684
37763
  * Would this price need approval?
36685
- * @description Evaluates `price_clp` against the unit named by exactly one of `vehicle_id` / `quote_id` / `reservation_id` / `sale_note_id` (UUID or folio), with the same policy `POST /price-approvals` enforces — so a screen that hides «Pedir aprobación» on `needs_approval: false` hides exactly the request the POST would refuse. `reason` is the stable code (`below_reference` | `within_tolerance` | `at_or_above_reference` | `no_reference`); `message` is a ready-to-show Spanish sentence. When the reference is the unit floor, `reference_clp` and `shortfall_clp` are ABSENT unless the caller holds `dealership_economics:read`. Requires `price_approval:read` or `price_approval:request`.
37764
+ * @description Evaluates `price_clp` — what the buyer pays for the car, IVA included on an afecto sale, the same terms as the published price and the precio piso (ADR 0114 §2.2) — against the unit named by exactly one of `vehicle_id` / `quote_id` / `reservation_id` / `sale_note_id` (UUID or folio), with the same policy `POST /price-approvals` enforces — so a screen that hides «Pedir aprobación» on `needs_approval: false` hides exactly the request the POST would refuse. `reason` is the stable code (`below_reference` | `within_tolerance` | `at_or_above_reference` | `no_reference`); `message` is a ready-to-show Spanish sentence. When the reference is the unit floor, `reference_clp` and `shortfall_clp` are ABSENT unless the caller holds `dealership_economics:read`. Requires `price_approval:read` or `price_approval:request`.
36686
37765
  */
36687
37766
  get: {
36688
37767
  parameters: {
@@ -37771,7 +38850,9 @@ interface paths {
37771
38850
  * "subject_contact_id": null,
37772
38851
  * "uploaded_by": "11111111-0000-4000-8000-000000000001",
37773
38852
  * "uploaded_at": "2026-09-15T18:47:01.784Z",
37774
- * "created_at": "2026-09-15T18:47:01.784Z"
38853
+ * "created_at": "2026-09-15T18:47:01.784Z",
38854
+ * "signed_document_type": null,
38855
+ * "signed_document_id": null
37775
38856
  * },
37776
38857
  * {
37777
38858
  * "id": "f1f1f1f1-0000-4000-8000-000000000002",
@@ -37786,7 +38867,26 @@ interface paths {
37786
38867
  * "subject_contact_id": "22222222-0000-4000-8000-000000000001",
37787
38868
  * "uploaded_by": "11111111-0000-4000-8000-000000000001",
37788
38869
  * "uploaded_at": "2026-09-15T18:47:01.784Z",
37789
- * "created_at": "2026-09-15T18:47:01.784Z"
38870
+ * "created_at": "2026-09-15T18:47:01.784Z",
38871
+ * "signed_document_type": null,
38872
+ * "signed_document_id": null
38873
+ * },
38874
+ * {
38875
+ * "id": "f1f1f1f1-0000-4000-8000-000000000003",
38876
+ * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
38877
+ * "vehicle_id": "e1e1e1e1-0000-4000-8000-000000000001",
38878
+ * "kind": "contrato",
38879
+ * "storage_bucket": "vitrina-registry",
38880
+ * "storage_path": "a1a1a1a1-0000-4000-8000-000000000001/e1e1e1e1-0000-4000-8000-000000000001/compraventa-firmada.pdf",
38881
+ * "filename": "compraventa-firmada.pdf",
38882
+ * "mime_type": "application/pdf",
38883
+ * "byte_size": 812004,
38884
+ * "subject_contact_id": null,
38885
+ * "uploaded_by": "11111111-0000-4000-8000-000000000001",
38886
+ * "uploaded_at": "2026-09-15T18:47:01.784Z",
38887
+ * "created_at": "2026-09-15T18:47:01.784Z",
38888
+ * "signed_document_type": "compraventa",
38889
+ * "signed_document_id": "d4d4d4d4-0000-4000-8000-000000000001"
37790
38890
  * }
37791
38891
  * ]
37792
38892
  * }
@@ -37859,6 +38959,8 @@ interface paths {
37859
38959
  /**
37860
38960
  * Upload a registry document for a vehicle (multipart/form-data)
37861
38961
  * @description Capped at the configured max size; the file part is required.
38962
+ *
38963
+ * A SIGNED COPY of one of the car’s documents (ADR 0114 §7) is filed with `signed_document_type` (`purchase_note`, `sale_note`, `compraventa`, `consignment_contract`, `liquidacion`) and `signed_document_id` (the nota de venta’s id for a compraventa, the consignación’s id for a liquidación). The document must be this car’s, and a compraventa must have been printed; `kind` may then be omitted — it is `contrato` for the compraventa and the mandato, `otro` for the rest — and a contradicting `kind` is refused (400). `GET /vehicles/{id}/documents` shows the copy on its document.
37862
38964
  */
37863
38965
  post: {
37864
38966
  parameters: {
@@ -37883,9 +38985,13 @@ interface paths {
37883
38985
  /** Format: uuid */
37884
38986
  vehicle_id: string;
37885
38987
  /** @enum {string} */
37886
- kind: "padron" | "cedula" | "contrato" | "certificado_anotaciones" | "factura" | "otro";
38988
+ kind?: "padron" | "cedula" | "contrato" | "certificado_anotaciones" | "factura" | "otro";
37887
38989
  /** Format: uuid */
37888
38990
  subject_contact_id?: string;
38991
+ /** @enum {string} */
38992
+ signed_document_type?: "purchase_note" | "sale_note" | "compraventa" | "consignment_contract" | "liquidacion";
38993
+ /** Format: uuid */
38994
+ signed_document_id?: string;
37889
38995
  file?: unknown;
37890
38996
  };
37891
38997
  };
@@ -37912,7 +39018,9 @@ interface paths {
37912
39018
  * "subject_contact_id": null,
37913
39019
  * "uploaded_by": "11111111-0000-4000-8000-000000000001",
37914
39020
  * "uploaded_at": "2026-09-15T18:47:01.784Z",
37915
- * "created_at": "2026-09-15T18:47:01.784Z"
39021
+ * "created_at": "2026-09-15T18:47:01.784Z",
39022
+ * "signed_document_type": null,
39023
+ * "signed_document_id": null
37916
39024
  * }
37917
39025
  * }
37918
39026
  */
@@ -38180,7 +39288,7 @@ interface paths {
38180
39288
  };
38181
39289
  /**
38182
39290
  * Export the deals and their margins (xlsx / csv)
38183
- * @description One row per live nota de venta in the window, with every settlement column: folio, date, status, patente, vehicle, regime, seller, buyer, buyer origin channel, leads, days in stock, published price, discount (amount and %), total paid (with IVA), IVA, net sale price, retained add-ons, net revenue, purchase cost, gross margin, additional costs, commissions, Utilidad del negocio, pass-through add-ons (neutral) and `Completo`. A figure that is not recorded or not computable is an EMPTY cell, never 0.
39291
+ * @description One row per live nota de venta in the window, with every settlement column: folio, date, status, patente, vehicle, regime, seller, buyer, buyer origin channel, leads, days in stock; then the cifras del negocio, NET of IVA (sale price, Adicionales con margen, revenue, purchase cost, Margen bruto, additional costs, commissions, Utilidad del negocio), the Cobros por cuenta del comprador (cobrado / rendido, neutral); then the cifras del comprador, GROSS and labelled so (sale price con IVA, IVA, published price, discount amount and %); and `Completo` / `Pendiente` (what an incomplete sale lacks: «Sin costo», «Sin comisión», «Sin liquidación»). Every sale is a row. A figure that is not recorded or not computable is an EMPTY cell, never 0.
38184
39292
  *
38185
39293
  * Pass `period` (`YYYY-MM`, the Margen screen’s month) OR `from`/`to` (`YYYY-MM-DD`, inclusive, on the dealership’s calendar) — one of the two is required (400 otherwise), never both. `format` is `xlsx` (default) or `csv`. **413** over 2000 deals. Requires `dealership_economics:read`.
38186
39294
  */
@@ -38284,6 +39392,12 @@ interface paths {
38284
39392
  * The Resumen del negocio of one unit
38285
39393
  * @description Everything about one car’s deal on one read: the published price, the discount (amount and %), the sale price, the purchase or consignment basis, the cost lines grouped by category with who absorbs each (`automotora` / `dueno` / `cliente`), the margin (the platform’s one margin definition, embedded whole with `complete` and `gaps`), the commission of each salesperson, the seller, the buyer and the buyer’s origin channel (the sale note’s lead first, then the buyer’s first conversation, then the contact’s recorded origin), how many people asked about the unit, days in stock (entry → approval) and days to sell (first publication → sale).
38286
39394
  *
39395
+ * Cifras del negocio are NET of IVA (ADR 0114 §2.2): `pricing.sale_price_clp` and every `margin` figure. Cifras del comprador are GROSS: `pricing.total_clp` (what the buyer paid, net + IVA), `pricing.list_price_clp` and `pricing.discount_clp` (measured against the published price, which includes IVA). Where both appear together an afecto sale reads «Precio de venta $5.806.723 neto · $6.910.000 con IVA» under a «Cifras sin IVA» heading.
39396
+ *
39397
+ * The car’s lifecycle facts ride along: `ingreso` (how the car entered stock — `compra`, `consignacion` or `retoma` — the day, and the backing document with its folio; `null` = «Sin costo»), `sale_note.emitted_by` and `sale_note.approved_by` (who emitted and who approved the sale, by name; `null` = not recorded), `basis.consignment.contract_id` (where the Liquidación lives) and `post_sale` (the trámites the approved sale opened: total, pending, overdue on the dealership day and the next deadline; `null` until the sale is approved).
39398
+ *
39399
+ * Cobros por cuenta del comprador (the transfer tax, registry fees, notary — charged at exact cost) are in no margin figure; `pricing.pass_through_clp` (cobrado) and `pricing.pass_through_paid_out_clp` (rendido) carry the memo line «Cobrado por cuenta del comprador $X · rendido $Y».
39400
+ *
38287
39401
  * `state` is `sold` (the newest live nota de venta is approved), `pending_approval` (issued, not yet approved) or `preview` (no live nota de venta: the settlement at the published price, with no discount, add-ons or commissions, flagged by a `preview` gap). A figure that is not recorded is `null`, never 0. Requires `dealership_economics:read`.
38288
39402
  */
38289
39403
  get: {
@@ -38329,8 +39443,21 @@ interface paths {
38329
39443
  * "status": "approved",
38330
39444
  * "issued_at": "2026-09-19T13:00:00.000Z",
38331
39445
  * "approved_at": "2026-09-20T10:30:00.000Z",
39446
+ * "approved_by": {
39447
+ * "user_id": "a1a1a1a1-0000-4000-8000-000000000003",
39448
+ * "name": "Paz Ortiz"
39449
+ * },
38332
39450
  * "seller_of_record": "automotora"
38333
39451
  * },
39452
+ * "ingreso": {
39453
+ * "kind": "compra",
39454
+ * "acquired_on": "2026-07-24",
39455
+ * "document": {
39456
+ * "type": "purchase_note",
39457
+ * "id": "e5e5e5e5-0000-4000-8000-000000000001",
39458
+ * "folio": "P-34"
39459
+ * }
39460
+ * },
38334
39461
  * "pricing": {
38335
39462
  * "list_price_clp": 12490000,
38336
39463
  * "sale_price_clp": 11900000,
@@ -38339,7 +39466,8 @@ interface paths {
38339
39466
  * "discount_clp": 590000,
38340
39467
  * "discount_pct": 4.7,
38341
39468
  * "add_on_charges_clp": 100000,
38342
- * "pass_through_clp": 89900
39469
+ * "pass_through_clp": 89900,
39470
+ * "pass_through_paid_out_clp": 89900
38343
39471
  * },
38344
39472
  * "basis": {
38345
39473
  * "regime": "propia",
@@ -38421,6 +39549,7 @@ interface paths {
38421
39549
  * "precio_venta_clp": 11900000,
38422
39550
  * "add_on_charges_clp": 100000,
38423
39551
  * "pass_through_clp": 89900,
39552
+ * "pass_through_paid_out_clp": 89900,
38424
39553
  * "dealer_take_clp": null
38425
39554
  * },
38426
39555
  * "costo_venta_clp": 9800000,
@@ -38509,6 +39638,13 @@ interface paths {
38509
39638
  * "first_contact_at": "2026-08-02T14:10:00.000Z",
38510
39639
  * "last_contact_at": "2026-09-18T21:45:00.000Z"
38511
39640
  * },
39641
+ * "post_sale": {
39642
+ * "total": 3,
39643
+ * "pending": 1,
39644
+ * "overdue": 0,
39645
+ * "next_due_on": "2026-10-20",
39646
+ * "completed_at": null
39647
+ * },
38512
39648
  * "timeline": {
38513
39649
  * "entered_stock_at": "2026-07-24T12:00:00.000Z",
38514
39650
  * "first_published_at": "2026-07-26T15:00:00.000Z",
@@ -38594,6 +39730,185 @@ interface paths {
38594
39730
  patch?: never;
38595
39731
  trace?: never;
38596
39732
  };
39733
+ "/vehicles/{id}/documents": {
39734
+ parameters: {
39735
+ query?: never;
39736
+ header?: never;
39737
+ path?: never;
39738
+ cookie?: never;
39739
+ };
39740
+ /**
39741
+ * Every document of one car
39742
+ * @description The car’s papers in one read (ADR 0114 §7), in the dealership’s order: how it entered (`purchase_note`, nota de compra — or the `sale_note` with `role: parte_de_pago` that took it as a trade-in), the `consignment_contract` (contrato de consignación, the mandato), each `sale_note` (nota de venta, voided ones included) followed by its `compraventa` (contrato de compraventa), the `deal_settlement` (Resumen del negocio; `preview` while the car is in stock) and the `liquidacion` (liquidación al consignante).
39743
+ *
39744
+ * A paper the car is expected to have and does not is listed with `status: missing` (a nota de venta before the sale, a compraventa before approval, a liquidación before the consignor is paid). Other statuses: `issued`, `approved`, `voided` (notas), `printed` / `unprinted` (compraventa, mandato — frozen instruments), `preview` / `final` (Resumen del negocio), `paid` / `withdrawal` (liquidación).
39745
+ *
39746
+ * `pdf` is where the PDF is read (`method` + `path` under `/api/v1`); `print` is the call that issues an unprinted instrument (needs the write scope). `signable` says whether a signed copy belongs on the document; `signed_copy` is that copy in the expediente (upload it with `POST /vehicle-attachments` and `signed_document_type` + `signed_document_id`), `null` when missing and ABSENT for a caller without `vehicle_registry:read`.
39747
+ *
39748
+ * Requires `marketplace:read`. Each document type is listed only for a caller holding its read scope (`purchase_notes:read`, `consignments:read`, `sale_notes:read`, `dealership_economics:read`). No amounts.
39749
+ */
39750
+ get: {
39751
+ parameters: {
39752
+ query?: never;
39753
+ header?: never;
39754
+ path: {
39755
+ id: string;
39756
+ };
39757
+ cookie?: never;
39758
+ };
39759
+ requestBody?: never;
39760
+ responses: {
39761
+ /** @description The car’s documents */
39762
+ 200: {
39763
+ headers: {
39764
+ [name: string]: unknown;
39765
+ };
39766
+ content: {
39767
+ /**
39768
+ * @example {
39769
+ * "data": {
39770
+ * "vehicle_id": "e1e1e1e1-0000-4000-8000-000000000001",
39771
+ * "documents": [
39772
+ * {
39773
+ * "type": "purchase_note",
39774
+ * "id": "d5d5d5d5-0000-4000-8000-000000000001",
39775
+ * "folio": "P-34",
39776
+ * "issued_at": "2026-08-02T14:10:00.000Z",
39777
+ * "printed_at": null,
39778
+ * "status": "issued",
39779
+ * "pdf": {
39780
+ * "method": "GET",
39781
+ * "path": "/purchase-notes/d5d5d5d5-0000-4000-8000-000000000001/pdf"
39782
+ * },
39783
+ * "print": null,
39784
+ * "signable": true,
39785
+ * "signed_copy": null
39786
+ * },
39787
+ * {
39788
+ * "type": "sale_note",
39789
+ * "id": "d4d4d4d4-0000-4000-8000-000000000001",
39790
+ * "folio": "V-12",
39791
+ * "issued_at": "2026-09-20T15:02:00.000Z",
39792
+ * "printed_at": null,
39793
+ * "status": "approved",
39794
+ * "pdf": {
39795
+ * "method": "GET",
39796
+ * "path": "/sale-notes/d4d4d4d4-0000-4000-8000-000000000001/pdf"
39797
+ * },
39798
+ * "print": null,
39799
+ * "signable": true,
39800
+ * "signed_copy": null
39801
+ * },
39802
+ * {
39803
+ * "type": "compraventa",
39804
+ * "id": "d4d4d4d4-0000-4000-8000-000000000001",
39805
+ * "folio": "V-12",
39806
+ * "issued_at": "2026-09-20T16:40:00.000Z",
39807
+ * "printed_at": "2026-09-20T16:40:00.000Z",
39808
+ * "status": "printed",
39809
+ * "pdf": {
39810
+ * "method": "GET",
39811
+ * "path": "/sale-notes/d4d4d4d4-0000-4000-8000-000000000001/compraventa/pdf"
39812
+ * },
39813
+ * "print": null,
39814
+ * "signable": true,
39815
+ * "signed_copy": {
39816
+ * "attachment_id": "f1f1f1f1-0000-4000-8000-000000000003",
39817
+ * "filename": "compraventa-firmada.pdf",
39818
+ * "mime_type": "application/pdf",
39819
+ * "uploaded_at": "2026-09-21T10:05:00.000Z"
39820
+ * }
39821
+ * },
39822
+ * {
39823
+ * "type": "deal_settlement",
39824
+ * "id": null,
39825
+ * "folio": null,
39826
+ * "issued_at": "2026-09-20T15:30:00.000Z",
39827
+ * "printed_at": null,
39828
+ * "status": "final",
39829
+ * "pdf": {
39830
+ * "method": "GET",
39831
+ * "path": "/vehicles/e1e1e1e1-0000-4000-8000-000000000001/deal-settlement/pdf"
39832
+ * },
39833
+ * "print": null,
39834
+ * "signable": false
39835
+ * }
39836
+ * ]
39837
+ * }
39838
+ * }
39839
+ */
39840
+ "application/json": {
39841
+ data?: unknown;
39842
+ meta?: {
39843
+ [key: string]: unknown;
39844
+ };
39845
+ };
39846
+ };
39847
+ };
39848
+ /** @description Validation error */
39849
+ 400: {
39850
+ headers: {
39851
+ [name: string]: unknown;
39852
+ };
39853
+ content: {
39854
+ "application/json": components["schemas"]["Error"];
39855
+ };
39856
+ };
39857
+ /** @description Unauthorized */
39858
+ 401: {
39859
+ headers: {
39860
+ [name: string]: unknown;
39861
+ };
39862
+ content: {
39863
+ "application/json": components["schemas"]["Error"];
39864
+ };
39865
+ };
39866
+ /** @description Forbidden */
39867
+ 403: {
39868
+ headers: {
39869
+ [name: string]: unknown;
39870
+ };
39871
+ content: {
39872
+ "application/json": components["schemas"]["Error"];
39873
+ };
39874
+ };
39875
+ /** @description Not found */
39876
+ 404: {
39877
+ headers: {
39878
+ [name: string]: unknown;
39879
+ };
39880
+ content: {
39881
+ "application/json": components["schemas"]["Error"];
39882
+ };
39883
+ };
39884
+ /** @description Conflict (incl. Idempotency-Key reuse with different body) */
39885
+ 409: {
39886
+ headers: {
39887
+ [name: string]: unknown;
39888
+ };
39889
+ content: {
39890
+ "application/json": components["schemas"]["Error"];
39891
+ };
39892
+ };
39893
+ /** @description Rate limited */
39894
+ 429: {
39895
+ headers: {
39896
+ [name: string]: unknown;
39897
+ };
39898
+ content: {
39899
+ "application/json": components["schemas"]["Error"];
39900
+ };
39901
+ };
39902
+ };
39903
+ };
39904
+ put?: never;
39905
+ post?: never;
39906
+ delete?: never;
39907
+ options?: never;
39908
+ head?: never;
39909
+ patch?: never;
39910
+ trace?: never;
39911
+ };
38597
39912
  "/vehicles/{id}/deal-settlement/pdf": {
38598
39913
  parameters: {
38599
39914
  query?: never;
@@ -38603,7 +39918,7 @@ interface paths {
38603
39918
  };
38604
39919
  /**
38605
39920
  * Print the Resumen del negocio (PDF)
38606
- * @description The Resumen del negocio as a PDF (`application/pdf`, served `inline`): the workspace’s default `deal_settlement` template — or `template_id` — filled with the deal’s facts, followed by a fixed table of the result walk, the costs by category and who absorbs them, and the commissions. With no live template it prints the standard text. A missing fact prints «no registrado»; nothing is refused. A preview carries a «VISTA PREVIA» banner. `X-Template-Version` names the prose used. Requires `dealership_economics:read`.
39921
+ * @description The Resumen del negocio as a PDF (`application/pdf`, served `inline`): the workspace’s default `deal_settlement` template — or `template_id` — filled with the deal’s facts, followed by a fixed table of the result walk headed «Cifras sin IVA», the costs by category and who absorbs them, and the commissions. Every figure of the walk is net of IVA (ADR 0114 §2.2); an afecto sale’s price reads «$5.806.723 neto · $6.910.000 con IVA», and no gross figure is a step of the walk. With no live template it prints the standard text. A missing fact prints «no registrado»; nothing is refused. A preview carries a «VISTA PREVIA» banner. `X-Template-Version` names the prose used. Requires `dealership_economics:read`.
38607
39922
  */
38608
39923
  get: {
38609
39924
  parameters: {
@@ -38700,7 +40015,7 @@ interface paths {
38700
40015
  };
38701
40016
  /**
38702
40017
  * Export the Resumen del negocio (xlsx / csv)
38703
- * @description The same Resumen del negocio as a planilla. `xlsx` (default) carries three sheets — **Resumen** (the result walk and the deal’s facts), **Costos** (by category and party) and **Comisiones** (per salesperson); `csv` carries the Resumen. Requires `dealership_economics:read`.
40018
+ * @description The same Resumen del negocio as a planilla. `xlsx` (default) carries three sheets — **Resumen** (the result walk, net of IVA — its `Monto sin IVA` column sums to the Utilidad; an afecto sale’s gross price, the published price and the discount are stated as facts, never in that column — and the deal’s facts), **Costos** (by category and party) and **Comisiones** (per salesperson); `csv` carries the Resumen. Requires `dealership_economics:read`.
38704
40019
  */
38705
40020
  get: {
38706
40021
  parameters: {
@@ -106265,7 +107580,9 @@ interface paths {
106265
107580
  *
106266
107581
  * `by_tenencia` (Tenencia, ADR 0025) splits the lot four ways: `propio`, `consignacion_en_local`, `consignacion_virtual` and `consignacion_sin_contrato` (consigned on the vehicle row with NO contract in `estado=activo`). The four PARTITION the lot — they sum to `total` — and each equals the length of the list its chip opens: `GET /vehicles?active=false&tenencia=…[&consignacion_modalidad=…]`, the same predicate builder serving both. Like `by_location` and `total`, they count the WHOLE lot rather than active stock only, which is what the Stock screen shows (it sends `active=false`).
106267
107582
  *
106268
- * `propio_sin_clasificar` (Phase 2, tenencia_source, 20270903000000) is a SUB-COUNT of `propio`, NOT a fifth bucket — the four above still sum to `total`. It is the cars nobody has ever classified (`tenencia_source=default`), provably coextensive with "sin clasificar" (a consignación can never be `default`). Measured on production 2026-08-31: 903 of 967 vehicles carried `propio` with nobody having said so — that is what this number answers, rather than leaving `propio` an unresolved warning. Opens with `GET /vehicles?active=false&tenencia=propio&tenencia_source=default`. Automotive-vertical only: a workspace on another vertical gets 403 here however its scopes are set.
107583
+ * `propio_sin_clasificar` (Phase 2, tenencia_source, 20270903000000) is a SUB-COUNT of `propio`, NOT a fifth bucket — the four above still sum to `total`. It is the cars nobody has ever classified (`tenencia_source=default`), provably coextensive with "sin clasificar" (a consignación can never be `default`). Measured on production 2026-08-31: 903 of 967 vehicles carried `propio` with nobody having said so — that is what this number answers, rather than leaving `propio` an unresolved warning. Opens with `GET /vehicles?active=false&tenencia=propio&tenencia_source=default`.
107584
+ *
107585
+ * `sin_costo` (ADR 0114 §8, «Sin costo») counts the active, non-vendido cars with NO acquisition — no nota de compra, contrato de consignación or parte de pago — so their cost is unknown. Opens with `GET /vehicles?view=sin_costo`, the same predicate. A statement about the cost basis: ABSENT (not 0) for a caller without `dealership_economics:read`. Automotive-vertical only: a workspace on another vertical gets 403 here however its scopes are set.
106269
107586
  */
106270
107587
  get: {
106271
107588
  parameters: {
@@ -106295,6 +107612,7 @@ interface paths {
106295
107612
  * "with_error": 0,
106296
107613
  * "unpublished": 7,
106297
107614
  * "stale": 0,
107615
+ * "sin_costo": 7,
106298
107616
  * "by_location": {
106299
107617
  * "b1b1b1b1-0000-4000-8000-000000000001": 3,
106300
107618
  * "b1b1b1b1-0000-4000-8000-000000000002": 1,