Transport Templates (Auftrags-Vorlagen)
Transport Templates allow you to create reusable configurations for transport orders, streamlining the creation of frequently used transport routes and requirements.
Overview
Transport Templates (Auftrags-Vorlagen) provide a way to:
- Save common transport configurations for quick reuse
- Pre-fill transport creation forms with template data
- Track template usage to identify popular routes
- Define requirements (equipment, certifications, training) per template
- Configure recurring schedules for automated transport generation (coming soon)
Features
Template Management
- Create Templates: Build templates with 4-step wizard (Basic Info, Route & Stops, Requirements, Schedule)
- Edit Templates: Update existing templates while preserving usage history
- Delete Templates: Remove unused templates (with confirmation)
- Template Categories: Organize templates by type (Standard, Express, Bulk, Hazardous, Refrigerated, Custom)
- Priority Levels: Set default priority (Low, Medium, High, Urgent)
Route Configuration
- Origin & Destination Zones: Define start and end points
- Intermediate Stops: Add multiple pickup/delivery points along the route
- Time Estimates: Set load time and estimated duration
- Stop Types: Mark stops as pickup, delivery, or intermediate
Requirements
- Equipment Requirements: Specify required equipment (forklift, pallet jack, etc.)
- Certifications: Define required certifications (hazmat, refrigeration, etc.)
- Training: List required training courses
- Safety Requirements: Link to Safety Pro checklists
- Mandatory vs Optional: Mark requirements as mandatory or optional
Usage Tracking
- Usage History: View all transports created from a template
- Usage Count: See how many times each template has been used
- Template Snapshots: Store template state at time of use for audit trail
Permissions
Admin & Mitarbeiter
- ✅ Create templates
- ✅ Edit templates
- ✅ Delete templates
- ✅ View all templates
- ✅ Generate transports from templates
- ✅ View usage history
Fahrer
- ✅ View templates (read-only)
- ❌ Cannot create, edit, or delete templates
- ✅ Can use templates to create transports (if enabled)
Creating a Template
Step 1: Basic Information
- Template Name: Enter a descriptive name (e.g., "Standard Delivery Zone A → B")
- Description: Optional description of the template
- Category: Select category (Standard, Express, Bulk, Hazardous, Refrigerated, Custom)
- Priority: Set default priority level
Step 2: Route & Stops
- Origin Zone: Select the starting zone
- Destination Zone: Select the destination zone
- Load Time Estimate: Estimated loading time in minutes
- Estimated Duration: Total transport duration in minutes
- Intermediate Stops: Add any intermediate pickup/delivery points
Step 3: Requirements
- Add Requirements: Click "Add Requirement" for each requirement
- Requirement Type: Select type (Equipment, Certification, Training, Safety, Custom)
- Requirement Value: Enter the specific requirement (e.g., "forklift", "hazmat_cert")
- Mandatory: Mark as mandatory or optional
Step 4: Schedule (Coming Soon)
Recurring schedule configuration will be available in a future version.
Using Templates
Generate Transport Directly
- Navigate to Transport Templates
- Click the Play icon (▶) on a template
- System automatically creates a transport with template data
- Transport appears in the shipments list
Use Template in Create Dialog
- Navigate to Transport Templates
- Click the File icon (📄) on a template
- Create Transport dialog opens with pre-filled data
- Review and modify as needed
- Click Create Order
Integration
Routing Engine
When a template includes route information:
- Auto-route selection: System suggests optimal route if Routing Engine is enabled
- Distance calculation: Uses zone coordinates for route planning
- Multi-stop optimization: Optimizes order of intermediate stops
Safety Pro
When Safety Pro is active:
- Checklist linking: Link templates to Safety Pro checklists
- Auto-risk assessment: System performs risk assessment based on template requirements
- Training validation: Validates driver training before assignment
Auto-Assignment
When auto-assignment is enabled:
- Driver suggestions: System suggests drivers based on template requirements
- Zone permissions: Validates driver zone permissions automatically
- Equipment availability: Checks equipment availability if specified
API Usage
Get Templates
typescript
import { useTransportTemplates } from '@/lib/queries/transportTemplates';
function MyComponent() {
const { data: templates } = useTransportTemplates({
is_active: true,
category: 'standard'
});
return (
<div>
{templates?.map(template => (
<div key={template.id}>{template.template_name}</div>
))}
</div>
);
}Create Template
typescript
import { useCreateTransportTemplate } from '@/lib/queries/transportTemplates';
function CreateTemplate() {
const createTemplate = useCreateTransportTemplate();
const handleCreate = async () => {
await createTemplate.mutateAsync({
template_name: 'Standard Delivery',
category: 'standard',
priority: 'medium',
origin_zone_id: 'zone-a-id',
destination_zone_id: 'zone-b-id',
stops: [
{
zone_id: 'zone-c-id',
stop_order: 1,
stop_type: 'pickup',
}
],
requirements: [
{
requirement_type: 'equipment',
requirement_value: 'forklift',
is_mandatory: true,
}
]
});
};
}Generate Transport from Template
typescript
import { useGenerateTransportFromTemplate } from '@/lib/queries/transportTemplates';
function GenerateTransport() {
const generateTransport = useGenerateTransportFromTemplate();
const handleGenerate = async () => {
const result = await generateTransport.mutateAsync({
template_id: 'template-id',
name: 'Custom Name', // Optional override
priority: 'high', // Optional override
driver_id: 'driver-id', // Optional override
});
console.log('Created transport:', result.order_number);
};
}Best Practices
Naming Convention: Use descriptive names that indicate route and purpose
- ✅ "Standard Delivery Zone A → B"
- ❌ "Template 1"
Category Selection: Choose appropriate category for better organization
- Use "Hazardous" for dangerous goods
- Use "Express" for time-sensitive deliveries
- Use "Bulk" for large-volume transports
Requirements: Be specific with requirements
- ✅ "forklift_certification_level_2"
- ❌ "forklift"
Time Estimates: Provide realistic estimates
- Base on historical data when available
- Consider zone distance and complexity
Template Maintenance: Regularly review and update templates
- Archive unused templates instead of deleting
- Update requirements as regulations change
- Adjust time estimates based on actual performance
Troubleshooting
Template Not Appearing
- Check if template is marked as Active
- Verify user has access to template's tenant
- Check RLS policies for template visibility
Cannot Generate Transport
- Ensure template is Active
- Verify origin and destination zones exist
- Check that required zones are accessible to user
Requirements Not Applied
- Verify requirements are marked as Mandatory
- Check that Safety Pro integration is enabled (for safety requirements)
- Ensure equipment/certifications exist in system