Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ierinconc/billar-pro-backend/llms.txt

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

The reports module aggregates data from closed session records and provides five distinct views of hall revenue across multiple time windows — a single day, an arbitrary date range, or a full calendar month. All computations are performed in-memory by iterating over the matching Sesion rows returned from the database, keeping the queries simple and the logic transparent.
Every report endpoint filters strictly on sessions where horaFin IS NOT NULL. Sessions that are currently open (table still occupied) are never included in any report figure. This guarantees that all numbers reflect fully settled, closed transactions only.

1. Revenue Summary — ReporteDTO

The summary report aggregates the total money earned from table time and product sales for a given window. Three sub-endpoints share the same ReporteDTO response shape.

Response fields

FieldTypeDescription
totalMesasDoubleSum of sesion.totalMesa across all matching sessions.
totalConsumosDoubleSum of sesion.totalConsumos across all matching sessions.
totalGeneralDoubleSum of sesion.totalGeneral — equivalent to totalMesas + totalConsumos.
numeroSesionesIntegerCount of closed sessions in the requested window.

Daily summary

Requires a single date expressed as YYYY-MM-DD.
GET /api/reportes/diario?fecha=2025-01-15
curl -X GET "http://localhost:8080/api/reportes/diario?fecha=2025-01-15" \
  -H "Authorization: Bearer <token>"
Example response:
{
  "totalMesas": 48000.0,
  "totalConsumos": 15200.0,
  "totalGeneral": 63200.0,
  "numeroSesiones": 6
}

Weekly summary

Requires explicit start and end dates. The range is inclusive on both ends.
GET /api/reportes/semanal?inicio=2025-01-13&fin=2025-01-19
curl -X GET "http://localhost:8080/api/reportes/semanal?inicio=2025-01-13&fin=2025-01-19" \
  -H "Authorization: Bearer <token>"

Monthly summary

Requires mes (integer, 1–12) and anio (four-digit year). The service computes the first and last day of the month internally using LocalDate.of(anio, mes, 1) and primerDia.withDayOfMonth(primerDia.lengthOfMonth()).
GET /api/reportes/mensual?mes=1&anio=2025
curl -X GET "http://localhost:8080/api/reportes/mensual?mes=1&anio=2025" \
  -H "Authorization: Bearer <token>"

2. Income by Table — IngresoPorMesaDTO

Breaks down revenue by individual table for a given window. Results are returned as a list — one entry per table that had at least one closed session in the period. The list is not guaranteed to be in any particular order.

Response fields

FieldTypeDescription
numeroIntegerThe table’s human-readable number (e.g., 3).
totalRecaudadoDoubleSum of sesion.totalGeneral for all sessions on this table within the window.
numeroSesionesIntegerCount of closed sessions on this table within the window.

Endpoints

GET /api/reportes/ingresos-por-mesa/diario?fecha=2025-01-15
GET /api/reportes/ingresos-por-mesa/semanal?inicio=2025-01-13&fin=2025-01-19
GET /api/reportes/ingresos-por-mesa/mensual?mes=1&anio=2025
# Daily breakdown by table
curl -X GET "http://localhost:8080/api/reportes/ingresos-por-mesa/diario?fecha=2025-01-15" \
  -H "Authorization: Bearer <token>"
Example response:
[
  { "numero": 1, "totalRecaudado": 24000.0, "numeroSesiones": 3 },
  { "numero": 3, "totalRecaudado": 18000.0, "numeroSesiones": 2 },
  { "numero": 5, "totalRecaudado": 12000.0, "numeroSesiones": 1 }
]

3. Income by Day — IngresoPorDiaDTO

Produces a time-series of daily revenue totals within an arbitrary date range. The service groups sessions by their fecha field (the calendar date on which they were closed) and returns the list sorted ascending by date.

Response fields

FieldTypeDescription
fechaLocalDateThe calendar date (YYYY-MM-DD).
totalMesasDoubleSum of table-time charges for all sessions closed on this date.
totalConsumosDoubleSum of product consumption charges for all sessions closed on this date.
totalGeneralDoubletotalMesas + totalConsumos for this date.

Endpoint

GET /api/reportes/ingresos-por-dia?inicio=2025-01-01&fin=2025-01-31
curl -X GET "http://localhost:8080/api/reportes/ingresos-por-dia?inicio=2025-01-01&fin=2025-01-31" \
  -H "Authorization: Bearer <token>"
