Saltar al contenido principal
Versión: v0.7.1-beta

Reports

Reportes​

Endpoints para generar reportes de ventas por producto.

GET /reports​

Genera un reporte de ventas por producto, con filtros opcionales.

Authorization: reports_read

Query Parameters (todos opcionales):

  • period (string): periodo predefinido (ej. day, week, month).
  • productName (string): filtra por nombre de producto.
  • userId (string): filtra por usuario.
  • paymentMethod (string): filtra por mĆ©todo de pago.
  • startDate (string, YYYY-MM-DD): fecha de inicio.
  • endDate (string, YYYY-MM-DD): fecha de fin.
Reglas de fechas

startDate y endDate deben usarse juntas (ambas o ninguna) y startDate no puede ser posterior a endDate. El formato debe ser YYYY-MM-DD; de lo contrario se devuelve 400.

cURL Example:

curl -X GET "http://127.0.0.1:9154/reports?startDate=2025-01-01&endDate=2025-01-31&paymentMethod=Efectivo" \
-H "Cookie: accessToken=$ACCESS_TOKEN"

Response Body (Ɖxito - 200 OK): objeto ProductSalesReport.

{
"totalRevenueCents": 150000,
"totalItemsSold": 12,
"totalBtcSatoshis": 0,
"sales": [
{
"orderId": "order-uuid",
"productName": "CafƩ americano",
"quantity": 2,
"priceAtOrder": 25000,
"userName": "Ana GarcĆ­a",
"paymentMethod": "Efectivo",
"saleDate": "2025-01-15T14:30:00Z",
"satoshiAmount": null,
"exchangeRateAtPayment": null,
"exchangeRateCurrency": null,
"fiatAmountAtPayment": null,
"paymentId": "payment-uuid"
}
]
}

Response Body (ParƔmetros invƔlidos - 400 Bad Request):

{ "message": "Invalid startDate: 2025-13-01. Expected format YYYY-MM-DD" }

Notas​

Modelo
  • totalRevenueCents y priceAtOrder se expresan en centavos; totalBtcSatoshis en satoshis.
  • En esta versión, ProductSaleItem no incluye variantId ni discountAmount.
Reportes relacionados

Otros reportes de órdenes viven en Restaurant / Orders:

  • GET /orders/with-payments — órdenes con información de pago (orders_read).
  • GET /orders/total-sales/{date} — total de ventas por fecha (orders_read).