Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/FloresJesus/SS_RESTAURANT/llms.txt

Use this file to discover all available pages before exploring further.

Every transaction in SS Restaurant begins with a pedido (order). When a waiter opens a new order it is immediately linked to a physical table, optionally to a reservation that exists for that table today, and to the waiter who is serving it. From that moment the order travels through a well-defined service pipeline — kitchen staff advance it toward preparation and delivery, while cashiers handle payment at the end. Every step is recorded in the audit log and triggers a real-time notification to the appropriate role.

Order status flow

Orders carry two independent status fields:
  • estado_servicio — tracks where the order is in the service pipeline.
  • estado_pago — tracks whether it has been paid (pendientepagado).
The API uses English values for estado_servicio transitions; the database stores Spanish equivalents.
API value (status)Database value (estado_servicio)Meaning
pendingpendienteOrder placed, not yet started in kitchen
preparingpreparandoKitchen is actively working on it
readylistoReady on the pass, waiting for the waiter
deliveredentregadoDelivered to the table
cancelledcanceladoOrder voided
1

pending

Order is created and the table is marked ocupada automatically.
2

preparing

Kitchen staff advance the order when preparation begins.
3

ready

Kitchen marks the order ready; a notification is sent to the waiter role.
4

delivered / cancelled

Completing or cancelling the order marks the table back to libre.

Role permissions

Create orders

Roles admin, mesero, and cajero may call POST /api/orders.

Edit items

Roles admin and mesero may call PUT /api/orders/:id/items and DELETE /api/orders/:id/items/:itemId.

Update status

All authenticated roles can call PUT /api/orders/:id/status. The Vue frontend additionally enforces per-role transitions: kitchen can advance to preparing, waiters can mark ready, admins can do any transition.

Creating an order

Send a POST request to /api/orders. The mesa_id, mesero_id, and at least one item are required.
POST /api/orders
Content-Type: application/json

{
  "mesa_id": 3,
  "mesero_id": 7,
  "cliente_id": null,
  "reserva_id": null,
  "observaciones": "Sin cebolla en el lomo",
  "metodo_pago": null,
  "items": [
    {
      "producto_id": 12,
      "cantidad": 2,
      "precio_unitario": 45.00,
      "observaciones": null
    },
    {
      "producto_id": 5,
      "cantidad": 1,
      "precio_unitario": 18.50,
      "observaciones": "Bien cocido"
    }
  ]
}
Successful response (201):
{
  "id": 84,
  "message": "Pedido creado correctamente"
}
FieldRequiredDescription
mesa_idID of the table
mesero_idID of the waiter
itemsArray with at least one element
items[].producto_idProduct ID from the menu
items[].cantidadQuantity (integer ≥ 1)
items[].precio_unitarioOptionalOverrides the current product price if provided
items[].observacionesOptionalPer-item notes for kitchen
cliente_idOptionalLink to an existing customer record
reserva_idOptionalExplicitly link a reservation
observacionesOptionalGeneral order notes
metodo_pagoOptionalPassing a valid payment method here also creates a payment record immediately and marks the order pagado
If metodo_pago is provided on creation, a pago row is inserted and estado_pago is set to 'pagado' in the same database transaction — useful for walk-in customers who pay upfront.

Managing order items

Use PUT /api/orders/:id/items to add new products or update quantities on an existing order. Pass each item with either an id (to update an existing detail row) or no id (to insert a new row).
PUT /api/orders/84/items
Content-Type: application/json

{
  "items": [
    {
      "id": 201,
      "producto_id": 12,
      "cantidad": 3
    },
    {
      "producto_id": 9,
      "cantidad": 1
    }
  ]
}
To remove a single item line, use:
DELETE /api/orders/:id/items/:itemId

Updating order status

PUT /api/orders/84/status
Content-Type: application/json

{
  "status": "preparing"
}
Valid values for status: pending, preparing, ready, delivered, cancelled. Successful response:
{
  "message": "Estado del pedido actualizado"
}
Passing delivered or cancelled automatically changes the associated table’s estado to libre. Make sure no other active orders exist on that table before cancelling.

Automatic behaviors

The order controller performs several side-effects automatically within a single database transaction:
  • Table occupation — Creating any order sets the table’s estado to 'ocupada'.
  • Table liberation — Transitioning to entregado or cancelado sets the table back to 'libre'.
  • Reservation detection — If no reserva_id is supplied, the system queries for a confirmada or pendiente reservation for that table dated today and links it automatically.
  • Reservation completion — Once a reservation is linked to a new order, its estado is updated to 'completada'.

Notifications

Every status transition fires a createNotification call with a destination role:
StatusNotification destination
pendingcocina (kitchen)
preparingcocina (kitchen)
readymesero (waiter)
deliveredadmin
Notification failures are logged but do not roll back the status update.

Sales statistics

The GET /api/orders/stats endpoint powers the dashboard charts. Use the optional range query parameter to switch between weekly and monthly views.
GET /api/orders/stats?range=week
GET /api/orders/stats?range=month
Response shape:
{
  "weekly": [
    { "day": "Lun", "sales": 1250.50, "date": "2025-01-06" },
    { "day": "Mar", "sales": 980.00, "date": "2025-01-07" }
  ],
  "topProducts": [
    { "name": "Lomo Saltado", "quantity": 34, "value": 1530.00 }
  ],
  "today": {
    "orders": 12,
    "sales": 640.75
  },
  "categories": [
    { "categoria": "Platos de fondo", "total_ventas": 3200.00 }
  ]
}
When range=week the day field uses abbreviated day names (Lun, Mar, …). When range=month the day field is the numeric day of the month as a string (“1”, “2”, …).

Build docs developers (and LLMs) love