using ERPCore.Domain.Enums;

namespace ERPCore.Dtos.Stock;

/// <summary>Stock enquiry (docs/11 §5.1). available = onHand − onHold − reserved − inTransit(out).</summary>
public sealed record StockOnHandDto(
    int ItemId, int WarehouseId, decimal OnHand, decimal Available,
    decimal OnHold, decimal InTransit, decimal Reserved, DateTime AsOf);

/// <summary>A stock-ledger row (docs/11 §5.2).</summary>
public sealed record StockLedgerRowDto(
    int LedgerId, int ItemId, int WarehouseId, int? BinId, int? BatchId, int? SerialId,
    Direction Direction, decimal QtyBase, decimal UnitCost, decimal Value, decimal RunningBalance,
    string SourceDocType, int SourceDocId, int UserId, DateTime CreatedAt);

/// <summary>An open FIFO layer in a valuation (docs/11 §5.3).</summary>
public sealed record StockValuationLayerDto(int LayerId, decimal QtyRemaining, decimal UnitCost, decimal Value, DateTime ReceiptDate);

/// <summary>Valuation of on-hand stock from open FIFO layers (docs/11 §5.3).</summary>
public sealed record StockValuationDto(
    int ItemId, int WarehouseId, IReadOnlyList<StockValuationLayerDto> Layers,
    decimal TotalQty, decimal TotalValue, string Currency, string CostingMethod);
