namespace Apollinare.Domain.Entities.Warehouse;

/// <summary>
/// Rappresenta un magazzino fisico o logico
/// </summary>
public class WarehouseLocation : BaseEntity
{
    /// <summary>
    /// Codice univoco del magazzino - generato automaticamente
    /// </summary>
    public string Code { get; set; } = string.Empty;

    /// <summary>
    /// Codice alternativo (opzionale, inserito dall'utente)
    /// </summary>
    public string? AlternativeCode { get; set; }

    /// <summary>
    /// Nome descrittivo del magazzino
    /// </summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// Descrizione estesa
    /// </summary>
    public string? Description { get; set; }

    /// <summary>
    /// Indirizzo del magazzino
    /// </summary>
    public string? Address { get; set; }

    /// <summary>
    /// Città
    /// </summary>
    public string? City { get; set; }

    /// <summary>
    /// Provincia
    /// </summary>
    public string? Province { get; set; }

    /// <summary>
    /// CAP
    /// </summary>
    public string? PostalCode { get; set; }

    /// <summary>
    /// Nazione
    /// </summary>
    public string? Country { get; set; } = "Italia";

    /// <summary>
    /// Tipo di magazzino (fisico, logico, transito, reso, etc.)
    /// </summary>
    public WarehouseType Type { get; set; } = WarehouseType.Physical;

    /// <summary>
    /// Se true, è il magazzino predefinito per carichi/scarichi
    /// </summary>
    public bool IsDefault { get; set; }

    /// <summary>
    /// Se attivo può ricevere movimenti
    /// </summary>
    public bool IsActive { get; set; } = true;

    /// <summary>
    /// Ordine di visualizzazione
    /// </summary>
    public int SortOrder { get; set; }

    /// <summary>
    /// Note aggiuntive
    /// </summary>
    public string? Notes { get; set; }

    // Navigation properties
    public ICollection<StockLevel> StockLevels { get; set; } = new List<StockLevel>();
    public ICollection<StockMovement> SourceMovements { get; set; } = new List<StockMovement>();
    public ICollection<StockMovement> DestinationMovements { get; set; } = new List<StockMovement>();
}

/// <summary>
/// Tipo di magazzino
/// </summary>
public enum WarehouseType
{
    /// <summary>
    /// Magazzino fisico standard
    /// </summary>
    Physical = 0,

    /// <summary>
    /// Magazzino logico (virtuale)
    /// </summary>
    Logical = 1,

    /// <summary>
    /// Magazzino di transito
    /// </summary>
    Transit = 2,

    /// <summary>
    /// Magazzino resi
    /// </summary>
    Returns = 3,

    /// <summary>
    /// Magazzino scarti/difettosi
    /// </summary>
    Defective = 4,

    /// <summary>
    /// Magazzino conto lavoro
    /// </summary>
    Subcontract = 5
}
