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.

SS Restaurant includes a built-in PDF reporting engine powered by PDFKit. Reports are generated server-side, stored as .pdf files in the Backend/reports/ directory, and made available for download via a dedicated endpoint. Every report is scoped to admin role — the routes are protected and each generation is written to the audit log. The GET /api/reports/tipos endpoint returns the complete list of valid report types so that client applications can build dynamic report menus without hard-coding values.

Available report types

The engine supports exactly 10 report types. Each type has an internal value (used in the API) and a human-readable label (returned by /api/reports/tipos and used as the PDF title).
valuelabelPrimary date parameters
ventas_diariasVentas Diariasfecha
ventas_periodoVentas por Periodofecha_inicio, fecha_fin
productos_mas_vendidosProductos Más Vendidosfecha_inicio, fecha_fin
ventas_por_categoriaVentas por Categoríafecha_inicio, fecha_fin
ocupacion_mesasOcupación de Mesasfecha_inicio, fecha_fin
rendimiento_meserosRendimiento de Meserosfecha_inicio, fecha_fin
historial_pedidosHistorial de Pedidosfecha_inicio, fecha_fin
historial_pagosHistorial de Pagosfecha_inicio, fecha_fin
reservasReservasfecha_inicio, fecha_fin
cierre_cajaCierre de Cajafecha
All PDF files are written to Backend/reports/ on the server. The filename pattern is {tipo}_{unix_timestamp}.pdf, for example ventas_diarias_1721433600000.pdf.

Generating a report

POST /api/reports/generate/:tipo
Content-Type: application/json
Send the date parameters as a JSON body. The server validates tipo against the list of 10 known values and returns 400 for any unknown type.
Generates a one-day sales summary showing total orders, total revenue, and a breakdown by payment method.
POST /api/reports/generate/ventas_diarias

{
  "fecha": "2025-07-20"
}
If fecha is omitted, the report defaults to today’s date.
Successful response (201):
{
  "id": 14,
  "tipo": "ventas_diarias",
  "archivo_pdf": "ventas_diarias_1721433600000.pdf",
  "total_generado": 1450.75,
  "message": "Reporte generado correctamente"
}
Use the returned id to download the file.

Downloading a report

GET /api/reports/download/:id
Returns the PDF file as a binary download attachment. The Content-Disposition header is set to attachment; filename="{tipo}_{id}.pdf". If the database record exists but the PDF file has been deleted from disk, the endpoint returns 404 Archivo PDF no encontrado.

Listing reports

GET /api/reports
GET /api/reports?tipo=ventas_diarias
Returns an array of all generated report records. Use the optional tipo query parameter to filter by report type. The parametros field is returned as a parsed JSON object.
[
  {
    "id": 14,
    "usuario_id": 1,
    "tipo": "ventas_diarias",
    "parametros": { "fecha": "2025-07-20" },
    "fecha_inicio": "2025-07-20",
    "fecha_fin": "2025-07-20",
    "total_generado": 1450.75,
    "archivo_pdf": "ventas_diarias_1721433600000.pdf",
    "creado_en": "2025-07-20T18:00:00.000Z"
  }
]

Deleting a report

DELETE /api/reports/:id
Deletes both the database record and the PDF file from Backend/reports/. If the file no longer exists on disk, the deletion proceeds without error (the file is simply skipped).
{
  "message": "Reporte eliminado correctamente"
}
Deletion is permanent. There is no recycle bin — once the PDF file is removed from disk it cannot be recovered. Download the file before deleting if you need a permanent copy.

Querying available types

GET /api/reports/tipos
Returns the full list of valid report types with their display labels. Use this in UI code to avoid hard-coding the type list.
[
  { "value": "ventas_diarias",          "label": "Ventas Diarias" },
  { "value": "ventas_periodo",          "label": "Ventas por Periodo" },
  { "value": "productos_mas_vendidos",  "label": "Productos Más Vendidos" },
  { "value": "ventas_por_categoria",    "label": "Ventas por Categoría" },
  { "value": "ocupacion_mesas",         "label": "Ocupación de Mesas" },
  { "value": "rendimiento_meseros",     "label": "Rendimiento de Meseros" },
  { "value": "historial_pedidos",       "label": "Historial de Pedidos" },
  { "value": "historial_pagos",         "label": "Historial de Pagos" },
  { "value": "reservas",                "label": "Reservas" },
  { "value": "cierre_caja",             "label": "Cierre de Caja" }
]

PDF structure

Every generated PDF follows the same layout regardless of type:
  1. Header — Restaurant name (from the configuracion table), address, phone, and NIT centred at the top, followed by the report title and the period covered.
  2. Generated timestamp — Printed below the header in the server’s locale (es-BO).
  3. Data table — PDFKit renders a bordered table with alternating shaded header row. Long tables automatically paginate, repeating the column headers on each new page.
  4. Totals footer — A bold Total General line right-aligned below the table (where applicable).
  5. Page number — Printed at the bottom of each page.
The restaurant name, address, and NIT printed in each PDF are pulled from configuracion row id = 1. Update that record in the database to change the branding on all future reports.

Build docs developers (and LLMs) love