Example response:
[
  {
    "fecha": "2025-01-13",
    "totalMesas": 16000.0,
    "totalConsumos": 4800.0,
    "totalGeneral": 20800.0
  },
  {
    "fecha": "2025-01-14",
    "totalMesas": 22000.0,
    "totalConsumos": 6100.0,
    "totalGeneral": 28100.0
  }
]

4. Top Products — ProductoTopDTO

Identifies the best-selling products within a window by aggregating consumption records that belong to closed sessions. Results are sorted by cantidadVendida descending and capped at the top 10 products.

Response fields

FieldTypeDescription
nombreStringProduct name as stored in the catalog.
cantidadVendidaIntegerTotal units sold across all matching closed-session consumptions.
totalRecaudadoDoubleSum of consumo.subtotal for this product within the window.

Endpoints

GET /api/reportes/productos-top/diario?fecha=2025-01-15
GET /api/reportes/productos-top/semanal?inicio=2025-01-13&fin=2025-01-19
GET /api/reportes/productos-top/mensual?mes=1&anio=2025
# Weekly top products
curl -X GET "http://localhost:8080/api/reportes/productos-top/semanal?inicio=2025-01-13&fin=2025-01-19" \
  -H "Authorization: Bearer <token>"
Example response:
[
  { "nombre": "Gatorade 500ml", "cantidadVendida": 42, "totalRecaudado": 147000.0 },
  { "nombre": "Agua Postobón 600ml", "cantidadVendida": 38, "totalRecaudado": 76000.0 },
  { "nombre": "Papas Margarita", "cantidadVendida": 25, "totalRecaudado": 62500.0 }
]

5. Average Ticket — TicketPromedioDTO

Computes per-session averages over an arbitrary date range, giving a measure of how much each closed game generates on average in table time, product sales, and combined total.

Response fields

FieldTypeDescription
totalFacturadoDoubleGrand total (totalGeneral) across all sessions in the range.
totalMesasDoubleCumulative table-time revenue across all sessions in the range.
totalConsumosDoubleCumulative product-consumption revenue across all sessions in the range.
partidasCerradasIntegerNumber of closed sessions in the range.
ticketPromedioDoubletotalFacturado / partidasCerradas. Returns 0.0 if there are no sessions.
promedioMesaDoubletotalMesas / partidasCerradas. Returns 0.0 if there are no sessions.
promedioConsumosDoubletotalConsumos / partidasCerradas. Returns 0.0 if there are no sessions.

Endpoint

GET /api/reportes/ticket-promedio?inicio=2025-01-01&fin=2025-01-31
curl -X GET "http://localhost:8080/api/reportes/ticket-promedio?inicio=2025-01-01&fin=2025-01-31" \
  -H "Authorization: Bearer <token>"
Example response:
{
  "totalFacturado": 420000.0,
  "totalMesas": 312000.0,
  "totalConsumos": 108000.0,
  "partidasCerradas": 48,
  "ticketPromedio": 8750.0,
  "promedioMesa": 6500.0,
  "promedioConsumos": 2250.0
}

Quick Reference

ReportEndpointTime params
Daily summaryGET /api/reportes/diario?fecha=YYYY-MM-DD
Weekly summaryGET /api/reportes/semanal?inicio=YYYY-MM-DD&fin=YYYY-MM-DD
Monthly summaryGET /api/reportes/mensual?mes=M&anio=YYYY
Income by table (daily)GET /api/reportes/ingresos-por-mesa/diario?fecha=YYYY-MM-DD
Income by table (weekly)GET /api/reportes/ingresos-por-mesa/semanal?inicio=YYYY-MM-DD&fin=YYYY-MM-DD
Income by table (monthly)GET /api/reportes/ingresos-por-mesa/mensual?mes=M&anio=YYYY
Income by dayGET /api/reportes/ingresos-por-dia?inicio=YYYY-MM-DD&fin=YYYY-MM-DD
Top products (daily)GET /api/reportes/productos-top/diario?fecha=YYYY-MM-DD
Top products (weekly)GET /api/reportes/productos-top/semanal?inicio=YYYY-MM-DD&fin=YYYY-MM-DD
Top products (monthly)GET /api/reportes/productos-top/mensual?mes=M&anio=YYYY
Average ticketGET /api/reportes/ticket-promedio?inicio=YYYY-MM-DD&fin=YYYY-MM-DD

Build docs developers (and LLMs) love