namespace PowderCoating.Core.Entities;

/// <summary>
/// Represents a single coating layer applied to a job item.
/// Supports multi-coat configurations (primer, base coat, top coat, clear coat, etc.)
/// </summary>
public class JobItemCoat : BaseEntity
{
    // Parent relationship
    public int JobItemId { get; set; }

    // Coat identification (user-defined)
    public string CoatName { get; set; } = string.Empty; // "Primer", "Base Coat", "Top Coat", etc.
    public int Sequence { get; set; } // 1, 2, 3... for ordering

    // Powder selection (from quote)
    public int? InventoryItemId { get; set; }  // In-stock powder
    public string? ColorName { get; set; }      // Color name
    public int? VendorId { get; set; }          // Vendor for custom powder
    public string? ColorCode { get; set; }      // RAL code, etc.
    public string? Finish { get; set; }         // Gloss, Matte, Textured, etc.

    // Coverage parameters (from quote)
    public decimal CoverageSqFtPerLb { get; set; } = 30m;
    public decimal TransferEfficiency { get; set; } = 65m;

    // Cost information (from quote)
    public decimal? PowderCostPerLb { get; set; }  // $/lb
    public decimal? PowderToOrder { get; set; }     // Pounds estimated to order

    // Job completion tracking
    public decimal? ActualPowderUsedLbs { get; set; }  // Actual powder used when job is completed

    // Powder ordering tracking
    public bool PowderOrdered { get; set; } = false;
    public DateTime? PowderOrderedAt { get; set; }
    public string? PowderOrderedByUserId { get; set; }

    // Powder receiving tracking
    public bool PowderReceived { get; set; } = false;
    public DateTime? PowderReceivedAt { get; set; }
    public string? PowderReceivedByUserId { get; set; }
    public decimal? PowderReceivedLbs { get; set; }

    // Pricing flags
    /// <summary>
    /// When true, the additional layer labor charge is not applied for this coat even if it is
    /// not the first coat in the sequence. Used for clear coats, sealers, etc.
    /// </summary>
    public bool NoExtraLayerCharge { get; set; }

    // Notes
    public string? Notes { get; set; }

    // Navigation properties
    public virtual JobItem JobItem { get; set; } = null!;
    public virtual InventoryItem? InventoryItem { get; set; }
    public virtual Vendor? Vendor { get; set; }
}
