namespace SIGCM2.Domain.Entities;

/// <summary>
/// PRD-003 — Immutable record representing a price snapshot for a Product.
/// Business dates are Cat2 (civil Argentina dates, DateOnly). Forward-only — no mutations.
/// PriceValidTo = null means the row is the currently active price.
/// </summary>
public sealed record ProductPrice(
    long Id,
    int ProductId,
    decimal Price,
    DateOnly PriceValidFrom,
    DateOnly? PriceValidTo,
    DateTime FechaCreacion)
{
    /// <summary>True if this row is the currently active price (PriceValidTo is null).</summary>
    public bool IsActive => PriceValidTo is null;

    /// <summary>
    /// True if this price's window covers the given civil date (inclusive on both ends).
    /// An active row (PriceValidTo = null) covers any date on or after PriceValidFrom.
    /// </summary>
    public bool CoversDate(DateOnly date)
        => PriceValidFrom <= date && (PriceValidTo is null || PriceValidTo >= date);
}
