using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.ListQuery; using GB5Shared.QueryExecutor; using QMSDAL.DTO; using QMSDAL.Query.Matrix; namespace QMSBLL.Matrix { public interface IMatrixBLL { Task GetMatrixAsync(int matrixId, LoginDTO login, CancellationToken ct = default); Task> GetAllMatricesFullAsync(LoginDTO login, CancellationToken ct = default); Task> GetMatrixListAsync(MatrixListQuery query, LoginDTO login, CancellationToken ct = default); Task SaveMatrixAsync(MatrixDTO dto, LoginDTO login, CancellationToken ct = default); Task DeleteMatrixAsync(int matrixId, LoginDTO login, CancellationToken ct = default); Task ActivateMatrixAsync( int matrixId, LoginDTO login, CancellationToken ct = default); /// /// Matrix-independent Set View / FG View preview. Caller passes AllotedAllocationId /// (e.g. from GetSelectListAllocationWithItem) instead of MatrixId. Read-only — no /// DB writes. Does not touch TMATRIX / TMATRIXINPUT / TMATRIXOUTPUT. /// Task GenerateMatrixLotsAsync( int allotedAllocationId, int setsToGenerate, LoginDTO login, CancellationToken ct = default); Task SupersedeMatrixAsync(int oldMatrixId, MatrixDTO newDto, LoginDTO login, CancellationToken ct = default); Task ExplodeBOMAsync(int itemId, int setFrom, int setTo, LoginDTO login, CancellationToken ct = default, int? allotedAllocationId = null); Task GetAvailableBatchesAsync( int itemId, int skuId, decimal? requiredQty, LoginDTO login, CancellationToken ct = default) ; Task ValidateIssueAsync(int indentId, int itemId, int lotId, decimal qty, LoginDTO login, CancellationToken ct = default); Task GetSelectListMatrix(CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct); Task GetSelectListAllocationWithItem(CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct); Task GetMatrixPreviewAsync( int matrixId, LoginDTO login, CancellationToken ct = default); Task GetMatrixSummaryAsync( int allotedAllocationId, LoginDTO login, CancellationToken ct = default); /// /// Combines GetMatrixBasedAllocation (summary) and GetMatrixPreview (BOM/serial /// breakdown) into one call. Caller passes AllotedAllocationId only. /// Task GetMatrixAllocationPreviewAsync( int allotedAllocationId, LoginDTO login, CancellationToken ct = default); /// /// Recomputes the Product Composition & Next Serial Numbers dashboard for a /// caller-supplied SetsToGenerate (the "Generate Now" input) without saving /// anything. Defaults to Remaining sets when setsToGenerate is null. /// Task GetMatrixCompositionPreviewAsync( int allotedAllocationId, int? setsToGenerate, LoginDTO login, CancellationToken ct = default); /// /// Matrix-independent SAVE — persists the same per-item serials shown by /// GenerateMatrixLotsAsync into TLOT and TLOTDETAIL only. Caller passes /// AllotedAllocationId instead of MatrixId. Does not touch TMATRIX / /// TMATRIXINPUT / TMATRIXOUTPUT. Irreversible. /// /// selectedSerials: optional per-FG-item list of RunningNumbers the user /// left CHECKED in the FG View before saving (e.g. component had /// QtyPerSet=5, user kept 3 of the 5 tiles checked — 2157, 2160, 2161). /// When a given ItemId has an entry here, only those RunningNumbers are /// treated as issued (Status=1); every other number in that item's /// generated range for this run is still written (so the running /// sequence never reissues it) but as Status=0 ("skipped/available"), /// offered back later via GetSkippedSerialsAsync. When an ItemId has NO /// entry (null, or not present in the dictionary), ALL its generated /// numbers are treated as selected/issued — preserves today's behavior /// for callers that don't support per-serial selection yet. /// Task SaveSetSerialGenerationAsync( int allotedAllocationId, int setsToGenerate, LoginDTO login, CancellationToken ct = default, Dictionary>? selectedSerials = null); /// /// Lists previously-skipped serials (Status=0, i.e. deselected during a prior /// save) for the given FG item — so a future generation run can offer them /// back for manual reuse instead of leaving them permanently unused. /// Task> GetSkippedSerialsAsync( int itemId, LoginDTO login, CancellationToken ct = default); /// /// Backs the "Select Serial" button on one FG item row. Caller sends a /// CriteriaDTO with an "ItemId" field (required) and an optional /// "SerialNumber" field (partial/contains text search over the picklist's /// LotNumbers). Resolves QtyPerSet from the item's own BOM output line, /// merges previously-skipped ("Available") and never-issued ("Fresh") /// numbers into one sorted, ready-to-render picklist, and returns the /// exact RequiredQty the user must pick from it. /// Task GetSelectableSerialsAsync( CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct = default); /// /// Backs the old Matrix Planner's SetFrom/SetTo picklist. Caller sends a /// CriteriaDTO with an "AllotedAllocationId" field. Returns exactly which /// set numbers have actually been generated (via /// SaveSetSerialGenerationAsync) for this allocation — e.g. [1,2,3,4,5] /// if 5 sets were created — plus SetFrom/SetTo bounds (MIN/MAX of the /// real set numbers, never 0) so the picker can be restricted to real /// sets instead of accepting an arbitrary typed range. /// Task GetGeneratedSetsAsync( CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct = default); } }