namespace QMSDAL.DTO
{
// One pickable entry in the Select Serial list — a number that's actually
// free to pick right now: either a previously-skipped TLOT row (Status=0,
// reactivated on save) or a never-issued number within the current
// AvailableQty range (no TLOT row yet — created fresh on save if picked,
// or written as a new Status=0 row if left unpicked).
public class SelectableSerialDTO
{
public int RunningNumber { get; set; }
public string LotNumber { get; set; } = string.Empty;
/// Always "Available".
public string Source { get; set; } = string.Empty;
/// The existing TLOT row's LotId for a previously-skipped entry. -1 for a not-yet-created fresh number.
public int LotId { get; set; } = -1;
}
// Response for GetSelectableSerials — the pickable pool for one FG item's
// next run: previously-skipped numbers (e.g. 2538 and 2542 left over from
// an earlier pick of 2539,2540 out of a 6-wide 2538-2543 range) PLUS a
// fresh sequential range sized to the item's current AvailableQty
// (TotalQuantity − ReservedQuantity, same value shown on the Composition
// table), starting right after LastRun. Never includes historical
// already-issued serials from unrelated past runs. Empty when AvailableQty
// is 0 and no skipped stock exists (e.g. a first-ever run) — the caller
// falls back to normal auto-generation for this run.
public class SelectableSerialPicklistDTO
{
public int ItemId { get; set; }
public string ItemCode { get; set; } = string.Empty;
public string ItemName { get; set; } = string.Empty;
/// Quantity required per set for this component (from its BOM).
public int QtyPerSet { get; set; }
/// Number of sets this run covers — echoes the caller's SetsToGenerate (defaults to 1 if omitted).
public int SetsToGenerate { get; set; }
/// QtyPerSet × SetsToGenerate — the exact total count the user must pick from Picklist for this run.
public int RequiredQty { get; set; }
/// Highest running number ever actually issued (Status=1) for this item. 0 if never issued.
public int LastRun { get; set; }
/// Total pickable entries. Same as Picklist.Count.
public int AvailableCount { get; set; }
/// The pickable pool, sorted ascending by RunningNumber. Empty if nothing is available to pick.
public List Picklist { get; set; } = new();
}
}