Skip to main content

Reporting

Base path: /api/reporting

All reporting endpoints require Admin auth.

GET /reporting/sales-summary

Total sales revenue from all POS orders.

Response:

{ "total_sales": 12450.00 }

GET /reporting/booking-count

Total number of bookings ever created.

Response:

{ "booking_count": 384 }

GET /reporting/item-breakdown

Top 10 products and top 10 services by revenue from POS orders.

Query parameters: from (date), to (date)

Response:

{
"products": [
{ "product_id": 3, "name": "Shampoo X", "qty_sold": 24, "revenue": 288.00 }
],
"services": [
{ "service_id": 1, "name": "Haircut", "qty_sold": 56, "revenue": 1400.00 }
]
}

GET /reporting/staff-performance

Revenue, completed booking count, and average review rating per staff member.

Query parameters: from (date), to (date)

Response: Array ordered by revenue descending. Staff members with zero revenue and zero bookings are excluded.

[
{
"id": 2,
"name": "Lisa",
"revenue": 3200.00,
"booking_count": 48,
"avg_rating": "4.7",
"review_count": 22
}
]

GET /reporting/retention

Client retention analysis: returning clients, churn list, and average visit frequency.

Query parameters: from (date), to (date), churn_days (integer, default 90)

Response:

{
"active_count": 45,
"returning_count": 32,
"retention_rate": 71,
"avg_visit_days": 28,
"churned": [
{
"id": 12,
"name": "Jane Doe",
"email": "jane@example.com",
"last_booking": "2025-12-01",
"total_spent": 340.00
}
],
"churn_days": 90
}

The churned list is limited to 50 clients ordered by name.


GET /reporting/heatmap

Booking count by day-of-week and hour for a peak-hours heatmap. Excludes cancelled bookings.

Response: Array of { day, hour, count } objects.

[
{ "day": 2, "hour": 10, "count": 14 },
{ "day": 3, "hour": 14, "count": 11 }
]

day uses MariaDB's DAYOFWEEK() convention: 1=Sunday, 2=Monday, ..., 7=Saturday.


GET /reporting/forecast

Revenue forecast based on scheduled (not yet completed) bookings.

Query parameters: days (integer, default 30) — number of days ahead to forecast

Response: Array of { day, expected_revenue, booking_count } objects grouped by day.

[
{ "day": "2026-03-26", "expected_revenue": 425.00, "booking_count": 8 }
]

GET /reporting/promotions

Promotion usage statistics.

Query parameters: from (date), to (date)

Response:

{
"total_used": 38,
"total_discount": 284.50,
"promotions": [
{ "id": 1, "name": "Spring Sale", "code": "SPRING20", "times_used": 14, "total_discount": 112.00 }
]
}

GET /reporting/gift-cards

Gift card overview: sold count/value and outstanding balance.

Query parameters: from (date), to (date)


Date Filtering

All endpoints that accept from/to accept dates in YYYY-MM-DD format. When a to date is provided, it is treated as end-of-day (23:59:59).