namespace ERPCore.Domain.Entities;

/// <summary>
/// FIFO cost layer — a quantity received at a specific unit cost, consumed
/// oldest-first (FR-STK-02). Keyed per item **per warehouse**; quantities and
/// <see cref="UnitCost"/> are in the item's base UOM. Answers valuation
/// ("what's on hand and at what cost"). Model: docs/10 Part C.5.
/// </summary>
public class StockLayer
{
    public int LayerId { get; set; }

    public int ItemId { get; set; }
    public Item? Item { get; set; }

    public int WarehouseId { get; set; }
    public Warehouse? Warehouse { get; set; }

    public int? BatchId { get; set; }
    public Batch? Batch { get; set; }

    public int? SerialId { get; set; }
    public Serial? Serial { get; set; }

    /// <summary>Originating GRN line — carries the inspection hold status for this stock.</summary>
    public int? GrnLineId { get; set; }
    public GrnLine? GrnLine { get; set; }

    public decimal QtyReceived { get; set; }
    public decimal QtyRemaining { get; set; }
    public decimal UnitCost { get; set; }
    public DateTime ReceiptDate { get; set; }
}
