All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (pull_request) Successful in 6m37s
- Added stockitem_id column to PhLSM_ExpeditionDetails - Added FK to PhLSM_StockItem - Added indexes (StockItem and Expedition_StockItem) - Updated scaffold models - Updated UI merge to preserve StockItemId - CreateFullExpeditionAsync now persists stockitem_id - Base step to enable logistic states and double-trace prevention Closes #3
46 lines
1.7 KiB
C#
46 lines
1.7 KiB
C#
namespace Domain.Dtos.Stock
|
|
{
|
|
/// <summary>
|
|
/// Contexto de lo ya agregado en la expedición (no se persiste).
|
|
/// Sirve para evitar duplicados y calcular disponible efectivo.
|
|
/// </summary>
|
|
public class StockSnapshotItem
|
|
{
|
|
public int ProductId { get; set; }
|
|
public int StockitemId { get; set; }
|
|
public string? ProductName { get; set; } = string.Empty;
|
|
public int LocationId { get; set; }
|
|
public string Batch { get; set; } = string.Empty;
|
|
public DateOnly? Expiration { get; set; }
|
|
public string Serial { get; set; } = string.Empty;
|
|
|
|
/// <summary> 1=No aplica, 2=Por cantidad, 3=Por lote y vencimiento (solo UI/validación; no se persiste). </summary>
|
|
public int TraceabilityType { get; set; }
|
|
|
|
/// <summary>Cantidad ya agregada en la expedición para esta clave de negocio.</summary>
|
|
public decimal Quantity { get; set; }
|
|
|
|
/// <summary>Clave de fusión para idempotencia (no se persiste).</summary>
|
|
public string BusinessKey { get; set; } = string.Empty;
|
|
}
|
|
|
|
public static class StockKeys
|
|
{
|
|
public static string BuildBusinessKey(int productId, int locationId, string batch, DateOnly? expiration, string serial)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(serial))
|
|
return $"P{productId}-S{serial.Trim()}";
|
|
|
|
batch = batch?.Trim() ?? string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(batch) && expiration.HasValue)
|
|
return $"P{productId}-L{locationId}-B{batch}-E{expiration.Value:yyyyMMdd}";
|
|
|
|
if (!string.IsNullOrEmpty(batch))
|
|
return $"P{productId}-L{locationId}-B{batch}";
|
|
|
|
return $"P{productId}-L{locationId}";
|
|
}
|
|
}
|
|
}
|