This commit is contained in:
2025-11-29 16:06:13 +01:00
parent c7dbcde5dd
commit cedcc503fa
34 changed files with 9097 additions and 191 deletions

View File

@@ -2,7 +2,16 @@ namespace Apollinare.Domain.Entities;
public class Articolo : BaseEntity
{
/// <summary>
/// Codice articolo - generato automaticamente
/// </summary>
public string Codice { get; set; } = string.Empty;
/// <summary>
/// Codice alternativo (opzionale, inserito dall'utente)
/// </summary>
public string? CodiceAlternativo { get; set; }
public string Descrizione { get; set; } = string.Empty;
public int? TipoMaterialeId { get; set; }
public int? CategoriaId { get; set; }

View File

@@ -0,0 +1,117 @@
namespace Apollinare.Domain.Entities;
/// <summary>
/// Configurazione per la generazione automatica di codici.
/// Ogni entità può avere la propria configurazione con pattern personalizzabile.
///
/// Pattern supportati:
/// - {SEQ:n} - Sequenza numerica con n cifre (es. {SEQ:5} → 00001)
/// - {YEAR} o {YYYY} - Anno corrente a 4 cifre
/// - {YY} - Anno corrente a 2 cifre
/// - {MONTH} o {MM} - Mese corrente a 2 cifre
/// - {DAY} o {DD} - Giorno corrente a 2 cifre
/// - {PREFIX} - Usa il prefisso definito
/// - Testo statico (es. "ART-", "-", "/")
///
/// Esempi di pattern:
/// - "ART-{YYYY}-{SEQ:5}" → ART-2025-00001
/// - "{PREFIX}{YY}{MM}{SEQ:4}" → MAG2511-0001
/// - "CLI/{YYYY}/{SEQ:6}" → CLI/2025/000001
/// </summary>
public class AutoCode : BaseEntity
{
/// <summary>
/// Codice univoco dell'entità (es. "warehouse_article", "warehouse_location", "cliente")
/// </summary>
public string EntityCode { get; set; } = string.Empty;
/// <summary>
/// Nome visualizzato dell'entità (es. "Articolo Magazzino", "Magazzino", "Cliente")
/// </summary>
public string EntityName { get; set; } = string.Empty;
/// <summary>
/// Prefisso opzionale da usare nel pattern con {PREFIX}
/// </summary>
public string? Prefix { get; set; }
/// <summary>
/// Pattern per la generazione del codice
/// </summary>
public string Pattern { get; set; } = "{PREFIX}{SEQ:5}";
/// <summary>
/// Ultimo numero di sequenza utilizzato (per {SEQ:n})
/// </summary>
public long LastSequence { get; set; } = 0;
/// <summary>
/// Se true, la sequenza viene resettata ogni anno
/// </summary>
public bool ResetSequenceYearly { get; set; } = false;
/// <summary>
/// Se true, la sequenza viene resettata ogni mese
/// </summary>
public bool ResetSequenceMonthly { get; set; } = false;
/// <summary>
/// Anno dell'ultimo reset della sequenza
/// </summary>
public int? LastResetYear { get; set; }
/// <summary>
/// Mese dell'ultimo reset della sequenza (se ResetSequenceMonthly)
/// </summary>
public int? LastResetMonth { get; set; }
/// <summary>
/// Se true, la generazione automatica è abilitata
/// </summary>
public bool IsEnabled { get; set; } = true;
/// <summary>
/// Se true, il codice non può essere modificato manualmente
/// </summary>
public bool IsReadOnly { get; set; } = false;
/// <summary>
/// Modulo di appartenenza (es. "core", "warehouse", "purchases")
/// </summary>
public string? ModuleCode { get; set; }
/// <summary>
/// Descrizione della configurazione
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Ordine di visualizzazione nel pannello admin
/// </summary>
public int SortOrder { get; set; } = 0;
/// <summary>
/// Esempio di codice generato (calcolato, non persistito)
/// </summary>
public string GetExampleCode()
{
var now = DateTime.Now;
return Pattern
.Replace("{PREFIX}", Prefix ?? "")
.Replace("{YEAR}", now.Year.ToString())
.Replace("{YYYY}", now.Year.ToString())
.Replace("{YY}", now.Year.ToString().Substring(2))
.Replace("{MONTH}", now.Month.ToString("D2"))
.Replace("{MM}", now.Month.ToString("D2"))
.Replace("{DAY}", now.Day.ToString("D2"))
.Replace("{DD}", now.Day.ToString("D2"))
.Replace("{SEQ:1}", "X")
.Replace("{SEQ:2}", "XX")
.Replace("{SEQ:3}", "XXX")
.Replace("{SEQ:4}", "XXXX")
.Replace("{SEQ:5}", "XXXXX")
.Replace("{SEQ:6}", "XXXXXX")
.Replace("{SEQ:7}", "XXXXXXX")
.Replace("{SEQ:8}", "XXXXXXXX");
}
}

View File

@@ -2,6 +2,16 @@ namespace Apollinare.Domain.Entities;
public class Cliente : BaseEntity
{
/// <summary>
/// Codice cliente - generato automaticamente
/// </summary>
public string Codice { get; set; } = string.Empty;
/// <summary>
/// Codice alternativo (opzionale, inserito dall'utente)
/// </summary>
public string? CodiceAlternativo { get; set; }
public string RagioneSociale { get; set; } = string.Empty;
public string? Indirizzo { get; set; }
public string? Cap { get; set; }

View File

@@ -6,10 +6,15 @@ namespace Apollinare.Domain.Entities.Warehouse;
public class WarehouseArticle : BaseEntity
{
/// <summary>
/// Codice univoco articolo (SKU)
/// Codice univoco articolo (SKU) - generato automaticamente
/// </summary>
public string Code { get; set; } = string.Empty;
/// <summary>
/// Codice alternativo (opzionale, inserito dall'utente)
/// </summary>
public string? AlternativeCode { get; set; }
/// <summary>
/// Descrizione articolo
/// </summary>

View File

@@ -6,10 +6,15 @@ namespace Apollinare.Domain.Entities.Warehouse;
public class WarehouseArticleCategory : BaseEntity
{
/// <summary>
/// Codice categoria
/// Codice categoria - generato automaticamente
/// </summary>
public string Code { get; set; } = string.Empty;
/// <summary>
/// Codice alternativo (opzionale, inserito dall'utente)
/// </summary>
public string? AlternativeCode { get; set; }
/// <summary>
/// Nome categoria
/// </summary>

View File

@@ -6,10 +6,15 @@ namespace Apollinare.Domain.Entities.Warehouse;
public class WarehouseLocation : BaseEntity
{
/// <summary>
/// Codice univoco del magazzino (es. "MAG01", "CENTRALE")
/// Codice univoco del magazzino - generato automaticamente
/// </summary>
public string Code { get; set; } = string.Empty;
/// <summary>
/// Codice alternativo (opzionale, inserito dall'utente)
/// </summary>
public string? AlternativeCode { get; set; }
/// <summary>
/// Nome descrittivo del magazzino
/// </summary>