Está
This commit is contained in:
@@ -6,11 +6,217 @@ using Entidades;
|
|||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using AlquilaFacil.StrategyBusquedaAdmin;
|
using AlquilaFacil.StrategyBusquedaAdmin;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using AlquilaFacil.Builder;
|
||||||
|
using Minio.DataModel.Args;
|
||||||
|
using Minio;
|
||||||
|
using AlquilaFacil.Config;
|
||||||
|
using System.Text.Json;
|
||||||
namespace AlquilaFacil.Controllers;
|
namespace AlquilaFacil.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class AdminController: ControllerBase
|
public class AdminController: ControllerBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[HttpGet("api/contratos/controlPagos")]
|
||||||
|
public IActionResult obtenerContratosInpagos([FromHeader(Name = "Auth")] string Auth) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioPermisos.Singleton.CheckPermisos(Auth, 14);
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
var contratos = RepositorioContratos.Singleton.ObtenerContratosInpagos();
|
||||||
|
|
||||||
|
List<ContratoDto> dtos = new();
|
||||||
|
foreach (var i in contratos) {
|
||||||
|
if (i.DniinquilinoNavigation == null || i.IdpropiedadNavigation == null
|
||||||
|
|| i.DnipropietarioNavigation == null) continue;
|
||||||
|
|
||||||
|
var cont = new ContratoDtoBuilder()
|
||||||
|
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||||
|
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||||
|
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||||
|
.SetId(i.Id)
|
||||||
|
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||||
|
.SetFechaInicio(i.Fechainicio)
|
||||||
|
.SetEstado(i.Habilitado, i.Cancelado)
|
||||||
|
.Build();
|
||||||
|
dtos.Add(cont);
|
||||||
|
}
|
||||||
|
return Ok(dtos);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/contratos/controlPagos/propiedad")]
|
||||||
|
public IActionResult obtenerPropiedad([FromHeader(Name = "Auth")] string Auth, int id = 0) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Admin");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (id <= 0) return BadRequest(new { message = "No hay propiedades con id igual o menor a 0"});
|
||||||
|
var i = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||||
|
if (i == null || i.DniinquilinoNavigation == null ||
|
||||||
|
i.IdpropiedadNavigation == null || i.DnipropietarioNavigation == null)return BadRequest(new { message = "Fallo la query"});
|
||||||
|
|
||||||
|
var cont = new ContratoPropiedadDtoBuilder()
|
||||||
|
.SetInquilino($"{i.DniinquilinoNavigation.Nombre} {i.DniinquilinoNavigation.Apellido}")
|
||||||
|
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||||
|
.SetId(i.Id)
|
||||||
|
.SetPropietario($"{i.DnipropietarioNavigation.Nombre} {i.DnipropietarioNavigation.Apellido}")
|
||||||
|
.SetTipo(i.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||||
|
.SetFechaInicio(i.Fechainicio)
|
||||||
|
.SetEstado(i.Habilitado, i.Cancelado)
|
||||||
|
.SetHabitaciones(i.IdpropiedadNavigation.Canthabitaciones)
|
||||||
|
.SetPiso(i.IdpropiedadNavigation.Piso??0)
|
||||||
|
.SetLetra(i.IdpropiedadNavigation.Letra??"")
|
||||||
|
.SetMesesAumento(i.MesesHastaAumento)
|
||||||
|
.SetMesesDuracion(i.MesesDurationContrato)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return Ok(cont);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IMinioClient mc;
|
||||||
|
public AdminController(IMinioClient minioClient) {
|
||||||
|
mc = minioClient;
|
||||||
|
if (mc == null){
|
||||||
|
MinioConfigcus? mcon = JsonSerializer.Deserialize<MinioConfigcus>(System.IO.File.ReadAllText("./settings.json"))?? null;
|
||||||
|
if (mcon == null) throw new Exception();
|
||||||
|
|
||||||
|
mc = new MinioClient().WithCredentials(mcon.usr, mcon.scrt)
|
||||||
|
.WithEndpoint("192.168.1.11:9000")
|
||||||
|
.WithSSL(false)
|
||||||
|
.Build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpGet("/api/admin/contrato/verDocumento")]
|
||||||
|
public IActionResult verDocumento([FromHeader(Name = "Auth")] string Auth, int idcontrato = 0){
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Admin");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (idcontrato <= 0) return BadRequest(new {message = "La id no puede ser igual o menor a 0"});
|
||||||
|
|
||||||
|
Contrato? contr = RepositorioContratos.Singleton.ObtenerContratoPorId(idcontrato);
|
||||||
|
|
||||||
|
try{
|
||||||
|
var memstream = new MemoryStream();
|
||||||
|
|
||||||
|
var goa = new GetObjectArgs()
|
||||||
|
.WithBucket("alquilafacil")
|
||||||
|
.WithObject(contr.UrlContrato)
|
||||||
|
.WithCallbackStream(stream => {
|
||||||
|
memstream.Position=0;
|
||||||
|
stream.CopyTo(memstream);
|
||||||
|
});
|
||||||
|
|
||||||
|
mc.GetObjectAsync(goa).Wait();
|
||||||
|
memstream.Position = 0;
|
||||||
|
|
||||||
|
if (memstream.Length == 0) return BadRequest(new { message = "El archivo está vacío" });
|
||||||
|
|
||||||
|
return File(memstream, "application/pdf", contr.UrlContrato);
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
Console.Error.WriteLine(e);
|
||||||
|
return BadRequest(new { message = "Fallo al intentar obtener el archivo del almacenamiento o este no existe"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/admin/contrato/canons")]
|
||||||
|
public IActionResult ObtenerCanones([FromHeader(Name="Auth")]string Auth, int id = 0){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Admin");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
var cont = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||||
|
if (cont == null) return BadRequest(new { message = "No existe el contrato"});
|
||||||
|
|
||||||
|
var list = RepositorioCanons.Singleton.ObtenerCanonsPorContrato(id);
|
||||||
|
if (list == null) return BadRequest(new { message = "No hay contrato por esa id"});
|
||||||
|
|
||||||
|
DateTime date = DateTime.Now;
|
||||||
|
bool ret =list.Any(x=>x.Pagado ==0 && date > x.Fecha);
|
||||||
|
if (ret == true) return BadRequest(new { message = "Este contrato no tiene canones vencidos"});
|
||||||
|
|
||||||
|
string divisa ="";
|
||||||
|
if (cont.Iddivisa == 0) divisa = "AR$"; else if (cont.Iddivisa == 1) divisa = "US$";
|
||||||
|
|
||||||
|
List<CanonDto> d = new();
|
||||||
|
|
||||||
|
foreach (var i in list) {
|
||||||
|
var c = new CanonDtoBuilder()
|
||||||
|
.SetId(i.Id)
|
||||||
|
.SetPago(i.Idrecibo==null?false:true)
|
||||||
|
.SetDivisa(divisa==""?"Ugh esta mal cargado la divisa en el contrato":divisa)
|
||||||
|
.SetMes(i.Fecha)
|
||||||
|
.SetMesNum(int.Parse((i.Fecha.Month - cont.Fechainicio.Month).ToString()) + 1)
|
||||||
|
.SetMonto(i.Monto)
|
||||||
|
.Build();
|
||||||
|
d.Add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/admin/contrato/marcarPago")]
|
||||||
|
public IActionResult realizarPago([FromHeader(Name="Auth")]string Auth, MarcarPagoDto dto) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Admin");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
if (dto.Idcontrato<=0) return BadRequest(new { message = "No puede existir un contrato con id 0 o menor"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null)return Unauthorized();
|
||||||
|
|
||||||
|
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.Idcontrato);
|
||||||
|
if (cont == null) return BadRequest(new { message = "No hay un contrato por esa id"});
|
||||||
|
|
||||||
|
Canon? c = RepositorioCanons.Singleton.ObtenerCanonContrato(dto.fecha, dto.Idcontrato);
|
||||||
|
if (c == null) return BadRequest(new { message = "no hay un canon por esa id"});
|
||||||
|
|
||||||
|
Recibo re = new Recibo{
|
||||||
|
Monto = c.Monto,
|
||||||
|
Fecha = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni, "Admin Marca Recibo Como Pago");
|
||||||
|
return ret ?
|
||||||
|
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/admin/notificarInquilino")]
|
||||||
|
public IActionResult NotificarInquilino([FromHeader(Name ="Auth")]string Auth, NotificarAdmin data){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Admin");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null)return Unauthorized();
|
||||||
|
|
||||||
|
if (data.Mensaje == "") return BadRequest(new {message = "El campo Mensaje esta vacio"});
|
||||||
|
if (data.Idcontrato <= 0) return BadRequest(new {message = "La id de contrato no puede ser 0 o menor"});
|
||||||
|
if (data.Idcanon <= 0) return BadRequest(new {message = "La id de contrato no puede ser 0 o menor"});
|
||||||
|
|
||||||
|
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(data.Idcontrato);
|
||||||
|
if (cont == null || cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null) return BadRequest(new { message = "no hay un contrato por esa id"});
|
||||||
|
|
||||||
|
Canon? can = RepositorioCanons.Singleton.ObtenerCanonPorId(data.Idcanon);
|
||||||
|
if (can == null)return BadRequest(new { message = "No existe un canon por esa id"});
|
||||||
|
|
||||||
|
var n = new NotificacioneBuilder()
|
||||||
|
.SetAccion("Notificacion Inquilino")
|
||||||
|
.SetMensaje(data.Mensaje)
|
||||||
|
.SetLeido(false)
|
||||||
|
.SetDnicliente(cont.DniinquilinoNavigation.Dni)
|
||||||
|
.SetDniremitente(cont.DnipropietarioNavigation.Dni)
|
||||||
|
.SetIdpropiedad(cont.IdpropiedadNavigation.Id)
|
||||||
|
.SetFecha(DateTime.Now)
|
||||||
|
.Build();
|
||||||
|
var ret = RepositorioNotificaciones.Singleton.AltaNotificacion(n, cli.Dni);
|
||||||
|
return ret?
|
||||||
|
Ok(new { message = "se envio el aviso" }):BadRequest(new { message = "Fallo al intentar enviar el aviso" });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("api/admin/clientes")]
|
[HttpGet("api/admin/clientes")]
|
||||||
public IActionResult GetClientes([FromHeader(Name ="Auth")]string Auth){
|
public IActionResult GetClientes([FromHeader(Name ="Auth")]string Auth){
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class ContratoController: ControllerBase {
|
|||||||
|
|
||||||
Recibo re = new Recibo{
|
Recibo re = new Recibo{
|
||||||
Monto = c.Monto,
|
Monto = c.Monto,
|
||||||
Fecha = c.Fecha,
|
Fecha = DateTime.Now,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
||||||
@@ -111,7 +111,7 @@ public class ContratoController: ControllerBase {
|
|||||||
|
|
||||||
Recibo re = new Recibo{
|
Recibo re = new Recibo{
|
||||||
Monto = c.Monto,
|
Monto = c.Monto,
|
||||||
Fecha = c.Fecha,
|
Fecha = DateTime.Now,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re, cli.Dni);
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Entidades.Admin;
|
||||||
|
public class NotificarAdmin {
|
||||||
|
public string Mensaje { get; set; }="";
|
||||||
|
public long Idcontrato{get;set;}
|
||||||
|
public long Idcanon {get; set;}
|
||||||
|
}
|
||||||
+12
-1
@@ -25,6 +25,8 @@
|
|||||||
import CompraYVentas from "./paginas/CompraYVenta.svelte";
|
import CompraYVentas from "./paginas/CompraYVenta.svelte";
|
||||||
import Ventas from "./paginas/Ventas.svelte";
|
import Ventas from "./paginas/Ventas.svelte";
|
||||||
import VerLogs from "./paginas/VerLogs.svelte";
|
import VerLogs from "./paginas/VerLogs.svelte";
|
||||||
|
import ControlPagos from "./paginas/ControlPagos.svelte";
|
||||||
|
import ContratoAdmin from "./paginas/ContratoAdmin.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Router>
|
<Router>
|
||||||
@@ -108,6 +110,11 @@
|
|||||||
<ProteRoute componente={CompraYVentas}/>
|
<ProteRoute componente={CompraYVentas}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!-- Control Pago Contratos Incumplidos -->
|
||||||
|
<Route path="/accion/14">
|
||||||
|
<ProteRoute componente={ControlPagos}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
<!-- Pagina Ventas -->
|
<!-- Pagina Ventas -->
|
||||||
<Route path="/Ventas">
|
<Route path="/Ventas">
|
||||||
<ProteRoute componente={Ventas}/>
|
<ProteRoute componente={Ventas}/>
|
||||||
@@ -141,6 +148,10 @@
|
|||||||
<Route path="/inquilino/contratos">
|
<Route path="/inquilino/contratos">
|
||||||
<ProteRoute componente={ContratoInquilino}/>
|
<ProteRoute componente={ContratoInquilino}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!--Contratos Inquilino-->
|
||||||
|
<Route path="/admin/contratos">
|
||||||
|
<ProteRoute componente={ContratoAdmin}/>
|
||||||
|
</Route>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,316 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import type { CanonDto, ContratoPropiedadDto, GaranteDto2, PropiedadDto } from "../types";
|
||||||
|
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
|
||||||
|
let token:string = sessionStorage.getItem("token")||"";
|
||||||
|
|
||||||
|
let canons:CanonDto[] = $state([]);
|
||||||
|
let contratoid:string = $state("");
|
||||||
|
let modaldata:string = $state("");
|
||||||
|
let garantes: GaranteDto2[] = $state([]);
|
||||||
|
let shownotif:boolean = $state(false);
|
||||||
|
let idcanon:number = $state(0);
|
||||||
|
|
||||||
|
let prop:ContratoPropiedadDto = $state({
|
||||||
|
estado:"",
|
||||||
|
fechainicio:"",
|
||||||
|
id:0,
|
||||||
|
inquilino:"",
|
||||||
|
propietario:"",
|
||||||
|
tipoPropiedad:"",
|
||||||
|
ubicacion:"",
|
||||||
|
habitaciones:0,
|
||||||
|
piso:0,
|
||||||
|
letra:"",
|
||||||
|
mesesAumento:0,
|
||||||
|
mesesDuracion:0,
|
||||||
|
});
|
||||||
|
|
||||||
|
onMount(()=>{
|
||||||
|
getparams();
|
||||||
|
obtenerDatosACargar();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
async function refreshCanon() {
|
||||||
|
try {
|
||||||
|
const ret = await fetch($urlG+"/api/admin/contrato/canons?id="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!ret.ok){
|
||||||
|
let data = await ret.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let data = await ret.json();
|
||||||
|
canons = data;
|
||||||
|
return;
|
||||||
|
} catch {
|
||||||
|
modaldata = "No se pudo obtener la lista de canones actualizada";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function obtenerDatosACargar() {
|
||||||
|
try {
|
||||||
|
const respPropiedad = fetch($urlG+"/api/contratos/controlPagos/propiedad?id="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const respCanons = fetch($urlG+"/api/admin/contrato/canons?id="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const [p, c] = await Promise.all([respPropiedad, respCanons]);
|
||||||
|
|
||||||
|
const datosPropiedad = await p.json();
|
||||||
|
const datosCanons = await c.json();
|
||||||
|
|
||||||
|
if(!(await respCanons).ok){
|
||||||
|
modaldata = datosCanons.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
prop = datosPropiedad;
|
||||||
|
canons = datosCanons;
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo hacer las request";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getparams(){
|
||||||
|
const qs = window.location.search;
|
||||||
|
const par = new URLSearchParams(qs);
|
||||||
|
contratoid = par.get("id")||"";
|
||||||
|
}
|
||||||
|
|
||||||
|
function abrirModalNotif(id:number) {
|
||||||
|
idcanon = id;
|
||||||
|
shownotif = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function verContrato() {
|
||||||
|
if (prop.id <= 0) {
|
||||||
|
modaldata = "no hay contratos con id 0 o menor";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const resp = await fetch ($urlG+"/api/admin/contrato/verDocumento?idcontrato="+prop.id, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
let blob = await resp.json();
|
||||||
|
modaldata=blob.message;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let blob = await resp.blob();
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
window.open(blobUrl, '_blank');
|
||||||
|
setTimeout(() => URL.revokeObjectURL(blobUrl), 100000);
|
||||||
|
} catch {
|
||||||
|
modaldata= "fallo intentar hacer la request";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function notificar(mes: Date) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function realizarpago(mes: Date) {
|
||||||
|
try {
|
||||||
|
const ret = await fetch($urlG+"/api/admin/contrato/marcarPago", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({idcontrato:contratoid, fecha:mes}),
|
||||||
|
});
|
||||||
|
let data = await ret.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
if (ret.ok){
|
||||||
|
refreshCanon()
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo al intentar hacer la request";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function EscribirNotificacion(message:string) {
|
||||||
|
if (message =="") {
|
||||||
|
modaldata = "no se puede enviar un mensaje vacio";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const r = await fetch($urlG+"/api/admin/notificarInquilino", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
mensaje: message,
|
||||||
|
idcontrato: prop.id,
|
||||||
|
idcanon: idcanon,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let data = await r.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
} catch {
|
||||||
|
modaldata ="No se pudo enviar el mensaje";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if shownotif}
|
||||||
|
<ModalNotificacion onCancel={()=>shownotif = false} onConfirm={EscribirNotificacion}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="container-fluid mt-4 d-flex">
|
||||||
|
<div class="col-md-4 me-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header text-center">Propiedad</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p><b>Tipo:</b> {prop.tipoPropiedad}</p>
|
||||||
|
<p><b>Ubicación:</b> {prop.ubicacion}</p>
|
||||||
|
<p><b>Propietario:</b> {prop.propietario}</p>
|
||||||
|
<p><b>Inquilino:</b> {prop.inquilino}</p>
|
||||||
|
<p><b>Habitaciones:</b> {prop.habitaciones}</p>
|
||||||
|
<p><b>Piso:</b> {prop.piso}</p>
|
||||||
|
<p><b>Letra:</b> {prop.letra}</p>
|
||||||
|
<p><b>Fecha Inicio:</b> {String(prop.fechainicio).split("T")[0]}</p>
|
||||||
|
<p><b>Estado:</b> {prop.estado}</p>
|
||||||
|
<button class="btn btn-secondary" onclick={verContrato}>
|
||||||
|
Ver Contrato
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
IdContrato: {prop.id}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col d-flex flex-column">
|
||||||
|
<div class="accordion mb-4" id="accordionExample">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="headingOne">
|
||||||
|
<button
|
||||||
|
class="accordion-button collapsed"
|
||||||
|
type="button"
|
||||||
|
data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseOne"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-controls="collapseOne"
|
||||||
|
>
|
||||||
|
Garantes
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
id="collapseOne"
|
||||||
|
class="accordion-collapse collapse"
|
||||||
|
aria-labelledby="headingOne"
|
||||||
|
data-bs-parent="#accordionExample"
|
||||||
|
>
|
||||||
|
<div class="accordion-body">
|
||||||
|
<table class="table table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Dni</th>
|
||||||
|
<th>Nombre</th>
|
||||||
|
<th>Apellido</th>
|
||||||
|
<th>Domicilio</th>
|
||||||
|
<th>Dom. Laboral</th>
|
||||||
|
<th>Celular</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{#each garantes as g}
|
||||||
|
<tr>
|
||||||
|
<td>{g.dni}</td>
|
||||||
|
<td>{g.nombre}</td>
|
||||||
|
<td>{g.apellido}</td>
|
||||||
|
<td>{g.domicilio}</td>
|
||||||
|
<td>{g.domiciliolaboral}</td>
|
||||||
|
<td>{g.celular}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="headingTwo">
|
||||||
|
<button
|
||||||
|
class="accordion-button"
|
||||||
|
type="button"
|
||||||
|
data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseTwo"
|
||||||
|
aria-expanded="true"
|
||||||
|
aria-controls="collapseTwo"
|
||||||
|
>
|
||||||
|
Canons
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
id="collapseTwo"
|
||||||
|
class="accordion-collapse collapse show"
|
||||||
|
aria-labelledby="headingTwo"
|
||||||
|
data-bs-parent="#accordionExample"
|
||||||
|
>
|
||||||
|
<div class="accordion-body">
|
||||||
|
<div class="row">
|
||||||
|
{#each canons as canon}
|
||||||
|
<div class="col-6 mb-3">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header text-center">
|
||||||
|
{canon.mesNum}/{prop.mesesDuracion}
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p><strong>Mes:</strong> {String(canon.mes).split("T")[0]}</p>
|
||||||
|
<p><strong>Monto:</strong> {canon.monto}</p>
|
||||||
|
<p><strong>Divisa:</strong> {canon.divisa}</p>
|
||||||
|
<p><strong>Pago:</strong> {canon.pago ? "Sí" : "No"}</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer d-flex justify-content-between">
|
||||||
|
<button class="btn btn-primary" disabled={canon.pago} onclick={()=>realizarpago(canon.mes)}>
|
||||||
|
Pagar
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-warning" disabled={canon.pago} onclick={()=>abrirModalNotif(canon.id)}>
|
||||||
|
Informar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import BarraHorizontalConTexto from "../Componentes/BarraHorizontalConTexto.svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import type { ContratoDto } from "../types";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import { navigate } from "svelte-routing";
|
||||||
|
|
||||||
|
let token: string = sessionStorage.getItem("token")|| "";
|
||||||
|
let alquileres:ContratoDto[]| null = $state(null);
|
||||||
|
let modaldata:string = $state("");
|
||||||
|
|
||||||
|
onMount(()=>{
|
||||||
|
obtenerContratosAdmin();
|
||||||
|
});
|
||||||
|
async function obtenerContratosAdmin() {
|
||||||
|
try{
|
||||||
|
const responce = await fetch($urlG+"/api/contratos/controlPagos", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (responce.ok){
|
||||||
|
let data = await responce.json();
|
||||||
|
alquileres = data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = await responce.json();
|
||||||
|
modaldata = data.message;
|
||||||
|
|
||||||
|
}catch{
|
||||||
|
modaldata = "fallo al intentar hacer la request";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata }
|
||||||
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata="")}/>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="container-fluid mt-2">
|
||||||
|
<BarraHorizontalConTexto text="Control de Pagos" />
|
||||||
|
<div class="text-center">
|
||||||
|
Lista de contratos que tienen canones atrasados
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="row g-3">
|
||||||
|
{#if alquileres == null}
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
<div class="spinner-border" role="status">
|
||||||
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
{#if alquileres.length == 0}
|
||||||
|
<h1 class=" d-flex justify-content-center">
|
||||||
|
No hay Alquileres que deban meses
|
||||||
|
</h1>
|
||||||
|
{/if}
|
||||||
|
{#each alquileres as alquiler}
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-header bg-primary text-white">
|
||||||
|
<h5 class="mb-0 text-center">{alquiler.tipoPropiedad}</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h6 class="card-subtitle mb-2 text-muted">{alquiler.ubicacion}</h6>
|
||||||
|
<p class="card-text">
|
||||||
|
<strong>Fecha de inicio:</strong> {new Date(alquiler.fechainicio).toLocaleDateString()}<br />
|
||||||
|
<strong>Inquilino:</strong> {alquiler.inquilino}<br />
|
||||||
|
<strong>Propietario:</strong> {alquiler.propietario}<br>
|
||||||
|
<strong>Id Propiedad: </strong>{alquiler.id}
|
||||||
|
</p>
|
||||||
|
<div class="d-flex justify-content-center">
|
||||||
|
<button class="btn btn-primary" onclick={()=>navigate("/admin/contratos?id="+alquiler.id)}>
|
||||||
|
Ver
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center">
|
||||||
|
<strong>Estado:</strong> {alquiler.estado}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -27,7 +27,13 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
|||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetRecibo(Canon c, Recibo re, long dni) {
|
public Canon? ObtenerCanonPorId(long id){
|
||||||
|
var con = Context;
|
||||||
|
var cnn = con.Canons.FirstOrDefault(x=>x.Id == id);
|
||||||
|
return cnn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetRecibo(Canon c, Recibo re, long dni, string mensaje= "Set Recibo") {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
var cc = con.Canons
|
var cc = con.Canons
|
||||||
.Include(x=>x.Idcontratos)
|
.Include(x=>x.Idcontratos)
|
||||||
@@ -51,7 +57,7 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
|||||||
ccc.IdpropiedadNavigation.Idestado = 3;
|
ccc.IdpropiedadNavigation.Idestado = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerarLog(con, dni, $"Set Recibo");
|
GenerarLog(con, dni, mensaje);
|
||||||
|
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,4 +242,17 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
|||||||
|
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IQueryable<Contrato> ObtenerContratosInpagos() {
|
||||||
|
var con = Context;
|
||||||
|
DateTime d = DateTime.Now;
|
||||||
|
var l = con.Contratos
|
||||||
|
.Include(x=>x.DniinquilinoNavigation)
|
||||||
|
.Include(x=>x.DnipropietarioNavigation)
|
||||||
|
.Include(x=>x.IdpropiedadNavigation)
|
||||||
|
.ThenInclude(x=>x.IdtipropiedadNavigation)
|
||||||
|
.Include(x=>x.Idcanons)
|
||||||
|
.Where(x=>x.Idcanons.Any(x=>x.Pagado ==0 && d > x.Fecha));
|
||||||
|
return l;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,13 @@ public class RepositorioNotificaciones : RepositorioBase<RepositorioNotificacion
|
|||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AltaNotificacion(Notificacione n) {
|
public bool AltaNotificacion(Notificacione n, long dni=0) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
|
|
||||||
con.Notificaciones.Add(n);
|
con.Notificaciones.Add(n);
|
||||||
|
if (dni !=0){
|
||||||
|
GenerarLog(con, dni, "Se envio un informe");
|
||||||
|
}
|
||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user