ReFix Classes Tranversal GS1CodeParser
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 6m4s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 6m4s
This commit is contained in:
parent
8303751ab7
commit
2d1dc71343
@ -1,12 +0,0 @@
|
||||
namespace Domain.Dtos.Stock
|
||||
{
|
||||
public class Gs1ScanResult
|
||||
{
|
||||
public string? Gtin { get; set; }
|
||||
public string? Lot { get; set; }
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
public string? Serial { get; set; }
|
||||
public string? Raw { get; set; }
|
||||
public string? Variant { get; set; }
|
||||
}
|
||||
}
|
||||
44
Transversal/Models/Gs1ScanResult.cs
Normal file
44
Transversal/Models/Gs1ScanResult.cs
Normal file
@ -0,0 +1,44 @@
|
||||
namespace Transversal.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Resultado del análisis de un código GS1 escaneado.
|
||||
/// Contiene la información parseada de acuerdo a los Application Identifiers (AIs).
|
||||
/// </summary>
|
||||
public class Gs1ScanResult
|
||||
{
|
||||
/// <summary>
|
||||
/// GTIN (AI 01). Identificador global del producto.
|
||||
/// Puede provenir del código de fábrica, del GTIN oficial o de un código alternativo.
|
||||
/// </summary>
|
||||
public string? Gtin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Lote / Batch (AI 10). Identifica el lote de producción del producto.
|
||||
/// </summary>
|
||||
public string? Lot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fecha de vencimiento (AI 17).
|
||||
/// Se expresa en formato YYYY-MM-DD. Puede ser null si el producto no aplica trazabilidad por fecha.
|
||||
/// </summary>
|
||||
public DateTime? ExpirationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Número de serie (AI 21).
|
||||
/// Aplica para productos con trazabilidad por unidad.
|
||||
/// </summary>
|
||||
public string? Serial { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Código original leído (raw input).
|
||||
/// Puede ser un código GS1 completo o un valor tipeado manualmente.
|
||||
/// </summary>
|
||||
public string? Raw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Variante o presentación (AI 22).
|
||||
/// Identifica una sub-versión del GTIN en caso de existir.
|
||||
/// </summary>
|
||||
public string? Variant { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
using Domain.Dtos.Stock;
|
||||
//using Domain.Dtos.Stock;
|
||||
|
||||
using Transversal.Models;
|
||||
|
||||
namespace Transversal.Services
|
||||
{
|
||||
@ -103,12 +105,10 @@ namespace Transversal.Services
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// === Helpers ===
|
||||
|
||||
private static bool TryTakeFixed(string s, ref int i, int length, out string value)
|
||||
{
|
||||
value = string.Empty;
|
||||
@ -132,13 +132,13 @@ namespace Transversal.Services
|
||||
return s.Substring(start, i - start);
|
||||
}
|
||||
|
||||
private static bool LooksLikeNextAi(string s, int index)
|
||||
{
|
||||
if (index + 1 >= s.Length) return false;
|
||||
return char.IsDigit(s[index]) && char.IsDigit(s[index + 1]) &&
|
||||
(s[index] == '0' || s[index] == '1' || s[index] == '2') &&
|
||||
(s.Substring(index, 2) is "01" or "10" or "11" or "17" or "21" or "22");
|
||||
}
|
||||
//private static bool LooksLikeNextAi(string s, int index)
|
||||
//{
|
||||
// if (index + 1 >= s.Length) return false;
|
||||
// return char.IsDigit(s[index]) && char.IsDigit(s[index + 1]) &&
|
||||
// (s[index] == '0' || s[index] == '1' || s[index] == '2') &&
|
||||
// (s.Substring(index, 2) is "01" or "10" or "11" or "17" or "21" or "22");
|
||||
//}
|
||||
|
||||
private static void SkipUnknownUntilFnc1(string s, ref int i)
|
||||
{
|
||||
@ -174,6 +174,43 @@ namespace Transversal.Services
|
||||
while (i < s.Length && s[i] != FNC1) i++;
|
||||
return s.Substring(start, i - start);
|
||||
}
|
||||
|
||||
}
|
||||
//public class Gs1ScanResult
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// GTIN (AI 01). Identificador global del producto.
|
||||
// /// Puede provenir del código de fábrica, del GTIN oficial o de un código alternativo.
|
||||
// /// </summary>
|
||||
// public string? Gtin { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Lote / Batch (AI 10). Identifica el lote de producción del producto.
|
||||
// /// </summary>
|
||||
// public string? Lot { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Fecha de vencimiento (AI 17).
|
||||
// /// Se expresa en formato YYYY-MM-DD. Puede ser null si el producto no aplica trazabilidad por fecha.
|
||||
// /// </summary>
|
||||
// public DateTime? ExpirationDate { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Número de serie (AI 21).
|
||||
// /// Aplica para productos con trazabilidad por unidad.
|
||||
// /// </summary>
|
||||
// public string? Serial { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Código original leído (raw input).
|
||||
// /// Puede ser un código GS1 completo o un valor tipeado manualmente.
|
||||
// /// </summary>
|
||||
// public string? Raw { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// Variante o presentación (AI 22).
|
||||
// /// Identifica una sub-versión del GTIN en caso de existir.
|
||||
// /// </summary>
|
||||
// public string? Variant { get; set; }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user