Spaces:
Sleeping
Sleeping
Ticket Management Implementation Checklist
β Phase 1: Ticket Creation (COMPLETED)
- Ticket model with PERMANENT deduplication strategy (timestamp-based, never cleared)
- Removed project_subcontractor_id (use assignments via project_team)
- Ticket schemas (create/update/response)
- Ticket service (create from sales_order/task)
- Ticket API endpoints (create, list, get, update, reschedule, cancel, stats)
- Supabase migration to remove subcontractor_id column
- Update SalesOrder.promote() to use new ticket service
π² Phase 2: Ticket Assignment (NEXT)
- Assignment model (ticket_assignments table)
- Assignment schemas
- Assignment service (assign, accept, reject, drop)
- Assignment API endpoints
- Self-assignment limit (3 tickets per agent)
π² Phase 3: Ticket Execution
- Status transitions (open β assigned β in_progress β completed)
- GPS tracking integration
- Arrival verification
- Work completion with location capture
π² Phase 4: Ticket Rescheduling
- Reschedule API endpoint
- Customer availability handling
- Reschedule history/audit
π² Phase 5: Ticket Expenses
- Ticket expenses model (fuel, materials, transport)
- Expense creation/approval workflow
- Location-based expense validation
- Expense reports
π² Phase 6: Ticket Inventory
- Equipment assignment to tickets
- Material consumption tracking
- Stock deduction on completion
- Inventory return workflow
π² Phase 7: Ticket Invoicing
- Invoice generation from completed tickets
- Contractor invoicing
- Payment tracking
- Invoice approval workflow
π² Phase 8: Ticket Analytics
- Performance metrics (completion time, SLA compliance)
- Agent performance dashboards
- Regional performance
- Customer satisfaction metrics
π² Phase 9: Ticket Communication
- Ticket comments/notes
- Customer communication tracking
- SMS/Email notifications
- Real-time updates
π² Phase 10: Advanced Features
- Ticket templates
- Bulk operations
- Auto-assignment algorithms
- Route optimization
- Ticket dependencies (prerequisites)
Notes
Deduplication Strategy (CORRECTED - With Reactivation)
dedup_key = MD5(source + source_id + ticket_type + created_at)- PERMANENT - never cleared on completion/cancellation
- Timestamp-based - ensures uniqueness for each creation
- Business Rules:
- One source = One ticket per creation (dedup_key tracks creation instance)
- Same service reactivation: Cancelled ticket β Reactivate (REUSE same ticket/dedup_key)
- Different service: Create NEW sales order β NEW ticket (new dedup_key)
- Space efficient: No duplicate rows for reactivations
- Payment tracking: If customer paid before cancelling, we retain that history
- Customer behavior: Can identify chronic cancellers
Example Scenarios:
- Customer cancels WiFi β Wants same WiFi again β REACTIVATE ticket (update status cancelledβopen)
- Customer had 10Mbps (cancelled) β Now wants 50Mbps β NEW sales order β NEW ticket
- History shows: Multiple sales orders per customer (each with their own ticket)
Ticket Scheduling
scheduled_dateon ticket can be different frompreferred_visit_dateon sales_order- Original sales order date remains unchanged
- Ticket date can be modified for rescheduling (customer availability)
- Reschedule history tracked in notes
Ticket Lifecycle (With Reactivation Support)
1. CREATE: Sales order/task β Ticket created (status=open, permanent dedup_key)
2. ASSIGN: Dispatcher assigns to agent via ticket_assignments (status=assigned)
3. ACCEPT: Agent accepts assignment (status=in_progress)
4. EXECUTE: Agent performs work, logs expenses
5. COMPLETE/CANCEL: Agent completes or customer cancels (status=completed/cancelled)
- Location captured and verified
- Dedup key REMAINS (permanent audit trail)
- Subscription created (for installations if completed)
6. REACTIVATION (Same Service):
- Customer wants same service again
- Find cancelled/completed ticket
- Update: status=open, new dates, add reactivation note
- REUSE same dedup_key (space efficient, payment history preserved)
7. NEW SERVICE:
- Customer wants different package/service
- Create NEW sales order
- Creates NEW ticket (new dedup_key, new creation timestamp)
- History: Multiple tickets for customer (each with own dedup_key)
Subcontractor Assignment
- Removed
project_subcontractor_idfrom tickets table - Subcontractor relationship handled via:
ticket_assignments β users β project_team β project_subcontractors - Migration:
20241116000001_remove_subcontractor_from_tickets.sql
Future Integrations
- Expenses: Track fuel, materials, transport costs
- Inventory: Assign equipment (ONT, cables, etc.)
- Invoicing: Generate contractor invoices
- Assignments: Full assignment history with GPS
- Communication: Customer contact attempts
- Images: Before/after photos for proof of work