using ERPCore.Domain.Enums;

namespace ERPCore.Domain.Entities;

/// <summary>
/// Item type master (FR-MD-10) — a selectable dimension name such as Color, Size or
/// Material.
/// <para>
/// <b>Deliberately unlinked.</b> Nothing references this entity and it references
/// nothing: there is no value table and no join to <see cref="Item"/>. The chosen
/// values (Red, S, M) are encoded by the client into the generated SKU
/// (e.g. <c>BL-100-0003</c>) and are never stored or parsed server-side — the item list
/// is the record of what was built. See the accepted trade-off in docs/10 Part C.9.
/// </para>
/// <para>
/// It does, however, carry one piece of meaning the client acts on:
/// <see cref="IsMeasurable"/>. So this is no longer purely a dropdown source.
/// </para>
/// Not to be confused with <see cref="Enums.StockNature"/> (Stocked/NonStocked/Service),
/// which is what the old <c>ItemType</c> enum became.
/// Model: docs/10-BACKEND-PHASE1.md Part C.1.
/// </summary>
public class ItemType
{
    public int ItemTypeId { get; set; }
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// When true, this dimension's values are content <b>measurements</b> (500 ml, 1 L) rather
    /// than plain labels (Red, S). The item builder then captures a number + unit per value and
    /// stamps that pair onto each generated item's <see cref="Item.ContentQty"/> /
    /// <see cref="Item.ContentUnit"/>, instead of copying one form-level pair into every variant
    /// — which is what makes "Coca-Cola in 500 ml / 1 L / 250 ml" three correctly sized items.
    /// <para>
    /// This is what lets an apparel <c>Size</c> (S/M/L) stay plain text while a
    /// <c>Pack Size</c>/<c>Volume</c> dimension carries ml/g/L/kg.
    /// </para>
    /// <para>
    /// A client hint only: the server never reads it when writing an item. Each item's pair is
    /// still validated and normalised on its own by <c>ItemContent</c>.
    /// </para>
    /// </summary>
    public bool IsMeasurable { 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; }
}
