Skip to main content

Documentation 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.

CafeteriaPM includes built-in report generation for all major operational areas. Every report is available in both PDF (generated with ReportLab) and XLSX (generated with openpyxl) formats and is accessible directly through the API as a file download. All report endpoints return a binary response with a Content-Disposition: attachment header so browsers and HTTP clients treat them as file downloads automatically. Reports are accessed through the /stats/ router and all require the admin role.

Available Reports

ReportPDF EndpointXLSX EndpointRole
SalesGET /stats/reporte-ventas/pdfGET /stats/reporte-ventas/xlsxadmin
ExpensesGET /stats/reporte-gastos/pdfGET /stats/reporte-gastos/xlsxadmin
ProductsGET /stats/reporte-productos/pdfGET /stats/reporte-productos/xlsxadmin
OrdersGET /stats/reporte-pedidos/pdfGET /stats/reporte-pedidos/xlsxadmin
InventoryGET /stats/reporte-inventario/pdfGET /stats/reporte-inventario/xlsxadmin
Activity HistoryGET /stats/reporte-historial/pdfGET /stats/reporte-historial/xlsxadmin

Downloading a Report

Reports are downloaded by making an authenticated GET request and saving the response body to a file.
# Download sales report as PDF
curl http://localhost:8000/stats/reporte-ventas/pdf \
  -H "Authorization: Bearer <token>" \
  -o ventas_report.pdf

# Download expenses report as XLSX
curl http://localhost:8000/stats/reporte-gastos/xlsx \
  -H "Authorization: Bearer <token>" \
  -o gastos_report.xlsx
Both formats return a binary response body. The Content-Disposition header specifies the suggested filename:
Content-Disposition: attachment; filename=reporte_ventas.pdf
Content-Disposition: attachment; filename=reporte_gastos.xlsx

Report Query Filters

Most reports accept query parameters to narrow the data included. All date parameters accept ISO 8601 date strings (YYYY-MM-DD). Sales and Expenses reports (reporte-ventas, reporte-gastos, reporte-historial):
ParameterTypeDescription
fecha_iniciostringInclude records on or after this date
fecha_finstringInclude records on or before this date
Products report (reporte-productos):
ParameterTypeDescription
categoria_idintegerFilter by product category ID
disponiblebooleanFilter by availability (true or false)
Orders report (reporte-pedidos):
ParameterTypeDescription
estado_idintegerFilter by order state ID
fecha_iniciostringInclude orders created on or after this date
fecha_finstringInclude orders created on or before this date
Inventory report: No query parameters — always exports the full current inventory snapshot. When no date filters are provided, sales and expense reports include all records in the database. The applied filter range is printed in the PDF header as "Fechas: <inicio> - <fin>".
# Sales for January 2024
curl "http://localhost:8000/stats/reporte-ventas/pdf?fecha_inicio=2024-01-01&fecha_fin=2024-01-31" \
  -H "Authorization: Bearer <token>" \
  -o ventas_enero.pdf

# Only available products in category 3
curl "http://localhost:8000/stats/reporte-productos/xlsx?categoria_id=3&disponible=true" \
  -H "Authorization: Bearer <token>" \
  -o productos_cat3.xlsx

PDF Format

PDF reports are generated with ReportLab using SimpleDocTemplate with US letter page size. Each PDF contains:
  • Title header — e.g., “Reporte de Ventas - Cafetería”
  • Generation timestamp — the date and time the report was produced
  • Filter summary — the date range applied (for reports that accept date filters), rendered in italics
  • Data table — a formatted table with a grey header row, Helvetica-Bold header font, centered alignment, and a grid for all data rows
  • Total row — a light-grey highlighted summary row at the bottom (for sales and expense reports)
The Activity History PDF (reporte-historial) is structured differently — it contains three sequential tables on a single document: recent orders, recent sales, and recent expenses, each limited to the 20 most recent records within the date filter. For single-order receipts, use GET /pedidos/{id}/ticket/pdf instead. Tickets include quantity, product name, unit price, subtotal, and a grand total, and are accessible to admin, caja, and mesero roles.

XLSX Format

XLSX files are generated with openpyxl. Each report contains:
  • A header row in the first row of the sheet
  • One data row per record
  • A totals row appended after the data (for sales and expenses)
  • Auto-adjusted column widths — each column is sized to fit its longest cell value, capped at 30 characters wide, so the file is immediately readable without manual resizing
The Activity History XLSX (reporte-historial) is the exception — it creates a workbook with three worksheets: Pedidos, Ventas, and Gastos, each populated independently with the same date filters applied. This makes it easy to reference all activity from a single file.

Column Reference

Each report’s data table contains the following columns:
ReportColumns
SalesID Venta, Pedido, Cajero, Método Pago, Monto, Fecha
ExpensesID, Descripción, Categoría, Usuario, Monto, Fecha
ProductsID, Nombre, Categoría, Precio, Disponible
OrdersID, Mesa, Mesero, Estado, Total, Fecha
InventoryID, Nombre, Unidad, Stock actual, Stock mínimo, Estado
History (PDF)Three sub-tables: Orders (ID, Mesa, Estado, Fecha), Sales (ID, Pedido, Monto, Fecha), Expenses (ID, Descripción, Monto, Fecha)

Admin Web Panel Integration

The admin web panel proxies these API endpoints and presents download buttons directly in the statistics UI at routes prefixed with /proxy/reporte-*. Admin users can download any report from the browser without constructing curl commands manually. The proxy routes pass the same JWT token and forward query parameters, so date filters entered in the UI are applied to the downloaded file.

Build docs developers (and LLMs) love