cambios 17/02/2026
This commit is contained in:
46
bdGrupoSanchoToro/extensiones/DesglosePorEmpresa.cs
Normal file
46
bdGrupoSanchoToro/extensiones/DesglosePorEmpresa.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using bdGrupoSanchoToro.db;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bdGrupoSanchoToro.extensiones
|
||||
{
|
||||
public class DesglosePorEmpresa
|
||||
{
|
||||
public int Empresa { get; set; }
|
||||
|
||||
public double TotalUnidades { get; set; }
|
||||
public double UnidadesInicialesOFabricadas { get; set; }
|
||||
public double UnidadesCompradas { get; set; }
|
||||
public double UnidadesAlquiladas { get; set; }
|
||||
public double UnidadesAveriadas { get; set; }
|
||||
public double UnidadesVendidas { get; set; }
|
||||
public double UnidadesSubAlquiladas { get; set; }
|
||||
public double UnidadesDesechadas { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public double UnidadesDisponibles
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.TotalUnidades - this.UnidadesAlquiladas - this.UnidadesAveriadas;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public string NombreEmpresa
|
||||
{
|
||||
get
|
||||
{
|
||||
var emp = empresas.ListadoEmpresas().FirstOrDefault(x => x.idEmpresa == Empresa);
|
||||
return emp == null ? "" : emp.RazonSocial;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
70
bdGrupoSanchoToro/extensiones/desgloseproductos.cs
Normal file
70
bdGrupoSanchoToro/extensiones/desgloseproductos.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class desgloseproductos
|
||||
{
|
||||
[NotMapped]
|
||||
public bool ContieneHijos
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idProductoNavigation is not null && this.idProductoNavigation.desgloseproductosidProductoPadreNavigation is not null)
|
||||
{
|
||||
return this.idProductoNavigation.desgloseproductosidProductoPadreNavigation.Any();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public ICollection<desgloseproductos> Hijos
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idProductoNavigation.desgloseproductosidProductoPadreNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public productos ProductoPadre
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idProductoPadreNavigation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.idProductoPadreNavigation = value;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public productos Producto
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idProductoNavigation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.idProductoNavigation = value;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public bool Descatalogado
|
||||
{
|
||||
get
|
||||
{
|
||||
return idProductoNavigation.Descatalogado;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
99
bdGrupoSanchoToro/extensiones/detallepresupuesto.cs
Normal file
99
bdGrupoSanchoToro/extensiones/detallepresupuesto.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class detallepresupuesto:INotifyPropertyChanged
|
||||
{
|
||||
[NotMapped]
|
||||
public productos? productos
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idProductoNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual string DescripcionEspecial
|
||||
{
|
||||
get
|
||||
{
|
||||
string Des = this.idProductoNavigation.Descripcion ;
|
||||
if (Des.Contains("("))
|
||||
{
|
||||
Des = Des.Split('(')[0];
|
||||
}
|
||||
return Des;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public virtual ICollection<detallepresupuesto>? detallepresupuesto1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.InverseidDetallePresupuestoPadreNavigation;
|
||||
}
|
||||
}
|
||||
|
||||
public double Importe
|
||||
{
|
||||
get
|
||||
{
|
||||
// If EsVenta Then
|
||||
return Math.Round(this.Cantidad * this.Precio, 2, MidpointRounding.AwayFromZero);
|
||||
// Else
|
||||
// Return Math.Round(Cantidad * Precio * presupuestos.DiasAlquiler, 2, MidpointRounding.AwayFromZero)
|
||||
// End If
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public bool ContieneHijos
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.detallepresupuesto1 is not null && this.detallepresupuesto1.Count > 0;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public virtual List<detallepresupuesto> DesgloseServicios
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.detallepresupuesto1.Where(x => x.productos.Tipo == (int)productos.TipoProductoEnum.SERVICIO).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual List<detallepresupuesto> DesgloseMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.detallepresupuesto1.Where(x => x.productos.Tipo < (int)productos.TipoProductoEnum.SERVICIO).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
public void RefrescaCamposTemporales()
|
||||
{
|
||||
this.OnPropertyChanged("Importe");
|
||||
this.OnPropertyChanged("ImporteGastos");
|
||||
// OnPropertyChanged("NumeroAsientosTotal")
|
||||
this.OnPropertyChanged("DesgloseServicios");
|
||||
this.OnPropertyChanged("DesgloseMaterial");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using static bdGrupoSanchoToro.db.productos;
|
||||
|
||||
@@ -7,13 +9,32 @@ namespace bdGrupoSanchoToro.db
|
||||
|
||||
public partial class detallesalbaranes
|
||||
{
|
||||
//public albaranes albaranes
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return this.idAlbaranNavigation;
|
||||
// }
|
||||
//}
|
||||
|
||||
private double? _UnidadesRecogidasTmp;
|
||||
|
||||
[NotMapped]
|
||||
public double? UnidadesRecogidasTmp
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UnidadesRecogidasTmp.HasValue == false)
|
||||
_UnidadesRecogidasTmp = Cantidad;
|
||||
return _UnidadesRecogidasTmp;
|
||||
}
|
||||
set
|
||||
{
|
||||
_UnidadesRecogidasTmp = value;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public string Producto
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.idProductoNavigation.Descripcion;
|
||||
}
|
||||
}
|
||||
public string NumeroAlbaran
|
||||
{
|
||||
get
|
||||
@@ -63,45 +84,68 @@ namespace bdGrupoSanchoToro.db
|
||||
return this.idAlbaranNavigation.Entidad;
|
||||
}
|
||||
}
|
||||
public void ActualizaProducto(bdGrupoSanchoToro.dbcontext.GrupoSanchoToroContext bd, int Factor)
|
||||
public void ActualizaProducto(bdGrupoSanchoToro.tscGrupoSanchoToro bd, albaranes.TipoAlbaranEnum Tipo, int Factor,int Empresa)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pr = bd.productos.First(x => x.idProducto == this.idProducto);
|
||||
if (pr.Tipo != (int)TipoProductoEnum.SERVICIO )
|
||||
if (pr.Tipo < (int)TipoProductoEnum.SERVICIO )
|
||||
{
|
||||
var almo = this.idAlbaranNavigation.idAlmacenOrigen.HasValue ? bd.almacenes.First(x => x.idAlmacen== idAlbaranNavigation.idAlmacenOrigen) : (almacenes)null;
|
||||
var almd = this.idAlbaranNavigation.idAlmacenDestino.HasValue ? bd.almacenes.First(x => x.idAlmacen == this.idAlbaranNavigation.idAlmacenDestino) : (almacenes)null;
|
||||
switch ((albaranes.TipoAlbaranEnum)this.idAlbaranNavigation.Tipo)
|
||||
almacenes almo;
|
||||
almacenes almd;
|
||||
if (Tipo==albaranes.TipoAlbaranEnum.RECOGIDA || Tipo==albaranes.TipoAlbaranEnum.DEVOLUCION_SUBALQUILER)
|
||||
{
|
||||
almo = this.idAlbaranRecogidaNavigation.idAlmacenOrigen.HasValue ? bd.almacenes.First(x => x.idAlmacen == idAlbaranRecogidaNavigation.idAlmacenOrigen) : (almacenes)null;
|
||||
almd = this.idAlbaranRecogidaNavigation.idAlmacenDestino.HasValue ? bd.almacenes.First(x => x.idAlmacen == this.idAlbaranRecogidaNavigation.idAlmacenDestino) : (almacenes)null;
|
||||
// Tipo = (albaranes.TipoAlbaranEnum)this.idAlbaranRecogidaNavigation.Tipo;
|
||||
}
|
||||
else
|
||||
{
|
||||
almo = this.idAlbaranNavigation.idAlmacenOrigen.HasValue ? bd.almacenes.First(x => x.idAlmacen == idAlbaranNavigation.idAlmacenOrigen) : (almacenes)null;
|
||||
almd = this.idAlbaranNavigation.idAlmacenDestino.HasValue ? bd.almacenes.First(x => x.idAlmacen == this.idAlbaranNavigation.idAlmacenDestino) : (almacenes)null;
|
||||
// Tipo = (albaranes.TipoAlbaranEnum)this.idAlbaranNavigation.Tipo;
|
||||
}
|
||||
switch (Tipo)
|
||||
{
|
||||
case albaranes.TipoAlbaranEnum.COMPRA:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
|
||||
pr.UnidadesCompradas += this.Cantidad * (double)Factor;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.COMPRADAS, Empresa, this.Cantidad * (double)Factor);
|
||||
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor, Empresa);
|
||||
break;
|
||||
}
|
||||
case albaranes.TipoAlbaranEnum.FABRICACION:
|
||||
case albaranes.TipoAlbaranEnum.REGULARIZACION_STOCK:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
|
||||
pr.UnidadesInicialesOFabricadas += this.Cantidad * (double)Factor;
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor);
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.INICIALES_O_FABRICADAS, Empresa, this.Cantidad * (double)Factor);
|
||||
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor, Empresa);
|
||||
break;
|
||||
}
|
||||
case albaranes.TipoAlbaranEnum.CAMBIO_ALMACEN:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor * -1, almo.idAlmacen, pr.idProducto);
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almo.Tipo, false, Factor * -1);
|
||||
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almo.Tipo, false, Factor * -1, Empresa);
|
||||
|
||||
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor);
|
||||
this.ActStockGlobal(bd, pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor, Empresa);
|
||||
break;
|
||||
}
|
||||
case albaranes.TipoAlbaranEnum.ENTREGA:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor * -1, almo.idAlmacen, pr.idProducto);
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almo.Tipo, this.EsVenta, Factor * -1);
|
||||
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almo.Tipo, this.EsVenta, Factor * -1, Empresa);
|
||||
if (this.EsVenta == false)
|
||||
{
|
||||
pr.UnidadesAlquiladas += this.Cantidad * (double)Factor;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.ALQUILADAS, Empresa, this.Cantidad * (double)Factor);
|
||||
}
|
||||
else
|
||||
{
|
||||
pr.UnidadesVendidas += this.Cantidad * (double)Factor;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.VENDIDAS, Empresa, this.Cantidad * (double)Factor);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -109,27 +153,29 @@ namespace bdGrupoSanchoToro.db
|
||||
case albaranes.TipoAlbaranEnum.RECOGIDA:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor);
|
||||
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almd.Tipo, false, Factor, Empresa);
|
||||
pr.UnidadesAlquiladas += this.Cantidad * (double)Factor * (double)-1;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.ALQUILADAS, Empresa, this.Cantidad * (double)Factor * (double)-1);
|
||||
break;
|
||||
}
|
||||
case albaranes.TipoAlbaranEnum.SUBALQUILER:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor, almd.idAlmacen, pr.idProducto);
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor);
|
||||
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almd.Tipo, true, Factor, Empresa);
|
||||
pr.UnidadesSubAlquiladas += this.Cantidad * (double)Factor;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.SUBALQUILADAS, Empresa, this.Cantidad * (double)Factor);
|
||||
break;
|
||||
}
|
||||
case albaranes.TipoAlbaranEnum.DEVOLUCION_SUBALQUILER:
|
||||
{
|
||||
this.ActStockPorAlmacen(bd, Factor * -1, almo.idAlmacen, pr.idProducto);
|
||||
this.ActStockGlobal(pr, (almacenes.TipoAlmacenEnum)almo.Tipo, true, Factor * -1);
|
||||
this.ActStockGlobal(bd,pr, (almacenes.TipoAlmacenEnum)almo.Tipo, true, Factor * -1, Empresa);
|
||||
pr.UnidadesSubAlquiladas += this.Cantidad * (double)Factor * (double)-1;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.SUBALQUILADAS, Empresa, this.Cantidad * (double)Factor * (double)-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// bd.SaveChanges()
|
||||
bd.GuardarCambios();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -137,7 +183,7 @@ namespace bdGrupoSanchoToro.db
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
private void ActStockPorAlmacen(bdGrupoSanchoToro.dbcontext.GrupoSanchoToroContext bd, int Factor, int idAlmacen, int idProducto)
|
||||
private void ActStockPorAlmacen(bdGrupoSanchoToro.tscGrupoSanchoToro bd, int Factor, int idAlmacen, int idProducto)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -151,13 +197,14 @@ namespace bdGrupoSanchoToro.db
|
||||
bd.stocks.Add(st);
|
||||
}
|
||||
st.Unidades += this.Cantidad * (double)Factor;
|
||||
bd.GuardarCambios();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
private void ActStockGlobal(productos pr, almacenes.TipoAlmacenEnum TipoAlmacen, bool ActTotalUnidades, int Factor)
|
||||
private void ActStockGlobal(bdGrupoSanchoToro.tscGrupoSanchoToro bd, productos pr, almacenes.TipoAlmacenEnum TipoAlmacen, bool ActTotalUnidades, int Factor,int Empresa)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -176,7 +223,11 @@ namespace bdGrupoSanchoToro.db
|
||||
}
|
||||
}
|
||||
if (ActTotalUnidades)
|
||||
{
|
||||
pr.TotalUnidades += this.Cantidad * (double)Factor;
|
||||
pr.ActualizaUnidades(TipoUnidadesEnum.TOTAL, Empresa, this.Cantidad * (double)Factor);
|
||||
}
|
||||
bd.GuardarCambios();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
23
bdGrupoSanchoToro/extensiones/empresas.cs
Normal file
23
bdGrupoSanchoToro/extensiones/empresas.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using PropertyChanged;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.CompilerServices;
|
||||
using tsUtilidades.Extensiones;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
public partial class empresas
|
||||
{
|
||||
private static List<empresas>? _ListadoEmpresas;
|
||||
public static List<empresas> ListadoEmpresas()
|
||||
{
|
||||
if (_ListadoEmpresas == null)
|
||||
{
|
||||
var bd= bdGrupoSanchoToro.tscGrupoSanchoToro.NuevoContexto();
|
||||
_ListadoEmpresas = bd.empresas.ToList();
|
||||
}
|
||||
return _ListadoEmpresas;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,35 +251,35 @@ namespace bdGrupoSanchoToro.db
|
||||
[NotMapped] public virtual string? Email2_TMP { get; set; }
|
||||
[NotMapped] public virtual bool EnviarEmail_TMP { get; set; }
|
||||
|
||||
#region Eventos
|
||||
#region Obras
|
||||
[NotMapped]
|
||||
public string ProvinciaEvento
|
||||
public string ProvinciaObra
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idEvento == null || this.idEventoNavigation.CodigoMunicipioNavigation == null) return "";
|
||||
if (this.idObra == null || this.idObraNavigation.CodigoMunicipioNavigation == null) return "";
|
||||
else
|
||||
return this.idEventoNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation.Nombre;
|
||||
return this.idObraNavigation.CodigoMunicipioNavigation.CodigoProvinciaNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string PoblacionEvento
|
||||
public string PoblacionObra
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idEvento == null || this.idEventoNavigation.CodigoMunicipioNavigation == null) return "";
|
||||
if (this.idObra == null || this.idObraNavigation.CodigoMunicipioNavigation == null) return "";
|
||||
else
|
||||
return this.idEventoNavigation.CodigoMunicipioNavigation.Nombre;
|
||||
return this.idObraNavigation.CodigoMunicipioNavigation.Nombre;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string DireccionEvento
|
||||
public string DireccionObra
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idEvento == null) return "";
|
||||
if (this.idObra == null) return "";
|
||||
else
|
||||
return this.idEventoNavigation.DireccionCompleta;
|
||||
return this.idObraNavigation.DireccionCompleta;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class eventos
|
||||
public partial class obras
|
||||
{
|
||||
public string DireccionCompleta
|
||||
{
|
||||
1070
bdGrupoSanchoToro/extensiones/presupuestos.cs
Normal file
1070
bdGrupoSanchoToro/extensiones/presupuestos.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,43 @@
|
||||
using System;
|
||||
using bdGrupoSanchoToro.db;
|
||||
using bdGrupoSanchoToro.extensiones;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class productos
|
||||
public partial class productos : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private List<DesglosePorEmpresa>? _DesgloseUnidades;
|
||||
[NotMapped]
|
||||
public List<DesglosePorEmpresa>? DesgloseUnidades
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DesgloseUnidades == null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(UnidadesPorEmpresa))
|
||||
{
|
||||
_DesgloseUnidades = new List<DesglosePorEmpresa>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_DesgloseUnidades = JsonSerializer.Deserialize<List<DesglosePorEmpresa>>(UnidadesPorEmpresa);
|
||||
}
|
||||
}
|
||||
return _DesgloseUnidades;
|
||||
}
|
||||
set => _DesgloseUnidades=value;
|
||||
|
||||
}
|
||||
[NotMapped]
|
||||
public bool Descatalogado
|
||||
{
|
||||
@@ -32,24 +58,307 @@ namespace bdGrupoSanchoToro.db
|
||||
}
|
||||
}
|
||||
}
|
||||
// [NotMapped]
|
||||
//public string DescripcionTipo
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return ((TipoProductoEnum)this.Tipo).ToString().Replace("_", " ");
|
||||
// }
|
||||
//}
|
||||
|
||||
[NotMapped]
|
||||
public virtual List<desgloseproductos> DesgloseMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return this.desgloseproductosidProductoPadreNavigation.Where(x => x.Producto.Tipo < (int)TipoProductoEnum.SERVICIO).OrderBy(x => x.idProductoNavigation.Descripcion).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public void RefrescaCamposTemporales()
|
||||
{
|
||||
// this.OnPropertyChanged("DesgloseServicios");
|
||||
this.OnPropertyChanged("DesgloseMaterial");
|
||||
this.OnPropertyChanged("NumeroProductoTMP");
|
||||
}
|
||||
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
[NotMapped]
|
||||
public string NumeroProductoTMP
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.idProducto == 0)
|
||||
{
|
||||
return "« AUTOMÁTICO »";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.idProducto.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string DescripcionTipo
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoProductoEnum)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public double UnidadesDisponibles
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.TotalUnidades - this.UnidadesAlquiladas - this.UnidadesAveriadas;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public int NumeroDescendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.desgloseproductosidProductoPadreNavigation.Count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public virtual ICollection<desgloseproductos> Padres
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.desgloseproductosidProductoNavigation;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public int NivelMaximoAscendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
int NivelMaximo = 0;
|
||||
int NivelActual = 0;
|
||||
ObtieneNivelMaximoAscendiente(this, NivelActual, ref NivelMaximo);
|
||||
return NivelMaximo - 1;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public int NivelMaximoDescendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
int NivelMaximo = 0;
|
||||
int NivelActual = 0;
|
||||
ObtieneNivelMaximoDescendientes(this, NivelActual, ref NivelMaximo);
|
||||
return NivelMaximo - 1;
|
||||
}
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual List<string> ListaAscendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
var Lista = new List<string>();
|
||||
ObtieneListaAscendientes(this, "", ref Lista);
|
||||
return Lista;
|
||||
}
|
||||
}
|
||||
private void ObtieneListaAscendientes(productos p, string NombrePadre, ref List<string> Lista)
|
||||
{
|
||||
string NombreActual = (NombrePadre + "/" + p.Descripcion).TrimStart('/');
|
||||
Lista.Add(NombreActual);
|
||||
foreach (var d in p.Padres)
|
||||
ObtieneListaAscendientes(d.ProductoPadre, NombreActual, ref Lista);
|
||||
}
|
||||
|
||||
private void ObtieneNivelMaximoAscendiente(productos p, int NivelActual, ref int NivelMaximo)
|
||||
{
|
||||
NivelActual += 1;
|
||||
NivelMaximo = Math.Max(NivelActual, NivelMaximo);
|
||||
foreach (var d in p.Padres)
|
||||
ObtieneNivelMaximoAscendiente(d.ProductoPadre, NivelActual, ref NivelMaximo);
|
||||
}
|
||||
public bool ContieneAscendiente(int idProducto)
|
||||
{
|
||||
bool bContiene = this.idProducto == idProducto;
|
||||
if (!bContiene)
|
||||
{
|
||||
foreach (var d in Padres)
|
||||
{
|
||||
bContiene = d.ProductoPadre.ContieneAscendiente(idProducto);
|
||||
if (bContiene)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return bContiene;
|
||||
}
|
||||
// Public Function ContieneDescendiente(idProducto As Integer) As Boolean
|
||||
// Dim bContiene As Boolean = (Me.idProducto = idProducto)
|
||||
// If Not bContiene Then
|
||||
// For Each d In Me.desgloseproductos
|
||||
// bContiene = d.Producto.ContieneDescendiente(idProducto)
|
||||
// If bContiene Then Exit For
|
||||
// Next
|
||||
// End If
|
||||
// Return bContiene
|
||||
// End Function
|
||||
[NotMapped]
|
||||
public bool ContieneDescendientes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.desgloseproductosidProductoPadreNavigation.Any();
|
||||
}
|
||||
}
|
||||
|
||||
private void ObtieneNivelMaximoDescendientes(productos p, int NivelActual, ref int NivelMaximo)
|
||||
{
|
||||
NivelActual += 1;
|
||||
NivelMaximo = Math.Max(NivelActual, NivelMaximo);
|
||||
foreach (var d in p.desgloseproductosidProductoPadreNavigation)
|
||||
this.ObtieneNivelMaximoDescendientes(d.Producto, NivelActual, ref NivelMaximo);
|
||||
}
|
||||
|
||||
[NotMapped] public int CantidadTMP { get; set; }
|
||||
[NotMapped] public int UnidadesPropiasAIntervaloFechasTMP { get; set; }
|
||||
[NotMapped] public int UnidadesSubarrendadasAIntervaloFechasTMP { get; set; }
|
||||
[NotMapped] public int TotalUnidadesAIntervaloFechasTMP { get; set; }
|
||||
[NotMapped] public int UnidadesPresupuestadasTMP { get; set; }
|
||||
[NotMapped] public int UnidadesPresupuestadasYAceptadasTMP { get; set; }
|
||||
[NotMapped] public int UnidadesDisponiblesNoPresupestadasTMP { get; set; }
|
||||
[NotMapped] public int UnidadesDisponiblesNoContratadasTMP { get; set; }
|
||||
[NotMapped] public int DisponibilidadTMP { get; set; }
|
||||
|
||||
|
||||
|
||||
public static void RecalculaStocks(tscGrupoSanchoToro bd, List<productos> lp = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var prds = lp is null ? bd.productos.Where(x => x.Tipo < (int)TipoProductoEnum.SERVICIO ).ToList() : lp;
|
||||
foreach (var pr in prds)
|
||||
{
|
||||
pr.TotalUnidades = 0d;
|
||||
pr.UnidadesInicialesOFabricadas = 0d;
|
||||
pr.UnidadesCompradas = 0d;
|
||||
pr.UnidadesVendidas = 0d;
|
||||
pr.UnidadesAlquiladas = 0d;
|
||||
pr.UnidadesAveriadas = 0d;
|
||||
pr.UnidadesDesechadas = 0d;
|
||||
pr.UnidadesSubAlquiladas = 0d;
|
||||
pr.DesgloseUnidades?.Clear();
|
||||
foreach (var st in pr.stocks)
|
||||
st.Unidades = 0d;
|
||||
bd.SaveChanges();
|
||||
List<detallesalbaranes> dets = pr.detallesalbaranes.Where(x=>x.idAlbaranRecogida.HasValue==false).ToList();
|
||||
foreach (var d in dets)
|
||||
{
|
||||
d.ActualizaProducto(bd, (albaranes.TipoAlbaranEnum)d.idAlbaranNavigation.Tipo, 1,d.idAlbaranNavigation.idEmpresa);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ActualizaUnidades(TipoUnidadesEnum Tipo, int Empresa, double Cantidad)
|
||||
{
|
||||
if (DesgloseUnidades == null) DesgloseUnidades = new List<DesglosePorEmpresa>();
|
||||
DesglosePorEmpresa du = DesgloseUnidades.FirstOrDefault(x => x.Empresa == Empresa);
|
||||
if (du == null)
|
||||
{
|
||||
du = new DesglosePorEmpresa();
|
||||
du.Empresa = Empresa;
|
||||
du.TotalUnidades = 0d;
|
||||
du.UnidadesInicialesOFabricadas = 0d;
|
||||
du.UnidadesCompradas = 0d;
|
||||
du.UnidadesVendidas = 0d;
|
||||
du.UnidadesAlquiladas = 0d;
|
||||
du.UnidadesAveriadas = 0d;
|
||||
du.UnidadesDesechadas = 0d;
|
||||
du.UnidadesSubAlquiladas = 0d;
|
||||
DesgloseUnidades.Add(du);
|
||||
}
|
||||
switch (Tipo)
|
||||
{
|
||||
case TipoUnidadesEnum.TOTAL:
|
||||
{
|
||||
du.TotalUnidades += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.INICIALES_O_FABRICADAS:
|
||||
{
|
||||
du.UnidadesInicialesOFabricadas += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.COMPRADAS:
|
||||
{
|
||||
du.UnidadesCompradas += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.ALQUILADAS:
|
||||
{
|
||||
du.UnidadesAlquiladas += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.VENDIDAS:
|
||||
{
|
||||
du.UnidadesVendidas += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.AVERIADAS:
|
||||
{
|
||||
du.UnidadesAveriadas += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.DESECHADAS:
|
||||
{
|
||||
du.UnidadesDesechadas += Cantidad;
|
||||
break;
|
||||
}
|
||||
case TipoUnidadesEnum.SUBALQUILADAS:
|
||||
{
|
||||
du.UnidadesSubAlquiladas += Cantidad;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UnidadesPorEmpresa = JsonSerializer.Serialize(DesgloseUnidades);
|
||||
|
||||
}
|
||||
public enum TipoUnidadesEnum
|
||||
{
|
||||
TOTAL=0,
|
||||
INICIALES_O_FABRICADAS=1,
|
||||
COMPRADAS = 2,
|
||||
VENDIDAS=3,
|
||||
ALQUILADAS=4,
|
||||
AVERIADAS=5,
|
||||
DESECHADAS=6,
|
||||
SUBALQUILADAS=7
|
||||
}
|
||||
|
||||
public enum TipoProductoEnum
|
||||
{
|
||||
GRUA = 0,
|
||||
ELEMENTO_GRUA = 1,
|
||||
REPUESTO =10,
|
||||
PIES_GRUA = 2,
|
||||
REPUESTO = 10,
|
||||
OTROS_PRODUCTOS = 11,
|
||||
CONSUMIBLES =12,
|
||||
CONSUMIBLES = 12,
|
||||
MATERIAL_OFICINA = 13,
|
||||
SERVICIO = 99,
|
||||
HERRAMIENTAS = 99,
|
||||
SERVICIO = 100,
|
||||
SOLO_OFERTAS = 200
|
||||
}
|
||||
}
|
||||
}
|
||||
39
bdGrupoSanchoToro/extensiones/v_albaranesextendidos.cs
Normal file
39
bdGrupoSanchoToro/extensiones/v_albaranesextendidos.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using static bdGrupoSanchoToro.db.albaranes;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
|
||||
namespace bdGrupoSanchoToro.db
|
||||
{
|
||||
|
||||
public partial class v_albaranesextendidos
|
||||
{
|
||||
public string PoblacionCarga
|
||||
{
|
||||
get
|
||||
{
|
||||
return Conversions.ToString(municipios.ObtienePoblacion(this.CodigoMunicipioCarga));
|
||||
}
|
||||
}
|
||||
public string PoblacionDescargarga
|
||||
{
|
||||
get
|
||||
{
|
||||
return Conversions.ToString(municipios.ObtienePoblacion(this.CodigoMunicipioDescarga));
|
||||
}
|
||||
}
|
||||
public string NumeroAlbaran
|
||||
{
|
||||
get
|
||||
{
|
||||
return albaranes.ObtieneNumeroAlbaran(this.idAlbaran, (PrefijoAlbaranEnum)this.Tipo);
|
||||
}
|
||||
}
|
||||
public string DescripcionTipoAlbaran
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((TipoAlbaranEnum)this.Tipo).ToString().Replace("_", " ");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user