using Extrudex.Domain.Base;
using Extrudex.Domain.Enums;
namespace Extrudex.Domain.Entities;
///
/// Represents a single filament usage log entry. Records how much filament
/// was consumed, by which printer, at what time, and optionally linked to
/// a print job. This provides a fine-grained audit trail of filament consumption
/// independent of print job lifecycle.
///
public class UsageLog : AuditableEntity
{
///
/// Foreign key to the spool that provided the filament.
///
public Guid SpoolId { get; set; }
///
/// Navigation to the spool that provided the filament.
///
public Spool Spool { get; set; } = null!;
///
/// Foreign key to the printer that consumed the filament.
/// Nullable to support manual entries without a specific printer.
///
public Guid? PrinterId { get; set; }
///
/// Navigation to the printer that consumed the filament.
///
public Printer? Printer { get; set; }
///
/// Foreign key to the print job associated with this usage entry.
/// Nullable because usage can be logged before or without a print job.
///
public Guid? PrintJobId { get; set; }
///
/// Navigation to the print job associated with this usage entry.
///
public PrintJob? PrintJob { get; set; }
///
/// The number of grams of filament consumed in this usage event.
///
public decimal GramsUsed { get; set; }
///
/// The number of millimeters of filament extruded in this usage event.
/// Optional — may not be available for all data sources.
///
public decimal? MmExtruded { get; set; }
///
/// Timestamp when the usage occurred (UTC). This is the actual time of
/// consumption, which may differ from CreatedAt if the entry was recorded later.
///
public DateTime UsageTimestamp { get; set; } = DateTime.UtcNow;
///
/// The source of the usage data (which integration path provided it).
///
public DataSource DataSource { get; set; } = DataSource.Manual;
///
/// Optional notes about this usage entry.
///
public string? Notes { get; set; }
}