The sales module is the operational core of Kantuta POS. Every product transaction is recorded as aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Eleazarguitar18/kantuta_pos_back/llms.txt
Use this file to discover all available pages before exploring further.
Venta — a parent record that groups line items (DetalleVenta), stores the payment method, links to the active cash register session, and tracks its own lifecycle state from COMPLETADA through to ANULADA or EDITADA. The backend automatically reduces stock on creation, maintains a full audit trail via BaseEntityAudit, and exposes summary endpoints for PDF report generation.
Prerequisites
You must have an active cash register session (
SesionCaja with estado_sesion: ABIERTA) before recording any sale. The id_sesion_caja returned when opening a session is required in every sale payload. See the Cash Register Flow guide to open a session.Creating a Sale
Gather Line-Item Data
For each product the customer is purchasing, collect:
id_producto— the product’s database IDcantidad— quantity sold (minimum1)precio_unitario— the unit selling price at the time of the transaction (decimal, min0)
cantidad × precio_unitario) and sums them into the Venta.total field automatically.POST /ventas — Create the Sale
Submit the full payload to register the sale, deduct stock, and link the transaction to the open session.TypeScript interface:JSON example:cURL example:
Inspect the Response
On success the endpoint returns
201 Created with the full Venta record including its computed total, the embedded detalles array with subtotals, and the assigned estado_venta.Stock is automatically deducted at the moment of creation. Each product’s
stock_actual is decremented by the cantidad specified in the corresponding DetalleVentaDto.Payment Methods
EFECTIVO
Cash payment. The amount is tracked against the open
SesionCaja balance and appears in the end-of-shift reconciliation.QR
QR code payment (e.g., via Bolivia’s QR interoperability network). Recorded in the sale but handled externally — no automatic cash drawer impact.
TRANSFERENCIA
Bank transfer. Like QR, the transaction is recorded on the sale record; the actual funds transfer occurs outside the POS system.
Listing Sales
detalles array with line-item subtotals and the linked sesion_caja.
Updating or Voiding a Sale
UsePATCH /ventas/:id to update sale metadata or change its state. Line-item details (detalles) are intentionally excluded from this endpoint to prevent stock inconsistencies — product-level corrections should be handled through inventory adjustments or a new sale.
ActualizarVentaDto fields:
| Field | Type | Required | Description |
|---|---|---|---|
estado_venta | COMPLETADA | ANULADA | EDITADA | Optional | New lifecycle state of the sale |
motivo_edicion | string | Optional | Reason for the change (free text) |
metodo_pago | EFECTIVO | QR | TRANSFERENCIA | Optional | Correct the payment method if mis-entered |
id_sesion_caja | integer | Optional | Reassign to a different session (admin use) |
id_user_update | integer | Optional | Audit field |
Sale States
estado_venta | Description |
|---|---|
COMPLETADA | Default state — sale finalized and stock deducted. |
ANULADA | Sale cancelled. Record is retained for audit; stock is not auto-restored. |
EDITADA | Sale metadata was modified after creation (e.g., payment method correction). |
Sales Report Summary
For aggregated reporting — total revenue, sales count, and payment method breakdowns grouped over a date range — use the dedicated summary endpoint.This endpoint uses
POST with the date range in the body but returns 200 OK (not 201). The POST verb was chosen because query strings can be unreliable with date formatting in some HTTP clients.Endpoint Summary
| Method | Endpoint | Description |
|---|---|---|
POST | /ventas | Create a sale (deducts stock) |
GET | /ventas | List all sales |
GET | /ventas/:id | Get sale with line items |
PATCH | /ventas/:id | Update or void a sale |
DELETE | /ventas/:id | Hard delete a sale record |
POST | /ventas/reporte-resumen | Grouped summary for reporting |