Locations
Hierarchical location management with multi-level support and automatic status updates
Overview
The Locations feature is a hierarchical location management system that supports up to 4 levels of organizational structure. It provides comprehensive location management including status tracking, provider associations, user permissions, and automated status updates based on dates.
Hierarchical Structure
The system supports flexible organizational hierarchies with 1-4 levels:
- Level 1: Direct locations only
- Level 2: Group → Locations (e.g., Division → Locations)
- Level 3: Group → Group → Locations (e.g., Division → District → Locations)
- Level 4: Group → Group → Group → Locations (e.g., Region → Division → District → Locations)
The depth is configured per tenant via tenantSettingsRow.locationsDepth.
Database Models
Location Model
Primary model for individual locations with fields including:
- Basic info:
name,code,description,status - Address:
streetAddressLine1/2,city,stateProvince,postalCode,country - Contact:
phone,email,managerName,managerEmail - Coordinates:
latitude,longitude,timeZone - Important dates:
preSaleStartDate,openingDate,closingDate - Parent relationships:
parentLevel1Id,parentLevel2Id,parentLevel3Id,parentLevel4Id
LocationLevel Model
Represents organizational groups/folders:
level: Numeric level (1-4)type: Type of group (e.g., "division", "district")- Owner information and parent relationships
Routes
Main Routes
/app/{tenant}/locations- List all locations and levels/app/{tenant}/locations/{id}- Individual location details (tabbed interface)/app/{tenant}/locations/levels/{id}- Location level management/app/{tenant}/locations/export- CSV export with filters
Key Features
Location Status Management
Locations have automatic status transitions based on configured dates:
- Pre-Sale: When
preSaleStartDateis reached - Open: When
openingDateis reached - Closed: When
closingDateis reached - Temporarily Closed: Manual override (not auto-updated)
Status updates happen automatically via cron job (location-status-update).
Provider Integration
Locations can be associated with providers through LocationProvider junction table:
- Multiple providers per location
- Activation/deactivation tracking
- Provider contracts and types
User Permissions
Two permission models:
-
LocationUser: Direct location access
- User assigned to specific locations
- Role-based permissions per location
-
LocationLevelUser: Group-level access
- User assigned to location levels
- Inherits access to all child locations
Operating Hours
Flexible operating hours system:
- Daily schedules with open/close times
- Individual 24-hour flags per day
- Stored as JSON in
operatingHoursfield
Format:
[
{ "day": 1, "open": "09:00", "close": "17:00", "is24Hours": false },
{ "day": 2, "open": "09:00", "close": "17:00", "is24Hours": false }
]Import/Export
- Import: Bulk location creation via CSV
- Export: Full data export with filters
- Maintains data relationships during import
- Validates required fields and formats
Website Configuration
Each location can have its own website settings:
- Custom URL and title
- Template selection
- Social media links
- HTML code injection
- Online booking configuration
Notes and Activity Tracking
- LocationNote: User and system notes
- LocationChangeLog: Detailed audit trail
- Tracks all field changes with before/after values
- User attribution for changes
Cron Jobs
Location Status Update Cron
Automatically updates location statuses based on configured dates:
- Type:
location-status-update - Frequency: Can be scheduled daily
- Process:
- Queries all locations with date fields
- Calculates correct status using
calculateLocationStatus() - Updates mismatched statuses
- Creates system notes for changes
- Skips "temporarily-closed" locations
Search and Filtering
Locations support comprehensive filtering:
- Text search: Name, code, address fields
- Status filter: Open, closed, pre-sale, etc.
- Level filter: By parent groups
- Provider filter: By associated providers
- User permissions: Automatically applied
Best Practices
- Hierarchical Design: Choose appropriate depth (1-4) based on organizational structure
- Status Management: Use date fields for automatic status transitions
- Permissions: Assign users at appropriate levels for inherited access
- Audit Trail: All changes are tracked in LocationChangeLog
- Bulk Operations: Use import/export for large-scale changes
- Provider Management: Link providers at location level for granular control
Common Operations
Creating a Location
- Navigate to
/app/{tenant}/locations - Click "Add Location"
- Select parent level (if applicable)
- Fill required fields: name, address, contact
- Configure optional settings: website, hours, dates
- Save and location status auto-calculates
Bulk Import
- Download template from locations page
- Fill CSV with location data
- Upload via import dialog
- System validates and creates locations
- Maintains parent relationships
Status Override
- Edit location
- Go to Blend tab
- Change status to "temporarily-closed"
- This prevents automatic updates
Managing Operating Hours
- Edit location
- Go to Website tab
- Set hours for each day
- Toggle 24-hour operation per day
- Changes tracked in activity log
Integration Points
- Providers: Via LocationProvider junction
- Employees: Via Employee.locationId
- Users: Via LocationUser and LocationLevelUser
- Apps: Various apps can reference locations
- Contracts: Through provider associations
- Audiences: Location-based audience segmentation

