using GB5Shared.DTO.Framework.Login; using System.Data.Common; namespace MMDAL.CustomCode.StockLedgerCost; public interface IStockLedgerCostDAL { /// /// Sets PostedCost/PostedValue on TSTOCKLEDGER rows from current TSTOCKPOSITION.AverageCost. /// For non-transfer transactions. /// Task ApplyAverageCostNonTransferAsync( int objectTypeId, int objectId, int ouid, LoginDTO login, DbTransaction tx, CancellationToken ct); /// /// Sets PostedCost/PostedValue on TSTOCKLEDGER rows using the FROM-store's AverageCost. /// For stock transfer transactions. /// Task ApplyAverageCostTransferAsync( int objectTypeId, int objectId, int ouid, int fromStoreId, LoginDTO login, DbTransaction tx, CancellationToken ct); /// /// Updates TSTOCKPOSITION.AverageValue from the document's posted movement values. /// For non-transfer transactions. /// Task UpdateAverageValueNonTransferAsync( int objectTypeId, int objectId, LoginDTO login, DbTransaction tx, CancellationToken ct); /// /// Updates TSTOCKPOSITION.AverageValue for the FROM-store only. /// For stock transfer transactions. /// Task UpdateAverageValueTransferFromStoreAsync( int objectTypeId, int objectId, int fromStoreId, LoginDTO login, DbTransaction tx, CancellationToken ct); /// /// Recomputes AverageCost from AverageValue/Quantity (store-wise valuation path). /// Task ApplyCostAffectingStorewiseAsync( int objectTypeId, int objectId, bool isStockTransfer, int toStoreId, LoginDTO login, DbTransaction tx, CancellationToken ct); /// /// Recomputes AverageCost consolidated across all stores for the item. /// Task ApplyCostAffectingConsolidatedAsync( int objectTypeId, int objectId, LoginDTO login, DbTransaction tx, CancellationToken ct); /// /// Returns the OU-level storewise valuation flag from MOULEVELSETTING. /// 0 = storewise (per-store), 1 = consolidated. Returns 1 (consolidated) if not configured. /// Task GetIsStorewiseAsync(int ouid, LoginDTO login, CancellationToken ct); /// /// Runs the 3-step perpetual rerun batch (computes running avg → joins ledger rows → /// updates PostedCost/PostedValue). All three steps share the same connection so temp /// tables remain in scope. Cleanup DROP statements always execute. /// Task RunPerpetualRerunBatchAsync( int ouid, DateOnly fromDate, DateOnly toDate, int documentId, bool isStorewise, LoginDTO login, CancellationToken ct); }