Billar Pro supports an in-house product catalog — beverages, snacks, or any other item sold at the hall — and lets staff register sales directly against an occupied table during an active session. When the table is eventually closed, all open consumptions are automatically summed and folded into the session total, giving a single, unified bill that covers both play time and product sales.Documentation 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.
The Producto Entity
Each item in the catalog is stored as aProducto record.
| Field | Type | Description |
|---|---|---|
id | Long | Auto-generated primary key. |
nombre | String | Display name of the product (e.g., "Agua Postobón 600ml"). |
categoria | String | Free-text category label (e.g., "Bebidas", "Snacks"). |
precio | Double | Unit price charged per item. |
disponible | boolean | Availability flag. Only products where disponible = true can be added to a consumption. |
Product Availability
Before saving aConsumo, the service checks producto.isDisponible(). If the flag is false, registration is blocked immediately:
The Consumo Entity
AConsumo row represents a single line-item sale of a product to a table.
| Field | Type | Description |
|---|---|---|
id | Long | Auto-generated primary key. |
mesa | Mesa | FK to the table where the product was ordered. |
producto | Producto | FK to the catalog item that was sold. |
cantidad | Integer | Number of units ordered. |
subtotal | Double | Computed as producto.getPrecio() × cantidad. Stored on the record at the time of registration. |
fecha | LocalDateTime | Exact timestamp when the consumption was registered (LocalDateTime.now()). |
sesion | Sesion | FK to the owning session. null while the table is still open. Set when the session closes. |
sesion field is the linking key that distinguishes open (in-flight) consumptions from closed (billed) ones. The query findByMesaAndSesionIsNull(mesa) is used both to list pending consumptions and to collect them during session closure.
The ConsumoRequest Body
Registering a consumption requires a JSON body with three fields:| Field | Type | Description |
|---|---|---|
mesaId | Long | ID of the occupied table. |
productoId | Long | ID of the catalog product being ordered. |
cantidad | Integer | Number of units. |
Registration Flow
Locate or create a product
List the existing catalog to find the product ID you need:If the product does not exist yet, create it:The response includes the new product’s
id, which you will use in the next step.Register the consumption against the table
While the target table’s The service:
estado is "OCUPADA", post the sale:- Resolves the
MesabymesaId— throwsRuntimeException("Mesa no encontrada")if absent. - Resolves the
ProductobyproductoId— throwsRuntimeException("Producto no encontrado")if absent. - Checks
producto.isDisponible()— throwsRuntimeException("Producto no disponible")iffalse. - Computes
subtotal = producto.getPrecio() * cantidad. - Saves the
Consumowithsesion = nullandfecha = LocalDateTime.now().
Consumo is returned in the response body.Query open consumptions for a table
To display a running tab for an occupied table, fetch all unlinked consumptions:This calls
consumoRepository.findByMesaAndSesionIsNull(mesa), returning only the line items that have not yet been assigned to a closed session — i.e., the active tab.Example response:Close the table to link all consumptions to the session
When play ends, call:
SesionService.guardarSesion fetches every Consumo where sesion IS NULL for this table, sums their subtotal values, persists the Sesion, and then updates each Consumo record to point at the new session. After this step the consumptions are permanently linked and no longer appear in the open tab query. See Tables & Sessions for the full closure flow.Managing the Product Catalog
List all products
disponible status.Get a single product
RuntimeException("Producto no encontrado") if the ID does not exist.Update a product
nombre, categoria, precio, and disponible in a single call.