diff --git a/Entidades/Detalle.cs b/Entidades/Detalle.cs index cafef6f..9bd8783 100644 --- a/Entidades/Detalle.cs +++ b/Entidades/Detalle.cs @@ -2,7 +2,7 @@ namespace Entidades { - public class Detalle where T:Producto + public class Detalle where T: Producto { public int Id { get; set; } diff --git a/Entidades/DetalleFactura.cs b/Entidades/DetalleFactura.cs index 966aa2b..b637c4e 100644 --- a/Entidades/DetalleFactura.cs +++ b/Entidades/DetalleFactura.cs @@ -3,8 +3,9 @@ using System.ComponentModel.DataAnnotations.Schema; namespace Entidades { - public class DetalleFactura: Detalle + public class DetalleFactura: Detalle, ICloneable { + public DetalleFactura() { } public int IdFactura { get; set; } public double Subtotal @@ -22,5 +23,17 @@ namespace Entidades return Producto.Nombre; } } + + private DetalleFactura(DetalleFactura detalle) + { + Id = detalle.Id; + IdFactura = detalle.IdFactura; + Producto = detalle.Producto; + Cantidad = detalle.Cantidad; + } + public object Clone() + { + return new DetalleFactura(this); + } } } diff --git a/Entidades/Lote.cs b/Entidades/Lote.cs index e56e288..efaee8d 100644 --- a/Entidades/Lote.cs +++ b/Entidades/Lote.cs @@ -8,7 +8,8 @@ namespace Entidades public int IdRemito { get; set; } public DateTime Fecha { get; set; } public bool Habilitado { get; set; } - + public int CantRecibida { get; set; } + [NotMapped] public string NombreProducto { @@ -31,6 +32,7 @@ namespace Entidades IdRemito = lote.IdRemito; Fecha = lote.Fecha; Habilitado = lote.Habilitado; + CantRecibida = CantRecibida; } public object Clone() diff --git a/Final_OOP.sln b/Final_OOP.sln index 3598bf4..2dda42c 100644 --- a/Final_OOP.sln +++ b/Final_OOP.sln @@ -23,8 +23,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Informes", "Informes\Inform {78A331E5-86D4-427E-AA45-5879F9E5E98B} = {78A331E5-86D4-427E-AA45-5879F9E5E98B} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "testing", "testing\testing.csproj", "{FC4E3D1E-306A-4F4E-8476-F7F37A6E9049}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -51,10 +49,6 @@ Global {6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Release|Any CPU.Build.0 = Release|Any CPU - {FC4E3D1E-306A-4F4E-8476-F7F37A6E9049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FC4E3D1E-306A-4F4E-8476-F7F37A6E9049}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FC4E3D1E-306A-4F4E-8476-F7F37A6E9049}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FC4E3D1E-306A-4F4E-8476-F7F37A6E9049}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Modelo/Migrations/20241016232125_PuseCantidadOriginalDeStock.Designer.cs b/Modelo/Migrations/20241016232125_PuseCantidadOriginalDeStock.Designer.cs new file mode 100644 index 0000000..ce11153 --- /dev/null +++ b/Modelo/Migrations/20241016232125_PuseCantidadOriginalDeStock.Designer.cs @@ -0,0 +1,559 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20241016232125_PuseCantidadOriginalDeStock")] + partial class PuseCantidadOriginalDeStock + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.8"); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .HasColumnType("INTEGER"); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdFactura") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("IdPresupuesto") + .HasColumnType("INTEGER"); + + b.Property("MontoCU") + .HasColumnType("REAL"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdPresupuesto") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("MontoCUPropuesto") + .HasColumnType("REAL"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClienteCuit") + .HasColumnType("INTEGER"); + + b.Property("Fecha") + .HasColumnType("TEXT"); + + b.Property("IdCliente") + .HasColumnType("INTEGER"); + + b.Property("Total") + .HasColumnType("REAL"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdRemito") + .HasColumnType("INTEGER"); + + b.Property("CantOriginal") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("Fecha") + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Entregado") + .HasColumnType("INTEGER"); + + b.Property("IdProveedor") + .HasColumnType("INTEGER"); + + b.Property("ProveedorCuit") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Aceptado") + .HasColumnType("INTEGER"); + + b.Property("Fecha") + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .HasColumnType("INTEGER"); + + b.Property("IdProveedor") + .HasColumnType("INTEGER"); + + b.Property("ProveedorCuit") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("TEXT"); + + b.Property("EsPerecedero") + .HasColumnType("INTEGER"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .HasColumnType("INTEGER"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ProveedorCuit") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProveedorId") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("ProveedorId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("INTEGER"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("INTEGER"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modelo/Migrations/20241016232125_PuseCantidadOriginalDeStock.cs b/Modelo/Migrations/20241016232125_PuseCantidadOriginalDeStock.cs new file mode 100644 index 0000000..8b10b5e --- /dev/null +++ b/Modelo/Migrations/20241016232125_PuseCantidadOriginalDeStock.cs @@ -0,0 +1,29 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class PuseCantidadOriginalDeStock : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "CantOriginal", + table: "Lotes", + type: "INTEGER", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "CantOriginal", + table: "Lotes"); + } + } +} diff --git a/Modelo/Migrations/20241016232600_RefactorNombre.Designer.cs b/Modelo/Migrations/20241016232600_RefactorNombre.Designer.cs new file mode 100644 index 0000000..9786825 --- /dev/null +++ b/Modelo/Migrations/20241016232600_RefactorNombre.Designer.cs @@ -0,0 +1,559 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Modelo; + +#nullable disable + +namespace Modelo.Migrations +{ + [DbContext(typeof(Context))] + [Migration("20241016232600_RefactorNombre")] + partial class RefactorNombre + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.8"); + + modelBuilder.Entity("Entidades.Categoria", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Descripcion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Categoria", (string)null); + }); + + modelBuilder.Entity("Entidades.Cliente", b => + { + b.Property("Cuit") + .HasColumnType("INTEGER"); + + b.Property("Apellido") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Correo") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.HasKey("Cuit"); + + b.ToTable("Clientes", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdFactura") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdFactura"); + + b.HasIndex("IdFactura"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallesFacturas", (string)null); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdOrdenDeCompra") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("IdPresupuesto") + .HasColumnType("INTEGER"); + + b.Property("MontoCU") + .HasColumnType("REAL"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdOrdenDeCompra"); + + b.HasIndex("IdOrdenDeCompra"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetalleOrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdPresupuesto") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("MontoCUPropuesto") + .HasColumnType("REAL"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdPresupuesto"); + + b.HasIndex("IdPresupuesto"); + + b.HasIndex("ProductoId"); + + b.ToTable("DetallePresupuestos"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClienteCuit") + .HasColumnType("INTEGER"); + + b.Property("Fecha") + .HasColumnType("TEXT"); + + b.Property("IdCliente") + .HasColumnType("INTEGER"); + + b.Property("Total") + .HasColumnType("REAL"); + + b.HasKey("Id"); + + b.HasIndex("ClienteCuit"); + + b.ToTable("Facturas", (string)null); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.Property("Id") + .HasColumnType("INTEGER"); + + b.Property("IdRemito") + .HasColumnType("INTEGER"); + + b.Property("CantRecibida") + .HasColumnType("INTEGER"); + + b.Property("Cantidad") + .HasColumnType("INTEGER"); + + b.Property("Fecha") + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("Id", "IdRemito"); + + b.HasIndex("IdRemito"); + + b.HasIndex("ProductoId"); + + b.ToTable("Lotes"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Entregado") + .HasColumnType("INTEGER"); + + b.Property("IdProveedor") + .HasColumnType("INTEGER"); + + b.Property("ProveedorCuit") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("OrdenDeCompras"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Aceptado") + .HasColumnType("INTEGER"); + + b.Property("Fecha") + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .HasColumnType("INTEGER"); + + b.Property("IdProveedor") + .HasColumnType("INTEGER"); + + b.Property("ProveedorCuit") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Presupuestos"); + }); + + modelBuilder.Entity("Entidades.Producto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Discriminator") + .IsRequired() + .HasMaxLength(21) + .HasColumnType("TEXT"); + + b.Property("EsPerecedero") + .HasColumnType("INTEGER"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("Precio") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Producto"); + + b.HasDiscriminator().HasValue("Producto"); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Entidades.Proveedor", b => + { + b.Property("Cuit") + .HasColumnType("INTEGER"); + + b.Property("Direccion") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.Property("Habilitado") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Nombre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("TEXT"); + + b.Property("RazonSocial") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("TEXT"); + + b.HasKey("Cuit"); + + b.ToTable("Proveedores"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ProveedorCuit") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ProveedorCuit"); + + b.ToTable("Remitos"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.Property("CategoriaId") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("CategoriaId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoCategoria"); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.Property("ProveedorId") + .HasColumnType("INTEGER"); + + b.Property("ProductoId") + .HasColumnType("INTEGER"); + + b.HasKey("ProveedorId", "ProductoId"); + + b.HasIndex("ProductoId"); + + b.ToTable("ProductoProveedor"); + }); + + modelBuilder.Entity("Entidades.ProductoNoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("TipoDeEnvase") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasDiscriminator().HasValue("ProductoNoPercedero"); + }); + + modelBuilder.Entity("Entidades.ProductoPercedero", b => + { + b.HasBaseType("Entidades.Producto"); + + b.Property("MesesHastaConsumoPreferente") + .HasColumnType("INTEGER"); + + b.Property("MesesHastaVencimiento") + .HasColumnType("INTEGER"); + + b.HasDiscriminator().HasValue("ProductoPercedero"); + }); + + modelBuilder.Entity("Entidades.DetalleFactura", b => + { + b.HasOne("Entidades.Factura", null) + .WithMany("Detalles") + .HasForeignKey("IdFactura") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetalleOrdenDeCompra", b => + { + b.HasOne("Entidades.OrdenDeCompra", null) + .WithMany("detalles") + .HasForeignKey("IdOrdenDeCompra") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.DetallePresupuesto", b => + { + b.HasOne("Entidades.Presupuesto", null) + .WithMany("detalles") + .HasForeignKey("IdPresupuesto") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.HasOne("Entidades.Cliente", "Cliente") + .WithMany() + .HasForeignKey("ClienteCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cliente"); + }); + + modelBuilder.Entity("Entidades.Lote", b => + { + b.HasOne("Entidades.Remito", null) + .WithMany("Lotes") + .HasForeignKey("IdRemito") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", "Producto") + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Producto"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.HasOne("Entidades.Proveedor", "Proveedor") + .WithMany() + .HasForeignKey("ProveedorCuit") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Proveedor"); + }); + + modelBuilder.Entity("ProductoCategoria", b => + { + b.HasOne("Entidades.Categoria", null) + .WithMany() + .HasForeignKey("CategoriaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ProductoProveedor", b => + { + b.HasOne("Entidades.Producto", null) + .WithMany() + .HasForeignKey("ProductoId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Entidades.Proveedor", null) + .WithMany() + .HasForeignKey("ProveedorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Entidades.Factura", b => + { + b.Navigation("Detalles"); + }); + + modelBuilder.Entity("Entidades.OrdenDeCompra", b => + { + b.Navigation("detalles"); + }); + + modelBuilder.Entity("Entidades.Presupuesto", b => + { + b.Navigation("detalles"); + }); + + modelBuilder.Entity("Entidades.Remito", b => + { + b.Navigation("Lotes"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Modelo/Migrations/20241016232600_RefactorNombre.cs b/Modelo/Migrations/20241016232600_RefactorNombre.cs new file mode 100644 index 0000000..102db84 --- /dev/null +++ b/Modelo/Migrations/20241016232600_RefactorNombre.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Modelo.Migrations +{ + /// + public partial class RefactorNombre : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "CantOriginal", + table: "Lotes", + newName: "CantRecibida"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "CantRecibida", + table: "Lotes", + newName: "CantOriginal"); + } + } +} diff --git a/Modelo/Migrations/ContextModelSnapshot.cs b/Modelo/Migrations/ContextModelSnapshot.cs index 3b580d3..81f3007 100644 --- a/Modelo/Migrations/ContextModelSnapshot.cs +++ b/Modelo/Migrations/ContextModelSnapshot.cs @@ -179,6 +179,9 @@ namespace Modelo.Migrations b.Property("IdRemito") .HasColumnType("INTEGER"); + b.Property("CantRecibida") + .HasColumnType("INTEGER"); + b.Property("Cantidad") .HasColumnType("INTEGER"); diff --git a/Modelo/RepositorioFactura.cs b/Modelo/RepositorioFactura.cs index 14725b7..95991c9 100644 --- a/Modelo/RepositorioFactura.cs +++ b/Modelo/RepositorioFactura.cs @@ -24,13 +24,25 @@ namespace Modelo { t.Cliente = context.Clientes.FirstOrDefault(x => x.Cuit == t.Cliente.Cuit); + var list = new List(); + + int contador = 0; foreach (var detalle in t.Detalles) + { + list.Add((DetalleFactura)detalle.Clone()); + list.Last().Producto = detalle.Producto; + list.Last().Id = contador++; + } + + foreach (var detalle in list) { detalle.Producto = (detalle.Producto.EsPerecedero) ? context.ProductoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id) : context.ProductoNoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id) ; } + t.Detalles = list; + context.Facturas.Add(t); } diff --git a/Modelo/RepositorioRemito.cs b/Modelo/RepositorioRemito.cs index 4342c5d..72afbbe 100644 --- a/Modelo/RepositorioRemito.cs +++ b/Modelo/RepositorioRemito.cs @@ -41,6 +41,7 @@ namespace Modelo { listaLotes.Add((Lote)lote.Clone()); listaLotes.Last().Producto = lote.Producto; + listaLotes.Last().CantRecibida = lote.Cantidad; } foreach (var lote in listaLotes) diff --git a/Vista/FrmRemitos.cs b/Vista/FrmRemitos.cs index ccabdea..d94a0f3 100644 --- a/Vista/FrmRemitos.cs +++ b/Vista/FrmRemitos.cs @@ -49,7 +49,7 @@ namespace Vista foreach (DataGridViewColumn column in dgvDetallesRemito.Columns) { column.Visible = column.Name == "Id" || column.Name == "Fecha" - || column.Name == "Cantidad" || column.Name == "NombreProducto"; + || column.Name == "Cantidad" || column.Name == "NombreProducto" || column.Name == "CantRecibida"; } } } diff --git a/testing/GlobalUsings.cs b/testing/GlobalUsings.cs deleted file mode 100644 index cefced4..0000000 --- a/testing/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; \ No newline at end of file diff --git a/testing/UnitTest1.cs b/testing/UnitTest1.cs deleted file mode 100644 index 2d65860..0000000 --- a/testing/UnitTest1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Modelo; - -namespace testing; - -public class Tests -{ - [SetUp] - public void Setup() - { - } - - [Test] - public void TestConeccion() - { - Context c = new(); - bool connect = c.Database.CanConnect(); - - Assert.That(connect, "true"); - } -} \ No newline at end of file diff --git a/testing/testing.csproj b/testing/testing.csproj deleted file mode 100644 index 8865687..0000000 --- a/testing/testing.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - net8.0 - enable - enable - - false - true - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - -