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.

The Reports API generates on-demand PDF documents from live restaurant data. Each call to POST /api/reports/generate/:tipo queries the relevant tables, renders a formatted PDF using PDFKit (including the restaurant’s name, address, phone, and NIT from the configuracion table in the header), saves the file to the server’s reports/ directory, and records metadata in the database. The generated PDF can then be downloaded by its assigned ID. All report endpoints are restricted to the admin role.

Endpoints

MethodPathAuthDescription
GET/api/reports/tiposadminList all valid report types with labels
GET/api/reportsadminList previously generated reports (optional ?tipo= filter)
GET/api/reports/:idadminGet metadata for a single generated report
POST/api/reports/generate/:tipoadminGenerate a new PDF report
GET/api/reports/download/:idadminDownload the PDF file
DELETE/api/reports/:idadminDelete the report record and its PDF file

GET /api/reports/tipos

Returns the list of all valid report type identifiers with their human-readable Spanish labels.
curl -X GET https://api.example.com/api/reports/tipos \
  -H "Authorization: Bearer <token>"
Response:
[
  { "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" }
]

Report types

Type identifierLabelDescription
ventas_diariasVentas DiariasOrders and payment totals for a single day, broken down by payment method
ventas_periodoVentas por PeriodoDay-by-day sales totals over a date range
productos_mas_vendidosProductos Más VendidosRanked list of products by quantity sold
ventas_por_categoriaVentas por CategoríaSales grouped by product category
ocupacion_mesasOcupación de MesasOrder count and revenue per table
rendimiento_meserosRendimiento de MeserosOrders attended and revenue per waiter
historial_pedidosHistorial de PedidosFull order history with statuses and totals
historial_pagosHistorial de PagosPayment transaction history with methods
reservasReservasReservation history with status breakdown
cierre_cajaCierre de CajaCash-close summary: orders, payment methods, and total collected

GET /api/reports

Returns metadata for all previously generated reports. Pass ?tipo= to filter by report type. Query parameters
tipo
string
Filter by report type identifier (e.g., ventas_diarias). Omit to return all reports.
curl -X GET "https://api.example.com/api/reports?tipo=ventas_diarias" \
  -H "Authorization: Bearer <token>"

GET /api/reports/:id

Returns the stored metadata for a single report. The parametros field contains the original generation parameters as a parsed JSON object.
curl -X GET https://api.example.com/api/reports/9 \
  -H "Authorization: Bearer <token>"
Response:
{
  "id": 9,
  "tipo": "ventas_diarias",
  "archivo_pdf": "ventas_diarias_1736956800000.pdf",
  "parametros": { "fecha": "2025-01-15" },
  "fecha_inicio": "2025-01-15",
  "fecha_fin": "2025-01-15",
  "total_generado": 1625.50,
  "creado_en": "2025-01-15T22:00:00.000Z"
}
id
number
Report primary key.
tipo
string
Report type identifier.
archivo_pdf
string
Filename of the stored PDF on the server (used internally).
parametros
object
Original generation parameters as a parsed JSON object.
fecha_inicio
string
Start of the report period (YYYY-MM-DD).
fecha_fin
string
End of the report period (YYYY-MM-DD).
total_generado
number
Grand total value shown in the report footer, in Bolivianos (Bs).
creado_en
string
ISO 8601 timestamp when the report was generated.

POST /api/reports/generate/:tipo

Generates a new PDF report of the specified type. The body parameters vary by report type as described below. On success the PDF is written to disk and a metadata record is inserted; the response includes the new report’s id which can be used to download the file.

Path parameter

tipo
string
required
One of the ten valid report type identifiers. Passing an unknown type returns 400.

Body parameters by report type

fecha
string
Target date in YYYY-MM-DD format. Used by ventas_diarias and cierre_caja. Defaults to today if omitted.
fecha_inicio
string
Start of the date range in YYYY-MM-DD format. Required for ventas_periodo, productos_mas_vendidos, ventas_por_categoria, ocupacion_mesas, rendimiento_meseros, historial_pedidos, historial_pagos, and reservas.
fecha_fin
string
End of the date range in YYYY-MM-DD format. Required alongside fecha_inicio for all period-based report types.
limit
number
Maximum number of rows to include in the productos_mas_vendidos report. Defaults to 20 if omitted.

Parameter matrix

Report typefechafecha_inicio + fecha_finlimit
ventas_diariasoptional (defaults today)
cierre_cajaoptional (defaults today)
ventas_periodorequired
historial_pedidosrequired
historial_pagosrequired
reservasrequired
productos_mas_vendidosrequiredoptional (default 20)
ventas_por_categoriarequired
ocupacion_mesasrequired
rendimiento_meserosrequired

Response

{
  "id": 9,
  "tipo": "ventas_diarias",
  "archivo_pdf": "ventas_diarias_1736956800000.pdf",
  "total_generado": 1625.50,
  "message": "Reporte generado correctamente"
}
id
number
ID of the newly created report record. Use this to download the PDF.
tipo
string
The report type that was generated.
archivo_pdf
string
Server-side filename of the generated PDF.
total_generado
number
Grand total value from the report data, in Bolivianos (Bs).

Example — generate ventas_diarias

curl -X POST https://api.example.com/api/reports/generate/ventas_diarias \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"fecha": "2025-01-15"}'

Example — generate ventas_periodo

curl -X POST https://api.example.com/api/reports/generate/ventas_periodo \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "fecha_inicio": "2025-01-01",
    "fecha_fin": "2025-01-31"
  }'

GET /api/reports/download/:id

Downloads the PDF file for the given report ID. The response sets Content-Disposition: attachment so browsers will save the file. The downloaded filename follows the pattern <tipo>_<id>.pdf (e.g., ventas_diarias_9.pdf).
curl -X GET https://api.example.com/api/reports/download/9 \
  -H "Authorization: Bearer <token>" \
  -o ventas_diarias_9.pdf
Returns 404 if either the database record or the physical PDF file cannot be found.

DELETE /api/reports/:id

Deletes the report metadata from the database and removes the PDF file from disk. This action is irreversible.
curl -X DELETE https://api.example.com/api/reports/9 \
  -H "Authorization: Bearer <token>"
Response 200 OK:
{ "message": "Reporte eliminado correctamente" }

The PDF header content (restaurant name, address, phone, NIT) is read from GET /api/settings at generation time. Update your restaurant’s configuration before generating reports if the header information is incomplete. See the Settings API for details.

Build docs developers (and LLMs) love