Two inventory types
Ingredientes
Raw ingredients with a floating-point
cantidad, a unidad of measure, and a cantidad_minima threshold for low-stock alerts. Their stock is reduced when a plato that uses them is sold.Productos
Standalone items (drinks, packaged goods, etc.) with an integer
stock. Their stock is reduced directly when the product is included as a line item in a closed transaction.Managing ingredientes
Create an ingredient
id is a 10-character nanoid generated by the server.
Update stock manually
UsePATCH /api/ingredientes/:id to adjust the quantity — for example after a delivery:
List all ingredients
cantidad < cantidad_minima.
Delete an ingredient
Deletion is a soft delete — the record is retained in the database withborrado_en set:
Only users with the
admin role can create, update, or delete ingredientes.Managing platos and recipes
A plato represents a cooked dish on the menu. Its price is set when you create it. The recipe (which ingredients it uses and in what quantities) is defined by linking ingredientes to the plato.Create a plato
Link ingredients to a plato
After creating the plato, define its recipe by adding ingredients. Thecantidad here is the amount of the ingredient consumed per serving of the plato.
View a plato’s ingredients
Update ingredient quantity in a recipe
Remove an ingredient from a recipe
How automatic stock deduction works
Stock is deducted only when a transaction closes (estado: cerrado). The deduction runs once at closure:
- For each
detalle_itemin the transaction:- If the item is a producto:
stockis decremented byitem.cantidad. - If the item is a plato: for each entry in
plato_ingredientes, the ingredient’scantidadis decremented byplato_ingredientes.cantidad × item.cantidad.
- If the item is a producto:
- For each
detalle_item_extrawith aningrediente_id: the ingredient’scantidadis decremented byextra.cantidad.
descripcion (free-text extras) do not affect inventory.
A transaction only closes when both
estado_cocina = terminado and monto_pendiente = 0. Stock is never deducted twice — the deduction is guarded by a check of the previous estado value.Checking low stock
There is no dedicated low-stock endpoint. To identify ingredients below their minimum threshold, retrieve the full list and filter:cantidad_minima field is set per ingredient when you create or update it. Set it to 0 to disable the threshold for that ingredient.