using GB5Shared.DTO.Framework.Login; using MMDAL.DTO.StockValuation; namespace MMBLL.StockValuation; public interface IStockValuationBLL { /// /// User-triggered batch valuation run. Validates the period is not locked, /// creates a TSTOCKVALUATIONRUN record, then publishes a Dapr event so the /// heavy lifting happens asynchronously. Returns immediately to the caller. /// Task StartBatchRunAsync(StockValuationFilterDTO filter, LoginDTO login, CancellationToken ct); /// /// Executes the full batch weighted-average calculation for a period. /// Called by the Dapr subscriber — runs to completion synchronously on the worker. /// Updates TSTOCKLEDGER PostedCost, applies make-item costs, syncs TSTOCKPOSITION. /// Task RunBatchAsync(StockValuationFilterDTO filter, long runId, LoginDTO login, CancellationToken ct); /// /// Runs the perpetual rerun (day-by-day recosting from a backdated entry date to today). /// Called by the Dapr subscriber on "mm.stockvaluation.recosting-required" events. /// Task RunPerpetualRerunAsync(StockValuationFilterDTO filter, LoginDTO login, CancellationToken ct); /// /// Returns list of valuation runs for display in the dashboard. /// Task GetValuationRunsAsync(int ouid, DateOnly fromDate, DateOnly toDate, LoginDTO login, CancellationToken ct); /// /// Marks the period-end snapshot certified after a successful batch run. /// Called as part of the period-lock process. /// Task CertifyPeriodSnapshotAsync(int ouid, DateOnly periodEndDate, LoginDTO login, CancellationToken ct); /// /// Returns the cost workings breakdown for a single item position: /// opening snapshot, TSTOCKLEDGER transactions, and closing balance. /// For make items, includes BOM level detail from MPRODUCTCOST. /// Task GetCostWorkingsAsync( int itemId, int skuId, int storeId, int ouid, DateOnly asOfDate, LoginDTO login, CancellationToken ct); /// /// On startup: marks any TSTOCKVALUATIONRUN stuck in "Running" older than 2 hours as Failed. /// Task RecoverStuckRunsAsync(LoginDTO login, CancellationToken ct); }