namespace MMDAL.DTO.StockValuation;
///
/// On-demand "how was this cost arrived at?" breakdown.
/// Returned by GET /StockValuation/GetCostWorkings.
/// Never cached — always computed live.
///
public class CostWorkingsDTO
{
public int ItemId { get; set; }
public string ItemCode { get; set; } = string.Empty;
public string ItemName { get; set; } = string.Empty;
public int SKUId { get; set; }
public string SKUName { get; set; } = string.Empty;
public int StoreId { get; set; }
public string StoreName { get; set; } = string.Empty;
public DateOnly AsOfDate { get; set; }
public string ValuationMethod { get; set; } = string.Empty;
public decimal CurrentCost { get; set; }
public decimal CurrentQuantity { get; set; }
public decimal CurrentValue { get; set; }
public CostWorkingsOpeningDTO? OpeningBalance { get; set; }
public List Transactions { get; set; } = [];
public CostWorkingsClosingDTO? ClosingBalance { get; set; }
// For WtAvg: formula description
public string? Formula { get; set; }
public decimal? CalculatedCost { get; set; }
// For FIFO/LIFO: open cost layers
public List? CostLayers { get; set; }
public decimal? BlendedCostNextIssue { get; set; }
// For make items: BOM breakdown
public MakeItemCostWorkingsDTO? MakeItemWorkings { get; set; }
}
public class CostWorkingsOpeningDTO
{
public DateOnly AsOf { get; set; }
public decimal Qty { get; set; }
public decimal Value { get; set; }
public decimal Cost { get; set; }
/// "CertifiedSnapshot" or "FullHistory"
public string Source { get; set; } = string.Empty;
}
public class CostWorkingsClosingDTO
{
public decimal Qty { get; set; }
public decimal Value { get; set; }
public decimal Cost { get; set; }
}
public class CostWorkingsLineDTO
{
public DateOnly Date { get; set; }
public string DocNumber { get; set; } = string.Empty;
public string TxnType { get; set; } = string.Empty;
public decimal Qty { get; set; }
public decimal UnitCost { get; set; }
public decimal Value { get; set; }
public decimal RunningQty { get; set; }
public decimal RunningValue { get; set; }
public decimal RunningCost { get; set; }
}
public class CostLayerWorkingDTO
{
public DateOnly ReceiptDate { get; set; }
public string DocNumber { get; set; } = string.Empty;
public decimal OriginalQty { get; set; }
public decimal RemainingQty { get; set; }
public decimal UnitCost { get; set; }
}
public class MakeItemCostWorkingsDTO
{
public string CostType { get; set; } = string.Empty; // "Standard" / "Actual"
public string CostAnalysisCode { get; set; } = string.Empty;
public DateOnly PeriodFrom { get; set; }
public decimal MaterialCost { get; set; }
public decimal ProcessCost { get; set; }
public decimal SubcontractCost { get; set; }
public decimal OverheadCost { get; set; }
public decimal TotalStandardCost { get; set; }
public decimal ActualVariance { get; set; }
public List BomLevels { get; set; } = [];
}
public class BomLevelCostDTO
{
public int BomLevel { get; set; }
public int ItemId { get; set; }
public string ItemName { get; set; } = string.Empty;
public decimal Quantity { get; set; }
public decimal UnitCost { get; set; }
public decimal LineValue { get; set; }
public decimal MaterialCost { get; set; }
public decimal ProcessCost { get; set; }
public decimal SubcontractCost { get; set; }
public decimal OverheadCost { get; set; }
/// Non-null for make sub-items: their own BOM breakdown.
public List? Children { get; set; }
}