using GB5Shared.DTO.Framework.Login;
using MMDAL.DTO.StockValuation;
using System.Data.Common;
namespace MMDAL.CustomCode.FifoLotCost;
public interface IFifoLotCostDAL
{
///
/// Returns one slice per lot consumed by this issue in FIFO or LIFO order.
/// isLifo=false → FIFO (oldest lot first); isLifo=true → LIFO (newest first).
///
Task> AllocateLotsAsync(
int itemId, int skuId, int storeId, int ouid,
decimal issueQty, bool isLifo,
LoginDTO login, CancellationToken ct);
///
/// Inserts a new TLOT row when stock is received for a lot-tracked item.
///
Task InsertLotReceiptAsync(
long lotId, int itemId, int skuId, int storeId, int ouid,
decimal quantity, decimal unitCost,
int objectTypeId, int objectId, long stockLedgerId,
DateOnly lotDate, string? lotNumber,
LoginDTO login, DbTransaction tx, CancellationToken ct);
///
/// Inserts a TLOTDETAIL row recording the inbound movement for a lot.
///
Task InsertLotDetailInboundAsync(
long lotDetailId, long lotId, long stockLedgerId,
decimal quantity, decimal unitCost,
LoginDTO login, DbTransaction tx, CancellationToken ct);
///
/// Inserts a TLOTDETAIL row for one slice of a FIFO/LIFO issue allocation.
///
Task InsertLotDetailIssueAsync(
long lotDetailId, long lotId, long issueStockLedgerId,
decimal consumedQuantity, decimal unitCost,
LoginDTO login, DbTransaction tx, CancellationToken ct);
///
/// Removes TLOTDETAIL rows for a document before re-allocation (batch rerun).
/// Cleans up orphaned TLOT rows (fully consumed lots with no detail).
///
Task DeleteLotDetailsForRerunAsync(
int objectTypeId, int objectId,
LoginDTO login, DbTransaction tx, CancellationToken ct);
}