using System.ComponentModel.DataAnnotations;

namespace Extrudex.API.DTOs.PrintJobs;

/// <summary>
/// Response DTO for cost-per-print calculation. Contains the full cost
/// breakdown and any warnings about missing or incomplete data.
/// </summary>
public class CostPerPrintResponse
{
    /// <summary>The print job identifier this result belongs to.</summary>
    public Guid PrintJobId { get; set; }

    /// <summary>Human-readable name of the print job.</summary>
    public string PrintName { get; set; } = string.Empty;

    /// <summary>The spool identifier that provided filament.</summary>
    public Guid SpoolId { get; set; }

    /// <summary>Serial number of the spool.</summary>
    public string SpoolSerial { get; set; } = string.Empty;

    /// <summary>Total millimeters of filament extruded.</summary>
    public decimal MmExtruded { get; set; }

    /// <summary>Derived grams consumed for this print.</summary>
    public decimal GramsDerived { get; set; }

    /// <summary>The spool's purchase price. Null if not recorded.</summary>
    public decimal? PurchasePrice { get; set; }

    /// <summary>The spool's total weight in grams when full.</summary>
    public decimal? WeightTotalGrams { get; set; }

    /// <summary>Cost per gram of filament. Null if purchase price or total weight is missing.</summary>
    public decimal? CostPerGram { get; set; }

    /// <summary>Calculated cost of this print job. Null if cost data is incomplete.</summary>
    public decimal? CostPerPrint { get; set; }

    /// <summary>
    /// Warnings about missing or incomplete data. Empty when all data is available
    /// and the calculation succeeded.
    /// </summary>
    public List<string> Warnings { get; set; } = new();
}

/// <summary>
/// Request DTO for batch cost calculation by spool. Returns cost breakdowns
/// for all print jobs associated with the specified spool.
/// </summary>
public class SpoolCostRequest
{
    /// <summary>The unique identifier of the spool to calculate costs for.</summary>
    [Required(ErrorMessage = "SpoolId is required.")]
    public Guid SpoolId { get; set; }
}

/// <summary>
/// Response DTO for spool-level cost calculation. Contains cost breakdowns
/// for all print jobs on the spool, plus a total cost summary.
/// </summary>
public class SpoolCostResponse
{
    /// <summary>The spool identifier.</summary>
    public Guid SpoolId { get; set; }

    /// <summary>Serial number of the spool.</summary>
    public string SpoolSerial { get; set; } = string.Empty;

    /// <summary>The spool's purchase price. Null if not recorded.</summary>
    public decimal? PurchasePrice { get; set; }

    /// <summary>The spool's total weight in grams when full.</summary>
    public decimal? WeightTotalGrams { get; set; }

    /// <summary>Cost per gram of filament. Null if cost data is incomplete.</summary>
    public decimal? CostPerGram { get; set; }

    /// <summary>Total grams consumed across all print jobs on this spool.</summary>
    public decimal TotalGramsConsumed { get; set; }

    /// <summary>Total calculated cost across all print jobs. Null if any job has missing data.</summary>
    public decimal? TotalCost { get; set; }

    /// <summary>Number of print jobs included in this calculation.</summary>
    public int JobCount { get; set; }

    /// <summary>
    /// Individual cost breakdowns per print job. Jobs with missing data
    /// will have null cost fields and populated warnings.
    /// </summary>
    public List<CostPerPrintResponse> Jobs { get; set; } = new();

    /// <summary>
    /// Aggregate warnings about missing data across all jobs.
    /// </summary>
    public List<string> Warnings { get; set; } = new();
}