namespace ERPCore.Domain.Entities;

/// <summary>
/// Product configuration (FR-MD-11) — a <b>singleton row</b> (single-tenant, docs/00-CORE §1)
/// gating optional product master-data features.
/// <para>
/// <see cref="SubcategoriesEnabled"/> and <see cref="BrandsEnabled"/> are enforced
/// server-side: an Item write carrying a subcategory/brand while the flag is off is
/// rejected with <c>CONFIG_DISABLED</c>. <see cref="ItemTypesEnabled"/> is
/// <b>advisory only</b> — items carry no item-type reference (see <see cref="ItemType"/>),
/// so there is nothing on a write to reject; the frontend honours it by hiding the
/// builder's type section. Reads are never gated, so existing data stays visible after a
/// flag is switched off.
/// </para>
/// Model: docs/10-BACKEND-PHASE1.md Part C.1.
/// </summary>
public class ProductConfig
{
    /// <summary>Always 1 — the singleton row's id.</summary>
    public const int SingletonId = 1;

    public int ConfigId { get; set; }

    public bool SubcategoriesEnabled { get; set; } = true;
    public bool BrandsEnabled { get; set; } = true;
    public bool ItemTypesEnabled { get; set; } = true;

    public DateTime? UpdatedAt { get; set; }

    public int? UpdatedBy { get; set; }
    public User? UpdatedByUser { get; set; }

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