añadido tercera estadistica
This commit is contained in:
@@ -4,6 +4,46 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo;
|
||||
public class RepositorioEstadisticas: RepositorioBase<RepositorioEstadisticas> {
|
||||
|
||||
|
||||
public (ChartData, List<InformePagos>) InformePagos(int year)
|
||||
{
|
||||
var con = Context;
|
||||
|
||||
ChartData data = new();
|
||||
data.Labels = ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"];
|
||||
|
||||
var can = con.Canons.Where(x => x.Fecha.Year == year)
|
||||
.Include(x=>x.IdreciboNavigation)
|
||||
.GroupBy(x => x.Fecha.Month)
|
||||
.Select(x=> new InformePagos{Mes = x.Key,
|
||||
Realizados = x.Count(x=> x.Pagado == 1 && x.IdreciboNavigation.Fecha <= x.Fecha),
|
||||
Atrasados = x.Count(x=> x.Pagado == 1 && x.IdreciboNavigation.Fecha > x.Fecha),
|
||||
Sin_realizar = x.Count(x=> x.Pagado == 0)});
|
||||
|
||||
List<InformePagos> lst = can.ToList();
|
||||
|
||||
data.Datasets.Add(new Dataset
|
||||
{
|
||||
Label = "Realizados",
|
||||
Data = lst.Select(x => x.Realizados.ToString()).ToList()
|
||||
});
|
||||
|
||||
data.Datasets.Add(new Dataset
|
||||
{
|
||||
Label = "Atrasados",
|
||||
Data = lst.Select(x => x.Atrasados.ToString()).ToList()
|
||||
});
|
||||
|
||||
data.Datasets.Add(new Dataset
|
||||
{
|
||||
Label = "Sin_realizar",
|
||||
Data = lst.Select(x => x.Sin_realizar.ToString()).ToList()
|
||||
});
|
||||
|
||||
return (data, lst);
|
||||
}
|
||||
|
||||
public ChartData? ObtenerDataIniciadosPorAño(int year){
|
||||
var con = Context;
|
||||
var contratosPorMes = con.Contratos
|
||||
@@ -98,4 +138,4 @@ public class RepositorioEstadisticas: RepositorioBase<RepositorioEstadisticas> {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user