@vitrina/api 17.49.3 → 17.51.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
@@ -17073,6 +17073,7 @@ interface paths {
17073
17073
  unitUf?: number;
17074
17074
  meter?: string;
17075
17075
  perUnitClpMonth?: number | null;
17076
+ perUnitUfMonth?: number | null;
17076
17077
  billedUnit?: string;
17077
17078
  /** @description The business types (`tenant.vertical`) this add-on is sold to. Omitted = every vertical. Read `offers` for the per-workspace answer. */
17078
17079
  verticals?: string[];
@@ -38374,11 +38375,11 @@ interface paths {
38374
38375
  *
38375
38376
  * **`print_missing_fields`** is what `GET /sale-notes/{id}/pdf` would refuse with right now — the SAME `{ variable, label, fix, contact_id? }` list as its 409 `details.missing_fields` — so a screen can ask for the buyer’s domicilio while the buyer is still at the counter. `[]` when the note prints, and always `[]` on a voided note.
38376
38377
  *
38377
- * **`history`** lists every correction (app#7317), oldest first: `{ id, kind (terms | buyer | add_on | payment), changes: { field: { from, to } }, at, actor, on_approved_note, price_approval_id, authorised_by }`. **`compraventa_outdated`** is `true` when the compraventa in force was printed before a later price or buyer correction (reprint with `POST /sale-notes/{id}/compraventa`). **`pending_price_change`** is a below-floor correction waiting for a manager: `{ price_approval_id, requested_at, requested_by, requested_price_clp, proposed_terms }`, or `null`.
38378
+ * **`history`** lists every correction (app#7317), oldest first: `{ id, kind (terms | buyer | add_on | payment), changes: { field: { from, to } }, at, actor, on_approved_note, price_approval_id, authorised_by }`. A `payment` entry with `changes.payment.from: null` is money a staff member put on the note: `changes.payment.to.origin` is `recorded` (a new payment) or `applied` (an existing payment on the client’s account, applied to the note). **`compraventa_outdated`** is `true` when the compraventa in force was printed before a later price or buyer correction (reprint with `POST /sale-notes/{id}/compraventa`). **`pending_price_change`** is a below-floor correction waiting for a manager: `{ price_approval_id, requested_at, requested_by, requested_price_clp, proposed_terms }`, or `null`.
38378
38379
  *
38379
- * **`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.
38380
+ * **`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. `delivered_by` (`{ contact_id, name }`) names who handed the car in when it is not the current buyer (after a buyer change the retoma stays the original person’s); `null` = the current buyer.
38380
38381
  *
38381
- * **`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.
38382
+ * **`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. `credit.holder` (`{ contact_id, name }`) names whose name the credit is in when it is not the current buyer (after a buyer change it stays the original person’s); `null` = the current buyer.
38382
38383
  */
38383
38384
  get: {
38384
38385
  parameters: {
@@ -39133,9 +39134,9 @@ interface paths {
39133
39134
  head?: never;
39134
39135
  /**
39135
39136
  * Assign or change the buyer of a nota de venta
39136
- * @description Sets `buyer_contact_id` on a live (issued or approved) nota de venta — the fix for a note issued without its comprador, without voiding it. Writes a `history` entry (`kind: buyer`, `buyer_contact_id` and `buyer_name` from → to). A printed compraventa does not block it: the note reads `compraventa_outdated: true` until it is reprinted. The open receivable and the payments applied to it move to the new buyer in the same transaction. The contact must belong to this workspace (404 otherwise, or when it was merged away). Responds with the same read as `GET /sale-notes/{id}`. Setting the buyer it already has is a no-op 200.
39137
+ * @description Sets `buyer_contact_id` on a live (issued or approved) nota de venta — the fix for a note issued without its comprador, without voiding it. Writes a `history` entry (`kind: buyer`, `buyer_contact_id` and `buyer_name` from → to). A printed compraventa does not block it: the note reads `compraventa_outdated: true` until it is reprinted. The open receivable and the payments applied to it move to the new buyer in the same transaction. A retoma or a credit on the note does not block it, and neither moves: the retoma stays recorded as handed in by the ORIGINAL person (its acquisition’s counterparty is never re-pointed) and the credit stays on the note as money received in the original person’s name (nothing is sent to any financiera). The read names them: `trade_ins[].delivered_by` and `credit.holder` (`{ contact_id, name }`, `null` when it is the current buyer). The contact must belong to this workspace (404 otherwise, or when it was merged away). Responds with the same read as `GET /sale-notes/{id}`. Setting the buyer it already has is a no-op 200.
39137
39138
  *
39138
- * **409** with `details.blocked_reason` and a Spanish message when the buyer is already written into something else: `sale_note_voided`, `trade_ins_recorded` (a retoma came from the current buyer), `payment_shared` (a payment on the note is also applied to another debt of the current buyer, e.g. the reserva) or `credit_attached` (the credit’s borrower is the current buyer). The way out for those is void + re-issue. Requires `sale_notes:write`.
39139
+ * **409** with `details.blocked_reason` and a Spanish message: `sale_note_voided`, or `payment_shared` (a payment on the note is also applied to another debt of the current buyer that is not this sale; release that application in Pagos first). Requires `sale_notes:write`.
39139
39140
  */
39140
39141
  patch: {
39141
39142
  parameters: {
@@ -39484,7 +39485,7 @@ interface paths {
39484
39485
  * * a payment the staff typed (`provenance: manual`) is **reversed**: the row is kept and marked reversed (actor, instant, reason, the same reversal as `POST /payments/{id}/reverse`) and every live allocation of it is released. It stops counting on the note and on the reserva it was carried from;
39485
39486
  * * a payment the bank or a gateway proved (`provenance: verified`) is **released** from this note only: the money did arrive, so it stays as the buyer’s credit (Pagos, «por asignar») to apply elsewhere or refund.
39486
39487
  *
39487
- * In the same transaction a `history` entry is written (`kind: payment`, `changes.payment: { from: { payment_id, instrument, amount_clp, on_note_clp, paid_on, provenance }, to: null }`, `changes.removal: { from: null, to: { effect, reason } }`); a compraventa printed before it reads `compraventa_outdated: true`. Adding a payment is `POST /document-payments` with `sale_note_id`; it writes the mirror entry (`changes.payment: { from: null, to: {…} }`). To change an amount, remove and add again. The receivable is not re-stated (what the buyer owes does not change); `totals`, saldo and `funding` follow.
39488
+ * In the same transaction a `history` entry is written (`kind: payment`, `changes.payment: { from: { payment_id, instrument, amount_clp, on_note_clp, paid_on, provenance }, to: null }`, `changes.removal: { from: null, to: { effect, reason } }`); a compraventa printed before it reads `compraventa_outdated: true`. Adding a payment is `POST /document-payments` with `sale_note_id`; it writes the mirror entry (`changes.payment: { from: null, to: { payment_id, instrument, amount_clp, on_note_clp, paid_on, provenance, origin } }`); `origin` is `recorded` for new money and `applied` when money already on the client’s account is put on the note (`POST /payments/{id}/allocations`). To change an amount, remove and add again. The receivable is not re-stated (what the buyer owes does not change); `totals`, saldo and `funding` follow.
39488
39489
  *
39489
39490
  * Responds with the same read as `GET /sale-notes/{id}` plus `payment_removal: { payment_id, effect: reversed | released, amount_clp, on_note_clp, reason, reservation_deposit, change_id }`. `reservation_deposit` names the reserva a carried payment came from and what the removal did to its seña: `no_longer_counted` (reversed) or `still_counted` (released); `null` otherwise.
39490
39491
  *
@@ -50094,7 +50095,7 @@ interface paths {
50094
50095
  *
50095
50096
  * `net_clp` is NET of IVA (cifras del negocio, ADR 0114 §2.2). The price a buyer agrees to on an afecto sale includes IVA, like the published price: send `round(price / 1,19)`. Writes nothing. Requires `dealership_economics:read`; 404 for a unit outside the workspace.
50096
50097
  *
50097
- * **`dealership_result` is the card’s one figure** («Queda en la automotora, sin IVA»), the SAME object on `POST /margin/preview` and `GET /margin/deals/{id}`: `result_clp` (= `margen_bruto_clp`) and the terms it is made of, all net of IVA — `price_net_clp`, `add_on_income_clp`, `cost_clp` (owned car; 0 on a consigned one), `owner_payout_clp` (consigned: payout incl. deducted costs) and `commission_iva_clp` (the IVA of a «+ IVA» comisión, taken out), with `result = price_net + add_on_income − cost − owner_payout − commission_iva` exact whenever `result_clp` is a number; `basis` is always `sin_iva`. `projected: true` while a consigned split is the contract’s projection (the form, and an issued note not settled yet, read the same projection); a liquidación replaces it. `null` `result_clp` = not computable (no cost recorded, no comisión).
50098
+ * **`dealership_result` is the card’s one figure** («Queda en la automotora, sin IVA»), the SAME object on `POST /margin/preview` and `GET /margin/deals/{id}`: `result_clp` (= `margen_bruto_clp − deductions.gastos_unidad_clp`) and the terms it is made of, all net of IVA — `price_net_clp`, `add_on_income_clp`, `cost_clp` (owned car; 0 on a consigned one), `owner_payout_clp` (consigned: payout incl. deducted costs), `commission_iva_clp` (the IVA of a «+ IVA» comisión, taken out) and `expenses_clp` (the unit’s expenses, «Gastos de la unidad»), with `result = price_net + add_on_income − cost − owner_payout − commission_iva − expenses` exact whenever `result_clp` is a number; seller commissions are not in it; `basis` is always `sin_iva`. `projected: true` while a consigned split is the contract’s projection (the form, and an issued note not settled yet, read the same projection); a liquidación replaces it. `null` `result_clp` = not computable (no cost recorded, no comisión).
50098
50099
  */
50099
50100
  post: {
50100
50101
  parameters: {
@@ -50178,12 +50179,13 @@ interface paths {
50178
50179
  * "deducciones_clp": 0
50179
50180
  * },
50180
50181
  * "dealership_result": {
50181
- * "result_clp": 800000,
50182
+ * "result_clp": 680000,
50182
50183
  * "price_net_clp": 10000000,
50183
50184
  * "add_on_income_clp": 0,
50184
50185
  * "cost_clp": 0,
50185
50186
  * "owner_payout_clp": 9200000,
50186
50187
  * "commission_iva_clp": 0,
50188
+ * "expenses_clp": 120000,
50187
50189
  * "projected": false,
50188
50190
  * "basis": "sin_iva"
50189
50191
  * },
@@ -50595,12 +50597,13 @@ interface paths {
50595
50597
  * "margen_neto_clp": 1490000,
50596
50598
  * "settlement": null,
50597
50599
  * "dealership_result": {
50598
- * "result_clp": 2200000,
50600
+ * "result_clp": 1560000,
50599
50601
  * "price_net_clp": 11900000,
50600
50602
  * "add_on_income_clp": 100000,
50601
50603
  * "cost_clp": 9800000,
50602
50604
  * "owner_payout_clp": null,
50603
50605
  * "commission_iva_clp": 0,
50606
+ * "expenses_clp": 640000,
50604
50607
  * "projected": false,
50605
50608
  * "basis": "sin_iva"
50606
50609
  * },
@@ -73369,7 +73372,7 @@ interface paths {
73369
73372
  };
73370
73373
  /**
73371
73374
  * Bank feed sources available to this clinic
73372
- * @description The e-mail rail (free, always on), Fintoc (optional add-on `bank_feed_fintoc`, billed per connected bank per month at the provider's list price — `price_clp_per_bank_month` is null until it is set) and BCI API Market (not configured until the partner approval lands). Requires `clinic_money:read`.
73375
+ * @description The e-mail rail (free, always on), Fintoc (add-on `bank_feed_fintoc`, also granted by the Finanzas plan, billed per connected bank per month at `price_uf_per_bank_month`; the Finanzas plan includes the first bank) and BCI API Market (not configured until the partner approval lands). Requires `clinic_money:read`.
73373
73376
  *
73374
73377
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
73375
73378
  */
@@ -73400,6 +73403,7 @@ interface paths {
73400
73403
  * "entitled": true,
73401
73404
  * "feature": "bank_feed_fintoc",
73402
73405
  * "price_clp_per_bank_month": null,
73406
+ * "price_uf_per_bank_month": 0.45,
73403
73407
  * "connected_banks": 1
73404
73408
  * },
73405
73409
  * "bci_api_market": {
@@ -75085,7 +75089,9 @@ interface paths {
75085
75089
  * "configured": true,
75086
75090
  * "entitled": true,
75087
75091
  * "feature": "bank_feed_fintoc",
75088
- * "price_clp_per_bank_month": 15000,
75092
+ * "price_clp_per_bank_month": null,
75093
+ * "price_uf_per_bank_month": 0.45,
75094
+ * "included_banks": 1,
75089
75095
  * "widget_public_key": "pk_test_ejemplo"
75090
75096
  * },
75091
75097
  * "bank_aggregator": {
@@ -145398,6 +145404,8 @@ interface paths {
145398
145404
  * @description `payments:write`. Writes one `payment_allocation` row per line, with `method: "staff"`. Passing `release` makes it a RE-allocation: the named rows are released FIRST, in the same transaction, because nothing is ever edited in place — a split is changed by releasing and writing anew, so the history stays readable.
145399
145405
  *
145400
145406
  * 409 `over_allocation` when the lines exceed what is left on the payment (`error.details.unallocated_clp` carries the figure, so the screen can say «solo quedan $5.000 sin asignar»), `obligation_not_open`, `contact_mismatch` (one person's money never settles another's debt — a row Postgres refuses, not a rule a service remembers), `payment_reversed`, `payer_unknown`. Re-sending an identical split is a no-op, not a double-allocation.
145407
+ *
145408
+ * Money applied to an ISSUED, non-voided nota de venta’s receivable writes a `kind: payment` entry in that note’s `history` with `changes.payment.to.origin: applied` (app#7319).
145401
145409
  */
145402
145410
  post: {
145403
145411
  parameters: {
@@ -150815,7 +150823,7 @@ interface paths {
150815
150823
  *
150816
150824
  * `deducciones_clp` is the Σ of the dueño share of every retained cost line the settlement discharged, and `deductions` lists them one by one (`cost_entry_id`, `label`, `entry_date`, `dueno_clp`). Selling a consigned car deducts them all: `monto_owner_clp` is `amount_venta_clp` minus the comisión minus `deducciones_clp`.
150817
150825
  *
150818
- * `sends` is the log of `POST /consignments/{id}/liquidacion/send`, newest first (last 10): `channel`, `to`, `sent_at`, `by` (member or API key id) and `by_name`. `whatsapp_send_enabled` says whether the workspace may send it on WhatsApp (its staff-WhatsApp switch is on); when false, offer email only.
150826
+ * `sends` is the log of `POST /consignments/{id}/liquidacion/send`, newest first (last 10): `channel` (`email` | `whatsapp` | `whatsapp_link`), `status` (`sent`, or `opened` for `whatsapp_link`: «abierto en WhatsApp», nothing was delivered by us), `to`, `sent_at`, `by` (member or API key id) and `by_name`. `whatsapp_send_enabled` says whether the workspace may send it through the WhatsApp API (its staff-WhatsApp switch is on). `owner_whatsapp: { phone_digits, window_open }`: the owner’s phone in E.164 digits for `https://wa.me/<digits>` (`null` = no dialable phone: offer email only) and whether their 24 h window is open on this workspace’s WhatsApp. Send through the API when `whatsapp_send_enabled && owner_whatsapp.window_open`; otherwise offer «Abrir WhatsApp» (`channel: whatsapp_link`) when `phone_digits` is set.
150819
150827
  *
150820
150828
  * `settlement_difference` (app#7320): `null` unless the sale’s price was corrected after this liquidación was paid (or adjustments exist). The record above is never rewritten; this says `paid_with_price_clp`, `current_price_clp`, `paid_to_owner_clp`, `due_to_owner_clp` (the owner’s share at the current price with this liquidación’s own terms and deductions), `adjusted_clp`, `difference_clp` (positive: the dealer owes the owner; negative: the owner owes the dealer), `status` and the `adjustments`. Close it with `POST /consignments/{id}/liquidacion/adjustments`.
150821
150829
  */
@@ -150867,12 +150875,17 @@ interface paths {
150867
150875
  * {
150868
150876
  * "channel": "email",
150869
150877
  * "to": "dueno@example.com",
150878
+ * "status": "sent",
150870
150879
  * "sent_at": "2026-11-14T15:20:00.000Z",
150871
150880
  * "by": "11111111-0000-4000-8000-000000000001",
150872
150881
  * "by_name": "Camila Rojas"
150873
150882
  * }
150874
150883
  * ],
150875
- * "whatsapp_send_enabled": false
150884
+ * "whatsapp_send_enabled": false,
150885
+ * "owner_whatsapp": {
150886
+ * "phone_digits": "56912345678",
150887
+ * "window_open": false
150888
+ * }
150876
150889
  * }
150877
150890
  * }
150878
150891
  */
@@ -284952,6 +284965,34 @@ interface components {
284952
284965
  price_approval_id: string | null;
284953
284966
  authorised_by: components["schemas"]["DealActor"] | null;
284954
284967
  };
284968
+ SaleNoteParty: {
284969
+ /** Format: uuid */
284970
+ contact_id: string;
284971
+ name: string | null;
284972
+ };
284973
+ SaleNoteTradeInRead: {
284974
+ /** Format: uuid */
284975
+ id: string;
284976
+ /** Format: uuid */
284977
+ vehicle_id: string;
284978
+ precio_toma_clp: number;
284979
+ /** Format: uuid */
284980
+ acquisition_id: string | null;
284981
+ delivered_by: components["schemas"]["SaleNoteParty"] | null;
284982
+ } & {
284983
+ [key: string]: unknown;
284984
+ };
284985
+ SaleNoteCreditRead: {
284986
+ /** Format: uuid */
284987
+ id: string;
284988
+ institution: string;
284989
+ amount_clp: number;
284990
+ /** @enum {string} */
284991
+ state: "committed" | "disbursed" | "detached";
284992
+ holder: components["schemas"]["SaleNoteParty"] | null;
284993
+ } & {
284994
+ [key: string]: unknown;
284995
+ };
284955
284996
  ProposedSaleNoteTerms: {
284956
284997
  net_clp?: number;
284957
284998
  tax_clp?: number | null;
@@ -285026,6 +285067,8 @@ interface components {
285026
285067
  /** @enum {string} */
285027
285068
  tax_treatment: "afecto" | "exento" | "no_gravado" | "pass_through";
285028
285069
  history: components["schemas"]["SaleNoteHistoryEntry"][];
285070
+ trade_ins: components["schemas"]["SaleNoteTradeInRead"][];
285071
+ credit: components["schemas"]["SaleNoteCreditRead"] | null;
285029
285072
  compraventa_outdated: boolean;
285030
285073
  pending_price_change: components["schemas"]["SaleNotePendingPriceChange"] | null;
285031
285074
  transfer_tax: components["schemas"]["SaleNoteTransferTax"] | null;
@@ -285528,6 +285571,7 @@ interface components {
285528
285571
  /** @enum {string} */
285529
285572
  feature: "bank_feed_fintoc";
285530
285573
  price_clp_per_bank_month: number | null;
285574
+ price_uf_per_bank_month: number | null;
285531
285575
  connected_banks: number;
285532
285576
  };
285533
285577
  bci_api_market: {
@@ -285762,6 +285806,8 @@ interface components {
285762
285806
  /** @enum {string} */
285763
285807
  feature: "bank_feed_fintoc";
285764
285808
  price_clp_per_bank_month: number | null;
285809
+ price_uf_per_bank_month: number | null;
285810
+ included_banks: number;
285765
285811
  widget_public_key: string | null;
285766
285812
  };
285767
285813
  /** @description Which provider a NEW direct bank link goes through. `fintoc`: open its widget (`…/fintoc/link-intent`). `emisso`: let the user pick one of `banks`, then open the page from `…/emisso/link-session`. */
package/dist/index.d.ts CHANGED
@@ -17073,6 +17073,7 @@ interface paths {
17073
17073
  unitUf?: number;
17074
17074
  meter?: string;
17075
17075
  perUnitClpMonth?: number | null;
17076
+ perUnitUfMonth?: number | null;
17076
17077
  billedUnit?: string;
17077
17078
  /** @description The business types (`tenant.vertical`) this add-on is sold to. Omitted = every vertical. Read `offers` for the per-workspace answer. */
17078
17079
  verticals?: string[];
@@ -38374,11 +38375,11 @@ interface paths {
38374
38375
  *
38375
38376
  * **`print_missing_fields`** is what `GET /sale-notes/{id}/pdf` would refuse with right now — the SAME `{ variable, label, fix, contact_id? }` list as its 409 `details.missing_fields` — so a screen can ask for the buyer’s domicilio while the buyer is still at the counter. `[]` when the note prints, and always `[]` on a voided note.
38376
38377
  *
38377
- * **`history`** lists every correction (app#7317), oldest first: `{ id, kind (terms | buyer | add_on | payment), changes: { field: { from, to } }, at, actor, on_approved_note, price_approval_id, authorised_by }`. **`compraventa_outdated`** is `true` when the compraventa in force was printed before a later price or buyer correction (reprint with `POST /sale-notes/{id}/compraventa`). **`pending_price_change`** is a below-floor correction waiting for a manager: `{ price_approval_id, requested_at, requested_by, requested_price_clp, proposed_terms }`, or `null`.
38378
+ * **`history`** lists every correction (app#7317), oldest first: `{ id, kind (terms | buyer | add_on | payment), changes: { field: { from, to } }, at, actor, on_approved_note, price_approval_id, authorised_by }`. A `payment` entry with `changes.payment.from: null` is money a staff member put on the note: `changes.payment.to.origin` is `recorded` (a new payment) or `applied` (an existing payment on the client’s account, applied to the note). **`compraventa_outdated`** is `true` when the compraventa in force was printed before a later price or buyer correction (reprint with `POST /sale-notes/{id}/compraventa`). **`pending_price_change`** is a below-floor correction waiting for a manager: `{ price_approval_id, requested_at, requested_by, requested_price_clp, proposed_terms }`, or `null`.
38378
38379
  *
38379
- * **`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.
38380
+ * **`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. `delivered_by` (`{ contact_id, name }`) names who handed the car in when it is not the current buyer (after a buyer change the retoma stays the original person’s); `null` = the current buyer.
38380
38381
  *
38381
- * **`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.
38382
+ * **`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. `credit.holder` (`{ contact_id, name }`) names whose name the credit is in when it is not the current buyer (after a buyer change it stays the original person’s); `null` = the current buyer.
38382
38383
  */
38383
38384
  get: {
38384
38385
  parameters: {
@@ -39133,9 +39134,9 @@ interface paths {
39133
39134
  head?: never;
39134
39135
  /**
39135
39136
  * Assign or change the buyer of a nota de venta
39136
- * @description Sets `buyer_contact_id` on a live (issued or approved) nota de venta — the fix for a note issued without its comprador, without voiding it. Writes a `history` entry (`kind: buyer`, `buyer_contact_id` and `buyer_name` from → to). A printed compraventa does not block it: the note reads `compraventa_outdated: true` until it is reprinted. The open receivable and the payments applied to it move to the new buyer in the same transaction. The contact must belong to this workspace (404 otherwise, or when it was merged away). Responds with the same read as `GET /sale-notes/{id}`. Setting the buyer it already has is a no-op 200.
39137
+ * @description Sets `buyer_contact_id` on a live (issued or approved) nota de venta — the fix for a note issued without its comprador, without voiding it. Writes a `history` entry (`kind: buyer`, `buyer_contact_id` and `buyer_name` from → to). A printed compraventa does not block it: the note reads `compraventa_outdated: true` until it is reprinted. The open receivable and the payments applied to it move to the new buyer in the same transaction. A retoma or a credit on the note does not block it, and neither moves: the retoma stays recorded as handed in by the ORIGINAL person (its acquisition’s counterparty is never re-pointed) and the credit stays on the note as money received in the original person’s name (nothing is sent to any financiera). The read names them: `trade_ins[].delivered_by` and `credit.holder` (`{ contact_id, name }`, `null` when it is the current buyer). The contact must belong to this workspace (404 otherwise, or when it was merged away). Responds with the same read as `GET /sale-notes/{id}`. Setting the buyer it already has is a no-op 200.
39137
39138
  *
39138
- * **409** with `details.blocked_reason` and a Spanish message when the buyer is already written into something else: `sale_note_voided`, `trade_ins_recorded` (a retoma came from the current buyer), `payment_shared` (a payment on the note is also applied to another debt of the current buyer, e.g. the reserva) or `credit_attached` (the credit’s borrower is the current buyer). The way out for those is void + re-issue. Requires `sale_notes:write`.
39139
+ * **409** with `details.blocked_reason` and a Spanish message: `sale_note_voided`, or `payment_shared` (a payment on the note is also applied to another debt of the current buyer that is not this sale; release that application in Pagos first). Requires `sale_notes:write`.
39139
39140
  */
39140
39141
  patch: {
39141
39142
  parameters: {
@@ -39484,7 +39485,7 @@ interface paths {
39484
39485
  * * a payment the staff typed (`provenance: manual`) is **reversed**: the row is kept and marked reversed (actor, instant, reason, the same reversal as `POST /payments/{id}/reverse`) and every live allocation of it is released. It stops counting on the note and on the reserva it was carried from;
39485
39486
  * * a payment the bank or a gateway proved (`provenance: verified`) is **released** from this note only: the money did arrive, so it stays as the buyer’s credit (Pagos, «por asignar») to apply elsewhere or refund.
39486
39487
  *
39487
- * In the same transaction a `history` entry is written (`kind: payment`, `changes.payment: { from: { payment_id, instrument, amount_clp, on_note_clp, paid_on, provenance }, to: null }`, `changes.removal: { from: null, to: { effect, reason } }`); a compraventa printed before it reads `compraventa_outdated: true`. Adding a payment is `POST /document-payments` with `sale_note_id`; it writes the mirror entry (`changes.payment: { from: null, to: {…} }`). To change an amount, remove and add again. The receivable is not re-stated (what the buyer owes does not change); `totals`, saldo and `funding` follow.
39488
+ * In the same transaction a `history` entry is written (`kind: payment`, `changes.payment: { from: { payment_id, instrument, amount_clp, on_note_clp, paid_on, provenance }, to: null }`, `changes.removal: { from: null, to: { effect, reason } }`); a compraventa printed before it reads `compraventa_outdated: true`. Adding a payment is `POST /document-payments` with `sale_note_id`; it writes the mirror entry (`changes.payment: { from: null, to: { payment_id, instrument, amount_clp, on_note_clp, paid_on, provenance, origin } }`); `origin` is `recorded` for new money and `applied` when money already on the client’s account is put on the note (`POST /payments/{id}/allocations`). To change an amount, remove and add again. The receivable is not re-stated (what the buyer owes does not change); `totals`, saldo and `funding` follow.
39488
39489
  *
39489
39490
  * Responds with the same read as `GET /sale-notes/{id}` plus `payment_removal: { payment_id, effect: reversed | released, amount_clp, on_note_clp, reason, reservation_deposit, change_id }`. `reservation_deposit` names the reserva a carried payment came from and what the removal did to its seña: `no_longer_counted` (reversed) or `still_counted` (released); `null` otherwise.
39490
39491
  *
@@ -50094,7 +50095,7 @@ interface paths {
50094
50095
  *
50095
50096
  * `net_clp` is NET of IVA (cifras del negocio, ADR 0114 §2.2). The price a buyer agrees to on an afecto sale includes IVA, like the published price: send `round(price / 1,19)`. Writes nothing. Requires `dealership_economics:read`; 404 for a unit outside the workspace.
50096
50097
  *
50097
- * **`dealership_result` is the card’s one figure** («Queda en la automotora, sin IVA»), the SAME object on `POST /margin/preview` and `GET /margin/deals/{id}`: `result_clp` (= `margen_bruto_clp`) and the terms it is made of, all net of IVA — `price_net_clp`, `add_on_income_clp`, `cost_clp` (owned car; 0 on a consigned one), `owner_payout_clp` (consigned: payout incl. deducted costs) and `commission_iva_clp` (the IVA of a «+ IVA» comisión, taken out), with `result = price_net + add_on_income − cost − owner_payout − commission_iva` exact whenever `result_clp` is a number; `basis` is always `sin_iva`. `projected: true` while a consigned split is the contract’s projection (the form, and an issued note not settled yet, read the same projection); a liquidación replaces it. `null` `result_clp` = not computable (no cost recorded, no comisión).
50098
+ * **`dealership_result` is the card’s one figure** («Queda en la automotora, sin IVA»), the SAME object on `POST /margin/preview` and `GET /margin/deals/{id}`: `result_clp` (= `margen_bruto_clp − deductions.gastos_unidad_clp`) and the terms it is made of, all net of IVA — `price_net_clp`, `add_on_income_clp`, `cost_clp` (owned car; 0 on a consigned one), `owner_payout_clp` (consigned: payout incl. deducted costs), `commission_iva_clp` (the IVA of a «+ IVA» comisión, taken out) and `expenses_clp` (the unit’s expenses, «Gastos de la unidad»), with `result = price_net + add_on_income − cost − owner_payout − commission_iva − expenses` exact whenever `result_clp` is a number; seller commissions are not in it; `basis` is always `sin_iva`. `projected: true` while a consigned split is the contract’s projection (the form, and an issued note not settled yet, read the same projection); a liquidación replaces it. `null` `result_clp` = not computable (no cost recorded, no comisión).
50098
50099
  */
50099
50100
  post: {
50100
50101
  parameters: {
@@ -50178,12 +50179,13 @@ interface paths {
50178
50179
  * "deducciones_clp": 0
50179
50180
  * },
50180
50181
  * "dealership_result": {
50181
- * "result_clp": 800000,
50182
+ * "result_clp": 680000,
50182
50183
  * "price_net_clp": 10000000,
50183
50184
  * "add_on_income_clp": 0,
50184
50185
  * "cost_clp": 0,
50185
50186
  * "owner_payout_clp": 9200000,
50186
50187
  * "commission_iva_clp": 0,
50188
+ * "expenses_clp": 120000,
50187
50189
  * "projected": false,
50188
50190
  * "basis": "sin_iva"
50189
50191
  * },
@@ -50595,12 +50597,13 @@ interface paths {
50595
50597
  * "margen_neto_clp": 1490000,
50596
50598
  * "settlement": null,
50597
50599
  * "dealership_result": {
50598
- * "result_clp": 2200000,
50600
+ * "result_clp": 1560000,
50599
50601
  * "price_net_clp": 11900000,
50600
50602
  * "add_on_income_clp": 100000,
50601
50603
  * "cost_clp": 9800000,
50602
50604
  * "owner_payout_clp": null,
50603
50605
  * "commission_iva_clp": 0,
50606
+ * "expenses_clp": 640000,
50604
50607
  * "projected": false,
50605
50608
  * "basis": "sin_iva"
50606
50609
  * },
@@ -73369,7 +73372,7 @@ interface paths {
73369
73372
  };
73370
73373
  /**
73371
73374
  * Bank feed sources available to this clinic
73372
- * @description The e-mail rail (free, always on), Fintoc (optional add-on `bank_feed_fintoc`, billed per connected bank per month at the provider's list price — `price_clp_per_bank_month` is null until it is set) and BCI API Market (not configured until the partner approval lands). Requires `clinic_money:read`.
73375
+ * @description The e-mail rail (free, always on), Fintoc (add-on `bank_feed_fintoc`, also granted by the Finanzas plan, billed per connected bank per month at `price_uf_per_bank_month`; the Finanzas plan includes the first bank) and BCI API Market (not configured until the partner approval lands). Requires `clinic_money:read`.
73373
73376
  *
73374
73377
  * **Connected apps:** every patient and contact in the response is a Seudónimo de paciente — initials plus a stable number, `"M.F. · #1001"` — unless the clinic allowed patient names, with RUT, phone and email masked in free text and `meta.patient_privacy` saying so. Clinical alerts (`flags`) are withheld in both modes, and a non-JSON body (an export, a file) is refused with `403 CONNECTED_APP_SENSITIVE_DATA`.
73375
73378
  */
@@ -73400,6 +73403,7 @@ interface paths {
73400
73403
  * "entitled": true,
73401
73404
  * "feature": "bank_feed_fintoc",
73402
73405
  * "price_clp_per_bank_month": null,
73406
+ * "price_uf_per_bank_month": 0.45,
73403
73407
  * "connected_banks": 1
73404
73408
  * },
73405
73409
  * "bci_api_market": {
@@ -75085,7 +75089,9 @@ interface paths {
75085
75089
  * "configured": true,
75086
75090
  * "entitled": true,
75087
75091
  * "feature": "bank_feed_fintoc",
75088
- * "price_clp_per_bank_month": 15000,
75092
+ * "price_clp_per_bank_month": null,
75093
+ * "price_uf_per_bank_month": 0.45,
75094
+ * "included_banks": 1,
75089
75095
  * "widget_public_key": "pk_test_ejemplo"
75090
75096
  * },
75091
75097
  * "bank_aggregator": {
@@ -145398,6 +145404,8 @@ interface paths {
145398
145404
  * @description `payments:write`. Writes one `payment_allocation` row per line, with `method: "staff"`. Passing `release` makes it a RE-allocation: the named rows are released FIRST, in the same transaction, because nothing is ever edited in place — a split is changed by releasing and writing anew, so the history stays readable.
145399
145405
  *
145400
145406
  * 409 `over_allocation` when the lines exceed what is left on the payment (`error.details.unallocated_clp` carries the figure, so the screen can say «solo quedan $5.000 sin asignar»), `obligation_not_open`, `contact_mismatch` (one person's money never settles another's debt — a row Postgres refuses, not a rule a service remembers), `payment_reversed`, `payer_unknown`. Re-sending an identical split is a no-op, not a double-allocation.
145407
+ *
145408
+ * Money applied to an ISSUED, non-voided nota de venta’s receivable writes a `kind: payment` entry in that note’s `history` with `changes.payment.to.origin: applied` (app#7319).
145401
145409
  */
145402
145410
  post: {
145403
145411
  parameters: {
@@ -150815,7 +150823,7 @@ interface paths {
150815
150823
  *
150816
150824
  * `deducciones_clp` is the Σ of the dueño share of every retained cost line the settlement discharged, and `deductions` lists them one by one (`cost_entry_id`, `label`, `entry_date`, `dueno_clp`). Selling a consigned car deducts them all: `monto_owner_clp` is `amount_venta_clp` minus the comisión minus `deducciones_clp`.
150817
150825
  *
150818
- * `sends` is the log of `POST /consignments/{id}/liquidacion/send`, newest first (last 10): `channel`, `to`, `sent_at`, `by` (member or API key id) and `by_name`. `whatsapp_send_enabled` says whether the workspace may send it on WhatsApp (its staff-WhatsApp switch is on); when false, offer email only.
150826
+ * `sends` is the log of `POST /consignments/{id}/liquidacion/send`, newest first (last 10): `channel` (`email` | `whatsapp` | `whatsapp_link`), `status` (`sent`, or `opened` for `whatsapp_link`: «abierto en WhatsApp», nothing was delivered by us), `to`, `sent_at`, `by` (member or API key id) and `by_name`. `whatsapp_send_enabled` says whether the workspace may send it through the WhatsApp API (its staff-WhatsApp switch is on). `owner_whatsapp: { phone_digits, window_open }`: the owner’s phone in E.164 digits for `https://wa.me/<digits>` (`null` = no dialable phone: offer email only) and whether their 24 h window is open on this workspace’s WhatsApp. Send through the API when `whatsapp_send_enabled && owner_whatsapp.window_open`; otherwise offer «Abrir WhatsApp» (`channel: whatsapp_link`) when `phone_digits` is set.
150819
150827
  *
150820
150828
  * `settlement_difference` (app#7320): `null` unless the sale’s price was corrected after this liquidación was paid (or adjustments exist). The record above is never rewritten; this says `paid_with_price_clp`, `current_price_clp`, `paid_to_owner_clp`, `due_to_owner_clp` (the owner’s share at the current price with this liquidación’s own terms and deductions), `adjusted_clp`, `difference_clp` (positive: the dealer owes the owner; negative: the owner owes the dealer), `status` and the `adjustments`. Close it with `POST /consignments/{id}/liquidacion/adjustments`.
150821
150829
  */
@@ -150867,12 +150875,17 @@ interface paths {
150867
150875
  * {
150868
150876
  * "channel": "email",
150869
150877
  * "to": "dueno@example.com",
150878
+ * "status": "sent",
150870
150879
  * "sent_at": "2026-11-14T15:20:00.000Z",
150871
150880
  * "by": "11111111-0000-4000-8000-000000000001",
150872
150881
  * "by_name": "Camila Rojas"
150873
150882
  * }
150874
150883
  * ],
150875
- * "whatsapp_send_enabled": false
150884
+ * "whatsapp_send_enabled": false,
150885
+ * "owner_whatsapp": {
150886
+ * "phone_digits": "56912345678",
150887
+ * "window_open": false
150888
+ * }
150876
150889
  * }
150877
150890
  * }
150878
150891
  */
@@ -284952,6 +284965,34 @@ interface components {
284952
284965
  price_approval_id: string | null;
284953
284966
  authorised_by: components["schemas"]["DealActor"] | null;
284954
284967
  };
284968
+ SaleNoteParty: {
284969
+ /** Format: uuid */
284970
+ contact_id: string;
284971
+ name: string | null;
284972
+ };
284973
+ SaleNoteTradeInRead: {
284974
+ /** Format: uuid */
284975
+ id: string;
284976
+ /** Format: uuid */
284977
+ vehicle_id: string;
284978
+ precio_toma_clp: number;
284979
+ /** Format: uuid */
284980
+ acquisition_id: string | null;
284981
+ delivered_by: components["schemas"]["SaleNoteParty"] | null;
284982
+ } & {
284983
+ [key: string]: unknown;
284984
+ };
284985
+ SaleNoteCreditRead: {
284986
+ /** Format: uuid */
284987
+ id: string;
284988
+ institution: string;
284989
+ amount_clp: number;
284990
+ /** @enum {string} */
284991
+ state: "committed" | "disbursed" | "detached";
284992
+ holder: components["schemas"]["SaleNoteParty"] | null;
284993
+ } & {
284994
+ [key: string]: unknown;
284995
+ };
284955
284996
  ProposedSaleNoteTerms: {
284956
284997
  net_clp?: number;
284957
284998
  tax_clp?: number | null;
@@ -285026,6 +285067,8 @@ interface components {
285026
285067
  /** @enum {string} */
285027
285068
  tax_treatment: "afecto" | "exento" | "no_gravado" | "pass_through";
285028
285069
  history: components["schemas"]["SaleNoteHistoryEntry"][];
285070
+ trade_ins: components["schemas"]["SaleNoteTradeInRead"][];
285071
+ credit: components["schemas"]["SaleNoteCreditRead"] | null;
285029
285072
  compraventa_outdated: boolean;
285030
285073
  pending_price_change: components["schemas"]["SaleNotePendingPriceChange"] | null;
285031
285074
  transfer_tax: components["schemas"]["SaleNoteTransferTax"] | null;
@@ -285528,6 +285571,7 @@ interface components {
285528
285571
  /** @enum {string} */
285529
285572
  feature: "bank_feed_fintoc";
285530
285573
  price_clp_per_bank_month: number | null;
285574
+ price_uf_per_bank_month: number | null;
285531
285575
  connected_banks: number;
285532
285576
  };
285533
285577
  bci_api_market: {
@@ -285762,6 +285806,8 @@ interface components {
285762
285806
  /** @enum {string} */
285763
285807
  feature: "bank_feed_fintoc";
285764
285808
  price_clp_per_bank_month: number | null;
285809
+ price_uf_per_bank_month: number | null;
285810
+ included_banks: number;
285765
285811
  widget_public_key: string | null;
285766
285812
  };
285767
285813
  /** @description Which provider a NEW direct bank link goes through. `fintoc`: open its widget (`…/fintoc/link-intent`). `emisso`: let the user pick one of `banks`, then open the page from `…/emisso/link-session`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrina/api",
3
- "version": "17.49.3",
3
+ "version": "17.51.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",