using PowderCoating.Core.Enums; namespace PowderCoating.Core.Entities; /// /// Tracks defect, warranty, or damage rework on a job. /// The original job owns the cost; a new linked job (ReworkJobId) handles the shop floor workflow. /// public class ReworkRecord : BaseEntity { // ── Links ───────────────────────────────────────────────────────────────── public int JobId { get; set; } public int? JobItemId { get; set; } // null = whole job; set = specific item // Optional new job created to do the redo work on the shop floor public int? ReworkJobId { get; set; } // ── Classification ──────────────────────────────────────────────────────── public ReworkType ReworkType { get; set; } public ReworkReason Reason { get; set; } public string DefectDescription { get; set; } = string.Empty; // ── Discovery ───────────────────────────────────────────────────────────── public ReworkDiscoveredBy DiscoveredBy { get; set; } public DateTime DiscoveredDate { get; set; } = DateTime.UtcNow; public string? ReportedByName { get; set; } // Customer name if external report // ── Cost & Billing ──────────────────────────────────────────────────────── public decimal EstimatedReworkCost { get; set; } public decimal ActualReworkCost { get; set; } public bool IsBillableToCustomer { get; set; } public string? BillingNotes { get; set; } // Pricing attribution for the linked rework job (null on pre-existing records) public ReworkPricingType? ReworkPricingType { get; set; } // ── Resolution ──────────────────────────────────────────────────────────── public ReworkStatus Status { get; set; } = ReworkStatus.Open; public ReworkResolution? Resolution { get; set; } public DateTime? ResolvedDate { get; set; } public string? ResolutionNotes { get; set; } // ── Navigation ──────────────────────────────────────────────────────────── public virtual Job Job { get; set; } = null!; public virtual JobItem? JobItem { get; set; } public virtual Job? ReworkJob { get; set; } }