- 1) Purpose
- 2) Scope
- 3) Key Concepts & Definitions
- 4) User Stories
- 5) UI/UX
- 6) Data Model (proposed)
- 7) Permissions & Visibility
- 8) API (illustrative)
- 9) Business Rules
- 10) Audit & Logging
- 11) Edge Cases
- 12) Acceptance Criteria
Date: 31‑Aug‑2025
Add a Customer Details capability under Super Admin → Customers to manage per‑facility onboarding defaults for a customer. During facility onboarding, the operator can:
Facility Template. Reusable JSON config applied per facility at onboarding (or later): widgets, KPIs, device table columns, alert prefs, thresholds, locale/timezone defaults, certification display rules.
Off‑Time Template. Reusable policy defining when the facility is considered off (e.g., nights/weekends/maintenance). Supports timezones, recurrence rules (RRULE), exceptions.
Assigned Customer Visibility. Super Admin sees all facilities for customers they manage; Admins see only facilities/customers assigned.
Step: Defaults
Read current assignments; Change action (role‑gated) with audit note prompt.
FacilityTemplate {
id: UUID,
name: string,
scope: enum[global, customer],
customer_id: UUID | null,
version: string,
description: string,
payload: jsonb, // KPI layout, device columns, alerts prefs, etc.
created_by: user_id,
created_at: timestamp,
updated_at: timestamp,
status: enum[active, archived]
}
OffTimeTemplate {
id: UUID,
name: string,
customer_id: UUID | null,
timezone: IANA_tz,
rrule: string, // e.g., RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR
daily_windows: [ { day: MON, start: "20:00", end: "06:00+1" } ],
exceptions: [ { date: "2025-09-12", include: false } ],
effective_from: date,
effective_to: date | null,
created_by: user_id,
created_at: timestamp,
updated_at: timestamp,
status: enum[active, archived]
}
FacilitySettings {
facility_id: UUID (PK/FK),
facility_template_id: UUID | null,
off_time_template_id: UUID | null,
overrides: jsonb, // per-facility deviations from template
updated_by: user_id,
updated_at: timestamp
}
Summary matrix:
GET /customers/{id}/templates/facility
POST /customers/{id}/templates/facility
PATCH /templates/facility/{templateId}
GET /customers/{id}/templates/offtime
POST /customers/{id}/templates/offtime
PATCH /templates/offtime/{templateId}
GET /customers/{id}/facilities // includes template bindings
POST /facilities // includes facility_template_id, off_time_template_id
PATCH /facilities/{id}/settings // update bindings/overrides
Response embed example:
{
"facility_id": "...",
"facility_template": {"id": "...", "name": "Retail‑Lite v1"},
"off_time": {"id": "...", "summary": "Mon–Fri 20:00–06:00, Weekend all‑day"}
}
Log create/update/archive on templates and any facility template re‑assignment with: actor, timestamp, reason, previous → new values. Expose in Facility Settings → Policies → History.