feat(reports): capacity-based utilization + report CSVs

Utilization now measures booked minutes against each member's
availability-rule capacity in the tenant timezone, replacing the
confirmed-share proxy. StaffMetric exposes booked/capacity minutes.

New endpoints: GET /v1/export/staff-report.csv (reuses StaffMetrics)
and GET /v1/export/service-report.csv (per-service bookings/cancelled/
revenue, class bookings rolled up). Export buttons on the staff
performance panel and services page.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Tomas DvorakandDevin committed 2026-09-18 17:10:15 +02:00
1 parent 2464aa45fa
commit 7b9080eb1c
13 files changed
+541 -33

No files matched your search

+103 -1
View File
@@ -724,6 +724,46 @@ export interface paths {
patch?: never;
trace?: never;
};
"/v1/export/service-report.csv": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/**
* Export per-service booking report as CSV
* @description Bookings, cancellations, and revenue aggregated per catalog service over a trailing window. Class bookings roll into a final "class sessions" row when present.
*/
get: operations["exportServiceReportCsv"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/v1/export/staff-report.csv": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
/**
* Export per-staff performance report as CSV
* @description Summarized per-staff metrics — bookings, completed, cancelled, booked and capacity minutes, capacity-based utilization, revenue — over a trailing window. Same aggregation as `GET /v1/metrics/staff`.
*/
get: operations["exportStaffReportCsv"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/v1/internal/jobs/reminders/dispatch": {
parameters: {
query?: never;
@@ -1603,8 +1643,12 @@ export interface components {
tenantId: string;
};
StaffMetric: {
/** @description Sum of non-cancelled booking durations in the window */
bookedMinutes: number;
bookings: number;
cancelled: number;
/** @description Sum of the member's availability-rule minutes across the window, evaluated on local dates in the tenant timezone */
capacityMinutes: number;
completed: number;
displayName: string;
/**
@@ -1614,7 +1658,7 @@ export interface components {
revenueCents: number;
/** Format: uuid */
staffId: string;
/** @description Share of bookings that stayed confirmed, 0-100 */
/** @description bookedMinutes / capacityMinutes as a percentage; 0 when the member has no availability rules */
utilizationPercent: number;
};
StaffMetricsResponse: {
@@ -3555,6 +3599,64 @@ export interface operations {
};
};
};
exportServiceReportCsv: {
parameters: {
query?: {
days?: number;
};
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description CSV file download */
200: {
headers: {
[name: string]: unknown;
};
content: {
"text/csv": string;
};
};
/** @description Tenant membership not found */
404: {
headers: {
[name: string]: unknown;
};
content?: never;
};
};
};
exportStaffReportCsv: {
parameters: {
query?: {
days?: number;
};
header?: never;
path?: never;
cookie?: never;
};
requestBody?: never;
responses: {
/** @description CSV file download */
200: {
headers: {
[name: string]: unknown;
};
content: {
"text/csv": string;
};
};
/** @description Tenant membership not found */
404: {
headers: {
[name: string]: unknown;
};
content?: never;
};
};
};
dispatchReminderJobs: {
parameters: {
query?: never;