using ERPCore.Domain.Enums;

namespace ERPCore.Domain.Entities;

/// <summary>
/// Item master (FR-MD-01). Mutable aggregate: carries a <see cref="RowVersion"/>
/// concurrency token surfaced as an ETag (docs/10 Part C.10). SKU is unique.
/// Model: docs/10-BACKEND-PHASE1.md Part C.1.
/// </summary>
public class Item
{
    public int ItemId { get; set; }
    public string Sku { get; set; } = string.Empty;
    public string Name { get; set; } = string.Empty;
    public string? Description { get; set; }

    public int CategoryId { get; set; }
    public Category? Category { get; set; }

    public int BaseUomId { get; set; }
    public Uom? BaseUom { get; set; }

    public int? DefaultVendorId { get; set; }
    public Vendor? DefaultVendor { get; set; }

    public ItemType ItemType { get; set; }
    public TrackingMode TrackingMode { get; set; }
    public string? TaxClass { get; set; }
    public EntityStatus Status { get; set; } = EntityStatus.Active;

    public DateTime CreatedAt { get; set; }
    public DateTime? UpdatedAt { get; set; }

    /// <summary>PostgreSQL xmin-backed optimistic concurrency token (ETag source).</summary>
    public uint RowVersion { get; set; }

    public ICollection<ItemReorder> ReorderSettings { get; set; } = new List<ItemReorder>();
    public ICollection<UomConversion> UomConversions { get; set; } = new List<UomConversion>();
}
