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
totalRevenueCentsypriceAtOrderse expresan en centavos;totalBtcSatoshisen satoshis.- En esta versión,
ProductSaleItemno incluyevariantIdnidiscountAmount.
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).