Consumptions (consumos) are the line items that link a product to a table during an active session. Each time a customer orders a drink or snack, staff register a consumption record pointing to the table and the product. Those records accumulate withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ierinconc/billar-pro-backend/llms.txt
Use this file to discover all available pages before exploring further.
sesion = null while the table is in use, and when the table is eventually closed via PUT /api/mesas/{id}/cerrar, the system automatically sums all open consumptions, computes the totalConsumos, and permanently attaches every pending record to the newly created Sesion — so the full bill is captured in one atomic operation.
Endpoints
GET /api/consumos
Returns every consumption record in the database, including those already linked to closed sessions. Authentication: Required — include a valid JWT Bearer token. Response:200 OK — array of Consumo objects.
Auto-generated primary key of the consumption record.
The table against which the sale was recorded.
The product that was sold.
Number of units sold in this consumption record.
Computed at registration time as
producto.precio × cantidad. Not recalculated if the product price changes later.Timestamp when the consumption was registered, e.g.
"2025-06-01T15:22:45".null while the consumption is open (table not yet closed). Once the table is closed, this field contains the full Sesion object to which this consumption was attached.Request example
POST /api/consumos
Registers a new product sale against a table. The server looks up the product price and computessubtotal automatically.
Authentication: Required — include a valid JWT Bearer token.
Request body (JSON):
ID of the table to charge. The table must already exist in the database.
ID of the product being sold. The product must exist and have
disponible = true or the request will be rejected.Number of units being sold. The server multiplies this by the product’s current unit price to set
subtotal.subtotal is persisted with the record and is not updated if the product price changes after registration.
Response: 201 Created — the created Consumo object.
Errors:
| Status | Meaning |
|---|---|
404 | mesaId does not exist ("Mesa no encontrada"). |
404 | productoId does not exist ("Producto no encontrado"). |
404 | Product exists but disponible = false ("Producto no disponible"). |
Request example
Response example
GET /api/consumos/mesa/{mesaId}
Returns only the open consumptions for a given table — that is, records wheresesion IS NULL. These are the pending items that will be included in the bill when the table is eventually closed.
Authentication: Required — include a valid JWT Bearer token.
Path parameters:
Primary key of the table whose open consumptions should be retrieved.
200 OK — array of Consumo objects (may be empty if no open consumptions exist).
Errors:
| Status | Meaning |
|---|---|
404 | No table with that mesaId exists ("Mesa no encontrada"). |
Request example
Consumption lifecycle: A consumption is created with
sesion = null, meaning it is unlinked and open. When PUT /api/mesas/{id}/cerrar is called, SesionService queries all records matching findByMesaAndSesionIsNull, totals their subtotals, saves the new Sesion, and then sets sesion on every matching Consumo. From that point the records become part of the immutable session history and will no longer appear in the /api/consumos/mesa/{mesaId} response.