using ERPCore.Domain.Enums;

namespace ERPCore.Domain.Entities;

/// <summary>
/// Immutable, append-only stock ledger (FR-STK-01, FR-X-05). One row per costed
/// movement; answers history ("what moved, when, by whom"). The originating
/// document is referenced polymorphically via
/// <see cref="SourceDocType"/>/<see cref="SourceDocId"/> (no hard FK per type) so
/// new transaction types write here without a schema change. Model: docs/10 Part C.5.
/// </summary>
public class StockLedger
{
    public int LedgerId { get; set; }

    public int ItemId { get; set; }
    public int WarehouseId { get; set; }
    public int? BinId { get; set; }
    public int? BatchId { get; set; }
    public int? SerialId { get; set; }
    public int UserId { get; set; }

    public Direction Direction { get; set; }
    public decimal QtyBase { get; set; }
    public decimal UnitCost { get; set; }
    public decimal Value { get; set; }
    public decimal RunningBalance { get; set; }

    public string SourceDocType { get; set; } = string.Empty;
    public int SourceDocId { get; set; }
    public DateTime CreatedAt { get; set; }
}
