using SolutionErp.Domain.Common;

namespace SolutionErp.Domain.Office;

// Phase 10.3 G-O6 (Mig 39 — S38) — Ticket CNTT helpdesk.
// KHÔNG dùng Workflow V2 (kanban status flow Open → InProgress → Resolved → Closed).
// Auto-assign round-robin + SLA timer DEFER Phase 11.
public class ItTicket : AuditableEntity
{
    public string? MaTicket { get; set; }                 // "IT/2026/001"
    public Guid RequesterUserId { get; set; }
    public string RequesterFullName { get; set; } = string.Empty;

    public string Title { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;

    public ItTicketCategory Category { get; set; }
    public ItTicketPriority Priority { get; set; } = ItTicketPriority.Medium;
    public ItTicketStatus Status { get; set; } = ItTicketStatus.Open;

    public Guid? AssignedToUserId { get; set; }           // IT staff được assign (admin set manual hoặc round-robin defer)
    public string? AssignedToFullName { get; set; }       // denorm

    public DateTime? ResolvedAt { get; set; }
    public string? Resolution { get; set; }               // ghi chú giải pháp (free text replace ItTicketComments thread defer Phase 11)

    // P11-D (Mig 46 — Wave 2) — SLA timer. SlaDueAt = CreatedAt + window theo Priority
    // (Urgent=4h / High=8h / Medium=24h / Low=72h). ItTicketSlaJob (BackgroundService
    // 15 phút) set SlaWarnedSent khi còn ≤20% window + SlaBreached khi quá hạn (notify
    // assignee). NO auto-transition status (khác SlaExpiryJob của HĐ — ticket chỉ cảnh báo).
    public DateTime? SlaDueAt { get; set; }
    public bool SlaWarnedSent { get; set; }
    public bool SlaBreached { get; set; }
}
