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.
/compras/ endpoints record ingredient supply purchases — the act of buying raw materials from a supplier to restock the kitchen. Every purchase is an atomic operation: a compras_suministros record is created and the associated ingredient’s stock_actual is incremented by the purchased cantidad in the same database transaction. This keeps inventory levels synchronized with procurement history without a separate stock adjustment step. Both the ingredient details and the purchasing user are embedded in every response for full traceability.
Endpoints
List all supply purchases
Bearer <token> — Roles: admin, cocina.created_at descending (most recent first). Each record includes full ingredient details and the user who registered the purchase.
Example response
Register a supply purchase
Bearer <token> — Roles: admin, cocina.stock_actual by cantidad. The id_usuario is taken from the JWT token automatically. The stock update and purchase record creation happen in a single database transaction — if either fails, both are rolled back.
Request body
ID of the ingredient being restocked. Must match an existing ingredient.
Quantity purchased, expressed in the ingredient’s configured unit (e.g. kg, litres, units). Must be greater than 0. This value is added directly to
Ingredient.stock_actual upon successful creation.Total cost of the purchase in currency units. Must be >= 0. This is the full invoice amount, not the per-unit cost. The per-unit cost (
costo_unitario) on the ingredient record itself is not updated by this endpoint.Purchase date in
YYYY-MM-DD format. Can be a past date to allow retroactive entry of receipts.201 Created
The response reflects the ingredient’s updated stock level (post-purchase).
| Status | Detail |
|---|---|
400 | "Ingrediente no encontrado" — id_ingrediente does not match any ingredient. |
The CompraOut object
Internal purchase record ID.
ID of the ingredient that was restocked.
Full ingredient snapshot at the time of the response:
{id, nombre, unidad, stock_actual, stock_minimo, costo_unitario}. The stock_actual shown here reflects the post-purchase level.Full user object for the person who registered the purchase:
{id, nombre, email, activo, created_at, role}. Populated from the JWT token automatically.Quantity purchased, in the ingredient’s configured unit.
Total purchase cost as recorded at time of entry.
Date the purchase occurred (
YYYY-MM-DD), as supplied by the caller.System timestamp when the purchase record was created.
Inventory impact
After a successfulPOST /compras/, the ingredient’s stock_actual is updated atomically:
ingrediente.stock_actual field or by calling GET /productos/ingredientes/{id}. The GET /stats/inventario-estado endpoint also reflects the update immediately and will remove the ingredient from the criticos list if restocking brought it above stock_minimo.