using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using static EgwCoreLib.Lux.Core.Enums; namespace EgwCoreLib.Lux.Data.DbModel.Items { // // This is here so CodeMaid doesn't reorganize this document // [Table("item_item")] public class ItemModel { /// /// ID dell'articolo /// [Key] public int ItemID { get; set; } /// /// Cod gruppo articolo (per selezione omogenea alternative) /// public string CodGroup { get; set; } = ""; /// /// Tipologia articolo /// public ItemClassType ItemType { get; set; } = ItemClassType.ND; /// /// Definisce l'articolo come servizio vs concreto=materiale /// public bool IsService { get; set; } = false; /// /// CodArticolo (opzionale) numerico /// public int ItemCode { get; set; } = 0; /// /// CodArticolo (opzionale) string /// public string ExtItemCode { get; set; } = ""; /// /// Cod Fornitore (opzionale) /// public string SupplCode { get; set; } = ""; /// /// Descrizione /// public string Description { get; set; } = ""; /// /// Costo (standard / senza listini) /// public double Cost { get; set; } = 0; /// /// Margine percentuale standard (che comprende info su resa) /// public double Margin { get; set; } = 0.2; /// /// Valore minimo per assegnazione in calcolo BOM /// public double QtyMin { get; set; } = 0; /// /// Valore massimo per assegnazione in calcolo BOM /// public double QtyMax { get; set; } = 0; /// /// Unità di Misura /// public string UM { get; set; } = "#"; /// /// Indica se il range quantity sia ok /// [NotMapped] public bool IsOkQty { get => QtyMax > 0 && QtyMax - QtyMin > 0; } /// /// Indica se il range quantity sia ok /// [NotMapped] public bool IsOkCost { get => Cost > 0; } #if false /// /// Opzionale, valore JWD di default come template di partenza in formato JWD /// public string TemplateJWD { get; set; } = ""; #endif /// /// ID dell'oggeto Parent da cui deriva (se zero è "originale") /// public int ItemIDParent { get; set; } = 0; /// /// Indica protetto = NON consentito edit completo (per oggetti BOM) /// /// [NotMapped] public bool IsProtected { get => ItemType == ItemClassType.Bom; } /// /// Navigation per ItemGroup /// [ForeignKey("CodGroup")] public virtual ItemGroupModel ItemGroupNav { get; set; } = null!; } }