@vitrina/api 17.89.0 → 17.91.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.
package/dist/index.d.cts CHANGED
@@ -18772,6 +18772,8 @@ interface paths {
18772
18772
  *
18773
18773
  * **Costo de compra in the same call (`purchase_cost_clp`).** Optional (vitrina-app#7719). The amount the dealership paid, recorded as the car’s Costo de compra exactly as `POST /vehicle-acquisitions` with `kind: "compra"` would; `invoice_includes_iva: true` says it includes IVA («Compra con factura»). Needs `dealership_economics:write`: without it the call is a **403 and nothing is saved**. The response then carries `acquisition` (the recorded row, the same shape `POST /vehicle-acquisitions` returns, shown only to callers holding `dealership_economics:read`); `acquisition: null` means the car was saved but its cost was not, and it can be typed on the car’s page. Both fields are create-only.
18774
18774
  *
18775
+ * **Creating a car by its plate alone.** Every field is optional: a form that creates the car from inside another document (the nota de compra, the «Auto en parte de pago» of a sale) sends `registration_number` plus whatever marca, modelo and año the dealer has (`GET /pricing/decode-plate` fills them when it knows the plate; its 404 means it does not). Without `publish_to` the car is on no portal. A plate another active car of the workspace already has is a **409 `CONFLICT`** whose `error.details` names that car: `vehicle_id` (the one to offer instead), `vehicle_ids` (every holder, newest first) and `vehicle_status` (its Estado comercial; `vendido` is a sold car still holding the plate, not one a document can take). A hidden car (`active: false`, not sold, not deleted) holding the plate answers the same 409 with `reason: "plate_inactive_holder"` and the same three fields: offer that car (it is made public again with `PUT /vehicles/{id} { active: true }`) instead of creating a second one. A sold car never blocks: a returning plate is a new car. Nothing is created on a 409.
18776
+ *
18775
18777
  * **Sanity range.** A price fans out to every connected portal, so a typo is stopped here. `price_amount` must be between 100.000 and 2.000.000.000 CLP (a UF price is bounded at the day's UF; other currencies are not bounded) and `odometer_value` between 0 and 2.000.000; `null` clears either and is always accepted. Outside the range: **422 `VEHICLE_VALUE_OUT_OF_RANGE`**, with a Spanish `message`, `field_errors.<field>` and `details.violations[]` (`field`, `reason` = `price_out_of_range` | `km_out_of_range`, `value`, `min`, `max`, `currency`). A price change beyond 10x up or down from the current price answers **422 `PRICE_CHANGE_CONFIRMATION_REQUIRED`** (`details.reason` = `large_price_change`, `current_price`, `requested_price`, `currency`, `factor`, `confirm_flag`) unless the body carries `confirm_large_price_change: true`; ask the user, then resend the same body with it. Nothing is written on either 422.
18776
18778
  *
18777
18779
  * **Normalization and `catalog_match`.** On create and update, `make` and `model` that equal an entry of GET /vehicles/catalog/brands and /catalog/models up to case, accents, spaces and hyphens are stored in the catalog's spelling ("toyota" → "Toyota", "mercedes benz" → "Mercedes-Benz", "rav 4" → "RAV4"); `fuel_type`, `gear_type` and `body_style` are stored as vocabulary codes ("Bencina" → `gasolina`, "Automática" → `automatica`, "Station Wagon" → `wagon`; codes: fuel `gasolina|diesel|hibrido|electrico|gnc|glp|otro`, gear `mecanica|automatica|otro`, body `sedan|hatchback|suv|camioneta|coupe|wagon|furgon|convertible|minivan|otro`; for `vehicle_type: moto` body_style is the «Tipo de moto» instead: `moto_calle|moto_deportiva|moto_touring|moto_trail|moto_enduro|moto_scooter|moto_custom|moto_cuatrimoto|moto_otro`, and "Trail" / "BODY.MOTORCYCLE.TRAIL" snap to `moto_trail`). Nothing is invented: a value with no match is stored exactly as sent. The response (and GET /vehicles/{id}) carries `catalog_match`: `make` / `model` are `matched` | `unmatched` | `missing` (`not_applicable` for a non-`auto` vehicle_type); `version` adds `approximate` (word overlap with a catalog version, same displacement) and `catalog_version` names the catalog version it matched or most resembles; `fuel_type` / `gear_type` / `body_style` are `matched` | `unmatched` | `missing`; `warnings[]` lists `{ field, code, message }` for everything not matched, with a Spanish `message` ready to show (codes: `make_missing`, `make_not_in_catalog`, `model_missing`, `model_not_in_catalog`, `version_approximate`, `version_not_in_catalog`, `fuel_type_not_recognized`, `gear_type_not_recognized`, `body_style_not_recognized`). A make or model that is not matched still saves, but Chileautos publishes it without a technical sheet (ficha). `catalog_match` is null only when the catalog could not be loaded. Example of an unmatched push: {"make":"matched","model":"unmatched","version":"unmatched","catalog_version":null,"fuel_type":"unmatched","gear_type":"matched","body_style":"missing","warnings":[{"field":"model","code":"model_not_in_catalog","message":"Modelo 'Rav-4 xx' no está en el catálogo de Toyota (GET /vehicles/catalog/models); Chileautos lo publicará sin ficha."},{"field":"fuel_type","code":"fuel_type_not_recognized","message":"Combustible 'Hidrógeno' no se reconoce; valores aceptados: gasolina, diesel, hibrido, electrico, gnc, glp, otro."}]}
@@ -39449,13 +39451,15 @@ interface paths {
39449
39451
  head?: never;
39450
39452
  /**
39451
39453
  * Correct the price terms of a nota de venta (issued or approved)
39452
- * @description Corrects `net_clp`, `tax_clp` (null = not recorded, 0 = no tax), `tax_treatment` and/or `issued_at` on a nota de venta that is ISSUED or APPROVED and not voided, with no cutoff. All optional, at least one; unknown keys are a 400. In one transaction the edit re-derives what issuing at the new terms would have: the buyer’s receivable (the sale note’s open obligation, re-stated from price + IVA + charged add-ons) and the participations’ DEFAULTED commissions (the margin basis and, when the sale’s day moves, the scheme rate); `discount_clp` follows. Payments already recorded, add-on lines, trade-ins, the credit and `list_price_clp` are kept; on an approved note the car stays sold and the deal stays won. Every correction writes a `history` entry (actor, instant, each field `{ from, to }`); a compraventa printed before it reads `compraventa_outdated: true` until it is reprinted. Responds with the same read as `GET /sale-notes/{id}` plus `correction: { outcome, price_approval_id, change_id }`, `outcome` = `applied` | `unchanged` (sending the values it already has is a no-op 200) | `pending_approval`.
39454
+ * @description Corrects `net_clp`, `tax_clp` (null = not recorded, 0 = no tax), `tax_treatment`, `issued_at` and/or the precio de toma (`trade_ins`) on a nota de venta that is ISSUED or APPROVED and not voided, with no cutoff. All optional, at least one; unknown keys are a 400. In one transaction the edit re-derives what issuing at the new terms would have: the buyer’s receivable (the sale note’s open obligation, re-stated from price + IVA + charged add-ons) and the participations’ DEFAULTED commissions (the margin basis and, when the sale’s day moves, the scheme rate); `discount_clp` follows. Payments already recorded, add-on lines, trade-ins, the credit and `list_price_clp` are kept; on an approved note the car stays sold and the deal stays won. Every correction writes a `history` entry (actor, instant, each field `{ from, to }`); a compraventa printed before it reads `compraventa_outdated: true` until it is reprinted. Responds with the same read as `GET /sale-notes/{id}` plus `correction: { outcome, price_approval_id, change_id }`, `outcome` = `applied` | `unchanged` (sending the values it already has is a no-op 200) | `pending_approval`.
39453
39455
  *
39454
39456
  * **202 `pending_approval`**: on an APPROVED note, a correction that lowers the price below the floor (the price-approval policy, tolerance included) by a caller WITHOUT `price_approval:approve` is not applied. It is filed as a price approval on the note carrying the proposed terms (`proposed_terms` on `GET /price-approvals`), shown as `pending_price_change` on the note; granting it (`POST /price-approvals/{id}/decision`) applies the correction in the same transaction, rejecting it leaves the note as it was. A caller holding `price_approval:approve`, a grant on this note that covers the price, a raise, or a pending (unapproved) note applies directly.
39455
39457
  *
39456
39458
  * **409** with `details.blocked_reason` = `sale_note_voided`, or `sale_note_approved` only when a PENDING note was approved while the edit ran (nothing changed; retry, it now applies the approved-note rule), and a Spanish message. Requires `sale_notes:write`.
39457
39459
  *
39458
39460
  * **`observaciones`** (app#7581) rides the same body: a string sets the text printed on the nota de venta (trimmed, up to 2000 characters), `null` or blank clears it. It is not a money fact: it applies on an issued or approved note with no price approval, no `history` entry and no `compraventa_outdated` (audited as `sale_notes.set_observaciones`). Sent alone it answers 200 with `correction.outcome` `applied` (or `unchanged`) and `change_id: null`; on a voided note it is the same **409** `sale_note_voided`.
39461
+ *
39462
+ * **`trade_ins`** (vitrina-app#7725): `[{ vehicle_id, precio_toma_clp }]` changes the precio de toma of cars this sale already took in part payment (cars are neither added nor removed here), on an issued or approved note. In one transaction, per car that moved: the trade-in line (the credit: the saldo follows on the next read), the car’s `retoma` cost (so its Ganancia follows when it sells), its live nota de compra’s amount (stamped as corrected) and a `history` entry (`kind: terms`, field `precio_toma_clp`). `correction.trade_ins` lists what moved: `{ vehicle_id, from_clp, to_clp, purchase_note_id, purchase_note_display_id, change_id }` (`[]` when nothing moved). 400 for a car the sale did not take, and `discounts_exceed_price` when the new price is below the nota de compra’s «Descuentos».
39459
39463
  */
39460
39464
  patch: {
39461
39465
  parameters: {
@@ -39483,6 +39487,11 @@ interface paths {
39483
39487
  issued_at?: string;
39484
39488
  /** @description Observaciones que se imprimen en la nota de venta, tal como se escribieron (hasta 2000 caracteres). Se guardan sin espacios al inicio ni al final; vacío o null las borra. No son notas internas. */
39485
39489
  observaciones?: string | null;
39490
+ trade_ins?: {
39491
+ /** Format: uuid */
39492
+ vehicle_id: string;
39493
+ precio_toma_clp: number;
39494
+ }[];
39486
39495
  };
39487
39496
  };
39488
39497
  };
@@ -42147,6 +42156,8 @@ interface paths {
42147
42156
  * Requires `sale_notes:void`, which is a DIFFERENT authority from `sale_notes:write` — holding the write scope does not permit a void.
42148
42157
  *
42149
42158
  * **`void_outcome` says what happened (app#7587)** — the voided row plus `{ reservation: { outcome: reopened | not_reopened | none, reason: hold_lapsed | another_hold_active | not_completed | different_vehicle | not_found | null, id, display_id, abono_clp }, vehicle: { id, status, changed, ads_closed_by_sale, ads_republished: false }, payments: { released_clp, returned_to_reservation_clp, buyer_credit_clp }, appointments: { cancelled_by_sale_restored: false }, deal_reopened, message }`. A reopened reserva carries its abono again and holds the car; a lapsed one is not reopened and the money stays with the buyer as credit (payments are kept: for the replacement note or to be refunded). Portal ads the sale closed are not re-published automatically, and test drives the sale cancelled are not restored. `message` is one short Spanish paragraph to show as is.
42159
+ *
42160
+ * **Cars taken in part payment** (vitrina-app#7725): `void_outcome.trade_ins` lists `{ vehicle_id, purchase_note_id, purchase_note_display_id, cost_removed: true }` per car. Its nota de compra (written when the sale was closed) is voided with the sale, and the car is left without a Costo de compra; it stays in Stock for the dealer to remove if it went back to the buyer. `message` says so.
42150
42161
  */
42151
42162
  post: {
42152
42163
  parameters: {
@@ -43799,6 +43810,8 @@ interface paths {
43799
43810
  *
43800
43811
  * **Each row carries the unit it bought**: `vehicle` is `{ id, make, model, year, registration_number }` or `null`, and `vehicle_count` says how many units the document acquired. One nota de compra may acquire SEVERAL units, so `vehicle` is the FIRST of them (deterministic: `acquired_on`, then `created_at`, then `id`) and `vehicle_count` is what keeps that from reading as "this note bought one car". `vehicle` is `null` exactly when `vehicle_count` is `0`, which is an ordinary state: the document is issued before anything is attached to it, and attaching is a separate act on `/vehicle-acquisitions`.
43801
43812
  *
43813
+ * **A nota de compra of a car taken in part payment** (vitrina-app#7725) is written by closing that sale: its row carries `sale_note_id`, `sale_note_trade_in_id` and `sale_note_display_id` (the sale’s folio, `V-n`), all `null` on any other nota. Its `vehicle` is the car taken.
43814
+ *
43802
43815
  * 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.
43803
43816
  */
43804
43817
  get: {
@@ -43837,13 +43850,17 @@ interface paths {
43837
43850
  * "notes": null,
43838
43851
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
43839
43852
  * "observaciones": "Se entrega con dos llaves.",
43853
+ * "sale_note_id": null,
43854
+ * "sale_note_trade_in_id": null,
43855
+ * "voided_vehicle_id": null,
43840
43856
  * "corrected_at": null,
43841
43857
  * "corrected_by": null,
43842
43858
  * "voided_at": null,
43843
43859
  * "void_reason": null,
43844
43860
  * "voided_by": null,
43845
43861
  * "created_at": "2026-09-12T10:15:00.000Z",
43846
- * "updated_at": "2026-09-12T10:15:00.000Z"
43862
+ * "updated_at": "2026-09-12T10:15:00.000Z",
43863
+ * "sale_note_display_id": null
43847
43864
  * }
43848
43865
  * ],
43849
43866
  * "meta": {
@@ -44040,6 +44057,9 @@ interface paths {
44040
44057
  * "notes": null,
44041
44058
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44042
44059
  * "observaciones": "Se entrega con dos llaves.",
44060
+ * "sale_note_id": null,
44061
+ * "sale_note_trade_in_id": null,
44062
+ * "voided_vehicle_id": null,
44043
44063
  * "corrected_at": null,
44044
44064
  * "corrected_by": null,
44045
44065
  * "voided_at": null,
@@ -44134,6 +44154,8 @@ interface paths {
44134
44154
  *
44135
44155
  * Since vitrina-app#7723 it also carries what the «Modificar» form opens with: `acquisition` (the car’s cost under this note, with `invoice_includes_iva` and `amount_paid_clp`, or `null`) and `retentions` (the note’s live «Descuentos», each with `description` and `net_clp`).
44136
44156
  *
44157
+ * A nota de compra written by closing a sale with a car in part payment (vitrina-app#7725) carries `sale_note_id`, `sale_note_trade_in_id` and `sale_note_display_id` (`V-n`); its amount is that sale’s precio de toma and `acquisition` is the car’s `retoma` cost. Every other nota has the three as `null`.
44158
+ *
44137
44159
  * A document belonging to another workspace is a 404, indistinguishable from one that does not exist.
44138
44160
  */
44139
44161
  get: {
@@ -44169,6 +44191,9 @@ interface paths {
44169
44191
  * "notes": null,
44170
44192
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44171
44193
  * "observaciones": "Se entrega con dos llaves.",
44194
+ * "sale_note_id": null,
44195
+ * "sale_note_trade_in_id": null,
44196
+ * "voided_vehicle_id": null,
44172
44197
  * "corrected_at": null,
44173
44198
  * "corrected_by": null,
44174
44199
  * "voided_at": null,
@@ -44184,6 +44209,7 @@ interface paths {
44184
44209
  * "registration_number": "KXPT21"
44185
44210
  * },
44186
44211
  * "vehicle_count": 1,
44212
+ * "sale_note_display_id": null,
44187
44213
  * "acquisition": {
44188
44214
  * "id": "7b0e1c52-3a1f-4d8e-9c2a-5f6b7c8d9e01",
44189
44215
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
@@ -44295,6 +44321,8 @@ interface paths {
44295
44321
  * Modify a nota de compra
44296
44322
  * @description **Everything is editable until the note is voided** (vitrina-app#7723): seller, car, price, date, «Descuentos», forma de pago, observaciones and the «Compra con factura (incluye IVA)» tick. **The car’s cost follows in the same write**: the acquisition takes the new payout (price − Descuentos), the seller, the day and the tax split; `acquisition.retentions` replaces the Descuentos (the old cost lines are voided, never edited); `acquisition.vehicle_id` moves the cost and the Descuentos to another car (the old one is left without a cost). Send `invoice_includes_iva` on every save of the form. The answer is the note as `GET` returns it plus `previous` (what it said before); every change is also an audit-log row with who and when. Refusals (`error.details.code`): `purchase_note_voided` (409), `discounts_exceed_price` (400), `vehicle_has_documented_cost` (409), `vehicle_sold_by_other_seller` (409), `purchase_note_has_several_cars` (409, a legacy note that bought several cars: price, tick, car or Descuentos), `purchase_note_changed_meanwhile` (409).
44297
44323
  *
44324
+ * **A nota de compra of a car taken in part payment** (`sale_note_id` set, vitrina-app#7725): its amount and its car follow the sale. A DIFFERENT `net_clp`, `invoice_includes_iva: true`, a different `tax_clp` / `tax_treatment` or another `acquisition.vehicle_id` is a 409 `purchase_note_follows_sale` (`details.field` = `amount` | `vehicle`, `details.sale_note_id`, `details.sale_note_display_id`; the message points to the sale); the same values are accepted, so the whole form can be sent. Everything else is editable: seller (also the retoma’s counterparty), date, «Descuentos» (the car’s cost stays the precio de toma: the retoma carries the price less the Descuentos), forma de pago, observaciones. The precio de toma is changed with `PATCH /sale-notes/{id}` `trade_ins`.
44325
+ *
44298
44326
  * Corrects a LIVE document and **stamps it**: `corrected_at` and the acting principal are written onto the row, so a reader of the document can tell it has been changed since it was issued without joining an audit table. The folio and the status are never touched.
44299
44327
  *
44300
44328
  * **An ABSENT field is left alone; an explicit `null` CLEARS it.** On `tax_clp` that is the difference between "not recorded" and "no tax", which ADR 0058 §2 keeps apart — so correcting away an amount entered by mistake is expressible without being confused with zero.
@@ -44402,6 +44430,9 @@ interface paths {
44402
44430
  * "notes": null,
44403
44431
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44404
44432
  * "observaciones": "Se entrega con dos llaves.",
44433
+ * "sale_note_id": null,
44434
+ * "sale_note_trade_in_id": null,
44435
+ * "voided_vehicle_id": null,
44405
44436
  * "corrected_at": "2026-09-13T09:00:00.000Z",
44406
44437
  * "corrected_by": "11111111-0000-4000-8000-000000000001",
44407
44438
  * "voided_at": null,
@@ -44642,6 +44673,8 @@ interface paths {
44642
44673
  *
44643
44674
  * **The car keeps its cost** (vitrina-app#7723): in the same transaction each car the note bought keeps the note’s total (payout + «Descuentos») as a plain Costo de compra, no longer linked to the note, and the Descuentos stop counting apart. That cost can then be corrected by typing it (`POST /vehicle-acquisitions`) or taken over by a new nota de compra. `void_outcome` says what happened per car, and `void_outcome.message` is ready to show as is. Voiding a voided note is a 409 `purchase_note_voided`.
44644
44675
  *
44676
+ * **A nota de compra of a car taken in part payment** (vitrina-app#7725) can be voided on its own: the document is cancelled, the sale is untouched and the car keeps its whole precio de toma as its cost (its «Descuentos» stop counting apart); `void_outcome.message` says so. Voiding the SALE voids it too.
44677
+ *
44645
44678
  * Requires `purchase_notes:void`, which is a DIFFERENT authority from `purchase_notes:write` — holding the write scope does not permit a void.
44646
44679
  */
44647
44680
  post: {
@@ -44691,6 +44724,9 @@ interface paths {
44691
44724
  * "notes": null,
44692
44725
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44693
44726
  * "observaciones": "Se entrega con dos llaves.",
44727
+ * "sale_note_id": null,
44728
+ * "sale_note_trade_in_id": null,
44729
+ * "voided_vehicle_id": null,
44694
44730
  * "corrected_at": null,
44695
44731
  * "corrected_by": null,
44696
44732
  * "voided_at": "2026-09-14T11:30:00.000Z",
@@ -324019,6 +324055,13 @@ interface components {
324019
324055
  price_approval_id: string | null;
324020
324056
  authorised_by: components["schemas"]["DealActor"] | null;
324021
324057
  };
324058
+ SaleNoteTradeInPurchaseNote: {
324059
+ /** Format: uuid */
324060
+ id: string;
324061
+ display_id: string;
324062
+ /** @enum {string} */
324063
+ status: "issued" | "voided";
324064
+ };
324022
324065
  SaleNoteParty: {
324023
324066
  /** Format: uuid */
324024
324067
  contact_id: string;
@@ -324032,6 +324075,7 @@ interface components {
324032
324075
  precio_toma_clp: number;
324033
324076
  /** Format: uuid */
324034
324077
  acquisition_id: string | null;
324078
+ purchase_note: components["schemas"]["SaleNoteTradeInPurchaseNote"] | null;
324035
324079
  delivered_by: components["schemas"]["SaleNoteParty"] | null;
324036
324080
  } & {
324037
324081
  [key: string]: unknown;
@@ -324194,6 +324238,17 @@ interface components {
324194
324238
  already_issued: boolean;
324195
324239
  template_version: string;
324196
324240
  };
324241
+ SaleNoteTradeInPriceChange: {
324242
+ /** Format: uuid */
324243
+ vehicle_id: string;
324244
+ from_clp: number;
324245
+ to_clp: number;
324246
+ /** Format: uuid */
324247
+ purchase_note_id: string | null;
324248
+ purchase_note_display_id: string | null;
324249
+ /** Format: uuid */
324250
+ change_id: string | null;
324251
+ };
324197
324252
  SaleNoteCorrection: {
324198
324253
  /** @enum {string} */
324199
324254
  outcome: "applied" | "pending_approval" | "unchanged";
@@ -324201,6 +324256,7 @@ interface components {
324201
324256
  price_approval_id: string | null;
324202
324257
  /** Format: uuid */
324203
324258
  change_id: string | null;
324259
+ trade_ins: components["schemas"]["SaleNoteTradeInPriceChange"][];
324204
324260
  };
324205
324261
  SaleNoteCorrected: components["schemas"]["SaleNoteRead"] & ({
324206
324262
  correction: components["schemas"]["SaleNoteCorrection"];
package/dist/index.d.ts CHANGED
@@ -18772,6 +18772,8 @@ interface paths {
18772
18772
  *
18773
18773
  * **Costo de compra in the same call (`purchase_cost_clp`).** Optional (vitrina-app#7719). The amount the dealership paid, recorded as the car’s Costo de compra exactly as `POST /vehicle-acquisitions` with `kind: "compra"` would; `invoice_includes_iva: true` says it includes IVA («Compra con factura»). Needs `dealership_economics:write`: without it the call is a **403 and nothing is saved**. The response then carries `acquisition` (the recorded row, the same shape `POST /vehicle-acquisitions` returns, shown only to callers holding `dealership_economics:read`); `acquisition: null` means the car was saved but its cost was not, and it can be typed on the car’s page. Both fields are create-only.
18774
18774
  *
18775
+ * **Creating a car by its plate alone.** Every field is optional: a form that creates the car from inside another document (the nota de compra, the «Auto en parte de pago» of a sale) sends `registration_number` plus whatever marca, modelo and año the dealer has (`GET /pricing/decode-plate` fills them when it knows the plate; its 404 means it does not). Without `publish_to` the car is on no portal. A plate another active car of the workspace already has is a **409 `CONFLICT`** whose `error.details` names that car: `vehicle_id` (the one to offer instead), `vehicle_ids` (every holder, newest first) and `vehicle_status` (its Estado comercial; `vendido` is a sold car still holding the plate, not one a document can take). A hidden car (`active: false`, not sold, not deleted) holding the plate answers the same 409 with `reason: "plate_inactive_holder"` and the same three fields: offer that car (it is made public again with `PUT /vehicles/{id} { active: true }`) instead of creating a second one. A sold car never blocks: a returning plate is a new car. Nothing is created on a 409.
18776
+ *
18775
18777
  * **Sanity range.** A price fans out to every connected portal, so a typo is stopped here. `price_amount` must be between 100.000 and 2.000.000.000 CLP (a UF price is bounded at the day's UF; other currencies are not bounded) and `odometer_value` between 0 and 2.000.000; `null` clears either and is always accepted. Outside the range: **422 `VEHICLE_VALUE_OUT_OF_RANGE`**, with a Spanish `message`, `field_errors.<field>` and `details.violations[]` (`field`, `reason` = `price_out_of_range` | `km_out_of_range`, `value`, `min`, `max`, `currency`). A price change beyond 10x up or down from the current price answers **422 `PRICE_CHANGE_CONFIRMATION_REQUIRED`** (`details.reason` = `large_price_change`, `current_price`, `requested_price`, `currency`, `factor`, `confirm_flag`) unless the body carries `confirm_large_price_change: true`; ask the user, then resend the same body with it. Nothing is written on either 422.
18776
18778
  *
18777
18779
  * **Normalization and `catalog_match`.** On create and update, `make` and `model` that equal an entry of GET /vehicles/catalog/brands and /catalog/models up to case, accents, spaces and hyphens are stored in the catalog's spelling ("toyota" → "Toyota", "mercedes benz" → "Mercedes-Benz", "rav 4" → "RAV4"); `fuel_type`, `gear_type` and `body_style` are stored as vocabulary codes ("Bencina" → `gasolina`, "Automática" → `automatica`, "Station Wagon" → `wagon`; codes: fuel `gasolina|diesel|hibrido|electrico|gnc|glp|otro`, gear `mecanica|automatica|otro`, body `sedan|hatchback|suv|camioneta|coupe|wagon|furgon|convertible|minivan|otro`; for `vehicle_type: moto` body_style is the «Tipo de moto» instead: `moto_calle|moto_deportiva|moto_touring|moto_trail|moto_enduro|moto_scooter|moto_custom|moto_cuatrimoto|moto_otro`, and "Trail" / "BODY.MOTORCYCLE.TRAIL" snap to `moto_trail`). Nothing is invented: a value with no match is stored exactly as sent. The response (and GET /vehicles/{id}) carries `catalog_match`: `make` / `model` are `matched` | `unmatched` | `missing` (`not_applicable` for a non-`auto` vehicle_type); `version` adds `approximate` (word overlap with a catalog version, same displacement) and `catalog_version` names the catalog version it matched or most resembles; `fuel_type` / `gear_type` / `body_style` are `matched` | `unmatched` | `missing`; `warnings[]` lists `{ field, code, message }` for everything not matched, with a Spanish `message` ready to show (codes: `make_missing`, `make_not_in_catalog`, `model_missing`, `model_not_in_catalog`, `version_approximate`, `version_not_in_catalog`, `fuel_type_not_recognized`, `gear_type_not_recognized`, `body_style_not_recognized`). A make or model that is not matched still saves, but Chileautos publishes it without a technical sheet (ficha). `catalog_match` is null only when the catalog could not be loaded. Example of an unmatched push: {"make":"matched","model":"unmatched","version":"unmatched","catalog_version":null,"fuel_type":"unmatched","gear_type":"matched","body_style":"missing","warnings":[{"field":"model","code":"model_not_in_catalog","message":"Modelo 'Rav-4 xx' no está en el catálogo de Toyota (GET /vehicles/catalog/models); Chileautos lo publicará sin ficha."},{"field":"fuel_type","code":"fuel_type_not_recognized","message":"Combustible 'Hidrógeno' no se reconoce; valores aceptados: gasolina, diesel, hibrido, electrico, gnc, glp, otro."}]}
@@ -39449,13 +39451,15 @@ interface paths {
39449
39451
  head?: never;
39450
39452
  /**
39451
39453
  * Correct the price terms of a nota de venta (issued or approved)
39452
- * @description Corrects `net_clp`, `tax_clp` (null = not recorded, 0 = no tax), `tax_treatment` and/or `issued_at` on a nota de venta that is ISSUED or APPROVED and not voided, with no cutoff. All optional, at least one; unknown keys are a 400. In one transaction the edit re-derives what issuing at the new terms would have: the buyer’s receivable (the sale note’s open obligation, re-stated from price + IVA + charged add-ons) and the participations’ DEFAULTED commissions (the margin basis and, when the sale’s day moves, the scheme rate); `discount_clp` follows. Payments already recorded, add-on lines, trade-ins, the credit and `list_price_clp` are kept; on an approved note the car stays sold and the deal stays won. Every correction writes a `history` entry (actor, instant, each field `{ from, to }`); a compraventa printed before it reads `compraventa_outdated: true` until it is reprinted. Responds with the same read as `GET /sale-notes/{id}` plus `correction: { outcome, price_approval_id, change_id }`, `outcome` = `applied` | `unchanged` (sending the values it already has is a no-op 200) | `pending_approval`.
39454
+ * @description Corrects `net_clp`, `tax_clp` (null = not recorded, 0 = no tax), `tax_treatment`, `issued_at` and/or the precio de toma (`trade_ins`) on a nota de venta that is ISSUED or APPROVED and not voided, with no cutoff. All optional, at least one; unknown keys are a 400. In one transaction the edit re-derives what issuing at the new terms would have: the buyer’s receivable (the sale note’s open obligation, re-stated from price + IVA + charged add-ons) and the participations’ DEFAULTED commissions (the margin basis and, when the sale’s day moves, the scheme rate); `discount_clp` follows. Payments already recorded, add-on lines, trade-ins, the credit and `list_price_clp` are kept; on an approved note the car stays sold and the deal stays won. Every correction writes a `history` entry (actor, instant, each field `{ from, to }`); a compraventa printed before it reads `compraventa_outdated: true` until it is reprinted. Responds with the same read as `GET /sale-notes/{id}` plus `correction: { outcome, price_approval_id, change_id }`, `outcome` = `applied` | `unchanged` (sending the values it already has is a no-op 200) | `pending_approval`.
39453
39455
  *
39454
39456
  * **202 `pending_approval`**: on an APPROVED note, a correction that lowers the price below the floor (the price-approval policy, tolerance included) by a caller WITHOUT `price_approval:approve` is not applied. It is filed as a price approval on the note carrying the proposed terms (`proposed_terms` on `GET /price-approvals`), shown as `pending_price_change` on the note; granting it (`POST /price-approvals/{id}/decision`) applies the correction in the same transaction, rejecting it leaves the note as it was. A caller holding `price_approval:approve`, a grant on this note that covers the price, a raise, or a pending (unapproved) note applies directly.
39455
39457
  *
39456
39458
  * **409** with `details.blocked_reason` = `sale_note_voided`, or `sale_note_approved` only when a PENDING note was approved while the edit ran (nothing changed; retry, it now applies the approved-note rule), and a Spanish message. Requires `sale_notes:write`.
39457
39459
  *
39458
39460
  * **`observaciones`** (app#7581) rides the same body: a string sets the text printed on the nota de venta (trimmed, up to 2000 characters), `null` or blank clears it. It is not a money fact: it applies on an issued or approved note with no price approval, no `history` entry and no `compraventa_outdated` (audited as `sale_notes.set_observaciones`). Sent alone it answers 200 with `correction.outcome` `applied` (or `unchanged`) and `change_id: null`; on a voided note it is the same **409** `sale_note_voided`.
39461
+ *
39462
+ * **`trade_ins`** (vitrina-app#7725): `[{ vehicle_id, precio_toma_clp }]` changes the precio de toma of cars this sale already took in part payment (cars are neither added nor removed here), on an issued or approved note. In one transaction, per car that moved: the trade-in line (the credit: the saldo follows on the next read), the car’s `retoma` cost (so its Ganancia follows when it sells), its live nota de compra’s amount (stamped as corrected) and a `history` entry (`kind: terms`, field `precio_toma_clp`). `correction.trade_ins` lists what moved: `{ vehicle_id, from_clp, to_clp, purchase_note_id, purchase_note_display_id, change_id }` (`[]` when nothing moved). 400 for a car the sale did not take, and `discounts_exceed_price` when the new price is below the nota de compra’s «Descuentos».
39459
39463
  */
39460
39464
  patch: {
39461
39465
  parameters: {
@@ -39483,6 +39487,11 @@ interface paths {
39483
39487
  issued_at?: string;
39484
39488
  /** @description Observaciones que se imprimen en la nota de venta, tal como se escribieron (hasta 2000 caracteres). Se guardan sin espacios al inicio ni al final; vacío o null las borra. No son notas internas. */
39485
39489
  observaciones?: string | null;
39490
+ trade_ins?: {
39491
+ /** Format: uuid */
39492
+ vehicle_id: string;
39493
+ precio_toma_clp: number;
39494
+ }[];
39486
39495
  };
39487
39496
  };
39488
39497
  };
@@ -42147,6 +42156,8 @@ interface paths {
42147
42156
  * Requires `sale_notes:void`, which is a DIFFERENT authority from `sale_notes:write` — holding the write scope does not permit a void.
42148
42157
  *
42149
42158
  * **`void_outcome` says what happened (app#7587)** — the voided row plus `{ reservation: { outcome: reopened | not_reopened | none, reason: hold_lapsed | another_hold_active | not_completed | different_vehicle | not_found | null, id, display_id, abono_clp }, vehicle: { id, status, changed, ads_closed_by_sale, ads_republished: false }, payments: { released_clp, returned_to_reservation_clp, buyer_credit_clp }, appointments: { cancelled_by_sale_restored: false }, deal_reopened, message }`. A reopened reserva carries its abono again and holds the car; a lapsed one is not reopened and the money stays with the buyer as credit (payments are kept: for the replacement note or to be refunded). Portal ads the sale closed are not re-published automatically, and test drives the sale cancelled are not restored. `message` is one short Spanish paragraph to show as is.
42159
+ *
42160
+ * **Cars taken in part payment** (vitrina-app#7725): `void_outcome.trade_ins` lists `{ vehicle_id, purchase_note_id, purchase_note_display_id, cost_removed: true }` per car. Its nota de compra (written when the sale was closed) is voided with the sale, and the car is left without a Costo de compra; it stays in Stock for the dealer to remove if it went back to the buyer. `message` says so.
42150
42161
  */
42151
42162
  post: {
42152
42163
  parameters: {
@@ -43799,6 +43810,8 @@ interface paths {
43799
43810
  *
43800
43811
  * **Each row carries the unit it bought**: `vehicle` is `{ id, make, model, year, registration_number }` or `null`, and `vehicle_count` says how many units the document acquired. One nota de compra may acquire SEVERAL units, so `vehicle` is the FIRST of them (deterministic: `acquired_on`, then `created_at`, then `id`) and `vehicle_count` is what keeps that from reading as "this note bought one car". `vehicle` is `null` exactly when `vehicle_count` is `0`, which is an ordinary state: the document is issued before anything is attached to it, and attaching is a separate act on `/vehicle-acquisitions`.
43801
43812
  *
43813
+ * **A nota de compra of a car taken in part payment** (vitrina-app#7725) is written by closing that sale: its row carries `sale_note_id`, `sale_note_trade_in_id` and `sale_note_display_id` (the sale’s folio, `V-n`), all `null` on any other nota. Its `vehicle` is the car taken.
43814
+ *
43802
43815
  * 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.
43803
43816
  */
43804
43817
  get: {
@@ -43837,13 +43850,17 @@ interface paths {
43837
43850
  * "notes": null,
43838
43851
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
43839
43852
  * "observaciones": "Se entrega con dos llaves.",
43853
+ * "sale_note_id": null,
43854
+ * "sale_note_trade_in_id": null,
43855
+ * "voided_vehicle_id": null,
43840
43856
  * "corrected_at": null,
43841
43857
  * "corrected_by": null,
43842
43858
  * "voided_at": null,
43843
43859
  * "void_reason": null,
43844
43860
  * "voided_by": null,
43845
43861
  * "created_at": "2026-09-12T10:15:00.000Z",
43846
- * "updated_at": "2026-09-12T10:15:00.000Z"
43862
+ * "updated_at": "2026-09-12T10:15:00.000Z",
43863
+ * "sale_note_display_id": null
43847
43864
  * }
43848
43865
  * ],
43849
43866
  * "meta": {
@@ -44040,6 +44057,9 @@ interface paths {
44040
44057
  * "notes": null,
44041
44058
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44042
44059
  * "observaciones": "Se entrega con dos llaves.",
44060
+ * "sale_note_id": null,
44061
+ * "sale_note_trade_in_id": null,
44062
+ * "voided_vehicle_id": null,
44043
44063
  * "corrected_at": null,
44044
44064
  * "corrected_by": null,
44045
44065
  * "voided_at": null,
@@ -44134,6 +44154,8 @@ interface paths {
44134
44154
  *
44135
44155
  * Since vitrina-app#7723 it also carries what the «Modificar» form opens with: `acquisition` (the car’s cost under this note, with `invoice_includes_iva` and `amount_paid_clp`, or `null`) and `retentions` (the note’s live «Descuentos», each with `description` and `net_clp`).
44136
44156
  *
44157
+ * A nota de compra written by closing a sale with a car in part payment (vitrina-app#7725) carries `sale_note_id`, `sale_note_trade_in_id` and `sale_note_display_id` (`V-n`); its amount is that sale’s precio de toma and `acquisition` is the car’s `retoma` cost. Every other nota has the three as `null`.
44158
+ *
44137
44159
  * A document belonging to another workspace is a 404, indistinguishable from one that does not exist.
44138
44160
  */
44139
44161
  get: {
@@ -44169,6 +44191,9 @@ interface paths {
44169
44191
  * "notes": null,
44170
44192
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44171
44193
  * "observaciones": "Se entrega con dos llaves.",
44194
+ * "sale_note_id": null,
44195
+ * "sale_note_trade_in_id": null,
44196
+ * "voided_vehicle_id": null,
44172
44197
  * "corrected_at": null,
44173
44198
  * "corrected_by": null,
44174
44199
  * "voided_at": null,
@@ -44184,6 +44209,7 @@ interface paths {
44184
44209
  * "registration_number": "KXPT21"
44185
44210
  * },
44186
44211
  * "vehicle_count": 1,
44212
+ * "sale_note_display_id": null,
44187
44213
  * "acquisition": {
44188
44214
  * "id": "7b0e1c52-3a1f-4d8e-9c2a-5f6b7c8d9e01",
44189
44215
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
@@ -44295,6 +44321,8 @@ interface paths {
44295
44321
  * Modify a nota de compra
44296
44322
  * @description **Everything is editable until the note is voided** (vitrina-app#7723): seller, car, price, date, «Descuentos», forma de pago, observaciones and the «Compra con factura (incluye IVA)» tick. **The car’s cost follows in the same write**: the acquisition takes the new payout (price − Descuentos), the seller, the day and the tax split; `acquisition.retentions` replaces the Descuentos (the old cost lines are voided, never edited); `acquisition.vehicle_id` moves the cost and the Descuentos to another car (the old one is left without a cost). Send `invoice_includes_iva` on every save of the form. The answer is the note as `GET` returns it plus `previous` (what it said before); every change is also an audit-log row with who and when. Refusals (`error.details.code`): `purchase_note_voided` (409), `discounts_exceed_price` (400), `vehicle_has_documented_cost` (409), `vehicle_sold_by_other_seller` (409), `purchase_note_has_several_cars` (409, a legacy note that bought several cars: price, tick, car or Descuentos), `purchase_note_changed_meanwhile` (409).
44297
44323
  *
44324
+ * **A nota de compra of a car taken in part payment** (`sale_note_id` set, vitrina-app#7725): its amount and its car follow the sale. A DIFFERENT `net_clp`, `invoice_includes_iva: true`, a different `tax_clp` / `tax_treatment` or another `acquisition.vehicle_id` is a 409 `purchase_note_follows_sale` (`details.field` = `amount` | `vehicle`, `details.sale_note_id`, `details.sale_note_display_id`; the message points to the sale); the same values are accepted, so the whole form can be sent. Everything else is editable: seller (also the retoma’s counterparty), date, «Descuentos» (the car’s cost stays the precio de toma: the retoma carries the price less the Descuentos), forma de pago, observaciones. The precio de toma is changed with `PATCH /sale-notes/{id}` `trade_ins`.
44325
+ *
44298
44326
  * Corrects a LIVE document and **stamps it**: `corrected_at` and the acting principal are written onto the row, so a reader of the document can tell it has been changed since it was issued without joining an audit table. The folio and the status are never touched.
44299
44327
  *
44300
44328
  * **An ABSENT field is left alone; an explicit `null` CLEARS it.** On `tax_clp` that is the difference between "not recorded" and "no tax", which ADR 0058 §2 keeps apart — so correcting away an amount entered by mistake is expressible without being confused with zero.
@@ -44402,6 +44430,9 @@ interface paths {
44402
44430
  * "notes": null,
44403
44431
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44404
44432
  * "observaciones": "Se entrega con dos llaves.",
44433
+ * "sale_note_id": null,
44434
+ * "sale_note_trade_in_id": null,
44435
+ * "voided_vehicle_id": null,
44405
44436
  * "corrected_at": "2026-09-13T09:00:00.000Z",
44406
44437
  * "corrected_by": "11111111-0000-4000-8000-000000000001",
44407
44438
  * "voided_at": null,
@@ -44642,6 +44673,8 @@ interface paths {
44642
44673
  *
44643
44674
  * **The car keeps its cost** (vitrina-app#7723): in the same transaction each car the note bought keeps the note’s total (payout + «Descuentos») as a plain Costo de compra, no longer linked to the note, and the Descuentos stop counting apart. That cost can then be corrected by typing it (`POST /vehicle-acquisitions`) or taken over by a new nota de compra. `void_outcome` says what happened per car, and `void_outcome.message` is ready to show as is. Voiding a voided note is a 409 `purchase_note_voided`.
44644
44675
  *
44676
+ * **A nota de compra of a car taken in part payment** (vitrina-app#7725) can be voided on its own: the document is cancelled, the sale is untouched and the car keeps its whole precio de toma as its cost (its «Descuentos» stop counting apart); `void_outcome.message` says so. Voiding the SALE voids it too.
44677
+ *
44645
44678
  * Requires `purchase_notes:void`, which is a DIFFERENT authority from `purchase_notes:write` — holding the write scope does not permit a void.
44646
44679
  */
44647
44680
  post: {
@@ -44691,6 +44724,9 @@ interface paths {
44691
44724
  * "notes": null,
44692
44725
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44693
44726
  * "observaciones": "Se entrega con dos llaves.",
44727
+ * "sale_note_id": null,
44728
+ * "sale_note_trade_in_id": null,
44729
+ * "voided_vehicle_id": null,
44694
44730
  * "corrected_at": null,
44695
44731
  * "corrected_by": null,
44696
44732
  * "voided_at": "2026-09-14T11:30:00.000Z",
@@ -324019,6 +324055,13 @@ interface components {
324019
324055
  price_approval_id: string | null;
324020
324056
  authorised_by: components["schemas"]["DealActor"] | null;
324021
324057
  };
324058
+ SaleNoteTradeInPurchaseNote: {
324059
+ /** Format: uuid */
324060
+ id: string;
324061
+ display_id: string;
324062
+ /** @enum {string} */
324063
+ status: "issued" | "voided";
324064
+ };
324022
324065
  SaleNoteParty: {
324023
324066
  /** Format: uuid */
324024
324067
  contact_id: string;
@@ -324032,6 +324075,7 @@ interface components {
324032
324075
  precio_toma_clp: number;
324033
324076
  /** Format: uuid */
324034
324077
  acquisition_id: string | null;
324078
+ purchase_note: components["schemas"]["SaleNoteTradeInPurchaseNote"] | null;
324035
324079
  delivered_by: components["schemas"]["SaleNoteParty"] | null;
324036
324080
  } & {
324037
324081
  [key: string]: unknown;
@@ -324194,6 +324238,17 @@ interface components {
324194
324238
  already_issued: boolean;
324195
324239
  template_version: string;
324196
324240
  };
324241
+ SaleNoteTradeInPriceChange: {
324242
+ /** Format: uuid */
324243
+ vehicle_id: string;
324244
+ from_clp: number;
324245
+ to_clp: number;
324246
+ /** Format: uuid */
324247
+ purchase_note_id: string | null;
324248
+ purchase_note_display_id: string | null;
324249
+ /** Format: uuid */
324250
+ change_id: string | null;
324251
+ };
324197
324252
  SaleNoteCorrection: {
324198
324253
  /** @enum {string} */
324199
324254
  outcome: "applied" | "pending_approval" | "unchanged";
@@ -324201,6 +324256,7 @@ interface components {
324201
324256
  price_approval_id: string | null;
324202
324257
  /** Format: uuid */
324203
324258
  change_id: string | null;
324259
+ trade_ins: components["schemas"]["SaleNoteTradeInPriceChange"][];
324204
324260
  };
324205
324261
  SaleNoteCorrected: components["schemas"]["SaleNoteRead"] & ({
324206
324262
  correction: components["schemas"]["SaleNoteCorrection"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrina/api",
3
- "version": "17.89.0",
3
+ "version": "17.91.0",
4
4
  "description": "Typed TypeScript SDK for the Vitrina API pública — generated from the committed openapi.public.json (ADR 0106).",
5
5
  "type": "module",
6
6
  "license": "MIT",