73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using Extrudex.Domain.Base;
|
||
|
||
namespace Extrudex.Domain.Entities;
|
||
|
||
/// <summary>
|
||
/// Tracks filament consumption for a specific print job on a specific spool.
|
||
/// Each record captures the grams used, which printer consumed it, and when the
|
||
/// usage was recorded. This enables granular per-job usage analytics, COGS
|
||
/// reconciliation, and spool weight depletion tracking.
|
||
///
|
||
/// A single PrintJob may have multiple FilamentUsage records if multiple spools
|
||
/// were consumed (e.g., multi-material prints via AMS).
|
||
/// </summary>
|
||
public class FilamentUsage : AuditableEntity
|
||
{
|
||
/// <summary>
|
||
/// Foreign key to the print job that consumed this filament.
|
||
/// A usage record is always tied to a print job.
|
||
/// </summary>
|
||
public Guid PrintJobId { get; set; }
|
||
|
||
/// <summary>
|
||
/// Navigation to the print job that consumed this filament.
|
||
/// </summary>
|
||
public PrintJob PrintJob { get; set; } = null!;
|
||
|
||
/// <summary>
|
||
/// Foreign key to the spool (filament) that provided the material.
|
||
/// Links usage back to the specific physical spool for inventory tracking.
|
||
/// </summary>
|
||
public Guid SpoolId { get; set; }
|
||
|
||
/// <summary>
|
||
/// Navigation to the spool that provided the material.
|
||
/// </summary>
|
||
public Spool Spool { get; set; } = null!;
|
||
|
||
/// <summary>
|
||
/// Foreign key to the printer that executed the print job.
|
||
/// Denormalized from PrintJob for direct querying of per-printer usage.
|
||
/// </summary>
|
||
public Guid PrinterId { get; set; }
|
||
|
||
/// <summary>
|
||
/// Navigation to the printer that executed the print job.
|
||
/// </summary>
|
||
public Printer Printer { get; set; } = null!;
|
||
|
||
/// <summary>
|
||
/// Grams of filament consumed during this print job.
|
||
/// Derived from mm_extruded × cross_section_area × material_density,
|
||
/// or measured directly from AMS weight delta.
|
||
/// </summary>
|
||
public decimal GramsUsed { get; set; }
|
||
|
||
/// <summary>
|
||
/// Millimeters of filament extruded for this usage record.
|
||
/// The primary physical measurement; grams_used is derived from this.
|
||
/// </summary>
|
||
public decimal MmExtruded { get; set; }
|
||
|
||
/// <summary>
|
||
/// Timestamp when this usage record was created (UTC).
|
||
/// Represents when the usage was first logged, which may differ from
|
||
/// the print job's started_at or completed_at timestamps.
|
||
/// </summary>
|
||
public DateTime RecordedAt { get; set; } = DateTime.UtcNow;
|
||
|
||
/// <summary>
|
||
/// Optional notes about this usage record (e.g., "AMS tray 3", "manual weight check").
|
||
/// </summary>
|
||
public string? Notes { get; set; }
|
||
} |