namespace ERPCore.Domain.Entities;

/// <summary>
/// A named quantity produced by a stage (FR-MFG-05). Intermediate outputs are
/// <b>internal WIP only</b> — <see cref="ItemId"/> is null, no stock and no ledger row
/// is ever written for them. The terminal stage is the exception: it has exactly one
/// output and that output <b>must</b> reference a real Item (the finished good), which
/// is what the production receipt creates a layer for. Model: docs/30 Part C.
/// </summary>
public class StageOutput
{
    public int OutputId { get; set; }

    public int StageId { get; set; }
    public TemplateStage? Stage { get; set; }

    /// <summary>Null on intermediate stages; required on the terminal stage.</summary>
    public int? ItemId { get; set; }
    public Item? Item { get; set; }

    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// Display label for intermediate work-in-progress. Required when <see cref="ItemId"/>
    /// is null and must be null when it is set — a real item's unit is its own base UOM.
    /// WIP never touches stock or the ledger, so this is never converted, only shown.
    /// </summary>
    public int? UomId { get; set; }
    public Uom? Uom { get; set; }

    /// <summary>Always a pack count: of the WIP unit above, or of the item's base UOM.</summary>
    public decimal QtyPerBatch { get; set; }
}
