diff --git a/Lux.Data/DataLayerContext.cs b/Lux.Data/DataLayerContext.cs index 838857c3..2b0ae5b9 100644 --- a/Lux.Data/DataLayerContext.cs +++ b/Lux.Data/DataLayerContext.cs @@ -55,6 +55,8 @@ namespace Lux.Data public virtual DbSet DbSetJob { 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; } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); diff --git a/Lux.Data/DbModel/OfferModel.cs b/Lux.Data/DbModel/OfferModel.cs index 6e4d13d2..3857c293 100644 --- a/Lux.Data/DbModel/OfferModel.cs +++ b/Lux.Data/DbModel/OfferModel.cs @@ -71,7 +71,7 @@ namespace Lux.Data.DbModel /// DataOra inserimento /// public DateTime Inserted { get; set; } = DateTime.Now; - + /// /// DataOra ultima modifica /// diff --git a/Lux.Data/DbModel/ProductionBatchModel.cs b/Lux.Data/DbModel/ProductionBatchModel.cs new file mode 100644 index 00000000..0bb16fe9 --- /dev/null +++ b/Lux.Data/DbModel/ProductionBatchModel.cs @@ -0,0 +1,41 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Lux.Data.DbModel +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + + [Table("ProductionBatch")] + public class ProductionBatchModel + { + /// + /// ID dell'articolo + /// + [Key] + public int ProductionBatchID { get; set; } + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + + /// + /// DataOra prevista esecuzione + /// + public DateTime DueDate { get; set; } = DateTime.Today.AddMonths(1); + + /// + /// DataOra inizio + /// + public DateTime? DateStart { get; set; } = null; + + /// + /// DataOra fine + /// + public DateTime? DateEnd { get; set; } = null; + + + } +} diff --git a/Lux.Data/DbModel/ProductionItemModel.cs b/Lux.Data/DbModel/ProductionItemModel.cs new file mode 100644 index 00000000..485dd66a --- /dev/null +++ b/Lux.Data/DbModel/ProductionItemModel.cs @@ -0,0 +1,79 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Lux.Data.DbModel +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + + [Table("ProductionItem")] + public class ProductionItemModel + { + /// + /// ID dell'articolo + /// + [Key] + public int ProdItemID { get; set; } + + /// + /// Riga Ordine da cui scaturisce + /// + public int OrderRowID { get; set; } + + /// + /// CodArticolo (opzionale) numerico + /// + public int ItemCode { get; set; } = 0; + + /// + /// CodArticolo (opzionale) string + /// + public string ExtItemCode { get; set; } = ""; + + /// + /// Batch di produzione cui è correlato + /// + public int ProductionBatchID { get; set; } = 0; +#if false + /// + /// Cod Fornitore (opzionale) + /// + public string SupplCode { get; set; } = ""; + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + + /// + /// Costo (standard / senza listini) + /// + public double Cost { get; set; } = 0; + + /// + /// Margine percentuale standard + /// + public double Margin { get; set; } = 0.1; + + /// + /// Unità di Misura + /// + public string UM { get; set; } = "#"; +#endif + + + /// + /// Navigazione OrderRow + /// + [ForeignKey("OrderRowID")] + public virtual OrderRowModel OrderRowNav { get; set; } = null!; + + /// + /// Navigazione Batch Produzione + /// + [ForeignKey("ProductionBatchID")] + public virtual ProductionBatchModel ProductionBatchNav { get; set; } = null!; + + } +} diff --git a/Lux.Data/Documentazione/DbSchema.png b/Lux.Data/Documentazione/DbSchema.png new file mode 100644 index 00000000..1cf4de3b Binary files /dev/null and b/Lux.Data/Documentazione/DbSchema.png differ diff --git a/Lux.Data/Migrations/20250703160708_AddProdBatch.Designer.cs b/Lux.Data/Migrations/20250703160708_AddProdBatch.Designer.cs new file mode 100644 index 00000000..fdfbe69a --- /dev/null +++ b/Lux.Data/Migrations/20250703160708_AddProdBatch.Designer.cs @@ -0,0 +1,1231 @@ +// +using System; +using 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 Lux.Data.Migrations +{ + [DbContext(typeof(DataLayerContext))] + [Migration("20250703160708_AddProdBatch")] + partial class AddProdBatch + { + /// + 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("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("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("Lux.Data.DbModel.ItemModel", b => + { + b.Property("ItemID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ItemID")); + + 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("Margin") + .HasColumnType("double"); + + b.Property("SupplCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UM") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("ItemID"); + + b.ToTable("RegItem"); + + b.HasData( + new + { + ItemID = 1, + Cost = 50.0, + Description = "Barra di legno 80x120", + ExtItemCode = "", + IsService = false, + ItemCode = 0, + Margin = 0.29999999999999999, + SupplCode = "", + UM = "#" + }, + new + { + ItemID = 2, + Cost = 35.0, + Description = "Vernice trasparente", + ExtItemCode = "", + IsService = false, + ItemCode = 0, + Margin = 0.29999999999999999, + SupplCode = "", + UM = "#" + }, + new + { + ItemID = 3, + Cost = 1.0, + Description = "Ferramenta", + ExtItemCode = "", + IsService = false, + ItemCode = 0, + Margin = 0.29999999999999999, + SupplCode = "", + UM = "#" + }); + }); + + modelBuilder.Entity("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("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 = 4.5 + }, + new + { + JobRowItemID = 2, + Description = "Vernice trasparente standard 1L", + Index = 2, + ItemID = 2, + JobRowID = 4, + Qty = 1.0 + }, + new + { + JobRowItemID = 3, + Description = "Ferramenta AGB - rif. AGFD.00000.00000", + Index = 3, + ItemID = 3, + JobRowID = 5, + Qty = 1.0 + }); + }); + + modelBuilder.Entity("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 = 4, + Qty = 1.0, + ResourceID = 6 + }, + new + { + JobRowID = 4, + Description = "", + Index = 4, + JobID = 2, + PhaseID = 3, + Qty = 1.0, + ResourceID = 4 + }, + new + { + JobRowID = 5, + Description = "", + Index = 5, + JobID = 2, + PhaseID = 5, + Qty = 1.0, + ResourceID = 6 + }, + new + { + JobRowID = 6, + Description = "", + Index = 6, + JobID = 2, + PhaseID = 6, + Qty = 1.0, + ResourceID = 7 + }); + }); + + modelBuilder.Entity("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, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4269), + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4271), + OffertState = 0, + RefNum = 1, + RefRev = 1, + RefYear = 2024, + ValidUntil = new DateTime(2025, 8, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4265) + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OfferRowModel", b => + { + b.Property("OfferRowID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OfferRowID")); + + b.Property("Cost") + .HasColumnType("double"); + + b.Property("Inserted") + .HasColumnType("datetime(6)"); + + b.Property("ItemSPP") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Modified") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OfferID") + .HasColumnType("int"); + + b.Property("Qty") + .HasColumnType("double"); + + b.Property("RowNum") + .HasColumnType("int"); + + b.Property("SellingItemID") + .HasColumnType("int"); + + b.Property("SerStruct") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("OfferRowID"); + + b.HasIndex("OfferID"); + + b.HasIndex("SellingItemID"); + + b.ToTable("OfferRowList"); + + b.HasData( + new + { + OfferRowID = 1, + Cost = 950.0, + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4291), + ItemSPP = "{}", + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4293), + Note = "Finestra anta singola 2025", + OfferID = 1, + Qty = 3.0, + RowNum = 1, + SellingItemID = 1, + SerStruct = "{}" + }, + new + { + OfferRowID = 2, + Cost = 160.0, + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4300), + ItemSPP = "{}", + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4302), + Note = "Persiana per Finestra anta singola 2025", + OfferID = 1, + Qty = 3.0, + RowNum = 1, + SellingItemID = 2, + SerStruct = "{}" + }, + new + { + OfferRowID = 3, + Cost = 200.0, + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4307), + ItemSPP = "{}", + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4309), + Note = "Installazione serramento", + OfferID = 1, + Qty = 3.0, + RowNum = 1, + SellingItemID = 3, + SerStruct = "{}" + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OrderModel", b => + { + b.Property("OrderID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OrderID")); + + 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("OfferID") + .HasColumnType("int"); + + 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("OrderID"); + + b.HasIndex("CustomerID"); + + b.HasIndex("DealerID"); + + b.HasIndex("OfferID"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OrderRowModel", b => + { + b.Property("OrderRowID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("OrderRowID")); + + b.Property("Cost") + .HasColumnType("double"); + + b.Property("Inserted") + .HasColumnType("datetime(6)"); + + b.Property("ItemSPP") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("Modified") + .HasColumnType("datetime(6)"); + + b.Property("Note") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("OrderID") + .HasColumnType("int"); + + b.Property("Qty") + .HasColumnType("double"); + + b.Property("RowNum") + .HasColumnType("int"); + + b.Property("SellingItemID") + .HasColumnType("int"); + + b.Property("SerStruct") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("OrderRowID"); + + b.HasIndex("OrderID"); + + b.HasIndex("SellingItemID"); + + b.ToTable("OrderRowList"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.PhaseModel", b => + { + b.Property("PhaseID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("PhaseID")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("PhaseID"); + + b.ToTable("RegPhase"); + + b.HasData( + new + { + PhaseID = 1, + Description = "Taglio tronchetti" + }, + new + { + PhaseID = 2, + Description = "Lavorazione pezzi serramento" + }, + new + { + PhaseID = 3, + Description = "Verniciatura" + }, + new + { + PhaseID = 4, + Description = "Assemblaggio completo" + }, + new + { + PhaseID = 5, + Description = "Assemblaggio Ferramenta" + }, + new + { + PhaseID = 6, + Description = "Installazione e posa in opera" + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.ProductionBatchModel", b => + { + b.Property("ProductionBatchID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProductionBatchID")); + + b.Property("DateEnd") + .HasColumnType("datetime(6)"); + + b.Property("DateStart") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DueDate") + .HasColumnType("datetime(6)"); + + b.HasKey("ProductionBatchID"); + + b.ToTable("ProductionBatch"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.ProductionItemModel", b => + { + b.Property("ProdItemID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProdItemID")); + + b.Property("ExtItemCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ItemCode") + .HasColumnType("int"); + + b.Property("OrderRowID") + .HasColumnType("int"); + + b.Property("ProductionBatchID") + .HasColumnType("int"); + + b.HasKey("ProdItemID"); + + b.HasIndex("OrderRowID"); + + b.HasIndex("ProductionBatchID"); + + b.ToTable("ProductionItem"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.ResourceModel", b => + { + b.Property("ResourceID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ResourceID")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("IsAsset") + .HasColumnType("tinyint(1)"); + + b.Property("IsHuman") + .HasColumnType("tinyint(1)"); + + b.Property("UM") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UnitCost") + .HasColumnType("double"); + + b.HasKey("ResourceID"); + + b.ToTable("RegResource"); + + b.HasData( + new + { + ResourceID = 1, + Description = "Sezionatrice", + IsAsset = true, + IsHuman = false, + UM = "€/h", + UnitCost = 15.0 + }, + new + { + ResourceID = 2, + Description = "Linea SAOMAD WoodPecker Just 3500", + IsAsset = true, + IsHuman = false, + UM = "€/h", + UnitCost = 540.0 + }, + new + { + ResourceID = 3, + Description = "Linea Pantografo", + IsAsset = true, + IsHuman = false, + UM = "€/h", + UnitCost = 250.0 + }, + new + { + ResourceID = 4, + Description = "Stazione Verniciatura", + IsAsset = true, + IsHuman = false, + UM = "€/h", + UnitCost = 10.0 + }, + new + { + ResourceID = 5, + Description = "Verniciatura Manuale", + IsAsset = false, + IsHuman = true, + UM = "€/h", + UnitCost = 40.0 + }, + new + { + ResourceID = 6, + Description = "Montaggio Manuale", + IsAsset = false, + IsHuman = true, + UM = "€/h", + UnitCost = 40.0 + }, + new + { + ResourceID = 7, + Description = "Installatore", + IsAsset = false, + IsHuman = true, + UM = "€/h", + UnitCost = 40.0 + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.SellingItemModel", b => + { + b.Property("SellingItemID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SellingItemID")); + + 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("ItemSPP") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("JobID") + .HasColumnType("int"); + + b.Property("Margin") + .HasColumnType("double"); + + b.Property("SerStruct") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("SupplCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("UM") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("SellingItemID"); + + b.HasIndex("JobID"); + + b.ToTable("SellingItem"); + + b.HasData( + new + { + SellingItemID = 1, + Cost = 820.0, + Description = "Finestra anta Singola", + ExtItemCode = "", + IsService = false, + ItemCode = 0, + ItemSPP = "", + JobID = 2, + Margin = 0.20000000000000001, + SerStruct = "", + SupplCode = "", + UM = "#" + }, + new + { + SellingItemID = 2, + Cost = 150.0, + Description = "Persiana anta singola", + ExtItemCode = "", + IsService = false, + ItemCode = 0, + ItemSPP = "", + JobID = 1, + Margin = 0.10000000000000001, + SerStruct = "", + SupplCode = "", + UM = "#" + }, + new + { + SellingItemID = 3, + Cost = 200.0, + Description = "Installazione", + ExtItemCode = "", + IsService = true, + ItemCode = 0, + ItemSPP = "", + JobID = 1, + Margin = 0.29999999999999999, + SerStruct = "", + SupplCode = "", + UM = "#" + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.SupplierModel", b => + { + b.Property("SupplierID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("SupplierID")); + + 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("SupplierID"); + + b.ToTable("RegSupplier"); + + b.HasData( + new + { + SupplierID = 1, + CompanyName = "Company One", + FirstName = "Supplier A", + LastName = "Egalware", + VAT = "7294857103879254" + }, + new + { + SupplierID = 2, + CompanyName = "Company Two", + FirstName = "Supplier B", + LastName = "User", + VAT = "7294857103879254" + }, + new + { + SupplierID = 3, + CompanyName = "Company Two", + FirstName = "Supplier C", + LastName = "User Test", + VAT = "7294857103879254" + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.TagsModel", b => + { + b.Property("TagID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("TagID")); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.HasKey("TagID"); + + b.ToTable("RegTags"); + + b.HasData( + new + { + TagID = 1, + Description = "Tag 01" + }, + new + { + TagID = 2, + Description = "Tag 02" + }, + new + { + TagID = 3, + Description = "Tag 03" + }, + new + { + TagID = 4, + Description = "Tag 04" + }, + new + { + TagID = 5, + Description = "Tag 05" + }); + }); + + modelBuilder.Entity("Lux.Data.DbModel.JobRowItemModel", b => + { + b.HasOne("Lux.Data.DbModel.ItemModel", "ItemNav") + .WithMany() + .HasForeignKey("ItemID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.JobRowModel", "JobRowNav") + .WithMany() + .HasForeignKey("JobRowID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("ItemNav"); + + b.Navigation("JobRowNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.JobRowModel", b => + { + b.HasOne("Lux.Data.DbModel.JobModel", "JobNav") + .WithMany() + .HasForeignKey("JobID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.PhaseModel", "PhaseNav") + .WithMany() + .HasForeignKey("PhaseID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.ResourceModel", "resourceNav") + .WithMany() + .HasForeignKey("ResourceID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("JobNav"); + + b.Navigation("PhaseNav"); + + b.Navigation("resourceNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OfferModel", b => + { + b.HasOne("Lux.Data.DbModel.CustomerModel", "CustomerNav") + .WithMany() + .HasForeignKey("CustomerID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.DealerModel", "DealerNav") + .WithMany() + .HasForeignKey("DealerID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CustomerNav"); + + b.Navigation("DealerNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OfferRowModel", b => + { + b.HasOne("Lux.Data.DbModel.OfferModel", "OfferNav") + .WithMany() + .HasForeignKey("OfferID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.SellingItemModel", "SellingItemNav") + .WithMany() + .HasForeignKey("SellingItemID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("OfferNav"); + + b.Navigation("SellingItemNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OrderModel", b => + { + b.HasOne("Lux.Data.DbModel.CustomerModel", "CustomerNav") + .WithMany() + .HasForeignKey("CustomerID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.DealerModel", "DealerNav") + .WithMany() + .HasForeignKey("DealerID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.OfferModel", "OfferNav") + .WithMany() + .HasForeignKey("OfferID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CustomerNav"); + + b.Navigation("DealerNav"); + + b.Navigation("OfferNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.OrderRowModel", b => + { + b.HasOne("Lux.Data.DbModel.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.SellingItemModel", "SellingItemNav") + .WithMany() + .HasForeignKey("SellingItemID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("SellingItemNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.ProductionItemModel", b => + { + b.HasOne("Lux.Data.DbModel.OrderRowModel", "OrderRowNav") + .WithMany() + .HasForeignKey("OrderRowID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.ProductionBatchModel", "ProductionBatchNav") + .WithMany() + .HasForeignKey("ProductionBatchID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("OrderRowNav"); + + b.Navigation("ProductionBatchNav"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.SellingItemModel", b => + { + b.HasOne("Lux.Data.DbModel.JobModel", "JobNav") + .WithMany() + .HasForeignKey("JobID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("JobNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Lux.Data/Migrations/20250703160708_AddProdBatch.cs b/Lux.Data/Migrations/20250703160708_AddProdBatch.cs new file mode 100644 index 00000000..c088151e --- /dev/null +++ b/Lux.Data/Migrations/20250703160708_AddProdBatch.cs @@ -0,0 +1,140 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Lux.Data.Migrations +{ + /// + public partial class AddProdBatch : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ProductionBatch", + columns: table => new + { + ProductionBatchID = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Description = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + DueDate = table.Column(type: "datetime(6)", nullable: false), + DateStart = table.Column(type: "datetime(6)", nullable: true), + DateEnd = table.Column(type: "datetime(6)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductionBatch", x => x.ProductionBatchID); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateTable( + name: "ProductionItem", + columns: table => new + { + ProdItemID = table.Column(type: "int", nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + OrderRowID = table.Column(type: "int", nullable: false), + ItemCode = table.Column(type: "int", nullable: false), + ExtItemCode = table.Column(type: "longtext", nullable: false) + .Annotation("MySql:CharSet", "utf8mb4"), + ProductionBatchID = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductionItem", x => x.ProdItemID); + table.ForeignKey( + name: "FK_ProductionItem_OrderRowList_OrderRowID", + column: x => x.OrderRowID, + principalTable: "OrderRowList", + principalColumn: "OrderRowID", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_ProductionItem_ProductionBatch_ProductionBatchID", + column: x => x.ProductionBatchID, + principalTable: "ProductionBatch", + principalColumn: "ProductionBatchID", + onDelete: ReferentialAction.Restrict); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.UpdateData( + table: "Offer", + keyColumn: "OfferID", + keyValue: 1, + columns: new[] { "Inserted", "Modified", "ValidUntil" }, + values: new object[] { new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4269), new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4271), new DateTime(2025, 8, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4265) }); + + migrationBuilder.UpdateData( + table: "OfferRowList", + keyColumn: "OfferRowID", + keyValue: 1, + columns: new[] { "Inserted", "Modified" }, + values: new object[] { new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4291), new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4293) }); + + migrationBuilder.UpdateData( + table: "OfferRowList", + keyColumn: "OfferRowID", + keyValue: 2, + columns: new[] { "Inserted", "Modified" }, + values: new object[] { new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4300), new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4302) }); + + migrationBuilder.UpdateData( + table: "OfferRowList", + keyColumn: "OfferRowID", + keyValue: 3, + columns: new[] { "Inserted", "Modified" }, + values: new object[] { new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4307), new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4309) }); + + migrationBuilder.CreateIndex( + name: "IX_ProductionItem_OrderRowID", + table: "ProductionItem", + column: "OrderRowID"); + + migrationBuilder.CreateIndex( + name: "IX_ProductionItem_ProductionBatchID", + table: "ProductionItem", + column: "ProductionBatchID"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ProductionItem"); + + migrationBuilder.DropTable( + name: "ProductionBatch"); + + migrationBuilder.UpdateData( + table: "Offer", + keyColumn: "OfferID", + keyValue: 1, + columns: new[] { "Inserted", "Modified", "ValidUntil" }, + values: new object[] { new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9450), new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9452), new DateTime(2025, 8, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9439) }); + + migrationBuilder.UpdateData( + table: "OfferRowList", + keyColumn: "OfferRowID", + keyValue: 1, + columns: new[] { "Inserted", "Modified" }, + values: new object[] { new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9478), new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9479) }); + + migrationBuilder.UpdateData( + table: "OfferRowList", + keyColumn: "OfferRowID", + keyValue: 2, + columns: new[] { "Inserted", "Modified" }, + values: new object[] { new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9486), new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9487) }); + + migrationBuilder.UpdateData( + table: "OfferRowList", + keyColumn: "OfferRowID", + keyValue: 3, + columns: new[] { "Inserted", "Modified" }, + values: new object[] { new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9494), new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9496) }); + } + } +} diff --git a/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs b/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs index b8900730..51551288 100644 --- a/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs +++ b/Lux.Data/Migrations/DataLayerContextModelSnapshot.cs @@ -456,13 +456,13 @@ namespace Lux.Data.Migrations CustomerID = 2, DealerID = 2, Description = "Offerta per tre serramenti", - Inserted = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9450), - Modified = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9452), + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4269), + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4271), OffertState = 0, RefNum = 1, RefRev = 1, RefYear = 2024, - ValidUntil = new DateTime(2025, 8, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9439) + ValidUntil = new DateTime(2025, 8, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4265) }); }); @@ -520,9 +520,9 @@ namespace Lux.Data.Migrations { OfferRowID = 1, Cost = 950.0, - Inserted = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9478), + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4291), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9479), + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4293), Note = "Finestra anta singola 2025", OfferID = 1, Qty = 3.0, @@ -534,9 +534,9 @@ namespace Lux.Data.Migrations { OfferRowID = 2, Cost = 160.0, - Inserted = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9486), + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4300), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9487), + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4302), Note = "Persiana per Finestra anta singola 2025", OfferID = 1, Qty = 3.0, @@ -548,9 +548,9 @@ namespace Lux.Data.Migrations { OfferRowID = 3, Cost = 200.0, - Inserted = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9494), + Inserted = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4307), ItemSPP = "{}", - Modified = new DateTime(2025, 7, 3, 17, 38, 38, 470, DateTimeKind.Local).AddTicks(9496), + Modified = new DateTime(2025, 7, 3, 18, 7, 7, 847, DateTimeKind.Local).AddTicks(4309), Note = "Installazione serramento", OfferID = 1, Qty = 3.0, @@ -712,6 +712,62 @@ namespace Lux.Data.Migrations }); }); + modelBuilder.Entity("Lux.Data.DbModel.ProductionBatchModel", b => + { + b.Property("ProductionBatchID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProductionBatchID")); + + b.Property("DateEnd") + .HasColumnType("datetime(6)"); + + b.Property("DateStart") + .HasColumnType("datetime(6)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("DueDate") + .HasColumnType("datetime(6)"); + + b.HasKey("ProductionBatchID"); + + b.ToTable("ProductionBatch"); + }); + + modelBuilder.Entity("Lux.Data.DbModel.ProductionItemModel", b => + { + b.Property("ProdItemID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property("ProdItemID")); + + b.Property("ExtItemCode") + .IsRequired() + .HasColumnType("longtext"); + + b.Property("ItemCode") + .HasColumnType("int"); + + b.Property("OrderRowID") + .HasColumnType("int"); + + b.Property("ProductionBatchID") + .HasColumnType("int"); + + b.HasKey("ProdItemID"); + + b.HasIndex("OrderRowID"); + + b.HasIndex("ProductionBatchID"); + + b.ToTable("ProductionItem"); + }); + modelBuilder.Entity("Lux.Data.DbModel.ResourceModel", b => { b.Property("ResourceID") @@ -1137,6 +1193,25 @@ namespace Lux.Data.Migrations b.Navigation("SellingItemNav"); }); + modelBuilder.Entity("Lux.Data.DbModel.ProductionItemModel", b => + { + b.HasOne("Lux.Data.DbModel.OrderRowModel", "OrderRowNav") + .WithMany() + .HasForeignKey("OrderRowID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Lux.Data.DbModel.ProductionBatchModel", "ProductionBatchNav") + .WithMany() + .HasForeignKey("ProductionBatchID") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("OrderRowNav"); + + b.Navigation("ProductionBatchNav"); + }); + modelBuilder.Entity("Lux.Data.DbModel.SellingItemModel", b => { b.HasOne("Lux.Data.DbModel.JobModel", "JobNav")