@vitrina/api 17.90.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
@@ -39451,13 +39451,15 @@ interface paths {
39451
39451
  head?: never;
39452
39452
  /**
39453
39453
  * Correct the price terms of a nota de venta (issued or approved)
39454
- * @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`.
39455
39455
  *
39456
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.
39457
39457
  *
39458
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`.
39459
39459
  *
39460
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».
39461
39463
  */
39462
39464
  patch: {
39463
39465
  parameters: {
@@ -39485,6 +39487,11 @@ interface paths {
39485
39487
  issued_at?: string;
39486
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. */
39487
39489
  observaciones?: string | null;
39490
+ trade_ins?: {
39491
+ /** Format: uuid */
39492
+ vehicle_id: string;
39493
+ precio_toma_clp: number;
39494
+ }[];
39488
39495
  };
39489
39496
  };
39490
39497
  };
@@ -42149,6 +42156,8 @@ interface paths {
42149
42156
  * Requires `sale_notes:void`, which is a DIFFERENT authority from `sale_notes:write` — holding the write scope does not permit a void.
42150
42157
  *
42151
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.
42152
42161
  */
42153
42162
  post: {
42154
42163
  parameters: {
@@ -43801,6 +43810,8 @@ interface paths {
43801
43810
  *
43802
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`.
43803
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
+ *
43804
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.
43805
43816
  */
43806
43817
  get: {
@@ -43839,13 +43850,17 @@ interface paths {
43839
43850
  * "notes": null,
43840
43851
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
43841
43852
  * "observaciones": "Se entrega con dos llaves.",
43853
+ * "sale_note_id": null,
43854
+ * "sale_note_trade_in_id": null,
43855
+ * "voided_vehicle_id": null,
43842
43856
  * "corrected_at": null,
43843
43857
  * "corrected_by": null,
43844
43858
  * "voided_at": null,
43845
43859
  * "void_reason": null,
43846
43860
  * "voided_by": null,
43847
43861
  * "created_at": "2026-09-12T10:15:00.000Z",
43848
- * "updated_at": "2026-09-12T10:15:00.000Z"
43862
+ * "updated_at": "2026-09-12T10:15:00.000Z",
43863
+ * "sale_note_display_id": null
43849
43864
  * }
43850
43865
  * ],
43851
43866
  * "meta": {
@@ -44042,6 +44057,9 @@ interface paths {
44042
44057
  * "notes": null,
44043
44058
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44044
44059
  * "observaciones": "Se entrega con dos llaves.",
44060
+ * "sale_note_id": null,
44061
+ * "sale_note_trade_in_id": null,
44062
+ * "voided_vehicle_id": null,
44045
44063
  * "corrected_at": null,
44046
44064
  * "corrected_by": null,
44047
44065
  * "voided_at": null,
@@ -44136,6 +44154,8 @@ interface paths {
44136
44154
  *
44137
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`).
44138
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
+ *
44139
44159
  * A document belonging to another workspace is a 404, indistinguishable from one that does not exist.
44140
44160
  */
44141
44161
  get: {
@@ -44171,6 +44191,9 @@ interface paths {
44171
44191
  * "notes": null,
44172
44192
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44173
44193
  * "observaciones": "Se entrega con dos llaves.",
44194
+ * "sale_note_id": null,
44195
+ * "sale_note_trade_in_id": null,
44196
+ * "voided_vehicle_id": null,
44174
44197
  * "corrected_at": null,
44175
44198
  * "corrected_by": null,
44176
44199
  * "voided_at": null,
@@ -44186,6 +44209,7 @@ interface paths {
44186
44209
  * "registration_number": "KXPT21"
44187
44210
  * },
44188
44211
  * "vehicle_count": 1,
44212
+ * "sale_note_display_id": null,
44189
44213
  * "acquisition": {
44190
44214
  * "id": "7b0e1c52-3a1f-4d8e-9c2a-5f6b7c8d9e01",
44191
44215
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
@@ -44297,6 +44321,8 @@ interface paths {
44297
44321
  * Modify a nota de compra
44298
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).
44299
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
+ *
44300
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.
44301
44327
  *
44302
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.
@@ -44404,6 +44430,9 @@ interface paths {
44404
44430
  * "notes": null,
44405
44431
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44406
44432
  * "observaciones": "Se entrega con dos llaves.",
44433
+ * "sale_note_id": null,
44434
+ * "sale_note_trade_in_id": null,
44435
+ * "voided_vehicle_id": null,
44407
44436
  * "corrected_at": "2026-09-13T09:00:00.000Z",
44408
44437
  * "corrected_by": "11111111-0000-4000-8000-000000000001",
44409
44438
  * "voided_at": null,
@@ -44644,6 +44673,8 @@ interface paths {
44644
44673
  *
44645
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`.
44646
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
+ *
44647
44678
  * Requires `purchase_notes:void`, which is a DIFFERENT authority from `purchase_notes:write` — holding the write scope does not permit a void.
44648
44679
  */
44649
44680
  post: {
@@ -44693,6 +44724,9 @@ interface paths {
44693
44724
  * "notes": null,
44694
44725
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44695
44726
  * "observaciones": "Se entrega con dos llaves.",
44727
+ * "sale_note_id": null,
44728
+ * "sale_note_trade_in_id": null,
44729
+ * "voided_vehicle_id": null,
44696
44730
  * "corrected_at": null,
44697
44731
  * "corrected_by": null,
44698
44732
  * "voided_at": "2026-09-14T11:30:00.000Z",
@@ -324021,6 +324055,13 @@ interface components {
324021
324055
  price_approval_id: string | null;
324022
324056
  authorised_by: components["schemas"]["DealActor"] | null;
324023
324057
  };
324058
+ SaleNoteTradeInPurchaseNote: {
324059
+ /** Format: uuid */
324060
+ id: string;
324061
+ display_id: string;
324062
+ /** @enum {string} */
324063
+ status: "issued" | "voided";
324064
+ };
324024
324065
  SaleNoteParty: {
324025
324066
  /** Format: uuid */
324026
324067
  contact_id: string;
@@ -324034,6 +324075,7 @@ interface components {
324034
324075
  precio_toma_clp: number;
324035
324076
  /** Format: uuid */
324036
324077
  acquisition_id: string | null;
324078
+ purchase_note: components["schemas"]["SaleNoteTradeInPurchaseNote"] | null;
324037
324079
  delivered_by: components["schemas"]["SaleNoteParty"] | null;
324038
324080
  } & {
324039
324081
  [key: string]: unknown;
@@ -324196,6 +324238,17 @@ interface components {
324196
324238
  already_issued: boolean;
324197
324239
  template_version: string;
324198
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
+ };
324199
324252
  SaleNoteCorrection: {
324200
324253
  /** @enum {string} */
324201
324254
  outcome: "applied" | "pending_approval" | "unchanged";
@@ -324203,6 +324256,7 @@ interface components {
324203
324256
  price_approval_id: string | null;
324204
324257
  /** Format: uuid */
324205
324258
  change_id: string | null;
324259
+ trade_ins: components["schemas"]["SaleNoteTradeInPriceChange"][];
324206
324260
  };
324207
324261
  SaleNoteCorrected: components["schemas"]["SaleNoteRead"] & ({
324208
324262
  correction: components["schemas"]["SaleNoteCorrection"];
package/dist/index.d.ts CHANGED
@@ -39451,13 +39451,15 @@ interface paths {
39451
39451
  head?: never;
39452
39452
  /**
39453
39453
  * Correct the price terms of a nota de venta (issued or approved)
39454
- * @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`.
39455
39455
  *
39456
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.
39457
39457
  *
39458
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`.
39459
39459
  *
39460
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».
39461
39463
  */
39462
39464
  patch: {
39463
39465
  parameters: {
@@ -39485,6 +39487,11 @@ interface paths {
39485
39487
  issued_at?: string;
39486
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. */
39487
39489
  observaciones?: string | null;
39490
+ trade_ins?: {
39491
+ /** Format: uuid */
39492
+ vehicle_id: string;
39493
+ precio_toma_clp: number;
39494
+ }[];
39488
39495
  };
39489
39496
  };
39490
39497
  };
@@ -42149,6 +42156,8 @@ interface paths {
42149
42156
  * Requires `sale_notes:void`, which is a DIFFERENT authority from `sale_notes:write` — holding the write scope does not permit a void.
42150
42157
  *
42151
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.
42152
42161
  */
42153
42162
  post: {
42154
42163
  parameters: {
@@ -43801,6 +43810,8 @@ interface paths {
43801
43810
  *
43802
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`.
43803
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
+ *
43804
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.
43805
43816
  */
43806
43817
  get: {
@@ -43839,13 +43850,17 @@ interface paths {
43839
43850
  * "notes": null,
43840
43851
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
43841
43852
  * "observaciones": "Se entrega con dos llaves.",
43853
+ * "sale_note_id": null,
43854
+ * "sale_note_trade_in_id": null,
43855
+ * "voided_vehicle_id": null,
43842
43856
  * "corrected_at": null,
43843
43857
  * "corrected_by": null,
43844
43858
  * "voided_at": null,
43845
43859
  * "void_reason": null,
43846
43860
  * "voided_by": null,
43847
43861
  * "created_at": "2026-09-12T10:15:00.000Z",
43848
- * "updated_at": "2026-09-12T10:15:00.000Z"
43862
+ * "updated_at": "2026-09-12T10:15:00.000Z",
43863
+ * "sale_note_display_id": null
43849
43864
  * }
43850
43865
  * ],
43851
43866
  * "meta": {
@@ -44042,6 +44057,9 @@ interface paths {
44042
44057
  * "notes": null,
44043
44058
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44044
44059
  * "observaciones": "Se entrega con dos llaves.",
44060
+ * "sale_note_id": null,
44061
+ * "sale_note_trade_in_id": null,
44062
+ * "voided_vehicle_id": null,
44045
44063
  * "corrected_at": null,
44046
44064
  * "corrected_by": null,
44047
44065
  * "voided_at": null,
@@ -44136,6 +44154,8 @@ interface paths {
44136
44154
  *
44137
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`).
44138
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
+ *
44139
44159
  * A document belonging to another workspace is a 404, indistinguishable from one that does not exist.
44140
44160
  */
44141
44161
  get: {
@@ -44171,6 +44191,9 @@ interface paths {
44171
44191
  * "notes": null,
44172
44192
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44173
44193
  * "observaciones": "Se entrega con dos llaves.",
44194
+ * "sale_note_id": null,
44195
+ * "sale_note_trade_in_id": null,
44196
+ * "voided_vehicle_id": null,
44174
44197
  * "corrected_at": null,
44175
44198
  * "corrected_by": null,
44176
44199
  * "voided_at": null,
@@ -44186,6 +44209,7 @@ interface paths {
44186
44209
  * "registration_number": "KXPT21"
44187
44210
  * },
44188
44211
  * "vehicle_count": 1,
44212
+ * "sale_note_display_id": null,
44189
44213
  * "acquisition": {
44190
44214
  * "id": "7b0e1c52-3a1f-4d8e-9c2a-5f6b7c8d9e01",
44191
44215
  * "tenant_id": "a1a1a1a1-0000-4000-8000-000000000001",
@@ -44297,6 +44321,8 @@ interface paths {
44297
44321
  * Modify a nota de compra
44298
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).
44299
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
+ *
44300
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.
44301
44327
  *
44302
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.
@@ -44404,6 +44430,9 @@ interface paths {
44404
44430
  * "notes": null,
44405
44431
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44406
44432
  * "observaciones": "Se entrega con dos llaves.",
44433
+ * "sale_note_id": null,
44434
+ * "sale_note_trade_in_id": null,
44435
+ * "voided_vehicle_id": null,
44407
44436
  * "corrected_at": "2026-09-13T09:00:00.000Z",
44408
44437
  * "corrected_by": "11111111-0000-4000-8000-000000000001",
44409
44438
  * "voided_at": null,
@@ -44644,6 +44673,8 @@ interface paths {
44644
44673
  *
44645
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`.
44646
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
+ *
44647
44678
  * Requires `purchase_notes:void`, which is a DIFFERENT authority from `purchase_notes:write` — holding the write scope does not permit a void.
44648
44679
  */
44649
44680
  post: {
@@ -44693,6 +44724,9 @@ interface paths {
44693
44724
  * "notes": null,
44694
44725
  * "forma_de_pago": "Transferencia a la cuenta del vendedor",
44695
44726
  * "observaciones": "Se entrega con dos llaves.",
44727
+ * "sale_note_id": null,
44728
+ * "sale_note_trade_in_id": null,
44729
+ * "voided_vehicle_id": null,
44696
44730
  * "corrected_at": null,
44697
44731
  * "corrected_by": null,
44698
44732
  * "voided_at": "2026-09-14T11:30:00.000Z",
@@ -324021,6 +324055,13 @@ interface components {
324021
324055
  price_approval_id: string | null;
324022
324056
  authorised_by: components["schemas"]["DealActor"] | null;
324023
324057
  };
324058
+ SaleNoteTradeInPurchaseNote: {
324059
+ /** Format: uuid */
324060
+ id: string;
324061
+ display_id: string;
324062
+ /** @enum {string} */
324063
+ status: "issued" | "voided";
324064
+ };
324024
324065
  SaleNoteParty: {
324025
324066
  /** Format: uuid */
324026
324067
  contact_id: string;
@@ -324034,6 +324075,7 @@ interface components {
324034
324075
  precio_toma_clp: number;
324035
324076
  /** Format: uuid */
324036
324077
  acquisition_id: string | null;
324078
+ purchase_note: components["schemas"]["SaleNoteTradeInPurchaseNote"] | null;
324037
324079
  delivered_by: components["schemas"]["SaleNoteParty"] | null;
324038
324080
  } & {
324039
324081
  [key: string]: unknown;
@@ -324196,6 +324238,17 @@ interface components {
324196
324238
  already_issued: boolean;
324197
324239
  template_version: string;
324198
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
+ };
324199
324252
  SaleNoteCorrection: {
324200
324253
  /** @enum {string} */
324201
324254
  outcome: "applied" | "pending_approval" | "unchanged";
@@ -324203,6 +324256,7 @@ interface components {
324203
324256
  price_approval_id: string | null;
324204
324257
  /** Format: uuid */
324205
324258
  change_id: string | null;
324259
+ trade_ins: components["schemas"]["SaleNoteTradeInPriceChange"][];
324206
324260
  };
324207
324261
  SaleNoteCorrected: components["schemas"]["SaleNoteRead"] & ({
324208
324262
  correction: components["schemas"]["SaleNoteCorrection"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrina/api",
3
- "version": "17.90.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",