namespace EgwCoreLib.Lux.Data.DbModel.Items
{
//
// This is here so CodeMaid doesn't reorganize this document
//
[Table("item_selling_item")]
public class SellingItemModel
{
///
/// ID dell'articolo di vendita/finito
///
[Key]
public int SellingItemID { get; set; }
///
/// Environment del selling item
///
public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS Envir { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
///
/// Definisce l'articolo come servizio vs concreto=materiale
///
public bool IsService { get; set; } = false;
///
/// SourceType dell'Item
///
public ItemSourceType SourceType { get; set; } = ItemSourceType.ND;
///
/// Se 1 = rivendita, >1 è il ciclo di produzione associato
///
public int JobID { get; set; } = 1;
///
/// 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
///
public double Margin { get; set; } = 0.1;
///
/// Unità di Misura
///
public string UM { get; set; } = "#";
///
/// Valore serializzato della composizione articolo (in formato JWD x finestra)
///
public string SerStruct { get; set; } = "";
///
/// Elenco StepDTO (Fasi) per la stima tempi / costi
/// potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
///
public string ItemSteps { get; set; } = "";
///
/// Tipo immagine da visualizzare
///
public ImageType ImgType { get; set; } = ImageType.ND;
///
/// URL Immagine calcolato
///
///
///
public static string CodeUid(int id)
{
return $"SP.{id:X12}";
}
///
/// Restituisce Url da impiegare x immagine
///
[NotMapped]
public string ImgUID
{
get => ImgType == ImageType.Fixed ? FileName : CodeUid(SellingItemID);
}
///
/// Definisce se sia calcolabile, dato il tipo SellingItem
///
[NotMapped]
public bool CalcEnabled
{
get => ImgType == ImageType.Calculated;
}
///
/// Restituisce Url immagine già calcolato (da sistemare!!!)
///
[NotMapped]
public string ImgUrl
{
get
{
string answ = "empty.svg";
string fType = Envir == Constants.EXECENVIRONMENTS.WINDOW ? "svg" : "png";
if (CalcEnabled)
{
string rndImg = $"{DateTime.Now:HHmmssfff}";
answ = $"cache/{ImgUID}-{rndImg}.{fType}?env={Envir}";
}
else
{
answ = $"static/{ImgUID}";
}
return answ;
}
}
#if false
///
/// Nomi risorsa file associato alla riga offerta (es per BTL)
/// URI come risorsa dentro folder offerta/riga-offerta/guid
///
public string FileResource { get; set; } = "";
///
/// Dimensione del file (per visualizzazione rapida)
///
public long FileSize { get; set; } = 0;
#endif
///
/// Nomi file (fixed) da mostrare e salvare
///
public string FileName { get; set; } = "";
///
/// Indica protetto = NON consentito edit completo (da definire...)
///
///
[NotMapped]
public bool IsProtected
{
get => false;
}
[NotMapped]
public bool HasBOM
{
get => SourceType == ItemSourceType.Jwd || SourceType == ItemSourceType.FileBTL;
}
///
/// Navigazione Job/Cicli
///
[ForeignKey("JobID")]
public virtual JobTaskModel JobNav { get; set; } = null!;
}
}