From e2a67bbcd46232369bfd575b24cac9e3109172f7 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 7 Jul 2025 19:20:18 +0200 Subject: [PATCH] Update modello, migrations, DB locale --- Lux.Data/DataLayerContext.cs | 23 +- Lux.Data/DbModel/ItemGroupModel.cs | 29 ++ Lux.Data/DbModel/ItemModel.cs | 10 + Lux.Data/DbModel/MovTypeModel.cs | 29 ++ Lux.Data/DbModel/StockMovModel.cs | 38 ++- ...r.cs => 20250707171119_InitDb.Designer.cs} | 253 ++++++++++++++-- ...305_InitDb.cs => 20250707171119_InitDb.cs} | 285 ++++++++++++------ .../DataLayerContextModelSnapshot.cs | 251 +++++++++++++-- Lux.Data/ModelBuilderExtensions.cs | 79 +++-- 9 files changed, 821 insertions(+), 176 deletions(-) create mode 100644 Lux.Data/DbModel/ItemGroupModel.cs create mode 100644 Lux.Data/DbModel/MovTypeModel.cs rename Lux.Data/Migrations/{20250707161305_InitDb.Designer.cs => 20250707171119_InitDb.Designer.cs} (85%) rename Lux.Data/Migrations/{20250707161305_InitDb.cs => 20250707171119_InitDb.cs} (81%) diff --git a/Lux.Data/DataLayerContext.cs b/Lux.Data/DataLayerContext.cs index 31b841af..c9f10620 100644 --- a/Lux.Data/DataLayerContext.cs +++ b/Lux.Data/DataLayerContext.cs @@ -40,6 +40,8 @@ namespace Lux.Data } + public virtual DbSet DbSetCounters { 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; } @@ -48,7 +50,7 @@ namespace Lux.Data public virtual DbSet DbSetSupplier { get; set; } public virtual DbSet DbSetOffer { get; set; } public virtual DbSet DbSetOfferRow { get; set; } - public virtual DbSet DbSetORDer { get; set; } + public virtual DbSet DbSetOrder { get; set; } public virtual DbSet DbSetORDerRow { get; set; } public virtual DbSet DbSetResource { get; set; } public virtual DbSet DbSetPhase { get; set; } @@ -59,6 +61,7 @@ namespace Lux.Data public virtual DbSet DbSetProdItem { 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; } @@ -86,6 +89,24 @@ namespace Lux.Data relationship.DeleteBehavior = DeleteBehavior.Restrict; } + // fix chiavi multiple + modelBuilder.Entity() + .HasKey(c => new { c.RefYear, c.CountName}); + + // fix valori timestamp + modelBuilder.Entity(entity => + { + entity.Property(e => e.DtCreate) + .HasColumnType("timestamp") + .HasDefaultValueSql("CURRENT_TIMESTAMP") + .ValueGeneratedOnAdd(); + + entity.Property(e => e.DtMod) + .HasColumnType("timestamp") + .HasDefaultValueSql("CURRENT_TIMESTAMP") + .ValueGeneratedOnAddOrUpdate(); + }); + // seed finale dei dati di default modelBuilder.Seed(); diff --git a/Lux.Data/DbModel/ItemGroupModel.cs b/Lux.Data/DbModel/ItemGroupModel.cs new file mode 100644 index 00000000..63942a2d --- /dev/null +++ b/Lux.Data/DbModel/ItemGroupModel.cs @@ -0,0 +1,29 @@ +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 Lux.Data.DbModel +{ // + // This is here so CodeMaid doesn't reorganize this document + // + + [Table("RegItemGroup")] + public class ItemGroupModel + { + + /// + /// Cod gruppo articolo (per selezione omogenea alternative) + /// + [Key] + public string CodGroup { get; set; } = ""; + + /// + /// Descrizione Cod gruppo articolo + /// + public string Description { get; set; } = ""; + } +} diff --git a/Lux.Data/DbModel/ItemModel.cs b/Lux.Data/DbModel/ItemModel.cs index 34ed99d7..0820c2cd 100644 --- a/Lux.Data/DbModel/ItemModel.cs +++ b/Lux.Data/DbModel/ItemModel.cs @@ -16,6 +16,11 @@ namespace Lux.Data.DbModel [Key] public int ItemID { get; set; } + /// + /// Cod gruppo articolo (per selezione omogenea alternative) + /// + public string CodGroup { get; set; } = ""; + /// /// Definisce l'articolo come servizio vs concreto=materiale /// @@ -63,5 +68,10 @@ namespace Lux.Data.DbModel public string TemplateJWD { get; set; } = ""; #endif + /// + /// Navigation per ItemGroup + /// + [ForeignKey("CodGroup")] + public virtual ItemGroupModel ItemGroupNav { get; set; } = null!; } } diff --git a/Lux.Data/DbModel/MovTypeModel.cs b/Lux.Data/DbModel/MovTypeModel.cs new file mode 100644 index 00000000..63c5a72e --- /dev/null +++ b/Lux.Data/DbModel/MovTypeModel.cs @@ -0,0 +1,29 @@ +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 Lux.Data.DbModel +{ // + // This is here so CodeMaid doesn't reorganize this document + // + + [Table("RegMovType")] + public class MovTypeModel + { + + /// + /// Cod movimento magazzino registrato + /// + [Key] + public string MovCod { get; set; } = ""; + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + } +} diff --git a/Lux.Data/DbModel/StockMovModel.cs b/Lux.Data/DbModel/StockMovModel.cs index c5dc8b7c..035d871b 100644 --- a/Lux.Data/DbModel/StockMovModel.cs +++ b/Lux.Data/DbModel/StockMovModel.cs @@ -29,30 +29,64 @@ namespace Lux.Data.DbModel public int StockStatusId { get; set; } /// - /// DateTime record + /// DateTime di creazione record /// - public DateTime DtRec { get; set; } = DateTime.Now; + public DateTime DtCreate { get; set; } = DateTime.Now; + + /// + /// DateTime registrazione dato + /// + public DateTime DtMod { get; set; } = DateTime.Now; /// /// Qty movimento registrato (delta +/-) /// public double QtyRec { get; set; } = 0; + /// + /// Valore unitario al movimento (costo acquisto / medio per vendita) + /// + public double UnitVal { get; set; } = 0; + + [NotMapped] + public double TotalVal + { + get => UnitVal * QtyRec; + } + /// /// User modificatore /// public string UserId { get; set; } = ""; + /// + /// Cod movimento magazzino registrato + /// + public string MovCod { get; set; } = ""; + + /// + /// Cod docuemnto (es DDT) - opzionale + /// + public string CodDoc { get; set; } = ""; + /// /// Note opzionali /// public string Note { get; set; } = ""; + + /// /// Navigation per giacenze /// [ForeignKey("StockStatusId")] public virtual StockStatusModel StockStatusNav { get; set; } = null!; + /// + /// Navigation per tipo movimento + /// + [ForeignKey("MovCod")] + public virtual MovTypeModel MovTypeNav { get; set; } = null!; + } } diff --git a/Lux.Data/Migrations/20250707161305_InitDb.Designer.cs b/Lux.Data/Migrations/20250707171119_InitDb.Designer.cs similarity index 85% rename from Lux.Data/Migrations/20250707161305_InitDb.Designer.cs rename to Lux.Data/Migrations/20250707171119_InitDb.Designer.cs index 4fad5a82..2cfb76d5 100644 --- a/Lux.Data/Migrations/20250707161305_InitDb.Designer.cs +++ b/Lux.Data/Migrations/20250707171119_InitDb.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Lux.Data.Migrations { [DbContext(typeof(DataLayerContext))] - [Migration("20250707161305_InitDb")] + [Migration("20250707171119_InitDb")] partial class InitDb { /// @@ -25,6 +25,22 @@ namespace Lux.Data.Migrations MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + modelBuilder.Entity("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("Lux.Data.DbModel.CustomerModel", b => { b.Property("CustomerID") @@ -135,6 +151,42 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("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 = "BARRA", + Description = "Barre legno per lavorazione" + }, + new + { + CodGroup = "VETRO", + Description = "Vetri serramento" + }, + new + { + CodGroup = "VERNICE", + Description = "Vernici per legno" + }, + new + { + CodGroup = "FERRAMENTA", + Description = "Ferramenta serramento" + }); + }); + modelBuilder.Entity("Lux.Data.DbModel.ItemModel", b => { b.Property("ItemID") @@ -143,6 +195,10 @@ namespace Lux.Data.Migrations MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID")); + b.Property("CodGroup") + .IsRequired() + .HasColumnType("varchar(255)"); + b.Property("Cost") .HasColumnType("double"); @@ -173,12 +229,15 @@ namespace Lux.Data.Migrations b.HasKey("ItemID"); + b.HasIndex("CodGroup"); + b.ToTable("RegItem"); b.HasData( new { ItemID = 1, + CodGroup = "BARRA", Cost = 20.0, Description = "BARRA-60x80 generica", ExtItemCode = "", @@ -191,6 +250,7 @@ namespace Lux.Data.Migrations new { ItemID = 2, + CodGroup = "BARRA", Cost = 16.5, Description = "Barra 60x80, lunghezza 12m", ExtItemCode = "BARRA-60x80x12000", @@ -203,6 +263,7 @@ namespace Lux.Data.Migrations new { ItemID = 3, + CodGroup = "BARRA", Cost = 17.5, Description = "Barra 60x80, lunghezza 8m", ExtItemCode = "BARRA-60x80x8000", @@ -215,6 +276,7 @@ namespace Lux.Data.Migrations new { ItemID = 4, + CodGroup = "BARRA", Cost = 15.5, Description = "Barra 60x80, lunghezza 16m", ExtItemCode = "BARRA-60x80x16000", @@ -227,6 +289,7 @@ namespace Lux.Data.Migrations new { ItemID = 5, + CodGroup = "VETRO", Cost = 300.0, Description = "Vetro triplo, basso indice termico, 800x1000", ExtItemCode = "VETRO-3L-THERMO-800x1000", @@ -239,6 +302,7 @@ namespace Lux.Data.Migrations new { ItemID = 6, + CodGroup = "VETRO", Cost = 200.0, Description = "Vetro doppio, 800x1000", ExtItemCode = "VETRO-2L-800x1000", @@ -251,6 +315,7 @@ namespace Lux.Data.Migrations new { ItemID = 7, + CodGroup = "VETRO", Cost = 250.0, Description = "Vetro triplo, 800x1000", ExtItemCode = "VETRO-3L-800x1000", @@ -263,6 +328,7 @@ namespace Lux.Data.Migrations new { ItemID = 8, + CodGroup = "VERNICE", Cost = 20.0, Description = "Vernice trasparente", ExtItemCode = "VERN-TRASP", @@ -275,6 +341,7 @@ namespace Lux.Data.Migrations new { ItemID = 9, + CodGroup = "FERRAMENTA", Cost = 65.0, Description = "Kit standard completo AGB tipo 001", ExtItemCode = "KIT-001", @@ -287,6 +354,7 @@ namespace Lux.Data.Migrations new { ItemID = 10, + CodGroup = "FERRAMENTA", Cost = 10.0, Description = "Cerniera AGB tipo 001", ExtItemCode = "CERN-001", @@ -299,6 +367,7 @@ namespace Lux.Data.Migrations new { ItemID = 11, + CodGroup = "FERRAMENTA", Cost = 15.0, Description = "Serratura AGB tipo 001", ExtItemCode = "SERR-001", @@ -311,6 +380,7 @@ namespace Lux.Data.Migrations new { ItemID = 12, + CodGroup = "FERRAMENTA", Cost = 25.0, Description = "Maniglia AGB tipo 001", ExtItemCode = "MAN-001", @@ -503,6 +573,52 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("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("Lux.Data.DbModel.OfferModel", b => { b.Property("OfferID") @@ -557,13 +673,13 @@ namespace Lux.Data.Migrations CustomerID = 2, DealerID = 2, Description = "Offerta per tre serramenti", - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8097), - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8099), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5570), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5571), OffertState = 0, RefNum = 1, RefRev = 1, RefYear = 2024, - ValidUntil = new DateTime(2025, 8, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8094) + ValidUntil = new DateTime(2025, 8, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5566) }); }); @@ -621,9 +737,9 @@ namespace Lux.Data.Migrations { OfferRowID = 1, Cost = 950.0, - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8123), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5601), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8125), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5602), Note = "Finestra anta singola 2025", OfferID = 1, Qty = 3.0, @@ -635,9 +751,9 @@ namespace Lux.Data.Migrations { OfferRowID = 2, Cost = 160.0, - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8137), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5609), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8138), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5611), Note = "Persiana per Finestra anta singola 2025", OfferID = 1, Qty = 3.0, @@ -649,9 +765,9 @@ namespace Lux.Data.Migrations { OfferRowID = 3, Cost = 200.0, - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8144), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5616), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8145), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5618), Note = "Installazione serramento", OfferID = 1, Qty = 3.0, @@ -972,7 +1088,7 @@ namespace Lux.Data.Migrations IsHuman = false, UmFix = "€/h", UmProp = "€/m", - UnitCostFix = 540.0, + UnitCostFix = 240.0, UnitCostProp = 1.8999999999999999 }, new @@ -982,9 +1098,9 @@ namespace Lux.Data.Migrations IsAsset = true, IsHuman = false, UmFix = "€/h", - UmProp = "", - UnitCostFix = 250.0, - UnitCostProp = 0.0 + UmProp = "€/m", + UnitCostFix = 90.0, + UnitCostProp = 5.9000000000000004 }, new { @@ -994,7 +1110,7 @@ namespace Lux.Data.Migrations IsHuman = false, UmFix = "€/h", UmProp = "€/m", - UnitCostFix = 10.0, + UnitCostFix = 40.0, UnitCostProp = 1.8999999999999999 }, new @@ -1005,7 +1121,7 @@ namespace Lux.Data.Migrations IsHuman = true, UmFix = "€/h", UmProp = "€/m", - UnitCostFix = 40.0, + UnitCostFix = 10.0, UnitCostProp = 1.8999999999999999 }, new @@ -1141,8 +1257,25 @@ namespace Lux.Data.Migrations MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StockMovID")); - b.Property("DtRec") - .HasColumnType("datetime(6)"); + b.Property("CodDoc") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DtCreate") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DtMod") + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("timestamp") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property("DtMod")); + + b.Property("MovCod") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("Note") .IsRequired() @@ -1154,12 +1287,17 @@ namespace Lux.Data.Migrations b.Property("StockStatusId") .HasColumnType("int"); + b.Property("UnitVal") + .HasColumnType("double"); + b.Property("UserId") .IsRequired() .HasColumnType("longtext"); b.HasKey("StockMovID"); + b.HasIndex("MovCod"); + b.HasIndex("StockStatusId"); b.ToTable("StockMov"); @@ -1168,91 +1306,131 @@ namespace Lux.Data.Migrations new { StockMovID = 1, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7890), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5254), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5321), + MovCod = "CAR", Note = "DEMO", QtyRec = 5.0, StockStatusId = 1, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 2, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7895), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5324), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5325), + MovCod = "CAR", Note = "DEMO", QtyRec = 8.0, StockStatusId = 2, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 3, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7899), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5327), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5329), + MovCod = "CAR", Note = "DEMO", QtyRec = 5.0, StockStatusId = 3, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 4, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7903), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5331), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5333), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 4, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 5, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7906), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5335), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5336), + MovCod = "CAR", Note = "DEMO", QtyRec = 10.0, StockStatusId = 5, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 6, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7910), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5338), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5340), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 6, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 7, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7914), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5342), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5343), + MovCod = "CAR", Note = "DEMO", QtyRec = 50.0, StockStatusId = 7, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 8, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7917), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5346), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5347), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 8, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 9, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7921), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5349), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5351), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 9, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 10, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7925), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5353), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5354), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 10, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }); }); @@ -1479,6 +1657,17 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("Lux.Data.DbModel.ItemModel", b => + { + b.HasOne("Lux.Data.DbModel.ItemGroupModel", "ItemGroupNav") + .WithMany() + .HasForeignKey("CodGroup") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ItemGroupNav"); + }); + modelBuilder.Entity("Lux.Data.DbModel.JobRowItemModel", b => { b.HasOne("Lux.Data.DbModel.ItemModel", "ItemNav") @@ -1668,12 +1857,20 @@ namespace Lux.Data.Migrations modelBuilder.Entity("Lux.Data.DbModel.StockMovModel", b => { + b.HasOne("Lux.Data.DbModel.MovTypeModel", "MovTypeNav") + .WithMany() + .HasForeignKey("MovCod") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.HasOne("Lux.Data.DbModel.StockStatusModel", "StockStatusNav") .WithMany() .HasForeignKey("StockStatusId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.Navigation("MovTypeNav"); + b.Navigation("StockStatusNav"); }); diff --git a/Lux.Data/Migrations/20250707161305_InitDb.cs b/Lux.Data/Migrations/20250707171119_InitDb.cs similarity index 81% rename from Lux.Data/Migrations/20250707161305_InitDb.cs rename to Lux.Data/Migrations/20250707171119_InitDb.cs index 3c89208e..19aedccc 100644 --- a/Lux.Data/Migrations/20250707161305_InitDb.cs +++ b/Lux.Data/Migrations/20250707171119_InitDb.cs @@ -17,6 +17,21 @@ namespace Lux.Data.Migrations migrationBuilder.AlterDatabase() .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "Counter", + columns: table => new + { + RefYear = table.Column(type: "int", nullable: false), + CountName = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Counter = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Counter", x => new { x.RefYear, x.CountName }); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( name: "JobList", columns: table => new @@ -93,27 +108,32 @@ namespace Lux.Data.Migrations .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( - name: "RegItem", + name: "RegItemGroup", columns: table => new { - ItemID = table.Column(type: "int", nullable: false) - .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - IsService = table.Column(type: "tinyint(1)", nullable: false), - ItemCode = table.Column(type: "int", nullable: false), - ExtItemCode = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - SupplCode = table.Column(type: "longtext", nullable: false) + CodGroup = table.Column(type: "varchar(255)", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Cost = table.Column(type: "double", nullable: false), - Margin = table.Column(type: "double", nullable: false), - UM = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { - table.PrimaryKey("PK_RegItem", x => x.ItemID); + table.PrimaryKey("PK_RegItemGroup", x => x.CodGroup); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "RegMovType", + columns: table => new + { + MovCod = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_RegMovType", x => x.MovCod); }) .Annotation("MySql:CharSet", "utf8mb4"); @@ -264,26 +284,34 @@ namespace Lux.Data.Migrations .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( - name: "StockStatus", + name: "RegItem", columns: table => new { - StockStatusId = table.Column(type: "int", nullable: false) + ItemID = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - ItemID = table.Column(type: "int", nullable: false), - QtyAvail = table.Column(type: "double", nullable: false), - IsDeleted = table.Column(type: "tinyint(1)", nullable: false), - IsRemn = table.Column(type: "tinyint(1)", nullable: false), - Location = table.Column(type: "longtext", nullable: false) + CodGroup = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + IsService = table.Column(type: "tinyint(1)", nullable: false), + ItemCode = table.Column(type: "int", nullable: false), + ExtItemCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + SupplCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Cost = table.Column(type: "double", nullable: false), + Margin = table.Column(type: "double", nullable: false), + UM = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { - table.PrimaryKey("PK_StockStatus", x => x.StockStatusId); + table.PrimaryKey("PK_RegItem", x => x.ItemID); table.ForeignKey( - name: "FK_StockStatus_RegItem_ItemID", - column: x => x.ItemID, - principalTable: "RegItem", - principalColumn: "ItemID", + name: "FK_RegItem_RegItemGroup_CodGroup", + column: x => x.CodGroup, + principalTable: "RegItemGroup", + principalColumn: "CodGroup", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); @@ -408,27 +436,26 @@ namespace Lux.Data.Migrations .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( - name: "StockMov", + name: "StockStatus", columns: table => new { - StockMovID = table.Column(type: "int", nullable: false) + StockStatusId = table.Column(type: "int", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), - StockStatusId = table.Column(type: "int", nullable: false), - DtRec = table.Column(type: "datetime(6)", nullable: false), - QtyRec = table.Column(type: "double", nullable: false), - UserId = table.Column(type: "longtext", nullable: false) - .Annotation("MySql:CharSet", "utf8mb4"), - Note = table.Column(type: "longtext", nullable: false) + ItemID = table.Column(type: "int", nullable: false), + QtyAvail = table.Column(type: "double", nullable: false), + IsDeleted = table.Column(type: "tinyint(1)", nullable: false), + IsRemn = table.Column(type: "tinyint(1)", nullable: false), + Location = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { - table.PrimaryKey("PK_StockMov", x => x.StockMovID); + table.PrimaryKey("PK_StockStatus", x => x.StockStatusId); table.ForeignKey( - name: "FK_StockMov_StockStatus_StockStatusId", - column: x => x.StockStatusId, - principalTable: "StockStatus", - principalColumn: "StockStatusId", + name: "FK_StockStatus_RegItem_ItemID", + column: x => x.ItemID, + principalTable: "RegItem", + principalColumn: "ItemID", onDelete: ReferentialAction.Restrict); }) .Annotation("MySql:CharSet", "utf8mb4"); @@ -502,6 +529,45 @@ namespace Lux.Data.Migrations }) .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( + name: "StockMov", + columns: table => new + { + StockMovID = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + StockStatusId = table.Column(type: "int", nullable: false), + DtCreate = table.Column(type: "timestamp", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + DtMod = table.Column(type: "timestamp", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP") + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn), + QtyRec = table.Column(type: "double", nullable: false), + UnitVal = table.Column(type: "double", nullable: false), + UserId = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + MovCod = table.Column(type: "varchar(255)", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + CodDoc = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + Note = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4") + }, + constraints: table => + { + table.PrimaryKey("PK_StockMov", x => x.StockMovID); + table.ForeignKey( + name: "FK_StockMov_RegMovType_MovCod", + column: x => x.MovCod, + principalTable: "RegMovType", + principalColumn: "MovCod", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_StockMov_StockStatus_StockStatusId", + column: x => x.StockStatusId, + principalTable: "StockStatus", + principalColumn: "StockStatusId", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + migrationBuilder.CreateTable( name: "ProductionItem", columns: table => new @@ -603,22 +669,27 @@ namespace Lux.Data.Migrations }); migrationBuilder.InsertData( - table: "RegItem", - columns: new[] { "ItemID", "Cost", "Description", "ExtItemCode", "IsService", "ItemCode", "Margin", "SupplCode", "UM" }, + table: "RegItemGroup", + columns: new[] { "CodGroup", "Description" }, values: new object[,] { - { 1, 20.0, "BARRA-60x80 generica", "", false, 1001, 0.29999999999999999, "BARR.001", "#" }, - { 2, 16.5, "Barra 60x80, lunghezza 12m", "BARRA-60x80x12000", false, 1002, 0.20999999999999999, "ABC.00123.12000", "#" }, - { 3, 17.5, "Barra 60x80, lunghezza 8m", "BARRA-60x80x8000", false, 1003, 0.22, "ABC.00123.8000", "#" }, - { 4, 15.5, "Barra 60x80, lunghezza 16m", "BARRA-60x80x16000", false, 1004, 0.20000000000000001, "ABC.00123.16000", "#" }, - { 5, 300.0, "Vetro triplo, basso indice termico, 800x1000", "VETRO-3L-THERMO-800x1000", false, 2001, 0.20000000000000001, "V3T.800.1000", "m2" }, - { 6, 200.0, "Vetro doppio, 800x1000", "VETRO-2L-800x1000", false, 2002, 0.14999999999999999, "V2.800.1000", "m2" }, - { 7, 250.0, "Vetro triplo, 800x1000", "VETRO-3L-800x1000", false, 2003, 0.17999999999999999, "V3.800.1000", "m2" }, - { 8, 20.0, "Vernice trasparente", "VERN-TRASP", false, 3001, 0.20000000000000001, "VT.STD", "l" }, - { 9, 65.0, "Kit standard completo AGB tipo 001", "KIT-001", false, 5001, 0.20000000000000001, "AGB-KIT-001", "#" }, - { 10, 10.0, "Cerniera AGB tipo 001", "CERN-001", false, 5002, 0.20000000000000001, "AGB-CERN-001", "#" }, - { 11, 15.0, "Serratura AGB tipo 001", "SERR-001", false, 5003, 0.20000000000000001, "AGB-SERR-001", "#" }, - { 12, 25.0, "Maniglia AGB tipo 001", "MAN-001", false, 5004, 0.20000000000000001, "AGB-MAN-001", "#" } + { "BARRA", "Barre legno per lavorazione" }, + { "FERRAMENTA", "Ferramenta serramento" }, + { "VERNICE", "Vernici per legno" }, + { "VETRO", "Vetri serramento" } + }); + + migrationBuilder.InsertData( + table: "RegMovType", + columns: new[] { "MovCod", "Description" }, + values: new object[,] + { + { "CAR", "Carico a magazzino" }, + { "MOV", "Movimento interno (spostamento)" }, + { "ND", "Non Definito" }, + { "OFOR", "Ordine Fornitore" }, + { "RETT", "Rettifica magazzino" }, + { "SCAR", "Scarico da magazzino" } }); migrationBuilder.InsertData( @@ -640,10 +711,10 @@ namespace Lux.Data.Migrations values: new object[,] { { 1, "Sezionatrice", true, false, "€/h", "", 15.0, 0.0 }, - { 2, "Linea SAOMAD WoodPecker Just 3500", true, false, "€/h", "€/m", 540.0, 1.8999999999999999 }, - { 3, "Linea Pantografo", true, false, "€/h", "", 250.0, 0.0 }, - { 4, "Stazione Verniciatura", true, false, "€/h", "€/m", 10.0, 1.8999999999999999 }, - { 5, "Verniciatura Manuale", false, true, "€/h", "€/m", 40.0, 1.8999999999999999 }, + { 2, "Linea SAOMAD WoodPecker Just 3500", true, false, "€/h", "€/m", 240.0, 1.8999999999999999 }, + { 3, "Linea Pantografo", true, false, "€/h", "€/m", 90.0, 5.9000000000000004 }, + { 4, "Stazione Verniciatura", true, false, "€/h", "€/m", 40.0, 1.8999999999999999 }, + { 5, "Verniciatura Manuale", false, true, "€/h", "€/m", 10.0, 1.8999999999999999 }, { 6, "Montaggio Manuale", false, true, "", "€/h", 0.0, 40.0 }, { 7, "Installatore", false, true, "", "€/h", 0.0, 40.0 } }); @@ -685,7 +756,26 @@ namespace Lux.Data.Migrations migrationBuilder.InsertData( table: "Offer", columns: new[] { "OfferID", "CustomerID", "DealerID", "Description", "Inserted", "Modified", "OffertState", "RefNum", "RefRev", "RefYear", "ValidUntil" }, - values: new object[] { 1, 2, 2, "Offerta per tre serramenti", new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8097), new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8099), 0, 1, 1, 2024, new DateTime(2025, 8, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8094) }); + values: new object[] { 1, 2, 2, "Offerta per tre serramenti", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5570), new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5571), 0, 1, 1, 2024, new DateTime(2025, 8, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5566) }); + + migrationBuilder.InsertData( + table: "RegItem", + columns: new[] { "ItemID", "CodGroup", "Cost", "Description", "ExtItemCode", "IsService", "ItemCode", "Margin", "SupplCode", "UM" }, + values: new object[,] + { + { 1, "BARRA", 20.0, "BARRA-60x80 generica", "", false, 1001, 0.29999999999999999, "BARR.001", "#" }, + { 2, "BARRA", 16.5, "Barra 60x80, lunghezza 12m", "BARRA-60x80x12000", false, 1002, 0.20999999999999999, "ABC.00123.12000", "#" }, + { 3, "BARRA", 17.5, "Barra 60x80, lunghezza 8m", "BARRA-60x80x8000", false, 1003, 0.22, "ABC.00123.8000", "#" }, + { 4, "BARRA", 15.5, "Barra 60x80, lunghezza 16m", "BARRA-60x80x16000", false, 1004, 0.20000000000000001, "ABC.00123.16000", "#" }, + { 5, "VETRO", 300.0, "Vetro triplo, basso indice termico, 800x1000", "VETRO-3L-THERMO-800x1000", false, 2001, 0.20000000000000001, "V3T.800.1000", "m2" }, + { 6, "VETRO", 200.0, "Vetro doppio, 800x1000", "VETRO-2L-800x1000", false, 2002, 0.14999999999999999, "V2.800.1000", "m2" }, + { 7, "VETRO", 250.0, "Vetro triplo, 800x1000", "VETRO-3L-800x1000", false, 2003, 0.17999999999999999, "V3.800.1000", "m2" }, + { 8, "VERNICE", 20.0, "Vernice trasparente", "VERN-TRASP", false, 3001, 0.20000000000000001, "VT.STD", "l" }, + { 9, "FERRAMENTA", 65.0, "Kit standard completo AGB tipo 001", "KIT-001", false, 5001, 0.20000000000000001, "AGB-KIT-001", "#" }, + { 10, "FERRAMENTA", 10.0, "Cerniera AGB tipo 001", "CERN-001", false, 5002, 0.20000000000000001, "AGB-CERN-001", "#" }, + { 11, "FERRAMENTA", 15.0, "Serratura AGB tipo 001", "SERR-001", false, 5003, 0.20000000000000001, "AGB-SERR-001", "#" }, + { 12, "FERRAMENTA", 25.0, "Maniglia AGB tipo 001", "MAN-001", false, 5004, 0.20000000000000001, "AGB-MAN-001", "#" } + }); migrationBuilder.InsertData( table: "SellingItem", @@ -697,6 +787,26 @@ namespace Lux.Data.Migrations { 3, 200.0, "Installazione", "", true, 0, "", 1, 0.29999999999999999, "", "", "#" } }); + migrationBuilder.InsertData( + table: "JobRowItemList", + columns: new[] { "JobRowItemID", "Description", "Index", "ItemID", "JobRowID", "Qty" }, + values: new object[,] + { + { 1, "Grezzo legno abete", 1, 1, 1, 1.0 }, + { 2, "Vernice trasparente standard 1L", 2, 8, 3, 0.10000000000000001 }, + { 3, "Ferramenta AGB - rif. AGFD.00000.00000", 3, 9, 4, 1.0 } + }); + + migrationBuilder.InsertData( + table: "OfferRowList", + columns: new[] { "OfferRowID", "Cost", "Inserted", "ItemSPP", "Modified", "Note", "OfferID", "Qty", "RowNum", "SellingItemID", "SerStruct" }, + values: new object[,] + { + { 1, 950.0, new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5601), "{}", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5602), "Finestra anta singola 2025", 1, 3.0, 1, 1, "{}" }, + { 2, 160.0, new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5609), "{}", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5611), "Persiana per Finestra anta singola 2025", 1, 3.0, 1, 2, "{}" }, + { 3, 200.0, new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5616), "{}", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5618), "Installazione serramento", 1, 3.0, 1, 3, "{}" } + }); + migrationBuilder.InsertData( table: "StockStatus", columns: new[] { "StockStatusId", "IsDeleted", "IsRemn", "ItemID", "Location", "QtyAvail" }, @@ -714,41 +824,21 @@ namespace Lux.Data.Migrations { 10, false, false, 10, "S001-001-001", 1.0 } }); - migrationBuilder.InsertData( - table: "JobRowItemList", - columns: new[] { "JobRowItemID", "Description", "Index", "ItemID", "JobRowID", "Qty" }, - values: new object[,] - { - { 1, "Grezzo legno abete", 1, 1, 1, 1.0 }, - { 2, "Vernice trasparente standard 1L", 2, 8, 3, 0.10000000000000001 }, - { 3, "Ferramenta AGB - rif. AGFD.00000.00000", 3, 9, 4, 1.0 } - }); - - migrationBuilder.InsertData( - table: "OfferRowList", - columns: new[] { "OfferRowID", "Cost", "Inserted", "ItemSPP", "Modified", "Note", "OfferID", "Qty", "RowNum", "SellingItemID", "SerStruct" }, - values: new object[,] - { - { 1, 950.0, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8123), "{}", new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8125), "Finestra anta singola 2025", 1, 3.0, 1, 1, "{}" }, - { 2, 160.0, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8137), "{}", new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8138), "Persiana per Finestra anta singola 2025", 1, 3.0, 1, 2, "{}" }, - { 3, 200.0, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8144), "{}", new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8145), "Installazione serramento", 1, 3.0, 1, 3, "{}" } - }); - migrationBuilder.InsertData( table: "StockMov", - columns: new[] { "StockMovID", "DtRec", "Note", "QtyRec", "StockStatusId", "UserId" }, + columns: new[] { "StockMovID", "CodDoc", "DtCreate", "MovCod", "Note", "QtyRec", "StockStatusId", "UnitVal", "UserId" }, values: new object[,] { - { 1, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7890), "DEMO", 5.0, 1, "samuele.locatelli@egalware.com" }, - { 2, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7895), "DEMO", 8.0, 2, "samuele.locatelli@egalware.com" }, - { 3, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7899), "DEMO", 5.0, 3, "samuele.locatelli@egalware.com" }, - { 4, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7903), "DEMO", 1.0, 4, "samuele.locatelli@egalware.com" }, - { 5, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7906), "DEMO", 10.0, 5, "samuele.locatelli@egalware.com" }, - { 6, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7910), "DEMO", 1.0, 6, "samuele.locatelli@egalware.com" }, - { 7, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7914), "DEMO", 50.0, 7, "samuele.locatelli@egalware.com" }, - { 8, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7917), "DEMO", 1.0, 8, "samuele.locatelli@egalware.com" }, - { 9, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7921), "DEMO", 1.0, 9, "samuele.locatelli@egalware.com" }, - { 10, new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7925), "DEMO", 1.0, 10, "samuele.locatelli@egalware.com" } + { 1, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5254), "CAR", "DEMO", 5.0, 1, 0.0, "samuele.locatelli@egalware.com" }, + { 2, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5324), "CAR", "DEMO", 8.0, 2, 0.0, "samuele.locatelli@egalware.com" }, + { 3, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5327), "CAR", "DEMO", 5.0, 3, 0.0, "samuele.locatelli@egalware.com" }, + { 4, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5331), "CAR", "DEMO", 1.0, 4, 0.0, "samuele.locatelli@egalware.com" }, + { 5, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5335), "CAR", "DEMO", 10.0, 5, 0.0, "samuele.locatelli@egalware.com" }, + { 6, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5338), "CAR", "DEMO", 1.0, 6, 0.0, "samuele.locatelli@egalware.com" }, + { 7, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5342), "CAR", "DEMO", 50.0, 7, 0.0, "samuele.locatelli@egalware.com" }, + { 8, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5346), "CAR", "DEMO", 1.0, 8, 0.0, "samuele.locatelli@egalware.com" }, + { 9, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5349), "CAR", "DEMO", 1.0, 9, 0.0, "samuele.locatelli@egalware.com" }, + { 10, "", new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5353), "CAR", "DEMO", 1.0, 10, 0.0, "samuele.locatelli@egalware.com" } }); migrationBuilder.CreateIndex( @@ -846,11 +936,21 @@ namespace Lux.Data.Migrations table: "ProductionItemRowList", column: "ResourceID"); + migrationBuilder.CreateIndex( + name: "IX_RegItem_CodGroup", + table: "RegItem", + column: "CodGroup"); + migrationBuilder.CreateIndex( name: "IX_SellingItem_JobID", table: "SellingItem", column: "JobID"); + migrationBuilder.CreateIndex( + name: "IX_StockMov_MovCod", + table: "StockMov", + column: "MovCod"); + migrationBuilder.CreateIndex( name: "IX_StockMov_StockStatusId", table: "StockMov", @@ -865,6 +965,9 @@ namespace Lux.Data.Migrations /// protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "Counter"); + migrationBuilder.DropTable( name: "JobRowItemList"); @@ -889,6 +992,9 @@ namespace Lux.Data.Migrations migrationBuilder.DropTable( name: "ProductionItem"); + migrationBuilder.DropTable( + name: "RegMovType"); + migrationBuilder.DropTable( name: "StockStatus"); @@ -913,6 +1019,9 @@ namespace Lux.Data.Migrations migrationBuilder.DropTable( name: "SellingItem"); + migrationBuilder.DropTable( + name: "RegItemGroup"); + migrationBuilder.DropTable( name: "Offer"); diff --git a/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs b/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs index 626162b7..2aeb3532 100644 --- a/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs +++ b/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs @@ -22,6 +22,22 @@ namespace Lux.Data.Migrations MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); + modelBuilder.Entity("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("Lux.Data.DbModel.CustomerModel", b => { b.Property("CustomerID") @@ -132,6 +148,42 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("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 = "BARRA", + Description = "Barre legno per lavorazione" + }, + new + { + CodGroup = "VETRO", + Description = "Vetri serramento" + }, + new + { + CodGroup = "VERNICE", + Description = "Vernici per legno" + }, + new + { + CodGroup = "FERRAMENTA", + Description = "Ferramenta serramento" + }); + }); + modelBuilder.Entity("Lux.Data.DbModel.ItemModel", b => { b.Property("ItemID") @@ -140,6 +192,10 @@ namespace Lux.Data.Migrations MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID")); + b.Property("CodGroup") + .IsRequired() + .HasColumnType("varchar(255)"); + b.Property("Cost") .HasColumnType("double"); @@ -170,12 +226,15 @@ namespace Lux.Data.Migrations b.HasKey("ItemID"); + b.HasIndex("CodGroup"); + b.ToTable("RegItem"); b.HasData( new { ItemID = 1, + CodGroup = "BARRA", Cost = 20.0, Description = "BARRA-60x80 generica", ExtItemCode = "", @@ -188,6 +247,7 @@ namespace Lux.Data.Migrations new { ItemID = 2, + CodGroup = "BARRA", Cost = 16.5, Description = "Barra 60x80, lunghezza 12m", ExtItemCode = "BARRA-60x80x12000", @@ -200,6 +260,7 @@ namespace Lux.Data.Migrations new { ItemID = 3, + CodGroup = "BARRA", Cost = 17.5, Description = "Barra 60x80, lunghezza 8m", ExtItemCode = "BARRA-60x80x8000", @@ -212,6 +273,7 @@ namespace Lux.Data.Migrations new { ItemID = 4, + CodGroup = "BARRA", Cost = 15.5, Description = "Barra 60x80, lunghezza 16m", ExtItemCode = "BARRA-60x80x16000", @@ -224,6 +286,7 @@ namespace Lux.Data.Migrations new { ItemID = 5, + CodGroup = "VETRO", Cost = 300.0, Description = "Vetro triplo, basso indice termico, 800x1000", ExtItemCode = "VETRO-3L-THERMO-800x1000", @@ -236,6 +299,7 @@ namespace Lux.Data.Migrations new { ItemID = 6, + CodGroup = "VETRO", Cost = 200.0, Description = "Vetro doppio, 800x1000", ExtItemCode = "VETRO-2L-800x1000", @@ -248,6 +312,7 @@ namespace Lux.Data.Migrations new { ItemID = 7, + CodGroup = "VETRO", Cost = 250.0, Description = "Vetro triplo, 800x1000", ExtItemCode = "VETRO-3L-800x1000", @@ -260,6 +325,7 @@ namespace Lux.Data.Migrations new { ItemID = 8, + CodGroup = "VERNICE", Cost = 20.0, Description = "Vernice trasparente", ExtItemCode = "VERN-TRASP", @@ -272,6 +338,7 @@ namespace Lux.Data.Migrations new { ItemID = 9, + CodGroup = "FERRAMENTA", Cost = 65.0, Description = "Kit standard completo AGB tipo 001", ExtItemCode = "KIT-001", @@ -284,6 +351,7 @@ namespace Lux.Data.Migrations new { ItemID = 10, + CodGroup = "FERRAMENTA", Cost = 10.0, Description = "Cerniera AGB tipo 001", ExtItemCode = "CERN-001", @@ -296,6 +364,7 @@ namespace Lux.Data.Migrations new { ItemID = 11, + CodGroup = "FERRAMENTA", Cost = 15.0, Description = "Serratura AGB tipo 001", ExtItemCode = "SERR-001", @@ -308,6 +377,7 @@ namespace Lux.Data.Migrations new { ItemID = 12, + CodGroup = "FERRAMENTA", Cost = 25.0, Description = "Maniglia AGB tipo 001", ExtItemCode = "MAN-001", @@ -500,6 +570,52 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("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("Lux.Data.DbModel.OfferModel", b => { b.Property("OfferID") @@ -554,13 +670,13 @@ namespace Lux.Data.Migrations CustomerID = 2, DealerID = 2, Description = "Offerta per tre serramenti", - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8097), - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8099), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5570), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5571), OffertState = 0, RefNum = 1, RefRev = 1, RefYear = 2024, - ValidUntil = new DateTime(2025, 8, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8094) + ValidUntil = new DateTime(2025, 8, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5566) }); }); @@ -618,9 +734,9 @@ namespace Lux.Data.Migrations { OfferRowID = 1, Cost = 950.0, - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8123), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5601), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8125), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5602), Note = "Finestra anta singola 2025", OfferID = 1, Qty = 3.0, @@ -632,9 +748,9 @@ namespace Lux.Data.Migrations { OfferRowID = 2, Cost = 160.0, - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8137), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5609), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8138), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5611), Note = "Persiana per Finestra anta singola 2025", OfferID = 1, Qty = 3.0, @@ -646,9 +762,9 @@ namespace Lux.Data.Migrations { OfferRowID = 3, Cost = 200.0, - Inserted = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8144), + Inserted = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5616), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(8145), + Modified = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5618), Note = "Installazione serramento", OfferID = 1, Qty = 3.0, @@ -969,7 +1085,7 @@ namespace Lux.Data.Migrations IsHuman = false, UmFix = "€/h", UmProp = "€/m", - UnitCostFix = 540.0, + UnitCostFix = 240.0, UnitCostProp = 1.8999999999999999 }, new @@ -979,9 +1095,9 @@ namespace Lux.Data.Migrations IsAsset = true, IsHuman = false, UmFix = "€/h", - UmProp = "", - UnitCostFix = 250.0, - UnitCostProp = 0.0 + UmProp = "€/m", + UnitCostFix = 90.0, + UnitCostProp = 5.9000000000000004 }, new { @@ -991,7 +1107,7 @@ namespace Lux.Data.Migrations IsHuman = false, UmFix = "€/h", UmProp = "€/m", - UnitCostFix = 10.0, + UnitCostFix = 40.0, UnitCostProp = 1.8999999999999999 }, new @@ -1002,7 +1118,7 @@ namespace Lux.Data.Migrations IsHuman = true, UmFix = "€/h", UmProp = "€/m", - UnitCostFix = 40.0, + UnitCostFix = 10.0, UnitCostProp = 1.8999999999999999 }, new @@ -1138,8 +1254,25 @@ namespace Lux.Data.Migrations MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("StockMovID")); - b.Property("DtRec") - .HasColumnType("datetime(6)"); + b.Property("CodDoc") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DtCreate") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DtMod") + .ValueGeneratedOnAddOrUpdate() + .HasColumnType("timestamp") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property("DtMod")); + + b.Property("MovCod") + .IsRequired() + .HasColumnType("varchar(255)"); b.Property("Note") .IsRequired() @@ -1151,12 +1284,17 @@ namespace Lux.Data.Migrations b.Property("StockStatusId") .HasColumnType("int"); + b.Property("UnitVal") + .HasColumnType("double"); + b.Property("UserId") .IsRequired() .HasColumnType("longtext"); b.HasKey("StockMovID"); + b.HasIndex("MovCod"); + b.HasIndex("StockStatusId"); b.ToTable("StockMov"); @@ -1165,91 +1303,131 @@ namespace Lux.Data.Migrations new { StockMovID = 1, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7890), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5254), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5321), + MovCod = "CAR", Note = "DEMO", QtyRec = 5.0, StockStatusId = 1, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 2, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7895), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5324), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5325), + MovCod = "CAR", Note = "DEMO", QtyRec = 8.0, StockStatusId = 2, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 3, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7899), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5327), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5329), + MovCod = "CAR", Note = "DEMO", QtyRec = 5.0, StockStatusId = 3, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 4, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7903), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5331), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5333), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 4, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 5, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7906), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5335), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5336), + MovCod = "CAR", Note = "DEMO", QtyRec = 10.0, StockStatusId = 5, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 6, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7910), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5338), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5340), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 6, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 7, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7914), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5342), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5343), + MovCod = "CAR", Note = "DEMO", QtyRec = 50.0, StockStatusId = 7, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 8, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7917), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5346), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5347), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 8, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 9, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7921), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5349), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5351), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 9, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }, new { StockMovID = 10, - DtRec = new DateTime(2025, 7, 7, 18, 13, 5, 424, DateTimeKind.Local).AddTicks(7925), + CodDoc = "", + DtCreate = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5353), + DtMod = new DateTime(2025, 7, 7, 19, 11, 19, 327, DateTimeKind.Local).AddTicks(5354), + MovCod = "CAR", Note = "DEMO", QtyRec = 1.0, StockStatusId = 10, + UnitVal = 0.0, UserId = "samuele.locatelli@egalware.com" }); }); @@ -1476,6 +1654,17 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("Lux.Data.DbModel.ItemModel", b => + { + b.HasOne("Lux.Data.DbModel.ItemGroupModel", "ItemGroupNav") + .WithMany() + .HasForeignKey("CodGroup") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ItemGroupNav"); + }); + modelBuilder.Entity("Lux.Data.DbModel.JobRowItemModel", b => { b.HasOne("Lux.Data.DbModel.ItemModel", "ItemNav") @@ -1665,12 +1854,20 @@ namespace Lux.Data.Migrations modelBuilder.Entity("Lux.Data.DbModel.StockMovModel", b => { + b.HasOne("Lux.Data.DbModel.MovTypeModel", "MovTypeNav") + .WithMany() + .HasForeignKey("MovCod") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.HasOne("Lux.Data.DbModel.StockStatusModel", "StockStatusNav") .WithMany() .HasForeignKey("StockStatusId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); + b.Navigation("MovTypeNav"); + b.Navigation("StockStatusNav"); }); diff --git a/Lux.Data/ModelBuilderExtensions.cs b/Lux.Data/ModelBuilderExtensions.cs index 307ec3a7..a9ce6d12 100644 --- a/Lux.Data/ModelBuilderExtensions.cs +++ b/Lux.Data/ModelBuilderExtensions.cs @@ -10,6 +10,8 @@ namespace Lux.Data { public static class ModelBuilderExtensions { + #region Public Methods + /// /// Estensione per seed iniziale dei dati nel DB /// @@ -46,27 +48,45 @@ namespace Lux.Data new SupplierModel { SupplierID = 3, CompanyName = "Company Two", FirstName = "Supplier C", LastName = "User Test", VAT = "7294857103879254" } ); + // inizializzazione dei valori di default x gruppi item + modelBuilder.Entity().HasData( + new ItemGroupModel { CodGroup = "BARRA", Description = "Barre legno per lavorazione" }, + new ItemGroupModel { CodGroup = "VETRO", Description = "Vetri serramento" }, + new ItemGroupModel { CodGroup = "VERNICE", Description = "Vernici per legno" }, + new ItemGroupModel { CodGroup = "FERRAMENTA", Description = "Ferramenta serramento" } + ); + + // inizializzazione tipo mov mag + modelBuilder.Entity().HasData( + new MovTypeModel { MovCod = "CAR", Description = "Carico a magazzino" }, + new MovTypeModel { MovCod = "MOV", Description = "Movimento interno (spostamento)" }, + new MovTypeModel { MovCod = "ND", Description = "Non Definito" }, + new MovTypeModel { MovCod = "OFOR", Description = "Ordine Fornitore" }, + new MovTypeModel { MovCod = "RETT", Description = "Rettifica magazzino" }, + new MovTypeModel { MovCod = "SCAR", Description = "Scarico da magazzino" } + ); + // inizializzazione dei valori di default x Item di magazzino modelBuilder.Entity().HasData( // barre grezzo - new ItemModel { ItemID = 1, IsService = false, ItemCode = 1001, Description = "BARRA-60x80 generica", SupplCode = "BARR.001", Cost = 20, Margin = 0.3, UM = "#" }, - new ItemModel { ItemID = 2, IsService = false, ItemCode = 1002, ExtItemCode = "BARRA-60x80x12000", SupplCode = "ABC.00123.12000", Description = "Barra 60x80, lunghezza 12m", Cost = 16.5, Margin = 0.21, UM = "#" }, - new ItemModel { ItemID = 3, IsService = false, ItemCode = 1003, ExtItemCode = "BARRA-60x80x8000", SupplCode = "ABC.00123.8000", Description = "Barra 60x80, lunghezza 8m", Cost = 17.5, Margin = 0.22, UM = "#" }, - new ItemModel { ItemID = 4, IsService = false, ItemCode = 1004, ExtItemCode = "BARRA-60x80x16000", SupplCode = "ABC.00123.16000", Description = "Barra 60x80, lunghezza 16m", Cost = 15.5, Margin = 0.2, UM = "#" }, + new ItemModel { ItemID = 1, CodGroup = "BARRA", IsService = false, ItemCode = 1001, Description = "BARRA-60x80 generica", SupplCode = "BARR.001", Cost = 20, Margin = 0.3, UM = "#" }, + new ItemModel { ItemID = 2, CodGroup = "BARRA", IsService = false, ItemCode = 1002, ExtItemCode = "BARRA-60x80x12000", SupplCode = "ABC.00123.12000", Description = "Barra 60x80, lunghezza 12m", Cost = 16.5, Margin = 0.21, UM = "#" }, + new ItemModel { ItemID = 3, CodGroup = "BARRA", IsService = false, ItemCode = 1003, ExtItemCode = "BARRA-60x80x8000", SupplCode = "ABC.00123.8000", Description = "Barra 60x80, lunghezza 8m", Cost = 17.5, Margin = 0.22, UM = "#" }, + new ItemModel { ItemID = 4, CodGroup = "BARRA", IsService = false, ItemCode = 1004, ExtItemCode = "BARRA-60x80x16000", SupplCode = "ABC.00123.16000", Description = "Barra 60x80, lunghezza 16m", Cost = 15.5, Margin = 0.2, UM = "#" }, // vetri - new ItemModel { ItemID = 5, IsService = false, ItemCode = 2001, ExtItemCode = "VETRO-3L-THERMO-800x1000", SupplCode = "V3T.800.1000", Description = "Vetro triplo, basso indice termico, 800x1000", Cost = 300, Margin = 0.20, UM = "m2" }, - new ItemModel { ItemID = 6, IsService = false, ItemCode = 2002, ExtItemCode = "VETRO-2L-800x1000", SupplCode = "V2.800.1000", Description = "Vetro doppio, 800x1000", Cost = 200, Margin = 0.15, UM = "m2" }, - new ItemModel { ItemID = 7, IsService = false, ItemCode = 2003, ExtItemCode = "VETRO-3L-800x1000", SupplCode = "V3.800.1000", Description = "Vetro triplo, 800x1000", Cost = 250, Margin = 0.18, UM = "m2" }, + new ItemModel { ItemID = 5, CodGroup = "VETRO", IsService = false, ItemCode = 2001, ExtItemCode = "VETRO-3L-THERMO-800x1000", SupplCode = "V3T.800.1000", Description = "Vetro triplo, basso indice termico, 800x1000", Cost = 300, Margin = 0.20, UM = "m2" }, + new ItemModel { ItemID = 6, CodGroup = "VETRO", IsService = false, ItemCode = 2002, ExtItemCode = "VETRO-2L-800x1000", SupplCode = "V2.800.1000", Description = "Vetro doppio, 800x1000", Cost = 200, Margin = 0.15, UM = "m2" }, + new ItemModel { ItemID = 7, CodGroup = "VETRO", IsService = false, ItemCode = 2003, ExtItemCode = "VETRO-3L-800x1000", SupplCode = "V3.800.1000", Description = "Vetro triplo, 800x1000", Cost = 250, Margin = 0.18, UM = "m2" }, // vernici - new ItemModel { ItemID = 8, IsService = false, ItemCode = 3001, ExtItemCode = "VERN-TRASP", SupplCode = "VT.STD", Description = "Vernice trasparente", Cost = 20, Margin = 0.20, UM = "l" }, + new ItemModel { ItemID = 8, CodGroup = "VERNICE", IsService = false, ItemCode = 3001, ExtItemCode = "VERN-TRASP", SupplCode = "VT.STD", Description = "Vernice trasparente", Cost = 20, Margin = 0.20, UM = "l" }, // ferramenta - new ItemModel { ItemID = 9, IsService = false, ItemCode = 5001, ExtItemCode = "KIT-001", SupplCode = "AGB-KIT-001", Description = "Kit standard completo AGB tipo 001", Cost = 65, Margin = 0.20, UM = "#" }, - new ItemModel { ItemID = 10, IsService = false, ItemCode = 5002, ExtItemCode = "CERN-001", SupplCode = "AGB-CERN-001", Description = "Cerniera AGB tipo 001", Cost = 10, Margin = 0.20, UM = "#" }, - new ItemModel { ItemID = 11, IsService = false, ItemCode = 5003, ExtItemCode = "SERR-001", SupplCode = "AGB-SERR-001", Description = "Serratura AGB tipo 001", Cost = 15, Margin = 0.20, UM = "#" }, - new ItemModel { ItemID = 12, IsService = false, ItemCode = 5004, ExtItemCode = "MAN-001", SupplCode = "AGB-MAN-001", Description = "Maniglia AGB tipo 001", Cost = 25, Margin = 0.20, UM = "#" } + new ItemModel { ItemID = 9, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5001, ExtItemCode = "KIT-001", SupplCode = "AGB-KIT-001", Description = "Kit standard completo AGB tipo 001", Cost = 65, Margin = 0.20, UM = "#" }, + new ItemModel { ItemID = 10, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5002, ExtItemCode = "CERN-001", SupplCode = "AGB-CERN-001", Description = "Cerniera AGB tipo 001", Cost = 10, Margin = 0.20, UM = "#" }, + new ItemModel { ItemID = 11, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5003, ExtItemCode = "SERR-001", SupplCode = "AGB-SERR-001", Description = "Serratura AGB tipo 001", Cost = 15, Margin = 0.20, UM = "#" }, + new ItemModel { ItemID = 12, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5004, ExtItemCode = "MAN-001", SupplCode = "AGB-MAN-001", Description = "Maniglia AGB tipo 001", Cost = 25, Margin = 0.20, UM = "#" } ); // inizializzazione dei valori di default x Item di giacenza @@ -93,32 +113,31 @@ namespace Lux.Data // inizializzazione dei valori di default x movimenti giacenze magazzino modelBuilder.Entity().HasData( // giacenza barre grezzo - new StockMovModel { StockMovID = 1, StockStatusId = 1, DtRec = DateTime.Now, QtyRec = 5, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, - new StockMovModel { StockMovID = 2, StockStatusId = 2, DtRec = DateTime.Now, QtyRec = 8, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, - new StockMovModel { StockMovID = 3, StockStatusId = 3, DtRec = DateTime.Now, QtyRec = 5, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 1, StockStatusId = 1, QtyRec = 5, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 2, StockStatusId = 2, QtyRec = 8, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 3, StockStatusId = 3, QtyRec = 5, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, // giacenza vetri - new StockMovModel { StockMovID = 4, StockStatusId = 4, DtRec = DateTime.Now, QtyRec = 1, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, - new StockMovModel { StockMovID = 5, StockStatusId = 5, DtRec = DateTime.Now, QtyRec = 10, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, - new StockMovModel { StockMovID = 6, StockStatusId = 6, DtRec = DateTime.Now, QtyRec = 1, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 4, StockStatusId = 4, QtyRec = 1, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 5, StockStatusId = 5, QtyRec = 10, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 6, StockStatusId = 6, QtyRec = 1, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, // giacenza vernici - new StockMovModel { StockMovID = 7, StockStatusId = 7, DtRec = DateTime.Now, QtyRec = 50, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 7, StockStatusId = 7, QtyRec = 50, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, // giacenza ferramenta - new StockMovModel { StockMovID = 8, StockStatusId = 8, DtRec = DateTime.Now, QtyRec = 1, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, - new StockMovModel { StockMovID = 9, StockStatusId = 9, DtRec = DateTime.Now, QtyRec = 1, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, - new StockMovModel { StockMovID = 10, StockStatusId = 10, DtRec = DateTime.Now, QtyRec = 1, UserId = "samuele.locatelli@egalware.com", Note = "DEMO" } + new StockMovModel { StockMovID = 8, StockStatusId = 8, QtyRec = 1, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 9, StockStatusId = 9, QtyRec = 1, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" }, + new StockMovModel { StockMovID = 10, StockStatusId = 10, QtyRec = 1, MovCod = "CAR", UserId = "samuele.locatelli@egalware.com", Note = "DEMO" } ); - // inizializzazione risorse modelBuilder.Entity().HasData( new ResourceModel { ResourceID = 1, Description = "Sezionatrice", IsAsset = true, IsHuman = false, UnitCostFix = 15, UmFix = "€/h" }, - new ResourceModel { ResourceID = 2, Description = "Linea SAOMAD WoodPecker Just 3500", IsAsset = true, IsHuman = false, UnitCostFix = 540, UmFix = "€/h", UnitCostProp = 1.9, UmProp = "€/m" }, - new ResourceModel { ResourceID = 3, Description = "Linea Pantografo", IsAsset = true, IsHuman = false, UnitCostFix = 250, UmFix = "€/h" }, - new ResourceModel { ResourceID = 4, Description = "Stazione Verniciatura", IsAsset = true, IsHuman = false, UnitCostFix = 10, UmFix = "€/h", UnitCostProp = 1.9, UmProp = "€/m" }, - new ResourceModel { ResourceID = 5, Description = "Verniciatura Manuale", IsAsset = false, IsHuman = true, UnitCostFix = 40, UmFix = "€/h", UnitCostProp = 1.9, UmProp = "€/m" }, + new ResourceModel { ResourceID = 2, Description = "Linea SAOMAD WoodPecker Just 3500", IsAsset = true, IsHuman = false, UnitCostFix = 240, UmFix = "€/h", UnitCostProp = 1.9, UmProp = "€/m" }, + new ResourceModel { ResourceID = 3, Description = "Linea Pantografo", IsAsset = true, IsHuman = false, UnitCostFix = 90, UmFix = "€/h", UnitCostProp = 5.9, UmProp = "€/m" }, + new ResourceModel { ResourceID = 4, Description = "Stazione Verniciatura", IsAsset = true, IsHuman = false, UnitCostFix = 40, UmFix = "€/h", UnitCostProp = 1.9, UmProp = "€/m" }, + new ResourceModel { ResourceID = 5, Description = "Verniciatura Manuale", IsAsset = false, IsHuman = true, UnitCostFix = 10, UmFix = "€/h", UnitCostProp = 1.9, UmProp = "€/m" }, new ResourceModel { ResourceID = 6, Description = "Montaggio Manuale", IsAsset = false, IsHuman = true, UnitCostProp = 40, UmProp = "€/h" }, new ResourceModel { ResourceID = 7, Description = "Installatore", IsAsset = false, IsHuman = true, UnitCostProp = 40, UmProp = "€/h" } ); @@ -167,7 +186,6 @@ namespace Lux.Data new JobRowItemModel { JobRowItemID = 3, JobRowID = 4, Index = 3, ItemID = 9, Qty = 1, Description = "Ferramenta AGB - rif. AGFD.00000.00000" } ); - // inizializzazione dei valori di default x SellingItem modelBuilder.Entity().HasData( new SellingItemModel { SellingItemID = 1, IsService = false, Description = "Finestra anta Singola", Cost = 820, Margin = 0.2, JobID = 2 }, @@ -189,7 +207,8 @@ namespace Lux.Data new OfferRowModel { OfferRowID = 2, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 160, SellingItemID = 2, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Persiana per Finestra anta singola 2025", ItemSPP = "{}" }, new OfferRowModel { OfferRowID = 3, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 200, SellingItemID = 3, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Installazione serramento", ItemSPP = "{}" } ); - } + + #endregion Public Methods } -} +} \ No newline at end of file