diff --git a/EgwCoreLib.Lux.Core/EgwCoreLib.Lux.Core.csproj b/EgwCoreLib.Lux.Core/EgwCoreLib.Lux.Core.csproj
index 59a004c1..cf161881 100644
--- a/EgwCoreLib.Lux.Core/EgwCoreLib.Lux.Core.csproj
+++ b/EgwCoreLib.Lux.Core/EgwCoreLib.Lux.Core.csproj
@@ -21,6 +21,8 @@
-
+
+
+
diff --git a/EgwCoreLib.Lux.Core/ParamDict.cs b/EgwCoreLib.Lux.Core/ParamDict.cs
new file mode 100644
index 00000000..05b6fad2
--- /dev/null
+++ b/EgwCoreLib.Lux.Core/ParamDict.cs
@@ -0,0 +1,89 @@
+using Newtonsoft.Json;
+
+namespace EgwCoreLib.Lux.Core
+{
+ ///
+ /// Generico dizionario parametri con funzione ricerca valore (SE presente)
+ ///
+ public class ParamDict
+ {
+ #region Public Constructors
+
+ ///
+ /// init classe dal valore serializzato del dizionario
+ ///
+ ///
+ public ParamDict(string rawVal)
+ {
+ DictVals = JsonConvert.DeserializeObject>(rawVal) ?? new Dictionary();
+ }
+
+ ///
+ /// init classe da dizionario
+ ///
+ ///
+ public ParamDict(Dictionary newDict)
+ {
+ DictVals = newDict;
+ }
+
+ #endregion Public Constructors
+
+ #region Public Properties
+
+ ///
+ /// Versione serializzata del dizionario
+ ///
+ public string Serialized
+ {
+ get => JsonConvert.SerializeObject(DictVals);
+ }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ ///
+ /// Ricerca (se disponibile) il valore della chiave richiesta
+ ///
+ ///
+ ///
+ public string GetVal(string reqKey)
+ {
+ string answ = "";
+ if (DictVals.ContainsKey(reqKey))
+ {
+ answ = DictVals[reqKey];
+ }
+ return answ;
+ }
+
+ ///
+ /// Imposta valore (aggiungendo se mancasse)
+ ///
+ ///
+ ///
+ public void SetVal(string Key, string Val)
+ {
+ if (DictVals.ContainsKey(Key))
+ {
+ DictVals[Key] = Val;
+ }
+ else
+ {
+ DictVals.Add(Key, Val);
+ }
+ }
+
+ #endregion Public Methods
+
+ #region Private Properties
+
+ ///
+ /// Dizionario interno valori
+ ///
+ private Dictionary DictVals { get; set; } = new Dictionary();
+
+ #endregion Private Properties
+ }
+}
\ No newline at end of file
diff --git a/EgwCoreLib.Lux.Data/AdminContext.cs b/EgwCoreLib.Lux.Data/AdminContext.cs
index 275d7b2e..e78ef64f 100644
--- a/EgwCoreLib.Lux.Data/AdminContext.cs
+++ b/EgwCoreLib.Lux.Data/AdminContext.cs
@@ -1,4 +1,4 @@
-using EgwCoreLib.Lux.Data.DbModel;
+using EgwCoreLib.Lux.Data.Data.DbModel.Admin;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
index 89182996..ef5f0a93 100644
--- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
+++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
@@ -1,34 +1,353 @@
using EgwCoreLib.Lux.Core.RestPayload;
-using EgwCoreLib.Lux.Data.DbModel;
+using EgwCoreLib.Lux.Data.DbModel.Config;
+using EgwCoreLib.Lux.Data.DbModel.Items;
+using EgwCoreLib.Lux.Data.DbModel.Sales;
+using EgwCoreLib.Lux.Data.DbModel.Utils;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NLog;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading.Tasks;
using static EgwCoreLib.Lux.Core.Enums;
-using static System.Runtime.InteropServices.JavaScript.JSType;
namespace EgwCoreLib.Lux.Data.Controllers
{
- public class LuxController
+ internal class LuxController
{
// manca costruttore parametrico contoller...
- #region Public Methods
+ #region Internal Methods
+
+ internal async Task> ConfEnvirParamGetAllAsync()
+ {
+ List dbResult = new List();
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ dbResult = await dbCtx
+ .DbSetEnvirPar
+ .ToListAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfEnvirParamGetAllAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Esegue eliminazione
+ ///
+ ///
+ ///
+ internal async Task ConfGlassDeleteAsync(GlassModel rec2del)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var dbResult = dbCtx
+ .DbSetConfGlass
+ .Where(x => x.GlassID == rec2del.GlassID)
+ .FirstOrDefault();
+
+ // se trovato --> elimino e sposto i rimanenti...
+ if (dbResult != null)
+ {
+ // elimino
+ dbCtx.DbSetConfGlass.Remove(dbResult);
+ // salvo tutto
+ await dbCtx.SaveChangesAsync();
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfGlassDeleteAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Elenco completo Config Glass
+ ///
+ ///
+ internal async Task> ConfGlassGetAllAsync()
+ {
+ List dbResult = new List();
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ dbResult = await dbCtx
+ .DbSetConfGlass
+ .ToListAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfGlassGetAllAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Upsert record ConfGlass
+ ///
+ ///
+ ///
+ internal async Task ConfGlassUpsertAsync(GlassModel upsRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetConfGlass
+ .Where(x => upsRec.GlassID > 0 && x.GlassID == upsRec.GlassID)
+ .FirstOrDefault();
+ // se trovato --> aggiorno
+ if (currRec != null)
+ {
+ currRec.Code = string.IsNullOrEmpty(upsRec.Code) ? $"{upsRec.GlassID:0000}" : upsRec.Code;
+ currRec.Description = upsRec.Description;
+ currRec.Thickness = upsRec.Thickness;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ // se mancasse --> aggiungo
+ else
+ {
+ dbCtx.DbSetConfGlass.Add(upsRec);
+ }
+ // salvo...
+ int numAct = await dbCtx.SaveChangesAsync();
+ answ = numAct > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfGlassUpsertAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Esegue eliminazione
+ ///
+ ///
+ ///
+ internal async Task ConfProfileDeleteAsync(ProfileModel rec2del)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var dbResult = dbCtx
+ .DbSetConfProfile
+ .Where(x => x.ProfileID == rec2del.ProfileID)
+ .FirstOrDefault();
+
+ // se trovato --> elimino e sposto i rimanenti...
+ if (dbResult != null)
+ {
+ // elimino
+ dbCtx.DbSetConfProfile.Remove(dbResult);
+ // salvo tutto
+ await dbCtx.SaveChangesAsync();
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfProfileDeleteAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Elenco completo Config Profile
+ ///
+ ///
+ internal async Task> ConfProfileGetAllAsync()
+ {
+ List dbResult = new List();
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ dbResult = await dbCtx
+ .DbSetConfProfile
+ .ToListAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfProfileGetAllAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Upsert record ConfProfile
+ ///
+ ///
+ ///
+ internal async Task ConfProfileUpsertAsync(ProfileModel upsRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetConfProfile
+ .Where(x => upsRec.ProfileID > 0 && x.ProfileID == upsRec.ProfileID)
+ .FirstOrDefault();
+ // se trovato --> aggiorno
+ if (currRec != null)
+ {
+ currRec.Code = string.IsNullOrEmpty(upsRec.Code) ? $"{upsRec.ProfileID:0000}" : upsRec.Code;
+ currRec.Description = upsRec.Description;
+ currRec.Thickness = upsRec.Thickness;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ // se mancasse --> aggiungo
+ else
+ {
+ dbCtx.DbSetConfProfile.Add(upsRec);
+ }
+ // salvo...
+ int numAct = await dbCtx.SaveChangesAsync();
+ answ = numAct > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfProfileUpsertAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Esegue eliminazione
+ ///
+ ///
+ ///
+ internal async Task ConfWoodDeleteAsync(WoodModel rec2del)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var dbResult = dbCtx
+ .DbSetConfWood
+ .Where(x => x.WoodID == rec2del.WoodID)
+ .FirstOrDefault();
+
+ // se trovato --> elimino e sposto i rimanenti...
+ if (dbResult != null)
+ {
+ // elimino
+ dbCtx.DbSetConfWood.Remove(dbResult);
+ // salvo tutto
+ await dbCtx.SaveChangesAsync();
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfWoodDeleteAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Elenco completo Config Wood
+ ///
+ ///
+ internal async Task> ConfWoodGetAllAsync()
+ {
+ List dbResult = new List();
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ dbResult = await dbCtx
+ .DbSetConfWood
+ .ToListAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfWoodGetAllAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Upsert record ConfWood
+ ///
+ ///
+ ///
+ internal async Task ConfWoodUpsertAsync(WoodModel upsRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetConfWood
+ .Where(x => upsRec.WoodID > 0 && x.WoodID == upsRec.WoodID)
+ .FirstOrDefault();
+ // se trovato --> aggiorno
+ if (currRec != null)
+ {
+ currRec.Code = string.IsNullOrEmpty(upsRec.Code) ? $"{upsRec.WoodID:0000}" : upsRec.Code;
+ currRec.Description = upsRec.Description;
+ currRec.Type = upsRec.Type;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ // se mancasse --> aggiungo
+ else
+ {
+ dbCtx.DbSetConfWood.Add(upsRec);
+ }
+ // salvo...
+ int numAct = await dbCtx.SaveChangesAsync();
+ answ = numAct > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante ConfWoodUpsertAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
///
/// Elenco completo Customers da DB
///
///
- public List CustomersGetAll()
+ internal List CustomersGetAll()
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -49,10 +368,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo Dealers da DB
///
///
- public List DealersGetAll()
+ internal List DealersGetAll()
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -69,15 +388,296 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
+ ///
+ /// Esegue eliminazione
+ ///
+ ///
+ ///
+ internal async Task GenClassDeleteAsync(GenClassModel rec2del)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var dbResult = dbCtx
+ .DbSetGenClass
+ .Where(x => x.ClassCod == rec2del.ClassCod)
+ .FirstOrDefault();
+
+ var numChild = dbCtx
+ .DbSetGenVal
+ .Count(x => x.ClassCod == rec2del.ClassCod);
+ // se trovato e NON HA record child --> elimino
+ if (dbResult != null && numChild == 0)
+ {
+ dbCtx.DbSetGenClass.Remove(dbResult);
+ await dbCtx.SaveChangesAsync();
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenClassDeleteAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Elenco completo GenClass
+ ///
+ ///
+ internal async Task> GenClassGetAllAsync()
+ {
+ List dbResult = new List();
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ dbResult = await dbCtx
+ .DbSetGenClass
+ .Include(o => o.GenValNav)
+ .ToListAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenClassGetAllAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Upsert record GenClass
+ ///
+ ///
+ ///
+ internal async Task GenClassUpsertAsync(GenClassModel upsRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetGenClass
+ .Where(x => x.ClassCod == upsRec.ClassCod)
+ .FirstOrDefault();
+ // se trovato --> aggiorno
+ if (currRec != null)
+ {
+ currRec.Description = upsRec.Description;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ // se mancasse --> aggiungo
+ else
+ {
+ dbCtx.DbSetGenClass.Add(upsRec);
+ }
+ // salvo...
+ int numAct = await dbCtx.SaveChangesAsync();
+ answ = numAct > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenClassUpsertAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Esegue eliminazione
+ ///
+ ///
+ ///
+ internal async Task GenValDeleteAsync(GenValueModel rec2del)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var dbResult = dbCtx
+ .DbSetGenVal
+ .Where(x => x.GenValID == rec2del.GenValID)
+ .FirstOrDefault();
+
+ // se trovato --> elimino e sposto i rimanenti...
+ if (dbResult != null)
+ {
+ // modifico record successivi...
+ var list2Move = dbCtx
+ .DbSetGenVal
+ .Where(x => x.ClassCod == rec2del.ClassCod && x.Ordinal > dbResult.Ordinal)
+ .ToList();
+ foreach (var item in list2Move)
+ {
+ item.Ordinal--;
+ dbCtx.Entry(item).State = EntityState.Modified;
+ }
+ // elimino
+ dbCtx.DbSetGenVal.Remove(dbResult);
+ // salvo tutto
+ await dbCtx.SaveChangesAsync();
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenValDeleteAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Elenco valori x classe richiesta
+ ///
+ ///
+ ///
+ internal async Task> GenValGetFiltAsync(string codClass)
+ {
+ List dbResult = new List();
+ if (!string.IsNullOrEmpty(codClass))
+ {
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ dbResult = await dbCtx
+ .DbSetGenVal
+ .Where(x => x.ClassCod == codClass)
+ .ToListAsync();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenValGetFiltAsync{Environment.NewLine}{exc}");
+ }
+ }
+ }
+ return dbResult;
+ }
+
+ ///
+ /// Esegue spostamento nell'ordinamento relativo alla classe
+ /// NB: verifica spostamento sia ammissibile: se primo rec non "sale", se ultimo non "scende"...
+ ///
+ ///
+ ///
+ ///
+ internal async Task GenValMoveAsync(GenValueModel selRec, bool moveUp)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetGenVal
+ .Where(x => x.GenValID == selRec.GenValID)
+ .FirstOrDefault();
+
+ if (currRec != null)
+ {
+ // recupero info del num rec del suo gruppo
+ int numRec = dbCtx
+ .DbSetGenVal
+ .Count(x => x.ClassCod == selRec.ClassCod);
+
+ // verifico NON sia primo/ultimo...
+ bool canMove = false;
+ int newPos = moveUp ? currRec.Ordinal - 1 : currRec.Ordinal + 1;
+ if (moveUp)
+ {
+ canMove = newPos > 0;
+ }
+ else
+ {
+ canMove = newPos <= numRec;
+ }
+ // se abilitato --> aggiorno i 2 record...
+ if (canMove)
+ {
+ var otherRec = dbCtx
+ .DbSetGenVal
+ .Where(x => x.ClassCod == selRec.ClassCod && x.Ordinal == newPos)
+ .FirstOrDefault();
+ if (otherRec != null)
+ {
+ otherRec.Ordinal = currRec.Ordinal;
+ dbCtx.Entry(otherRec).State = EntityState.Modified;
+ currRec.Ordinal = newPos;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ // salvo...
+ int numAct = await dbCtx.SaveChangesAsync();
+ answ = numAct > 0;
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenValMoveAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Esegue Upsert del record ricevuto
+ ///
+ ///
+ ///
+ internal async Task GenValUpsertAsync(GenValueModel upsRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currRec = dbCtx
+ .DbSetGenVal
+ .Where(x => x.GenValID == upsRec.GenValID)
+ .FirstOrDefault();
+ // se trovato --> aggiorno
+ if (currRec != null)
+ {
+ currRec.ValString = upsRec.ValString;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+ // se mancasse --> aggiungo
+ else
+ {
+ dbCtx.DbSetGenVal.Add(upsRec);
+ }
+ // salvo...
+ int numAct = await dbCtx.SaveChangesAsync();
+ answ = numAct > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante GenValUpsertAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
///
/// Eliminazione record item
///
///
///
- public async Task ItemDeleteAsync(ItemModel rec2del)
+ internal async Task ItemDeleteAsync(ItemModel rec2del)
{
bool result = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -104,10 +704,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo Items
///
///
- public List ItemGetAll()
+ internal List ItemGetAll()
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -130,7 +730,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
/// ID parent (valido quindi >0)
///
- public List ItemGetChild(int ItemIdParent)
+ internal List ItemGetChild(int ItemIdParent)
{
List dbResult = new List();
if (ItemIdParent > 0)
@@ -160,12 +760,12 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
/// ID item corrente (valido quindi >0)
///
- public List ItemGetAlt(int ItemId)
+ internal List ItemGetAlt(int ItemId)
{
List dbResult = new List();
if (ItemId > 0)
{
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -211,10 +811,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public List ItemGetFilt(string CodGroup, ItemClassType ItemType)
+ internal List ItemGetFilt(string CodGroup, ItemClassType ItemType)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -240,10 +840,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public List ItemGetFilt(string CodGroup, ItemClassType ItemType, string SearchVal)
+ internal List ItemGetFilt(string CodGroup, ItemClassType ItemType, string SearchVal)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -274,10 +874,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public async Task> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType)
+ internal async Task> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -304,10 +904,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public async Task> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType, string SearchVal)
+ internal async Task> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType, string SearchVal)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -336,10 +936,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public List ItemGetSearch(string SearchVal)
+ internal List ItemGetSearch(string SearchVal)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -362,10 +962,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public async Task> ItemGetSearchAsync(string SearchVal)
+ internal async Task> ItemGetSearchAsync(string SearchVal)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -387,10 +987,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo ItemGroup gestiti
///
///
- public List ItemGroupGetAll()
+ internal List ItemGroupGetAll()
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -411,17 +1011,17 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo ItemGroup gestiti async
///
///
- public async Task> ItemGroupGetAllAsync()
+ internal async Task> ItemGroupGetAllAsync()
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
{
dbResult = await dbCtx
- .DbSetItemGroup
- .ToListAsync();
+ .DbSetItemGroup
+ .ToListAsync();
}
catch (Exception exc)
{
@@ -431,10 +1031,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
- public bool ItemUpsert(ItemModel newRec)
+ internal bool ItemUpsert(ItemModel newRec)
{
bool answ = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -476,10 +1076,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public async Task ItemUpsertAsync(ItemModel currRec)
+ internal async Task ItemUpsertAsync(ItemModel currRec)
{
bool result = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -523,10 +1123,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public bool ItemUpsertFromBom(List bomList)
+ internal bool ItemUpsertFromBom(List bomList)
{
bool answ = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -581,10 +1181,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Elenco completo offerte da DB
///
///
- public async Task> OfferGetAll()
+ internal async Task> OfferGetAll()
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -609,10 +1209,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
///
///
///
- public List OfferRowGetByOffer(int OfferID)
+ internal List OfferRowGetByOffer(int OfferID)
{
List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -632,16 +1232,114 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
+ ///
+ /// Elimina riga e sposta eventuali righe successive...
+ ///
+ ///
+ ///
+ internal async Task OffertRowDelete(OfferRowModel rec2Del)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ // recupero offerta...
+ var currRec = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferRowID == rec2Del.OfferRowID)
+ .FirstOrDefault();
+
+ // se non trovo aggiungo
+ if (currRec != null)
+ {
+ // recupero indice attuale...
+ int currRowNum = rec2Del.RowNum;
+ // cerco righe successive
+ var list2move = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferID == rec2Del.OfferID && x.RowNum > currRowNum)
+ .ToList();
+ // se ci sono aggiorno!
+ if (list2move != null && list2move.Count > 0)
+ {
+ foreach (var item in list2move)
+ {
+ item.RowNum--;
+ dbCtx.Entry(item).State = EntityState.Modified;
+ }
+ }
+ // infine rimuovo riga
+ dbCtx.DbSetOfferRow.Remove(currRec);
+ }
+
+ // salvo TUTTI i cambiamenti...
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertRowDelete{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Aggiornamento valore UID non calcolato + ritorno elenco UID da aggiornare
+ ///
+ ///
+ ///
+ internal List OffertRowFixUid(int offertID)
+ {
+ List answ = new List();
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ var currList = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferID == offertID)
+ .ToList();
+ // se trovato --> verifico valori differenti, aggiorno e restituisco da calcolare
+ if (currList != null)
+ {
+ var list2fix = currList.Where(x => string.IsNullOrEmpty(x.OfferRowUID) || x.OfferRowUID != x.OfferRowDtx).ToList();
+ if (list2fix != null && list2fix.Count > 0)
+ {
+ // salvo elenco
+ answ = list2fix.Select(x => x.OfferRowDtx).ToList();
+ // sistemo UID
+ foreach (var item in list2fix)
+ {
+ item.OfferRowUID = item.OfferRowDtx;
+ dbCtx.Entry(item).State = EntityState.Modified;
+ }
+ // salvo...
+ var result = dbCtx.SaveChanges();
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertRowFixUid{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
///
/// Effettua update dei costi di tutte le righe dell'offerta indicata
///
/// ID riga offerta da aggiornare
/// Bom aggiornata da salvare
///
- public async Task OffertRowUpdateBom(int OfferRowID, List newBomList)
+ internal async Task OffertRowUpdateBom(int OfferRowID, List newBomList)
{
bool answ = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -667,21 +1365,25 @@ namespace EgwCoreLib.Lux.Data.Controllers
// calcolo il NUOVO costo e lo aggiorno...
double totCost = 0;
+ double totPrice = 0;
int numGroupOk = 0;
int numItemOk = 0;
int numElems = newBomList.Count;
// validazione e completamento BOM
- validateBom(itemGroupList, bomGenList, ref newBomList, ref totCost, ref numGroupOk, ref numItemOk);
+ validateBom(itemGroupList, bomGenList, ref newBomList, null, ref totCost, ref totPrice, ref numGroupOk, ref numItemOk);
// salvo BOM...
string itemBom = JsonConvert.SerializeObject(newBomList);
currRec.ItemBOM = itemBom;
- currRec.Cost = totCost;
+ // salvo arrotondato alla 3° decimale
+ currRec.BomCost = Math.Round(totCost, 3);
+ currRec.BomPrice = Math.Round(totPrice, 3);
currRec.BomOk = numElems == numGroupOk;
currRec.ItemOk = numElems == numItemOk;
dbCtx.Entry(currRec).State = EntityState.Modified;
}
// salvo modifiche...
- await dbCtx.SaveChangesAsync();
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
}
catch (Exception exc)
{
@@ -691,15 +1393,178 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
+ ///
+ /// Aggiorno sul DB i dati del file associato
+ ///
+ ///
+ ///
+ internal async Task OffertRowUpdateFileData(OfferRowModel updRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ // recupero righe offerta...
+ var currRec = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferRowID == updRec.OfferRowID)
+ .FirstOrDefault();
+
+ // aggiorno parametri (se inviati)
+ if (currRec != null)
+ {
+ currRec.FileName = updRec.FileName;
+ currRec.FileResource = updRec.FileResource;
+ currRec.FileSize = updRec.FileSize;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+
+ // salvo i cambiamenti...
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertRowUpdateFileData{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Effettua update serStruct per l'offerta indicata
+ ///
+ /// ID singola riga offerta
+ /// Se non nullo è il nuovo stato await BOM
+ /// Se non nullo è stato await Price
+ ///
+ internal async Task OffertRowUpdateSerStruct(int offerRowID, string serStruct)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ // recupero righe offerta...
+ var currRec = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferRowID == offerRowID)
+ .FirstOrDefault();
+
+ // aggiorno parametri (se inviati)
+ if (currRec != null)
+ {
+ currRec.SerStruct = serStruct;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+
+ // salvo i cambiamenti...
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertRowUpdateSerStruct{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Upsert record riga offerta
+ ///
+ ///
+ ///
+ internal async Task OffertRowUpsert(OfferRowModel updRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ // recupero offerta...
+ var currRec = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferRowID == updRec.OfferRowID)
+ .FirstOrDefault();
+
+ // se non trovo aggiungo
+ if (currRec == null)
+ {
+ dbCtx.DbSetOfferRow.Add(updRec);
+ }
+ // altrimenti aggiorno
+ else
+ {
+ dbCtx.Entry(currRec).CurrentValues.SetValues(updRec);
+ }
+
+ // salvo TUTTI i cambiamenti...
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertRowUpsert{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+ ///
+ /// Effettua update stato await BOM/PRICE per l'offerta indicata
+ ///
+ /// ID singola riga offerta
+ /// Se non nullo è il nuovo stato await BOM
+ /// Se non nullo è stato await Price
+ ///
+ internal async Task OffertUpdateAwaitState(int offerRowID, bool? awaitBom, bool? awaitPrice)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ // recupero righe offerta...
+ var currRec = dbCtx
+ .DbSetOfferRow
+ .Where(x => x.OfferRowID == offerRowID)
+ .FirstOrDefault();
+
+ // aggiorno parametri (se inviati)
+ if (currRec != null)
+ {
+ currRec.AwaitBom = awaitBom ?? currRec.AwaitBom;
+ currRec.AwaitPrice = awaitPrice ?? currRec.AwaitPrice;
+ dbCtx.Entry(currRec).State = EntityState.Modified;
+ }
+
+ // salvo i cambiamenti...
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertUpdateAwait{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
///
/// Effettua update dei costi di tutte le righe dell'offerta indicata
///
///
///
- public async Task OffertUpdateCost(int OfferID)
+ internal async Task OffertUpdateCost(int OfferID)
{
bool answ = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -734,60 +1599,18 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
// calcolo il NUOVO costo e lo aggiorno...
double totCost = 0;
+ double totPrice = 0;
int numGroupOk = 0;
int numItemOk = 0;
int numElems = bomList.Count;
// validazione e completamento BOM
- validateBom(itemGroupList, bomGenList, ref bomList, ref totCost, ref numGroupOk, ref numItemOk);
-#if false
- // ciclo x ogni elemento della BOM, cercando x gruppo e ExtItemCode
- foreach (var item in bomList)
- {
- // verifico item group esistente...
- if (itemGroupList.Where(x => x.CodGroup == item.ClassCode).Count() > 0)
- {
- numGroupOk++;
- }
- // 2025.09.16: se il prezzo arriva dalla BOM calcolata uso quello...
- if (item.Price > 0)
- {
- // resetto ItemID ma NON il prezzo
- item.ItemID = 0;
- // conto l'item
- numItemOk++;
- item.PriceEff = item.Price;
- }
- else
- {
- // cerco nella tab in memoria che ho precaricato il costo... cercando x dati di selezione + qtyRange
- var recCost = bomGenList
- .Where(x => x.CodGroup == item.ClassCode
- && x.ExtItemCode == item.ItemCode
- && item.Qty >= x.QtyMin
- && item.Qty < x.QtyMax)
- .OrderByDescending(x => x.Cost)
- .FirstOrDefault();
- // se trovato valorizzo!
- if (recCost != null)
- {
- numItemOk++;
- item.ItemID = recCost.ItemID;
- item.PriceEff = recCost.Cost * (1 + recCost.Margin);
- }
- else
- {
- item.ItemID = 0;
- item.PriceEff = 0;
- }
- // ...e aggiorno totale
- totCost += item.TotalCost;
- }
- }
-#endif
+ validateBom(itemGroupList, bomGenList, ref bomList, null, ref totCost, ref totPrice, ref numGroupOk, ref numItemOk);
// salvo BOM...
string itemBom = JsonConvert.SerializeObject(bomList);
currRec.ItemBOM = itemBom;
- currRec.Cost = totCost;
+ // salvo arrotondato alla 3° decimale
+ currRec.BomCost = Math.Round(totCost, 3);
+ currRec.BomPrice = Math.Round(totPrice, 3);
currRec.BomOk = numElems == numGroupOk;
currRec.ItemOk = numElems == numItemOk;
dbCtx.Entry(currRec).State = EntityState.Modified;
@@ -796,7 +1619,8 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
// salvo TUTTI i cambiamenti...
- await dbCtx.SaveChangesAsync();
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
}
catch (Exception exc)
{
@@ -806,15 +1630,57 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
+ ///
+ /// Upsert record offerta
+ ///
+ ///
+ ///
+ internal async Task OffertUpsert(OfferModel updRec)
+ {
+ bool answ = false;
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
+ using (DataLayerContext dbCtx = new DataLayerContext())
+ {
+ try
+ {
+ // recupero offerta...
+ var currRec = dbCtx
+ .DbSetOffer
+ .Where(x => x.OfferID == updRec.OfferID)
+ .FirstOrDefault();
+
+ // se non trovo aggiungo
+ if (currRec == null)
+ {
+ dbCtx.DbSetOffer.Add(updRec);
+ }
+ // altrimenti aggiorno
+ else
+ {
+ dbCtx.Entry(currRec).CurrentValues.SetValues(updRec);
+ }
+
+ // salvo TUTTI i cambiamenti...
+ var result = await dbCtx.SaveChangesAsync();
+ answ = result > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OffertUpsert{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
///
/// Esegue upsert del record offerta data la BOM ricevuta
///
///
///
- public bool OfferUpsertFromBom(string uID, List bomList)
+ internal bool OfferUpsertFromBom(string uID, List bomList)
{
bool answ = false;
- //using (DataLayerContext dbCtx = new DataLayerContext(configuration))
+ //using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
@@ -834,27 +1700,38 @@ namespace EgwCoreLib.Lux.Data.Controllers
// recupero il subset item da BOM...
var bomGenList = dbCtx
.DbSetItem
- .Where(x => x.ItemType == Core.Enums.ItemClassType.Bom)
+ //.Where(x => x.ItemType == Core.Enums.ItemClassType.Bom)
+ .Where(x => (x.ItemType == Core.Enums.ItemClassType.Bom || x.ItemType == Core.Enums.ItemClassType.BomAlt))
.ToList();
+ // recupero la BOM list precedente
+ var bomListPrev = JsonConvert.DeserializeObject>(currRec.ItemBOM);
+
// calcolo il NUOVO costo e lo aggiorno...
double totCost = 0;
+ double totPrice = 0;
int numGroupOk = 0;
int numItemOk = 0;
int numElems = bomList.Count;
// validazione e completamento BOM
- validateBom(itemGroupList, bomGenList, ref bomList, ref totCost, ref numGroupOk, ref numItemOk);
+ validateBom(itemGroupList, bomGenList, ref bomList, bomListPrev, ref totCost, ref totPrice, ref numGroupOk, ref numItemOk);
// salvo BOM...
string itemBom = JsonConvert.SerializeObject(bomList);
currRec.ItemBOM = itemBom;
- currRec.Cost = totCost;
+ // salvo arrotondato alla 3° decimale
+ currRec.BomCost = Math.Round(totCost, 3);
+ currRec.BomPrice = Math.Round(totPrice, 3);
currRec.BomOk = numElems == numGroupOk;
currRec.ItemOk = numElems == numItemOk;
+ // setto ok await di BOM e Price
+ currRec.AwaitBom = false;
+ currRec.AwaitPrice = false;
dbCtx.Entry(currRec).State = EntityState.Modified;
}
// salvo...
- dbCtx.SaveChanges();
+ var result = dbCtx.SaveChanges();
+ answ = result > 0;
}
catch (Exception exc)
{
@@ -864,7 +1741,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
- #endregion Public Methods
+ #endregion Internal Methods
#region Private Fields
@@ -880,17 +1757,22 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// Esegue completamento e la validazione dei dati BOM da lista articoli + gruppi,
/// validando i dati stessi
///
- ///
- ///
- ///
- ///
- ///
- ///
- private static void validateBom(List itemGroupList, List bomGenList, ref List bomList, ref double totCost, ref int numGroupOk, ref int numItemOk)
+ /// Elenco ItemGroup da considerare
+ /// Item di tipo BOM/BomAlt AMMESSI
+ /// Lista BOM ricevuta da validare
+ /// Lista BOM precedente da confrontare x scelta alternativi
+ /// Costo netto componenti BOM calcolato
+ /// Prezzo complessivo calcolato (con aggiunta marginalità )
+ /// Controllo coerenza calcoli sui gruppi items
+ /// Controllo coerenza calcoli su num items
+ private static void validateBom(List itemGroupList, List bomGenList, ref List bomList, List? bomListPrev, ref double totCost, ref double totPrice, ref int numGroupOk, ref int numItemOk)
{
+ double margin = 0;
// ciclo x ogni elemento della BOM, cercando x gruppo e ExtItemCode
foreach (var item in bomList)
{
+ // init del margine
+ margin = 0;
// verifico item group esistente...
if (itemGroupList.Where(x => x.CodGroup == item.ClassCode).Count() > 0)
{
@@ -905,6 +1787,8 @@ namespace EgwCoreLib.Lux.Data.Controllers
// conto l'item
numItemOk++;
item.PriceEff = item.Price;
+ // dovrei recuperare margine da BOM... da rivedere, x ora cablato 20%...
+ margin = 0.2;
}
else
{
@@ -924,9 +1808,33 @@ namespace EgwCoreLib.Lux.Data.Controllers
else
{
recCost = bomGenList
- .Where(x => x.CodGroup == item.ClassCode && x.ExtItemCode == item.ItemCode && item.Qty >= x.QtyMin && item.Qty < x.QtyMax)
+ .Where(x => x.CodGroup == item.ClassCode
+ && x.ItemIDParent == 0 // voglio NON sia un record CHILD
+ && x.ExtItemCode == item.ItemCode
+ && item.Qty >= x.QtyMin
+ && item.Qty < x.QtyMax)
.OrderByDescending(x => x.Cost)
.FirstOrDefault();
+ // 2025.09.24: se ho un elenco item della BOM precedente
+ if (bomListPrev != null && bomListPrev.Count > 0 && recCost != null)
+ {
+ // ...cerco item trovato come PARENT di altri item
+ var listAlt = bomGenList.Where(x => x.ItemIDParent == recCost.ItemID).ToList();
+
+ // che cerco nella nella BOM precedente...
+ var result = listAlt
+ .Join(
+ bomListPrev,
+ l1 => l1.ItemID,
+ l2 => l2.ItemID,
+ (l1, l2) => l1)
+ .ToList();
+ // nel caso ne trovassi solo 1 uso quello al posto del recCost...
+ if (result.Count == 1)
+ {
+ recCost = result.FirstOrDefault();
+ }
+ }
}
// se trovato valorizzo!
@@ -934,14 +1842,15 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
numItemOk++;
item.ItemID = recCost.ItemID;
- //item.PriceEff = recCost.Cost * (1 + recCost.Margin);
+ //item.PriceEff = recCost.BomCost * (1 + recCost.Margin);
item.PriceEff = recCost.Cost;
// se selezione esatta sovrascrivo altri valori
if (selExact)
{
item.ItemCode = recCost.ExtItemCode;
- //item.DescriptionCode = recCost.Description;
+ //item.DescriptionCode = recCost.Name;
}
+ margin = recCost.Margin;
}
else
{
@@ -951,6 +1860,8 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
// ...e aggiorno totale
totCost += item.TotalCost;
+ // e prezzo totale compreso margine
+ totPrice += item.TotalCost * (1 + margin);
}
}
diff --git a/EgwCoreLib.Lux.Data/DataLayerContext.cs b/EgwCoreLib.Lux.Data/DataLayerContext.cs
index 90cdcf13..af58ebce 100644
--- a/EgwCoreLib.Lux.Data/DataLayerContext.cs
+++ b/EgwCoreLib.Lux.Data/DataLayerContext.cs
@@ -1,4 +1,11 @@
-using EgwCoreLib.Lux.Data.DbModel;
+using EgwCoreLib.Lux.Data.DbModel.Config;
+using EgwCoreLib.Lux.Data.DbModel.Cost;
+using EgwCoreLib.Lux.Data.DbModel.Items;
+using EgwCoreLib.Lux.Data.DbModel.Production;
+using EgwCoreLib.Lux.Data.DbModel.Sales;
+using EgwCoreLib.Lux.Data.DbModel.Stock;
+using EgwCoreLib.Lux.Data.DbModel.Task;
+using EgwCoreLib.Lux.Data.DbModel.Utils;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using NLog;
@@ -39,12 +46,16 @@ namespace EgwCoreLib.Lux.Data
}
}
-
public virtual DbSet DbSetCounters { get; set; }
+ public virtual DbSet DbSetConfGlass { get; set; }
+ public virtual DbSet DbSetConfProfile { get; set; }
+ public virtual DbSet DbSetConfWood { get; set; }
+ public virtual DbSet DbSetEnvirPar { get; set; }
+
public virtual DbSet DbSetItemGroup { get; set; }
public virtual DbSet DbSetItem { get; set; }
public virtual DbSet DbSetSellItem { get; set; }
- public virtual DbSet DbSetRole { get; set; }
+ public virtual DbSet DbSetTags { get; set; }
public virtual DbSet DbSetCustomer { get; set; }
public virtual DbSet DbSetDealer { get; set; }
public virtual DbSet DbSetSupplier { get; set; }
@@ -55,14 +66,18 @@ namespace EgwCoreLib.Lux.Data
public virtual DbSet DbSetResource { get; set; }
public virtual DbSet DbSetPhase { get; set; }
public virtual DbSet DbSetJob { get; set; }
- public virtual DbSet DbSetJobRow { get; set; }
- public virtual DbSet DbSetJobRowItem { get; set; }
+ public virtual DbSet DbSetJobRow { get; set; }
+ public virtual DbSet DbSetJobRowItem { get; set; }
public virtual DbSet DbSetProdBatch { get; set; }
public virtual DbSet DbSetProdItem { get; set; }
- public virtual DbSet DbSetProdItemRow { get; set; }
+ public virtual DbSet DbSetProdItemRow { get; set; }
public virtual DbSet DbSetStockStatus { get; set; }
public virtual DbSet DbSetMovType { get; set; }
public virtual DbSet DbSetStockMov { get; set; }
+ public virtual DbSet DbSetGenClass { get; set; }
+ public virtual DbSet DbSetGenVal { get; set; }
+
+
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
@@ -73,12 +88,23 @@ namespace EgwCoreLib.Lux.Data
string connString = DbConfig.CONNECTION_STRING;
if (string.IsNullOrEmpty(connString))
{
+#if DEBUG
connString = "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;";
+ //connString = "Server=mdb.ufficio;port=3306;database=Lux_000_dev;uid=lux_user;pwd=Egal_pwd!;sslmode=None;";
+#else
+ connString = "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;";
+#endif
}
if (!optionsBuilder.IsConfigured)
{
var serverVersion = ServerVersion.AutoDetect(connString);
optionsBuilder.UseMySql(connString, serverVersion);
+ // verificare setup componente
+#if false
+ optionsBuilder
+ .UseMySql(connString, serverVersion)
+ .UseSnakeCaseNamingConvention(); // via EFCore.NamingConventions
+#endif
}
}
@@ -93,6 +119,13 @@ namespace EgwCoreLib.Lux.Data
modelBuilder.Entity()
.HasKey(c => new { c.RefYear, c.CountName});
+ modelBuilder.Entity()
+ .HasKey(c => new { c.GlassID });
+ modelBuilder.Entity()
+ .HasKey(c => new { c.ProfileID });
+ modelBuilder.Entity()
+ .HasKey(c => new { c.WoodID });
+
// fix valori timestamp
modelBuilder.Entity(entity =>
{
diff --git a/EgwCoreLib.Lux.Data/DbConfig.cs b/EgwCoreLib.Lux.Data/DbConfig.cs
index 9d91849e..23862df5 100644
--- a/EgwCoreLib.Lux.Data/DbConfig.cs
+++ b/EgwCoreLib.Lux.Data/DbConfig.cs
@@ -74,8 +74,12 @@ namespace EgwCoreLib.Lux.Data
DATABASE_NAME = $"Lux_{nKey}";
DATABASE_USER = $"user_{nKey}";
DATABASE_PWD = $"pwd_{sKey}";
- CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
// stringa admin con utente root egalware...
+#if DEBUG
+ CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME}_dev;uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
+#else
+ CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
+#endif
ADMIN_CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database=mysql;uid=root;pwd=Egalware_24068!;sslmode=None";
}
diff --git a/EgwCoreLib.Lux.Data/DbModel/UserPrivModel.cs b/EgwCoreLib.Lux.Data/DbModel/Admin/UserPrivModel.cs
similarity index 91%
rename from EgwCoreLib.Lux.Data/DbModel/UserPrivModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Admin/UserPrivModel.cs
index fa2a83c6..54831403 100644
--- a/EgwCoreLib.Lux.Data/DbModel/UserPrivModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Admin/UserPrivModel.cs
@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.Data.DbModel.Admin
{
///
/// Tabella dei USER di MySql
diff --git a/EgwCoreLib.Lux.Data/DbModel/Config/EnvirParamModel.cs b/EgwCoreLib.Lux.Data/DbModel/Config/EnvirParamModel.cs
new file mode 100644
index 00000000..aef7f46a
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Config/EnvirParamModel.cs
@@ -0,0 +1,26 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Config
+{
+ ///
+ /// Risorsa tipo di Glass x EF
+ ///
+ [Table("conf_envir")]
+ public class EnvirParamModel
+ {
+ ///
+ /// ID / Environment definito
+ ///
+ [Key]
+ public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS EnvirID { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
+
+ ///
+ /// Chiave da impiegare nel dizionario x inviare la struttura serializzata da calcolare
+ ///
+ public string SerStrucKey { get; set; } = "SerStr";
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Config/GlassModel .cs b/EgwCoreLib.Lux.Data/DbModel/Config/GlassModel .cs
new file mode 100644
index 00000000..1bab5f49
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Config/GlassModel .cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Config
+{
+ ///
+ /// Risorsa tipo di Glass x EF
+ ///
+ [Table("conf_glass")]
+ public class GlassModel : Egw.Window.Data.Glass
+ {
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Config/HardwareModel.cs b/EgwCoreLib.Lux.Data/DbModel/Config/HardwareModel.cs
new file mode 100644
index 00000000..59fb9cb7
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Config/HardwareModel.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Config
+{
+ ///
+ /// Risorsa tipo di Hardware x EF
+ ///
+ [Table("conf_Hardware")]
+ public class HardwareModel : Egw.Window.Data.Hardware
+ {
+ public HardwareModel(string Id, string FamilyName, string Description, Egw.Window.Data.Enums.OpeningTypes OpeningType, string Shape, int SashQty, int SashPosition) : base(Id, FamilyName, Description, OpeningType, Shape, SashQty, SashPosition)
+ {
+ }
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Config/ProfileModel.cs b/EgwCoreLib.Lux.Data/DbModel/Config/ProfileModel.cs
new file mode 100644
index 00000000..e6a9db9a
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Config/ProfileModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Config
+{
+ ///
+ /// Risorsa tipo di Wood x EF
+ ///
+ [Table("conf_profile")]
+ public class ProfileModel : Egw.Window.Data.Profile
+ {
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Config/WoodModel.cs b/EgwCoreLib.Lux.Data/DbModel/Config/WoodModel.cs
new file mode 100644
index 00000000..cd2aa5d7
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Config/WoodModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Config
+{
+ ///
+ /// Risorsa tipo di Wood x EF
+ ///
+ [Table("conf_wood")]
+ public class WoodModel : Egw.Window.Data.Wood
+ {
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Cost/CostDriverModel.cs b/EgwCoreLib.Lux.Data/DbModel/Cost/CostDriverModel.cs
new file mode 100644
index 00000000..a5ba4046
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Cost/CostDriverModel.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Cost
+{
+ ///
+ /// Rappresenta la definizione di un Driver Risorsa da convertire in WorkOur (driver di ResourceModel)
+ ///
+ [Table("cost_driver")]
+ public class CostDriverModel
+ {
+ [Key]
+ public int CostDriverID { get; set; }
+
+ ///
+ /// Nome driver
+ /// e.g. "WorkHour"
+ ///
+ public string Name { get; set; } = "";
+
+ ///
+ /// Nome dell'UM
+ /// e.g. "hour", "meter"
+ ///
+ public string Unit { get; set; } = "";
+
+ ///
+ /// Descrizione driver
+ /// e.g. "WorkHour"
+ ///
+ public string Descript { get; set; } = "";
+ }
+
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Cost/ResourceModel.cs b/EgwCoreLib.Lux.Data/DbModel/Cost/ResourceModel.cs
new file mode 100644
index 00000000..96d49aad
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Cost/ResourceModel.cs
@@ -0,0 +1,149 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Cost
+{
+ ///
+ /// Risorsa / Centro di Costo, con costi / Hourly
+ ///
+ [Table("cost_resource")]
+ public class ResourceModel
+ {
+ ///
+ /// ID del record
+ ///
+ [Key]
+ public int ResourceID { get; set; }
+
+ ///
+ /// Nome/Descrizione
+ ///
+ public string Name { get; set; } = string.Empty;
+
+ ///
+ /// ID del driver di costo impiegato, tipicamente 1 = WorkHour
+ ///
+ public int CostDriverID { get; set; }
+
+ ///
+ /// Valore di riferimento del CostDriver per il calcolo dell'importo unitario della risorsa
+ /// Se è basato su WorkHour diventa il budget annuale della risorsa disponibile
+ /// Tipicamente le Ore di impiego a buget risorsa, es 220gg x 8h
+ ///
+ public decimal CostDriverBudget { get; set; } = 1;
+
+ ///
+ /// Costo totale (rif al CostDriverBudget) componente FIXED (macchinari) della risorsa (ove applicabile), comprendendo
+ /// - ammortamenti
+ /// - costi di manutenzione ordinaria
+ /// - costi di manutenzione straordinaria (se stimabili, in periodo post ammortamento)
+ ///
+ public decimal FixedCost { get; set; } = 0;
+
+ ///
+ /// Costo totale (rif al CostDriverBudget) componente variabile (tipicamente Energia)
+ /// nb: stima basata sul (costo medio energia aziendale) * consumo effettivo (se disponibile), altrimenti (stima potenza media impiegata) * (ore di impiego stimate)
+ ///
+ public decimal VariableCost { get; set; } = 0;
+
+ ///
+ /// Costo della componente HR sulla gestione impianto (rif al CostDriverBudget)
+ ///
+ public decimal LaborCost { get; set; } = 0;
+
+ ///
+ /// Costi di OverHead (rif al CostDriverBudget) da ribaltare su risorsa (tipicamente struttura)
+ ///
+ public decimal OverHeadCost { get; set; } = 0;
+
+ ///
+ /// Costo di overhead (come % on top del resto)
+ ///
+ public decimal OverHeadPerc { get; set; } = 0.15M;
+
+ ///
+ /// EBT ovvero marginalità minima garantita on top del resto dei costi e OH
+ ///
+ public decimal EBTPerc { get; set; } = 0.1M;
+
+ ///
+ /// Margine sul prezzo ovvero valore da potersi eventualmente scontare
+ ///
+ public decimal PriceMargin { get; set; } = 0.2M;
+
+ ///
+ /// Costo Netto la risorsa su base CostDriver
+ ///
+
+ [NotMapped]
+ private decimal BaseNetCost
+ {
+ get => CostDriverBudget == 0 ? 0 : (FixedCost + VariableCost + OverHeadCost) / CostDriverBudget;
+ }
+
+ ///
+ /// Costo RockBottom Risorsa su base CostDriver
+ ///
+ [NotMapped]
+ public decimal BaseRockBottomCost
+ {
+ get => BaseNetCost * (1 + OverHeadPerc) * (1 + EBTPerc);
+ }
+
+ ///
+ /// Prezzo comprensivo di margine di ricarico massimo scontabile (sul RockBottom)
+ ///
+ [NotMapped]
+ public decimal BasePrice
+ {
+ get => BaseRockBottomCost * (1 + PriceMargin);
+ }
+
+
+ ///
+ /// Navigazione Driver costo
+ ///
+ [ForeignKey("CostDriverID")]
+ public virtual CostDriverModel DriverNav { get; set; } = null!;
+#if false
+ ///
+ /// Indica gli asset/cespiti
+ ///
+ public bool IsAsset { get; set; } = false;
+
+ ///
+ /// Indica che è un operatore umano
+ ///
+ public bool IsHuman { get; set; } = false;
+
+ ///
+ /// Costo fisso risorsa per UM tipo ammortamento
+ ///
+ public double UnitCostFix { get; set; } = 0;
+
+ ///
+ /// Unità di misura della risorsa tipo fisso/ammortamento
+ ///
+ public string UmFix { get; set; } = "";
+
+ ///
+ /// Costo unitario risorsa per UM tipo consumabili
+ ///
+ public double UnitCostProp { get; set; } = 0;
+
+ ///
+ /// Unità di misura della risorsa
+ ///
+ public string UmProp { get; set; } = string.Empty;
+#endif
+
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/ItemGroupModel.cs b/EgwCoreLib.Lux.Data/DbModel/Items/ItemGroupModel.cs
similarity index 90%
rename from EgwCoreLib.Lux.Data/DbModel/ItemGroupModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Items/ItemGroupModel.cs
index e4c88aca..732f0aa0 100644
--- a/EgwCoreLib.Lux.Data/DbModel/ItemGroupModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Items/ItemGroupModel.cs
@@ -6,12 +6,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Items
{ //
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegItemGroup")]
+ [Table("item_group")]
public class ItemGroupModel
{
diff --git a/EgwCoreLib.Lux.Data/DbModel/ItemModel.cs b/EgwCoreLib.Lux.Data/DbModel/Items/ItemModel.cs
similarity index 94%
rename from EgwCoreLib.Lux.Data/DbModel/ItemModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Items/ItemModel.cs
index 8c7e3754..0a5f5aeb 100644
--- a/EgwCoreLib.Lux.Data/DbModel/ItemModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Items/ItemModel.cs
@@ -2,13 +2,13 @@
using System.ComponentModel.DataAnnotations.Schema;
using static EgwCoreLib.Lux.Core.Enums;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Items
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegItem")]
+ [Table("item_item")]
public class ItemModel
{
///
@@ -85,7 +85,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
[NotMapped]
public bool IsOkQty
{
- get => QtyMax > 0 && (QtyMax - QtyMin) > 0;
+ get => QtyMax > 0 && QtyMax - QtyMin > 0;
}
///
@@ -117,7 +117,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
[NotMapped]
public bool IsProtected
{
- get => this.ItemType == EgwCoreLib.Lux.Core.Enums.ItemClassType.Bom;
+ get => ItemType == ItemClassType.Bom;
}
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/SellingItemModel.cs b/EgwCoreLib.Lux.Data/DbModel/Items/SellingItemModel.cs
similarity index 76%
rename from EgwCoreLib.Lux.Data/DbModel/SellingItemModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Items/SellingItemModel.cs
index 9f2d4101..921755d0 100644
--- a/EgwCoreLib.Lux.Data/DbModel/SellingItemModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Items/SellingItemModel.cs
@@ -1,13 +1,14 @@
-using System.ComponentModel.DataAnnotations;
+using EgwCoreLib.Lux.Data.DbModel.Task;
+using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Items
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("SellingItem")]
+ [Table("item_selling_item")]
public class SellingItemModel
{
///
@@ -16,6 +17,11 @@ namespace EgwCoreLib.Lux.Data.DbModel
[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
///
@@ -67,9 +73,10 @@ namespace EgwCoreLib.Lux.Data.DbModel
public string SerStruct { get; set; } = "";
///
- /// Json contenente la serializzazione delle fasi previste per la stima dei tempi e costi in formato SerializedPhasePreview; potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
+ /// Elenco StepDTO (Fasi) per la stima tempi / costi
+ /// potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
///
- public string ItemSPP { get; set; } = "";
+ public string ItemSteps { get; set; } = "";
///
/// Navigazione Job/Cicli
diff --git a/EgwCoreLib.Lux.Data/DbModel/SupplierModel.cs b/EgwCoreLib.Lux.Data/DbModel/Items/SupplierModel.cs
similarity index 94%
rename from EgwCoreLib.Lux.Data/DbModel/SupplierModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Items/SupplierModel.cs
index a43db096..437256ff 100644
--- a/EgwCoreLib.Lux.Data/DbModel/SupplierModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Items/SupplierModel.cs
@@ -6,13 +6,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Items
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegSupplier")]
+ [Table("item_supplier")]
public class SupplierModel
{
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/JobModel.cs b/EgwCoreLib.Lux.Data/DbModel/JobModel.cs
deleted file mode 100644
index 8d7effef..00000000
--- a/EgwCoreLib.Lux.Data/DbModel/JobModel.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace EgwCoreLib.Lux.Data.DbModel
-{
-
- [Table("JobList")]
- public class JobModel
- {
- ///
- /// ID del record
- ///
- [Key]
- public int JobID { get; set; }
-
- ///
- /// Descrizione del ciclo
- ///
- public string Description { get; set; } = "";
- }
-}
diff --git a/EgwCoreLib.Lux.Data/DbModel/JobRowModel.cs b/EgwCoreLib.Lux.Data/DbModel/JobRowModel.cs
deleted file mode 100644
index 7c885d68..00000000
--- a/EgwCoreLib.Lux.Data/DbModel/JobRowModel.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-//
-// This is here so CodeMaid doesn't reorganize this document
-//
-namespace EgwCoreLib.Lux.Data.DbModel
-{
- [Table("JobRowList")]
- public class JobRowModel
- {
- ///
- /// ID del record
- ///
- [Key]
- public int JobRowID { get; set; }
-
- ///
- /// Ciclo di appartenenza
- ///
- public int JobID { get; set; }
-
- ///
- /// Indice della fase all'interno del Job
- ///
- public int Index { get; set; } = 0;
-
- ///
- /// ID della fase realizzata
- ///
- public int PhaseID { get; set; }
-
- ///
- /// ID dellaa risorsa impiegata
- ///
- public int ResourceID { get; set; }
-
- ///
- /// Descrizione della fase del Job
- ///
- public string Description { get; set; } = "";
-
- ///
- /// Margine percentuale standard
- ///
- public double Qty { get; set; } = 1;
-
- ///
- /// Navigazione Job/Cicli
- ///
- [ForeignKey("JobID")]
- public virtual JobModel JobNav { get; set; } = null!;
-
- ///
- /// Navigazione Job/Cicli
- ///
- [ForeignKey("PhaseID")]
- public virtual PhaseModel PhaseNav { get; set; } = null!;
-
- ///
- /// Navigazione Job/Cicli
- ///
- [ForeignKey("ResourceID")]
- public virtual ResourceModel ResourceNav { get; set; } = null!;
- }
-}
diff --git a/EgwCoreLib.Lux.Data/DbModel/OfferRowModel.cs b/EgwCoreLib.Lux.Data/DbModel/OfferRowModel.cs
deleted file mode 100644
index 48295e22..00000000
--- a/EgwCoreLib.Lux.Data/DbModel/OfferRowModel.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace EgwCoreLib.Lux.Data.DbModel
-{
- //
- // This is here so CodeMaid doesn't reorganize this document
- //
-
- [Table("OfferRowList")]
- public class OfferRowModel
- {
- ///
- /// ID del record
- ///
- [Key]
- public int OfferRowID { get; set; }
-
- ///
- /// Riferimento offerta
- ///
- public int OfferID { get; set; }
-
- ///
- /// Riga Offerta (per ordinamento)
- ///
- public int RowNum { get; set; } = 0;
-
- ///
- /// Campo salvato dell'Environment
- ///
- public string Environment { get; set; } = "WINDOW";
-
- ///
- /// Campo salvato dell'UID da codice DataMatrix calcolato
- ///
- public string OfferRowUID { get; set; } = "OFF00001230AZ";
-
- ///
- /// Codice calcolato offerta ANNO.ID_RIGA_OFFERTA (0...Z come Dtx)
- ///
- [NotMapped]
- public string OfferRowDtx
- {
- get => $"OFF{Inserted.Year:yy}{OfferRowID:000000000}";
- }
-
- ///
- /// ID dell'articolo di vendita offerto
- ///
- public int SellingItemID { get; set; }
-
- ///
- /// Costo (standard / senza listini)
- ///
- public double Cost { get; set; } = 0;
-
- ///
- /// Margine percentuale standard
- ///
- public double Qty { get; set; } = 1;
-
- [NotMapped]
- public double TotalCost
- {
- get => Qty * Cost;
- }
-
- ///
- /// Valore serializzato della composizione articolo (in formato JWD x finestra)
- ///
- public string SerStruct { get; set; } = "";
-
- ///
- /// Json contenente la serializzazione delle fasi previste per la stima dei tempi e costi in formato SerializedPhasePreview; potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
- ///
- public string ItemSPP { get; set; } = "";
-
- ///
- /// BOM serializzata per la produzione dell'item
- ///
- public string ItemBOM { get; set; } = "";
-
- ///
- /// Validazione dati BOM (Inteso come gruppi tutti trovati/esistenti)
- ///
- public bool BomOk { get; set; } = false;
-
- ///
- /// Validazione livello item per Costo e range dimensione
- ///
- public bool ItemOk { get; set; } = false;
-
- ///
- /// Note libere
- ///
- public string Note { get; set; } = "";
-
-#if false
- ///
- /// Stack degli ultimi item serializzati per Uno/Redo actions
- ///
- [NotMapped]
- public List UndoRedoSerStruct { get; set; } = new List();
-#endif
-
-
- ///
- /// DataOra inserimento
- ///
- public DateTime Inserted { get; set; } = DateTime.Now;
-
- ///
- /// DataOra ultima modifica
- ///
- public DateTime Modified { get; set; } = DateTime.Now;
-
- ///
- /// Navigazione Offer
- ///
- [ForeignKey("OfferID")]
- public virtual OfferModel OfferNav { get; set; } = null!;
-
- ///
- /// Navigazione Item
- ///
- [ForeignKey("SellingItemID")]
- public virtual SellingItemModel SellingItemNav { get; set; } = null!;
- }
-}
diff --git a/EgwCoreLib.Lux.Data/DbModel/ProductionBatchModel.cs b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionBatchModel.cs
similarity index 92%
rename from EgwCoreLib.Lux.Data/DbModel/ProductionBatchModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Production/ProductionBatchModel.cs
index 8a333ea2..861240e1 100644
--- a/EgwCoreLib.Lux.Data/DbModel/ProductionBatchModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionBatchModel.cs
@@ -1,13 +1,13 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Production
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("ProductionBatch")]
+ [Table("production_batch")]
public class ProductionBatchModel
{
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/ProductionItemModel.cs b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionItemModel.cs
similarity index 92%
rename from EgwCoreLib.Lux.Data/DbModel/ProductionItemModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Production/ProductionItemModel.cs
index 802c0bb2..a3c30f23 100644
--- a/EgwCoreLib.Lux.Data/DbModel/ProductionItemModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionItemModel.cs
@@ -1,13 +1,14 @@
-using System.ComponentModel.DataAnnotations;
+using EgwCoreLib.Lux.Data.DbModel.Sales;
+using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Production
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("ProductionItem")]
+ [Table("production_item")]
public class ProductionItemModel
{
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/ProductionItemRowModel.cs b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionItemStepModel.cs
similarity index 86%
rename from EgwCoreLib.Lux.Data/DbModel/ProductionItemRowModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Production/ProductionItemStepModel.cs
index 0a423ef0..d980c01a 100644
--- a/EgwCoreLib.Lux.Data/DbModel/ProductionItemRowModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionItemStepModel.cs
@@ -1,4 +1,6 @@
-using System;
+using EgwCoreLib.Lux.Data.DbModel.Cost;
+using EgwCoreLib.Lux.Data.DbModel.Task;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -9,19 +11,19 @@ using System.Threading.Tasks;
//
// This is here so CodeMaid doesn't reorganize this document
//
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Production
{
///
- /// Tabella delel effettiva righe della fgasi di lavorazione x ogni item da produrre
+ /// Tabella delle fasi di lavorazione x ogni item da produrre
///
- [Table("ProductionItemRowList")]
- public class ProductionItemRowModel
+ [Table("production_item_step")]
+ public class ProductionItemStepModel
{
///
/// ID del record
///
[Key]
- public int ProdItemRowID { get; set; }
+ public int ProdItemStepID { get; set; }
///
/// Item di appartenenza
diff --git a/EgwCoreLib.Lux.Data/DbModel/ResourceModel.cs b/EgwCoreLib.Lux.Data/DbModel/ResourceModel.cs
deleted file mode 100644
index 3b8d08e6..00000000
--- a/EgwCoreLib.Lux.Data/DbModel/ResourceModel.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-//
-// This is here so CodeMaid doesn't reorganize this document
-//
-namespace EgwCoreLib.Lux.Data.DbModel
-{
- [Table("RegResource")]
- public class ResourceModel
- {
- ///
- /// ID del record
- ///
- [Key]
- public int ResourceID { get; set; }
-
- ///
- /// Descrizione
- ///
- public string Description { get; set; } = "";
-
- ///
- /// Indica gli assec/cespiti
- ///
- public bool IsAsset { get; set; } = false;
-
- ///
- /// Indica che è un operatore umano
- ///
- public bool IsHuman { get; set; } = false;
-
- ///
- /// Costo fisso risorsa per UM tipo ammortamento
- ///
- public double UnitCostFix { get; set; } = 0;
-
- ///
- /// Unità di misura della risorsa tipo fisso/ammortamento
- ///
- public string UmFix { get; set; } = "";
-
- ///
- /// Costo unitario risorsa per UM tipo consumabili
- ///
- public double UnitCostProp { get; set; } = 0;
-
- ///
- /// Unità di misura della risorsa
- ///
- public string UmProp { get; set; } = "";
-
- }
-}
diff --git a/EgwCoreLib.Lux.Data/DbModel/CustomerModel.cs b/EgwCoreLib.Lux.Data/DbModel/Sales/CustomerModel.cs
similarity index 94%
rename from EgwCoreLib.Lux.Data/DbModel/CustomerModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Sales/CustomerModel.cs
index 0bb9b024..cb9e62db 100644
--- a/EgwCoreLib.Lux.Data/DbModel/CustomerModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Sales/CustomerModel.cs
@@ -6,13 +6,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegCustomer")]
+ [Table("sales_customer")]
public class CustomerModel
{
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/DealerModel.cs b/EgwCoreLib.Lux.Data/DbModel/Sales/DealerModel.cs
similarity index 94%
rename from EgwCoreLib.Lux.Data/DbModel/DealerModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Sales/DealerModel.cs
index 45678c6c..b2e9cd5b 100644
--- a/EgwCoreLib.Lux.Data/DbModel/DealerModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Sales/DealerModel.cs
@@ -6,13 +6,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegDealer")]
+ [Table("sales_dealer")]
public class DealerModel
{
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/OfferModel.cs b/EgwCoreLib.Lux.Data/DbModel/Sales/OfferModel.cs
similarity index 63%
rename from EgwCoreLib.Lux.Data/DbModel/OfferModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Sales/OfferModel.cs
index 36406cdb..51c45065 100644
--- a/EgwCoreLib.Lux.Data/DbModel/OfferModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Sales/OfferModel.cs
@@ -1,20 +1,14 @@
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using static EgwCoreLib.Lux.Core.Enums;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("Offer")]
+ [Table("sales_offer")]
public class OfferModel
{
///
@@ -23,6 +17,11 @@ namespace EgwCoreLib.Lux.Data.DbModel
[Key]
public int OfferID { get; set; }
+ ///
+ /// Environment della richiesta
+ ///
+ public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS Envir { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
+
///
/// Anno rif offerta
///
@@ -40,11 +39,12 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
/// Codice calcolato offerta ANNO.NUMERO.REV
+ /// inizia per SO = SalesOffer
///
[NotMapped]
public string OfferCode
{
- get => $"{RefYear:00}.{RefNum:00000}.{RefRev:00}";
+ get => $"SO.{RefYear:00}.{RefNum:000000}.{RefRev:000}";
}
///
@@ -62,6 +62,16 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
public int DealerID { get; set; }
+ ///
+ /// Dizionario serializzato delle preselezioni (opzionale)
+ ///
+ public string DictPresel { get; set; } = "";
+
+ ///
+ /// note di consegna (opzionali)
+ ///
+ public string ConsNote { get; set; } = "";
+
///
/// Validità offerta
///
@@ -77,30 +87,61 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
public DateTime Modified { get; set; } = DateTime.Now;
-
///
/// Enum stato offerta
///
public OfferStates OffertState { get; set; } = OfferStates.Open;
+ ///
+ /// Sconto applicato (deve essere < del MAX)
+ ///
+ public double Discount { get; set; } = 0;
+
///
/// Numero Item compresi
///
[NotMapped]
- public int NumItems
+ public double NumItems
+ {
+ get => OfferRowNav?.Sum(x => x.Qty) ?? 0;
+ }
+ ///
+ /// Numero Item compresi
+ ///
+ [NotMapped]
+ public int NumRows
{
get => OfferRowNav?.Count ?? 0;
}
///
- /// Imposto totale offerta
+ /// Costo totale offerta (rock bottom)
///
[NotMapped]
public double TotalCost
{
- get => OfferRowNav?.Sum(x => x.Cost) ?? 0;
+ get => OfferRowNav?.Sum(x => x.TotalCost) ?? 0;
}
+ ///
+ /// Prezzo totale offerta (compreso di amrginalità )
+ ///
+ [NotMapped]
+ public double TotalPrice
+ {
+ get => OfferRowNav?.Sum(x => x.TotalPrice) ?? 0;
+ }
+
+ ///
+ /// Sconto massimo applicabile
+ ///
+ [NotMapped]
+ public double MaxDiscount
+ {
+ get => (TotalCost > 0 && TotalPrice > TotalCost) ? (TotalPrice - TotalCost) / TotalPrice : 0;
+ }
+
+
#if false
///
/// ID Ordine (nullo se non c'è ordine)
@@ -126,6 +167,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
[ForeignKey("DealerID")]
public virtual DealerModel DealerNav { get; set; } = null!;
+
///
/// Navigazione alle righe offerta
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/Sales/OfferRowModel.cs b/EgwCoreLib.Lux.Data/DbModel/Sales/OfferRowModel.cs
new file mode 100644
index 00000000..2cf93528
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Sales/OfferRowModel.cs
@@ -0,0 +1,214 @@
+using EgwCoreLib.Lux.Data.DbModel.Items;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Sales
+{
+
+ [Table("sales_offer_row")]
+ public class OfferRowModel
+ {
+ ///
+ /// ID del record
+ ///
+ [Key]
+ public int OfferRowID { get; set; }
+
+ ///
+ /// Riferimento offerta
+ ///
+ public int OfferID { get; set; }
+
+ ///
+ /// Riga Offerta (per ordinamento)
+ ///
+ public int RowNum { get; set; } = 0;
+
+ ///
+ /// Environment della richiesta
+ ///
+ public EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS Envir { get; set; } = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW;
+
+ ///
+ /// Campo salvato dell'UID da codice DataMatrix calcolato
+ /// inizia per SOR = SalesOfferRow
+ ///
+ public string OfferRowUID { get; set; } = "SOR.25.0123ABCD";
+
+ ///
+ /// Codice calcolato offerta ANNO.ID_RIGA_OFFERTA in HEX (0xFFFFFFFF)
+ ///
+ [NotMapped]
+ public string OfferRowDtx
+ {
+ get => $"SOR.{Inserted:yy}.{OfferRowID:X8}";
+ }
+
+ ///
+ /// ID dell'articolo di vendita offerto
+ ///
+ public int SellingItemID { get; set; }
+
+ ///
+ /// Quantità della risorsa
+ ///
+ public double Qty { get; set; } = 1;
+
+ ///
+ /// Costo dei componeti BOM (RockBottom)
+ ///
+ public double BomCost { get; set; } = 0;
+
+ ///
+ /// Prezzo dei componeti BOM (scontabile)
+ ///
+ public double BomPrice { get; set; } = 0;
+
+
+ ///
+ /// Costo produzione Fase/Step (RockBottom)
+ ///
+ public double StepCost { get; set; } = 0;
+
+ ///
+ /// Prezzo produzione Fase/Step (scontabile)
+ ///
+ public double StepPrice { get; set; } = 0;
+
+ ///
+ /// Costo Totale Risorsa (BOM + Fase)
+ ///
+ [NotMapped]
+ public double UnitCost
+ {
+ get => BomCost + StepCost;
+ }
+
+ ///
+ /// Costo Totale Risorsa (BOM + Fase)
+ ///
+ [NotMapped]
+ public double UnitPrice
+ {
+ get => BomPrice + StepPrice;
+ }
+
+ ///
+ /// Sconto massimo applicabile
+ ///
+ [NotMapped]
+ public double MaxDiscount
+ {
+ get => (UnitCost > 0 && UnitPrice > UnitCost) ? (UnitPrice - UnitCost) / UnitPrice : 0;
+ }
+
+ ///
+ /// Costo Totale risorsa
+ ///
+ [NotMapped]
+ public double TotalCost
+ {
+ get => UnitCost * Qty;
+ }
+
+ ///
+ /// Costo Totale risorsa
+ ///
+ [NotMapped]
+ public double TotalPrice
+ {
+ get => UnitPrice * Qty;
+ }
+
+ ///
+ /// Valore serializzato della composizione articolo (in formato JWD x finestra)
+ ///
+ public string SerStruct { get; set; } = "";
+
+ ///
+ /// Nomi risorsa file associato alla riga offerta (es per BTL)
+ /// URI come risorsa dentro folder offerta/riga-offerta/guid
+ ///
+ public string FileResource { get; set; } = "";
+
+ ///
+ /// Nomi file originale associato alla riga offerta (es per BTL)
+ ///
+ public string FileName { get; set; } = "";
+
+ ///
+ /// Dimensione del file (per visualizzazione rapida)
+ ///
+ public long FileSize { get; set; } = 0;
+
+ ///
+ /// Elenco StepDTO (Fasi) per la stima tempi / costi
+ /// potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
+ ///
+ public string ItemSteps { get; set; } = "";
+
+ ///
+ /// BOM serializzata per la produzione dell'item
+ ///
+ public string ItemBOM { get; set; } = "";
+
+ ///
+ /// Validazione dati BOM (Inteso come gruppi tutti trovati/esistenti)
+ ///
+ public bool BomOk { get; set; } = false;
+
+ ///
+ /// Validazione livello item per Costo e range dimensione
+ ///
+ public bool ItemOk { get; set; } = false;
+
+ ///
+ /// Note libere
+ ///
+ public string Note { get; set; } = "";
+
+#if false
+ ///
+ /// Stack degli ultimi item serializzati per Uno/Redo actions
+ ///
+ [NotMapped]
+ public List UndoRedoSerStruct { get; set; } = new List();
+#endif
+
+
+ ///
+ /// DataOra inserimento
+ ///
+ public DateTime Inserted { get; set; } = DateTime.Now;
+
+ ///
+ /// DataOra ultima modifica
+ ///
+ public DateTime Modified { get; set; } = DateTime.Now;
+
+ ///
+ /// Indica che è in attesa aggiornamento BOM
+ ///
+ public bool AwaitBom { get; set; } = false;
+
+ ///
+ /// Indica che è in attesa aggiornamento Price
+ ///
+ public bool AwaitPrice { get; set; } = false;
+
+ ///
+ /// Navigazione Offer
+ ///
+ [ForeignKey("OfferID")]
+ public virtual OfferModel OfferNav { get; set; } = null!;
+
+ ///
+ /// Navigazione Item
+ ///
+ [ForeignKey("SellingItemID")]
+ public virtual SellingItemModel SellingItemNav { get; set; } = null!;
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/OrderModel.cs b/EgwCoreLib.Lux.Data/DbModel/Sales/OrderModel.cs
similarity index 88%
rename from EgwCoreLib.Lux.Data/DbModel/OrderModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Sales/OrderModel.cs
index cc544a59..bf3969e0 100644
--- a/EgwCoreLib.Lux.Data/DbModel/OrderModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Sales/OrderModel.cs
@@ -8,7 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using static EgwCoreLib.Lux.Core.Enums;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
//
// This is here so CodeMaid doesn't reorganize this document
@@ -17,7 +17,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
/// Classe degli ordini commerciali
///
- [Table("Order")]
+ [Table("sales_order")]
public class OrderModel
{
///
@@ -70,6 +70,16 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
public int DealerID { get; set; }
+ ///
+ /// note di consegna (opzionali)
+ ///
+ public string ConsNote { get; set; } = "";
+
+ ///
+ /// Dizionario serializzato delle preselezioni (opzionale)
+ ///
+ public string DictPresel { get; set; } = "";
+
///
/// Validità Ordine
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/OrderRowModel.cs b/EgwCoreLib.Lux.Data/DbModel/Sales/OrderRowModel.cs
similarity index 55%
rename from EgwCoreLib.Lux.Data/DbModel/OrderRowModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Sales/OrderRowModel.cs
index 162720d4..68f12fda 100644
--- a/EgwCoreLib.Lux.Data/DbModel/OrderRowModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Sales/OrderRowModel.cs
@@ -1,4 +1,5 @@
-using Microsoft.EntityFrameworkCore;
+using EgwCoreLib.Lux.Data.DbModel.Items;
+using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@@ -7,13 +8,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Sales
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("OrderRowList")]
+ [Table("sales_order_row")]
public class OrderRowModel
{
///
@@ -33,12 +34,13 @@ namespace EgwCoreLib.Lux.Data.DbModel
public int RowNum { get; set; } = 0;
///
- /// Codice calcolato Ordine ANNO.NUMERO.REV
+ /// Codice calcolato Ordine ANNO.NUMERO
+ /// inizia per PO = PurchaseOrder
///
[NotMapped]
public string OrderRowCode
{
- get => $"{OrderRowID:0000}.{RowNum:000}";
+ get => $"PO{OrderRowID:000000}.{RowNum:000}";
}
///
@@ -47,19 +49,74 @@ namespace EgwCoreLib.Lux.Data.DbModel
public int SellingItemID { get; set; }
///
- /// Costo (standard / senza listini)
+ /// Costo dei componeti BOM (RockBottom)
///
- public double Cost { get; set; } = 0;
+ public double BomCost { get; set; } = 0;
///
/// Margine percentuale standard
///
public double Qty { get; set; } = 1;
+ ///
+ /// Prezzo dei componeti BOM (scontabile)
+ ///
+ public double BomPrice { get; set; } = 0;
+
+
+ ///
+ /// Costo produzione Fase/Step (RockBottom)
+ ///
+ public double StepCost { get; set; } = 0;
+
+ ///
+ /// Prezzo produzione Fase/Step (scontabile)
+ ///
+ public double StepPrice { get; set; } = 0;
+
+ ///
+ /// Costo Totale Risorsa (BOM + Fase)
+ ///
+ [NotMapped]
+ public double UnitCost
+ {
+ get => BomCost + StepCost;
+ }
+
+ ///
+ /// Costo Totale Risorsa (BOM + Fase)
+ ///
+ [NotMapped]
+ public double UnitPrice
+ {
+ get => BomPrice + StepPrice;
+ }
+
+ ///
+ /// Sconto massimo applicabile
+ ///
+ [NotMapped]
+ public double MaxDiscount
+ {
+ get => (UnitCost > 0 && UnitPrice > UnitCost) ? (UnitPrice - UnitCost) / UnitPrice : 0;
+ }
+
+ ///
+ /// Costo Totale risorsa
+ ///
[NotMapped]
public double TotalCost
{
- get => Qty * Cost;
+ get => UnitCost * Qty;
+ }
+
+ ///
+ /// Costo Totale risorsa
+ ///
+ [NotMapped]
+ public double TotalPrice
+ {
+ get => UnitPrice * Qty;
}
///
@@ -68,9 +125,10 @@ namespace EgwCoreLib.Lux.Data.DbModel
public string SerStruct { get; set; } = "";
///
- /// Json contenente la serializzazione delle fasi previste per la stima dei tempi e costi in formato SerializedPhasePreview; potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
+ /// Elenco StepDTO (Fasi) per la stima tempi / costi
+ /// potrebbe contenere anche altre info accessorie x definire dati logistico/gestionali
///
- public string ItemSPP { get; set; } = "";
+ public string ItemSteps { get; set; } = "";
///
/// Note libere
diff --git a/EgwCoreLib.Lux.Data/DbModel/StockMovModel.cs b/EgwCoreLib.Lux.Data/DbModel/Stock/StockMovModel.cs
similarity index 92%
rename from EgwCoreLib.Lux.Data/DbModel/StockMovModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Stock/StockMovModel.cs
index 7e986260..f7db6947 100644
--- a/EgwCoreLib.Lux.Data/DbModel/StockMovModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Stock/StockMovModel.cs
@@ -1,4 +1,5 @@
-using System;
+using EgwCoreLib.Lux.Data.DbModel.Utils;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -6,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Stock
{
//
// This is here so CodeMaid doesn't reorganize this document
@@ -14,7 +15,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
/// Tabella dei movimenti degli item in giacenza
///
- [Table("StockMov")]
+ [Table("stock_mov")]
public class StockMovModel
{
///
@@ -39,7 +40,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
public DateTime DtMod { get; set; } = DateTime.Now;
///
- /// Qty movimento registrato (delta +/-)
+ /// ProductivityRate movimento registrato (delta +/-)
///
public double QtyRec { get; set; } = 0;
diff --git a/EgwCoreLib.Lux.Data/DbModel/StockStatusModel.cs b/EgwCoreLib.Lux.Data/DbModel/Stock/StockStatusModel.cs
similarity index 91%
rename from EgwCoreLib.Lux.Data/DbModel/StockStatusModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Stock/StockStatusModel.cs
index 15b7d604..fad8b9fd 100644
--- a/EgwCoreLib.Lux.Data/DbModel/StockStatusModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Stock/StockStatusModel.cs
@@ -1,4 +1,5 @@
-using System;
+using EgwCoreLib.Lux.Data.DbModel.Items;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -6,7 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Stock
{
//
// This is here so CodeMaid doesn't reorganize this document
@@ -15,7 +16,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
/// Tabelal delle giacenze di magazzino
///
- [Table("StockStatus")]
+ [Table("stock_status")]
public class StockStatusModel
{
///
@@ -30,7 +31,7 @@ namespace EgwCoreLib.Lux.Data.DbModel
public int ItemID { get; set; } = 0;
///
- /// Qty in giacenza
+ /// ProductivityRate in giacenza
///
public double QtyAvail { get; set; } = 0;
diff --git a/EgwCoreLib.Lux.Data/DbModel/Task/JobModel.cs b/EgwCoreLib.Lux.Data/DbModel/Task/JobModel.cs
new file mode 100644
index 00000000..c26e9c5a
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Task/JobModel.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Task
+{
+ ///
+ /// Definizione macro dei Cicli di Lavoro / Job
+ ///
+ [Table("task_job")]
+ public class JobModel
+ {
+ ///
+ /// ID del record
+ ///
+ [Key]
+ public int JobID { get; set; }
+
+ ///
+ /// Descrizione del ciclo di lavoro
+ ///
+ public string Description { get; set; } = "";
+
+ ///
+ /// Navigation verso JobStep
+ ///
+ public virtual ICollection JobStepNav { get; set; } = new List();
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/JobRowItemModel.cs b/EgwCoreLib.Lux.Data/DbModel/Task/JobStepItemModel.cs
similarity index 74%
rename from EgwCoreLib.Lux.Data/DbModel/JobRowItemModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Task/JobStepItemModel.cs
index 015e2173..20229775 100644
--- a/EgwCoreLib.Lux.Data/DbModel/JobRowItemModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Task/JobStepItemModel.cs
@@ -1,29 +1,25 @@
-using System;
-using System.Collections.Generic;
+using EgwCoreLib.Lux.Data.DbModel.Items;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
//
// This is here so CodeMaid doesn't reorganize this document
//
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Task
{
- [Table("JobRowItemList")]
- public class JobRowItemModel
+ [Table("task_job_step_item")]
+ public class JobStepItemModel
{
///
/// ID del record
///
[Key]
- public int JobRowItemID { get; set; }
+ public int JobStepItemID { get; set; }
///
/// Fase del Ciclo di appartenenza
///
- public int JobRowID { get; set; }
+ public int JobStepID { get; set; }
///
/// Indice della fase all'interno del Job
@@ -48,8 +44,8 @@ namespace EgwCoreLib.Lux.Data.DbModel
///
/// Navigazione su fasi ciclo
///
- [ForeignKey("JobRowID")]
- public virtual JobRowModel JobRowNav { get; set; } = null!;
+ [ForeignKey("JobStepID")]
+ public virtual JobStepModel JobStepNav { get; set; } = null!;
///
/// Navigazione su Items
diff --git a/EgwCoreLib.Lux.Data/DbModel/Task/JobStepModel.cs b/EgwCoreLib.Lux.Data/DbModel/Task/JobStepModel.cs
new file mode 100644
index 00000000..e0881858
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Task/JobStepModel.cs
@@ -0,0 +1,116 @@
+using EgwCoreLib.Lux.Data.DbModel.Cost;
+using EgwCoreLib.Lux.Data.DbModel.Task;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Task
+{
+ ///
+ /// Routing dei cicli di lavoro, con riferimento a risorse e fasi
+ ///
+ [Table("task_job_step")]
+ public class JobStepModel
+ {
+ ///
+ /// ID del record
+ ///
+ [Key]
+ public int JobStepID { get; set; }
+
+ ///
+ /// Ciclo di appartenenza
+ ///
+ public int JobID { get; set; }
+
+ ///
+ /// Indice della fase all'interno del Job
+ ///
+ public int Index { get; set; } = 0;
+
+ ///
+ /// ID del driver di costo impiegato
+ ///
+ public int CostDriverID { get; set; }
+
+ ///
+ /// ID della fase realizzata
+ ///
+ public int PhaseID { get; set; }
+
+ ///
+ /// ID della risorsa impiegata
+ ///
+ public int ResourceID { get; set; }
+
+ ///
+ /// Descrizione della fase del Job
+ ///
+ public string Description { get; set; } = "";
+
+ ///
+ /// Rapporto produttività tra CostDriver Step e CostDriver Risorsa (es: m/h)
+ ///
+ public decimal ProductivityRate { get; set; } = 1;
+
+ ///
+ /// Costo RockBottom Fase (step) di produzione
+ /// sulla base del costo della risorsa, della produttività e della quantità impiegata
+ ///
+ /// Quantità risorsa impiegata
+ ///
+ public decimal RockBottomCost(decimal quantity)
+ {
+ decimal stepCost = 0;
+ var unitRequired = quantity / ProductivityRate;
+ if (ResourceNav != null)
+ {
+ stepCost = ResourceNav.BaseRockBottomCost * quantity;
+ }
+ return stepCost;
+ }
+
+ ///
+ /// Prezzo calcolato per Fase (step) di produzione
+ /// sulla base del costo RockBottom + marginalità standard
+ ///
+ /// Quantità risorsa impiegata
+ ///
+ public decimal RockBottomPrice(decimal quantity)
+ {
+ decimal stepCost = 0;
+ var unitRequired = quantity / ProductivityRate;
+ if (ResourceNav != null)
+ {
+ stepCost = ResourceNav.BasePrice * quantity;
+ }
+ return stepCost;
+ }
+
+ ///
+ /// Navigazione Job/Cicli
+ ///
+ [ForeignKey("JobID")]
+ public virtual JobModel JobNav { get; set; } = null!;
+
+ ///
+ /// Navigazione Driver costo
+ ///
+ [ForeignKey("CostDriverID")]
+ public virtual CostDriverModel DriverNav { get; set; } = null!;
+
+ ///
+ /// Navigazione Fasi
+ ///
+ [ForeignKey("PhaseID")]
+ public virtual PhaseModel PhaseNav { get; set; } = null!;
+
+ ///
+ /// Navigazione Risorse
+ ///
+ [ForeignKey("ResourceID")]
+ public virtual ResourceModel ResourceNav { get; set; } = null!;
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/PhaseModel.cs b/EgwCoreLib.Lux.Data/DbModel/Task/PhaseModel.cs
similarity index 80%
rename from EgwCoreLib.Lux.Data/DbModel/PhaseModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Task/PhaseModel.cs
index 4a963625..56d799e1 100644
--- a/EgwCoreLib.Lux.Data/DbModel/PhaseModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Task/PhaseModel.cs
@@ -9,10 +9,12 @@ using System.Threading.Tasks;
//
// This is here so CodeMaid doesn't reorganize this document
//
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Task
{
-
- [Table("RegPhase")]
+ ///
+ /// Fase di lavorazione / ProductionStage
+ ///
+ [Table("task_phase")]
public class PhaseModel
{
///
@@ -25,7 +27,5 @@ namespace EgwCoreLib.Lux.Data.DbModel
/// Descrizione
///
public string Description { get; set; } = "";
-
-
}
}
diff --git a/EgwCoreLib.Lux.Data/DbModel/CountersModel.cs b/EgwCoreLib.Lux.Data/DbModel/Utils/CountersModel.cs
similarity index 91%
rename from EgwCoreLib.Lux.Data/DbModel/CountersModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Utils/CountersModel.cs
index ef4de190..7103769b 100644
--- a/EgwCoreLib.Lux.Data/DbModel/CountersModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Utils/CountersModel.cs
@@ -6,13 +6,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Utils
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("Counter")]
+ [Table("utils_counter")]
public class CounterModel
{
///
diff --git a/EgwCoreLib.Lux.Data/DbModel/Utils/GenClassModel.cs b/EgwCoreLib.Lux.Data/DbModel/Utils/GenClassModel.cs
new file mode 100644
index 00000000..7e7f0b90
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Utils/GenClassModel.cs
@@ -0,0 +1,38 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Utils
+{
+
+ [Table("utils_gen_class")]
+ public class GenClassModel
+ {
+ ///
+ /// Cod della classe
+ ///
+ [Key]
+ public string ClassCod { get; set; } = "";
+
+ ///
+ /// Descrizione
+ ///
+ public string Description { get; set; } = "";
+
+ ///
+ /// Numero Item compresi
+ ///
+ [NotMapped]
+ public int NumChild
+ {
+ get => GenValNav?.Count ?? 0;
+ }
+
+ ///
+ /// Navigazione alle righe dei valori associati
+ ///
+ public virtual ICollection GenValNav { get; set; } = new List();
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/Utils/GenValueModel.cs b/EgwCoreLib.Lux.Data/DbModel/Utils/GenValueModel.cs
new file mode 100644
index 00000000..6c4bdf8f
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/DbModel/Utils/GenValueModel.cs
@@ -0,0 +1,40 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+//
+// This is here so CodeMaid doesn't reorganize this document
+//
+namespace EgwCoreLib.Lux.Data.DbModel.Utils
+{
+
+ [Table("utils_gen_value")]
+ public class GenValueModel
+ {
+ ///
+ /// ID del record
+ ///
+ [Key]
+ public int GenValID { get; set; }
+
+ ///
+ /// Riferimento Classe di appartenenza
+ ///
+ public string ClassCod { get; set; } = "";
+
+ ///
+ /// Valore ordinale (entro classe)
+ ///
+ public int Ordinal { get; set; } = 0;
+
+ ///
+ /// Valore String
+ ///
+ public string ValString { get; set; } = "";
+
+ ///
+ /// Navigazione GenClass
+ ///
+ [ForeignKey("ClassCod")]
+ public virtual GenClassModel GenClassNav { get; set; } = null!;
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/DbModel/MovTypeModel.cs b/EgwCoreLib.Lux.Data/DbModel/Utils/MovTypeModel.cs
similarity index 89%
rename from EgwCoreLib.Lux.Data/DbModel/MovTypeModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Utils/MovTypeModel.cs
index b580edbc..037d1133 100644
--- a/EgwCoreLib.Lux.Data/DbModel/MovTypeModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Utils/MovTypeModel.cs
@@ -6,12 +6,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Utils
{ //
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegMovType")]
+ [Table("utils_mov_type")]
public class MovTypeModel
{
diff --git a/EgwCoreLib.Lux.Data/DbModel/TagsModel.cs b/EgwCoreLib.Lux.Data/DbModel/Utils/TagsModel.cs
similarity index 90%
rename from EgwCoreLib.Lux.Data/DbModel/TagsModel.cs
rename to EgwCoreLib.Lux.Data/DbModel/Utils/TagsModel.cs
index 6e2fbd5d..1529bf12 100644
--- a/EgwCoreLib.Lux.Data/DbModel/TagsModel.cs
+++ b/EgwCoreLib.Lux.Data/DbModel/Utils/TagsModel.cs
@@ -6,13 +6,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace EgwCoreLib.Lux.Data.DbModel
+namespace EgwCoreLib.Lux.Data.DbModel.Utils
{
//
// This is here so CodeMaid doesn't reorganize this document
//
- [Table("RegTags")]
+ [Table("utils_tags")]
public class TagsModel
{
///
diff --git a/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj b/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj
index c3d746d3..74a1610f 100644
--- a/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj
+++ b/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj
@@ -17,6 +17,7 @@
+
@@ -26,6 +27,7 @@
+
@@ -40,7 +42,7 @@
-
+
@@ -48,6 +50,7 @@
+
diff --git a/EgwCoreLib.Lux.Data/Migrations/20250808143628_InitDb.Designer.cs b/EgwCoreLib.Lux.Data/Migrations/20250808143628_InitDb.Designer.cs
deleted file mode 100644
index 4f00571f..00000000
--- a/EgwCoreLib.Lux.Data/Migrations/20250808143628_InitDb.Designer.cs
+++ /dev/null
@@ -1,1973 +0,0 @@
-//
-using System;
-using EgwCoreLib.Lux.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace EgwCoreLib.Lux.Data.Migrations
-{
- [DbContext(typeof(DataLayerContext))]
- [Migration("20250808143628_InitDb")]
- partial class InitDb
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.17")
- .HasAnnotation("Relational:MaxIdentifierLength", 64);
-
- MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.CounterModel", b =>
- {
- b.Property("RefYear")
- .HasColumnType("int");
-
- b.Property("CountName")
- .HasColumnType("varchar(255)");
-
- b.Property("Counter")
- .HasColumnType("int");
-
- b.HasKey("RefYear", "CountName");
-
- b.ToTable("Counter");
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.CustomerModel", b =>
- {
- b.Property("CustomerID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("CustomerID"));
-
- b.Property("CompanyName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("FirstName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("LastName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("VAT")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("CustomerID");
-
- b.ToTable("RegCustomer");
-
- b.HasData(
- new
- {
- CustomerID = 1,
- CompanyName = "",
- FirstName = "Customer A",
- LastName = "Egalware",
- VAT = "1234567890123456"
- },
- new
- {
- CustomerID = 2,
- CompanyName = "",
- FirstName = "Customer B",
- LastName = "User",
- VAT = "1234567890123456"
- },
- new
- {
- CustomerID = 3,
- CompanyName = "",
- FirstName = "Customer C",
- LastName = "User Test",
- VAT = "1234567890123456"
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.DealerModel", b =>
- {
- b.Property("DealerID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("DealerID"));
-
- b.Property("CompanyName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("FirstName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("LastName")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("VAT")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("DealerID");
-
- b.ToTable("RegDealer");
-
- b.HasData(
- new
- {
- DealerID = 1,
- CompanyName = "Company First",
- FirstName = "Dealer A",
- LastName = "Egalware",
- VAT = "9587362514671527"
- },
- new
- {
- DealerID = 2,
- CompanyName = "Company First",
- FirstName = "Dealer B",
- LastName = "User",
- VAT = "9587362514671527"
- },
- new
- {
- DealerID = 3,
- CompanyName = "Company Second",
- FirstName = "Dealer C",
- LastName = "User Test",
- VAT = "9587362514671527"
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.ItemGroupModel", b =>
- {
- b.Property("CodGroup")
- .HasColumnType("varchar(255)");
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("CodGroup");
-
- b.ToTable("RegItemGroup");
-
- b.HasData(
- new
- {
- CodGroup = "WindowTrunk",
- Description = "Barre legno per lavorazione"
- },
- new
- {
- CodGroup = "WindowGlass",
- Description = "Vetri serramento"
- },
- new
- {
- CodGroup = "WindowVarnish",
- Description = "Vernici per legno"
- },
- new
- {
- CodGroup = "WindowHardware",
- Description = "Ferramenta serramento"
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.ItemModel", b =>
- {
- b.Property("ItemID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID"));
-
- b.Property("CodGroup")
- .IsRequired()
- .HasColumnType("varchar(255)");
-
- b.Property("Cost")
- .HasColumnType("double");
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("ExtItemCode")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("IsService")
- .HasColumnType("tinyint(1)");
-
- b.Property("ItemCode")
- .HasColumnType("int");
-
- b.Property("ItemType")
- .HasColumnType("int");
-
- b.Property("Margin")
- .HasColumnType("double");
-
- b.Property("QtyMax")
- .HasColumnType("double");
-
- b.Property("QtyMin")
- .HasColumnType("double");
-
- b.Property("SupplCode")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("UM")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("ItemID");
-
- b.HasIndex("CodGroup");
-
- b.ToTable("RegItem");
-
- b.HasData(
- new
- {
- ItemID = 1,
- CodGroup = "WindowTrunk",
- Cost = 20.0,
- Description = "BARRA-60x80 generica",
- ExtItemCode = "",
- IsService = false,
- ItemCode = 1001,
- ItemType = 1,
- Margin = 0.29999999999999999,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "BARR.001",
- UM = "#"
- },
- new
- {
- ItemID = 2,
- CodGroup = "WindowTrunk",
- Cost = 16.5,
- Description = "Barra 60x80, lunghezza 12m",
- ExtItemCode = "BARRA-60x80x12000",
- IsService = false,
- ItemCode = 1002,
- ItemType = 1,
- Margin = 0.20999999999999999,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "ABC.00123.12000",
- UM = "#"
- },
- new
- {
- ItemID = 3,
- CodGroup = "WindowTrunk",
- Cost = 17.5,
- Description = "Barra 60x80, lunghezza 8m",
- ExtItemCode = "BARRA-60x80x8000",
- IsService = false,
- ItemCode = 1003,
- ItemType = 1,
- Margin = 0.22,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "ABC.00123.8000",
- UM = "#"
- },
- new
- {
- ItemID = 4,
- CodGroup = "WindowTrunk",
- Cost = 15.5,
- Description = "Barra 60x80, lunghezza 16m",
- ExtItemCode = "BARRA-60x80x16000",
- IsService = false,
- ItemCode = 1004,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "ABC.00123.16000",
- UM = "#"
- },
- new
- {
- ItemID = 5,
- CodGroup = "WindowGlass",
- Cost = 300.0,
- Description = "Vetro triplo, basso indice termico, 800x1000",
- ExtItemCode = "VETRO-3L-THERMO-800x1000",
- IsService = false,
- ItemCode = 2001,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "V3T.800.1000",
- UM = "m2"
- },
- new
- {
- ItemID = 6,
- CodGroup = "WindowGlass",
- Cost = 200.0,
- Description = "Vetro doppio, 800x1000",
- ExtItemCode = "VETRO-2L-800x1000",
- IsService = false,
- ItemCode = 2002,
- ItemType = 1,
- Margin = 0.14999999999999999,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "V2.800.1000",
- UM = "m2"
- },
- new
- {
- ItemID = 7,
- CodGroup = "WindowGlass",
- Cost = 250.0,
- Description = "Vetro triplo, 800x1000",
- ExtItemCode = "VETRO-3L-800x1000",
- IsService = false,
- ItemCode = 2003,
- ItemType = 1,
- Margin = 0.17999999999999999,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "V3.800.1000",
- UM = "m2"
- },
- new
- {
- ItemID = 8,
- CodGroup = "WindowVarnish",
- Cost = 20.0,
- Description = "Vernice trasparente",
- ExtItemCode = "VERN-TRASP",
- IsService = false,
- ItemCode = 3001,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "VT.STD",
- UM = "l"
- },
- new
- {
- ItemID = 9,
- CodGroup = "WindowHardware",
- Cost = 65.0,
- Description = "Kit standard completo AGB tipo 001",
- ExtItemCode = "KIT-001",
- IsService = false,
- ItemCode = 5001,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "AGB-KIT-001",
- UM = "#"
- },
- new
- {
- ItemID = 10,
- CodGroup = "WindowHardware",
- Cost = 10.0,
- Description = "Cerniera AGB tipo 001",
- ExtItemCode = "CERN-001",
- IsService = false,
- ItemCode = 5002,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "AGB-CERN-001",
- UM = "#"
- },
- new
- {
- ItemID = 11,
- CodGroup = "WindowHardware",
- Cost = 15.0,
- Description = "Serratura AGB tipo 001",
- ExtItemCode = "SERR-001",
- IsService = false,
- ItemCode = 5003,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "AGB-SERR-001",
- UM = "#"
- },
- new
- {
- ItemID = 12,
- CodGroup = "WindowHardware",
- Cost = 25.0,
- Description = "Maniglia AGB tipo 001",
- ExtItemCode = "MAN-001",
- IsService = false,
- ItemCode = 5004,
- ItemType = 1,
- Margin = 0.20000000000000001,
- QtyMax = 0.0,
- QtyMin = 0.0,
- SupplCode = "AGB-MAN-001",
- UM = "#"
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.JobModel", b =>
- {
- b.Property("JobID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("JobID"));
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("JobID");
-
- b.ToTable("JobList");
-
- b.HasData(
- new
- {
- JobID = 1,
- Description = "Rivendita / servizi"
- },
- new
- {
- JobID = 2,
- Description = "Serramento Completo Legno su linea Saomad e installatore interno"
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.JobRowItemModel", b =>
- {
- b.Property("JobRowItemID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("JobRowItemID"));
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("Index")
- .HasColumnType("int");
-
- b.Property("ItemID")
- .HasColumnType("int");
-
- b.Property("JobRowID")
- .HasColumnType("int");
-
- b.Property("Qty")
- .HasColumnType("double");
-
- b.HasKey("JobRowItemID");
-
- b.HasIndex("ItemID");
-
- b.HasIndex("JobRowID");
-
- b.ToTable("JobRowItemList");
-
- b.HasData(
- new
- {
- JobRowItemID = 1,
- Description = "Grezzo legno abete",
- Index = 1,
- ItemID = 1,
- JobRowID = 1,
- Qty = 1.0
- },
- new
- {
- JobRowItemID = 2,
- Description = "Vernice trasparente standard 1L",
- Index = 2,
- ItemID = 8,
- JobRowID = 3,
- Qty = 0.10000000000000001
- },
- new
- {
- JobRowItemID = 3,
- Description = "Ferramenta AGB - rif. AGFD.00000.00000",
- Index = 3,
- ItemID = 9,
- JobRowID = 4,
- Qty = 1.0
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.JobRowModel", b =>
- {
- b.Property("JobRowID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("JobRowID"));
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("Index")
- .HasColumnType("int");
-
- b.Property("JobID")
- .HasColumnType("int");
-
- b.Property("PhaseID")
- .HasColumnType("int");
-
- b.Property("Qty")
- .HasColumnType("double");
-
- b.Property("ResourceID")
- .HasColumnType("int");
-
- b.HasKey("JobRowID");
-
- b.HasIndex("JobID");
-
- b.HasIndex("PhaseID");
-
- b.HasIndex("ResourceID");
-
- b.ToTable("JobRowList");
-
- b.HasData(
- new
- {
- JobRowID = 1,
- Description = "",
- Index = 1,
- JobID = 2,
- PhaseID = 1,
- Qty = 1.0,
- ResourceID = 1
- },
- new
- {
- JobRowID = 2,
- Description = "",
- Index = 2,
- JobID = 2,
- PhaseID = 2,
- Qty = 1.0,
- ResourceID = 2
- },
- new
- {
- JobRowID = 3,
- Description = "",
- Index = 3,
- JobID = 2,
- PhaseID = 3,
- Qty = 1.0,
- ResourceID = 4
- },
- new
- {
- JobRowID = 4,
- Description = "",
- Index = 4,
- JobID = 2,
- PhaseID = 4,
- Qty = 1.0,
- ResourceID = 6
- },
- new
- {
- JobRowID = 5,
- Description = "",
- Index = 5,
- JobID = 2,
- PhaseID = 6,
- Qty = 1.0,
- ResourceID = 7
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.MovTypeModel", b =>
- {
- b.Property("MovCod")
- .HasColumnType("varchar(255)");
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.HasKey("MovCod");
-
- b.ToTable("RegMovType");
-
- b.HasData(
- new
- {
- MovCod = "CAR",
- Description = "Carico a magazzino"
- },
- new
- {
- MovCod = "MOV",
- Description = "Movimento interno (spostamento)"
- },
- new
- {
- MovCod = "ND",
- Description = "Non Definito"
- },
- new
- {
- MovCod = "OFOR",
- Description = "Ordine Fornitore"
- },
- new
- {
- MovCod = "RETT",
- Description = "Rettifica magazzino"
- },
- new
- {
- MovCod = "SCAR",
- Description = "Scarico da magazzino"
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.OfferModel", b =>
- {
- b.Property("OfferID")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OfferID"));
-
- b.Property("CustomerID")
- .HasColumnType("int");
-
- b.Property("DealerID")
- .HasColumnType("int");
-
- b.Property("Description")
- .IsRequired()
- .HasColumnType("longtext");
-
- b.Property("Inserted")
- .HasColumnType("datetime(6)");
-
- b.Property("Modified")
- .HasColumnType("datetime(6)");
-
- b.Property("OffertState")
- .HasColumnType("int");
-
- b.Property("RefNum")
- .HasColumnType("int");
-
- b.Property("RefRev")
- .HasColumnType("int");
-
- b.Property("RefYear")
- .HasColumnType("int");
-
- b.Property("ValidUntil")
- .HasColumnType("datetime(6)");
-
- b.HasKey("OfferID");
-
- b.HasIndex("CustomerID");
-
- b.HasIndex("DealerID");
-
- b.ToTable("Offer");
-
- b.HasData(
- new
- {
- OfferID = 1,
- CustomerID = 2,
- DealerID = 2,
- Description = "Offerta per tre serramenti",
- Inserted = new DateTime(2025, 8, 8, 16, 36, 28, 420, DateTimeKind.Local).AddTicks(4215),
- Modified = new DateTime(2025, 8, 8, 16, 36, 28, 420, DateTimeKind.Local).AddTicks(4216),
- OffertState = 0,
- RefNum = 1,
- RefRev = 1,
- RefYear = 2024,
- ValidUntil = new DateTime(2025, 9, 8, 16, 36, 28, 420, DateTimeKind.Local).AddTicks(4212)
- });
- });
-
- modelBuilder.Entity("EgwCoreLib.Lux.Data.DbModel.OfferRowModel", b =>
- {
- b.Property