TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt
Use this file to discover all available pages before exploring further.
/ventas/ endpoints handle payment processing for the cafeteria. A sale (venta) is created when a cashier collects payment for a completed order. Each sale record stores the cashier who processed it, the payment method used, the server-calculated total, and the amount received along with computed change. Registering a sale automatically transitions the linked order to pagado status and writes an entry to the order status history — no separate order update call is needed.
Endpoints
List payment methods
Bearer <token> — Any authenticated user.id_metodo_pago field when registering a sale.
Example response
Payment method ID. Used as
id_metodo_pago when registering a sale.Human-readable payment method name (e.g.
"Efectivo", "Tarjeta").Optional description of the payment method.
List sales
Bearer <token> — Roles: admin, caja.fecha descending (most recent first). Optionally filtered by date range. Both fecha_inicio and fecha_fin are inclusive boundaries applied against the fecha timestamp on each sale.
Query parameters
Start of the date range filter (ISO date string, e.g.
"2024-01-01"). Inclusive.End of the date range filter (ISO date string, e.g.
"2024-01-31"). Inclusive.Get a single sale
Bearer <token> — Any authenticated user.Internal ID of the sale to retrieve.
| Status | Detail |
|---|---|
404 | "Venta no encontrada" |
Register a sale
Bearer <token> — Roles: admin, caja.- Validates the order exists and is in
listoorentregadostate. - Confirms the order has not already been paid (
"Este pedido ya fue cobrado"). - Validates the payment method ID.
- Calculates
monto_totalserver-side by summingsubtotalacross all order line items — the value supplied by the client is ignored. - Computes
cambioasmonto_recibido - monto_total(stored in the model,nullifmonto_recibidoisnull). - Transitions the order to
pagadoand appends a row toOrderStatusHistory.
ID of the order being paid. The order must be in
listo or entregado state.ID of the payment method. Must match an existing record from
GET /ventas/metodos-pago.Amount of cash (or equivalent) tendered by the customer. Optional for card or digital payment methods where no cash counting is needed. When provided,
cambio is calculated automatically.201 Created
| Status | Detail |
|---|---|
404 | "Pedido no encontrado" |
400 | "El pedido está en estado '{nombre}'. Debe estar 'listo' o 'entregado' para cobrar." |
400 | "Este pedido ya fue cobrado" |
400 | "Método de pago no válido" |
The SaleOut object
Internal sale ID.
ID of the order that was paid.
ID of the user who processed the payment (taken from the JWT token automatically).
Full user object for the cashier:
{id, nombre, email, activo, created_at, role}.Payment method used:
{id, nombre, descripcion}.Total amount due, calculated server-side from the sum of order item subtotals. Client-supplied values are ignored.
Amount tendered by the customer.
null for card or digital payments where this is not applicable.Change due to the customer (
monto_recibido - monto_total). null when monto_recibido is null. Not stored as a column — computed at the application level as a Python property on the model.Timestamp when the sale was registered (set by the database, not the client).
Notes on payment flow
The/ventas/ endpoint is the authoritative way to close an order as paid. For emergency situations where an order needs to be cleared without going through the full payment process, PATCH /mesas/{mesa_id}/liberar will force the order to pagado directly — but it creates no Sale record and the transaction will not appear in sales reports.