Añadida Funcionalidad Informes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Entidades;
|
||||
using Entidades.DTO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo
|
||||
@@ -15,8 +16,8 @@ namespace Modelo
|
||||
{
|
||||
return context.Facturas
|
||||
.AsNoTracking()
|
||||
.Include(x=>x.Detalles)
|
||||
.Include(x=>x.Cliente)
|
||||
.Include(x => x.Detalles)
|
||||
.Include(x => x.Cliente)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace Modelo
|
||||
{
|
||||
detalle.Producto = (detalle.Producto.EsPerecedero) ?
|
||||
context.ProductoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id) :
|
||||
context.ProductoNoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id) ;
|
||||
context.ProductoNoPercederos.FirstOrDefault(x => x.Id == detalle.Producto.Id);
|
||||
}
|
||||
|
||||
t.Detalles = list;
|
||||
@@ -61,10 +62,45 @@ namespace Modelo
|
||||
public Factura ObtenerPorId(Factura fac)
|
||||
{
|
||||
var factura = context.Facturas
|
||||
.Include(x=>x.Detalles)
|
||||
.ThenInclude(x=>x.Producto)
|
||||
.Include(x => x.Detalles)
|
||||
.ThenInclude(x => x.Producto)
|
||||
.FirstOrDefault(x => x.Id == fac.Id);
|
||||
return factura;
|
||||
}
|
||||
|
||||
public List<Factura> ObtenerFacturasDeClienteEnRangoFechas(Cliente cli, DateTime fecInicio, DateTime fecFin)
|
||||
{
|
||||
return context.Facturas
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Detalles)
|
||||
.Include(x => x.Cliente)
|
||||
.Where(x => x.Fecha > fecInicio && x.Fecha < fecFin && x.Cliente.Cuit == cli.Cuit)
|
||||
.ToList();
|
||||
}
|
||||
public List<Factura> ObtenerFacturasEnRangoFechas(DateTime fecInicio, DateTime fecFinal)
|
||||
{
|
||||
return context.Facturas
|
||||
.AsNoTracking()
|
||||
.Include(x => x.Detalles)
|
||||
.Where(x => (x.Fecha > fecInicio && x.Fecha < fecFinal))
|
||||
.ToList();
|
||||
|
||||
}
|
||||
|
||||
public List<DtoProductoInforme> ObtenerInformeProductoMasUsados()
|
||||
{
|
||||
List<DtoProductoInforme> list
|
||||
= context.DetalleFacturas
|
||||
.GroupBy(df => df.Producto)
|
||||
.Select(g => new DtoProductoInforme
|
||||
(
|
||||
g.Key.Id,
|
||||
g.Key.Nombre,
|
||||
g.Sum(df => df.Cantidad),
|
||||
context.Lotes.Include(x => x.Producto).Where(x=>x.Id == g.Key.Id).Sum(x => x.Cantidad)
|
||||
))
|
||||
.ToList();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user