hecho rf 16
This commit is contained in:
@@ -17,6 +17,19 @@ public class EstadisticaController: ControllerBase {
|
|||||||
var a = RepositorioEstadisticas.Singleton.ObtenerDataIniciadosPorAño(year);
|
var a = RepositorioEstadisticas.Singleton.ObtenerDataIniciadosPorAño(year);
|
||||||
return Ok(a);
|
return Ok(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/contrato/stats")]
|
||||||
|
public IActionResult ObtenerMesesPagos([FromHeader(Name ="Auth")]string Auth, long idcontrato=0){
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (idcontrato<=0) return BadRequest(new {message = "No puede tener un id contrato menor o igual a 0"});
|
||||||
|
|
||||||
|
var ret = RepositorioEstadisticas.Singleton.ObtenerDatosPagosContrato(idcontrato);
|
||||||
|
return Ok(ret);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("api/tabla/alquileresIniciados")]
|
[HttpGet("api/tabla/alquileresIniciados")]
|
||||||
public IActionResult tablaalquileresIniciadosEsteAño([FromHeader(Name ="Auth")]string Auth, int year) {
|
public IActionResult tablaalquileresIniciadosEsteAño([FromHeader(Name ="Auth")]string Auth, int year) {
|
||||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import {urlG} from "../stores/urlStore";
|
import {urlG} from "../stores/urlStore";
|
||||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2, OpcionVentaDto } from "../types";
|
import type { CanonDto, ChartData, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2, OpcionVentaDto } from "../types";
|
||||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||||
import { navigate } from "svelte-routing";
|
import { navigate } from "svelte-routing";
|
||||||
|
import FChart from "../Componentes/Estadisticas/fChart.svelte";
|
||||||
|
|
||||||
let token:string = sessionStorage.getItem("token")||"";
|
let token:string = sessionStorage.getItem("token")||"";
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
let selMod:any =$state();
|
let selMod:any =$state();
|
||||||
let showmodal:boolean = $state(false);
|
let showmodal:boolean = $state(false);
|
||||||
let shownotif:boolean = $state(false);
|
let shownotif:boolean = $state(false);
|
||||||
|
let chartData:ChartData|any = $state();
|
||||||
|
|
||||||
let max:number=$state(0);
|
let max:number=$state(0);
|
||||||
|
|
||||||
@@ -47,8 +48,26 @@
|
|||||||
await obtenerDatosACargar();
|
await obtenerDatosACargar();
|
||||||
max = canons.at(-1).mesNum||0;
|
max = canons.at(-1).mesNum||0;
|
||||||
opcionVenta();
|
opcionVenta();
|
||||||
|
await setChartData();
|
||||||
});
|
});
|
||||||
|
async function setChartData() {
|
||||||
|
try{
|
||||||
|
const r = await fetch($urlG+"/api/contrato/stats?idcontrato="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let data = await r.json();
|
||||||
|
if (r.ok){
|
||||||
|
chartData = data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modaldata = data.message;
|
||||||
|
}catch{
|
||||||
|
modaldata = "no se pudo obtener el chartdata";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function opcionVenta() {
|
async function opcionVenta() {
|
||||||
try {
|
try {
|
||||||
@@ -309,7 +328,6 @@
|
|||||||
if (r.ok) {
|
if (r.ok) {
|
||||||
refreshDefectos();
|
refreshDefectos();
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch {
|
}catch {
|
||||||
modaldata = "No se pudo marcar como pago";
|
modaldata = "No se pudo marcar como pago";
|
||||||
}
|
}
|
||||||
@@ -424,6 +442,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="h6">
|
||||||
|
<button class="accordion-button collapsed"
|
||||||
|
data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#c6"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-controls="c6">
|
||||||
|
Estadisticas
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="c6" class="accordion-collapse collapse"
|
||||||
|
data-bs-parent="#accordionExample">
|
||||||
|
<div class="accordion-body d-flex justify-content-center" >
|
||||||
|
<div style="width: 500px; height: 500px;">
|
||||||
|
{#if chartData != null}
|
||||||
|
<FChart {chartData} typec="doughnut" />
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="accordion-item">
|
<div class="accordion-item">
|
||||||
<h2 class="accordion-header" id="headingTwo">
|
<h2 class="accordion-header" id="headingTwo">
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -47,6 +47,34 @@ public class RepositorioEstadisticas: RepositorioBase<RepositorioEstadisticas> {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChartData? ObtenerDatosPagosContrato(long idcontrato) {
|
||||||
|
var con = Context;
|
||||||
|
var cont = con.Contratos.Include(c=>c.Idcanons).ThenInclude(x=>x.IdreciboNavigation)
|
||||||
|
.Where(x=>x.Habilitado==1)
|
||||||
|
.FirstOrDefault(x=>x.Id == idcontrato);
|
||||||
|
if(cont==null)return null;
|
||||||
|
|
||||||
|
var data = new ChartData();
|
||||||
|
data.Labels= ["Pago", "Sin Pagar", "Pago Atrasado"];
|
||||||
|
|
||||||
|
Dataset d1 = new();
|
||||||
|
d1.Label="Estadistica Pagos";
|
||||||
|
|
||||||
|
var l = new List<string>(["0","0","0"]);
|
||||||
|
|
||||||
|
l[0] = cont.Idcanons.Where(x=>x.Pagado == 1Lu && x.IdreciboNavigation != null && x.IdreciboNavigation.Fecha <= x.Fecha)
|
||||||
|
.Count().ToString();
|
||||||
|
|
||||||
|
l[1] = cont.Idcanons.Where(x=>x.Pagado==0).Count().ToString();
|
||||||
|
|
||||||
|
l[2] = cont.Idcanons.Where(x=>x.Pagado == 1Lu && x.IdreciboNavigation != null && x.IdreciboNavigation.Fecha > x.Fecha)
|
||||||
|
.Count().ToString();
|
||||||
|
d1.Data.AddRange(l);
|
||||||
|
data.Datasets.Add(d1);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
public IQueryable<Contrato> TablaObtenerContratosIniciadosPorAño(int year) {
|
public IQueryable<Contrato> TablaObtenerContratosIniciadosPorAño(int year) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
var contratosPorMes = con.Contratos.Include(x=>x.IddivisaNavigation).Include(x=>x.IdpropiedadNavigation)
|
var contratosPorMes = con.Contratos.Include(x=>x.IddivisaNavigation).Include(x=>x.IdpropiedadNavigation)
|
||||||
@@ -69,4 +97,5 @@ public class RepositorioEstadisticas: RepositorioBase<RepositorioEstadisticas> {
|
|||||||
return l;
|
return l;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user