dev #48
@@ -16,6 +16,71 @@ namespace AlquilaFacil.Controllers;
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class ContratoController: ControllerBase {
|
public class ContratoController: ControllerBase {
|
||||||
|
|
||||||
|
[HttpPost("api/contratos/marcarPago")]
|
||||||
|
public IActionResult marcarPago([FromHeader(Name="Auth")]string Auth, MarcarPagoDto dto) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
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"});
|
||||||
|
|
||||||
|
if (cli.Dni != cont.Dnipropietario) return BadRequest(new {message = "No sos propietario o intenta volviendote a logear"});
|
||||||
|
|
||||||
|
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 = c.Fecha,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re);
|
||||||
|
return ret ?
|
||||||
|
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/contratos/realizarPago")]
|
||||||
|
public IActionResult realizarPago([FromHeader(Name="Auth")]string Auth, MarcarPagoDto dto) {
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
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"});
|
||||||
|
|
||||||
|
if (cli.Dni != cont.Dniinquilino) return BadRequest(new {message = "No sos inquilino o intenta volviendote a logear"});
|
||||||
|
|
||||||
|
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 = c.Fecha,
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ret = RepositorioCanons.Singleton.SetRecibo(c, re);
|
||||||
|
return ret ?
|
||||||
|
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("api/contratos/crearcanons")] //WIP
|
||||||
|
public IActionResult crearCanons([FromHeader(Name="Auth")]string Auth){
|
||||||
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false)return Unauthorized();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("api/contratos/canon")]
|
[HttpGet("api/contratos/canon")]
|
||||||
public ActionResult getCanons([FromHeader(Name="Auth")]string Auth, int id = 0) {
|
public ActionResult getCanons([FromHeader(Name="Auth")]string Auth, int id = 0) {
|
||||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||||
@@ -26,12 +91,16 @@ public class ContratoController: ControllerBase {
|
|||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if(cli == null) return Unauthorized();
|
||||||
|
|
||||||
|
var cont = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
||||||
|
if (cont == null) return BadRequest(new { message = "No existe el contrato"});
|
||||||
|
if ( cont.Dnipropietario != cli.Dni && cont.Dniinquilino != cli.Dni) return Unauthorized();
|
||||||
|
|
||||||
var list = RepositorioCanons.Singleton.ObtenerCanonsPorContrato(id);
|
var list = RepositorioCanons.Singleton.ObtenerCanonsPorContrato(id);
|
||||||
if (list == null) return BadRequest(new { message = "No hay contrato por esa id"});
|
if (list == null) return BadRequest(new { message = "No hay contrato por esa id"});
|
||||||
|
|
||||||
var cont = RepositorioContratos.Singleton.ObtenerContratoPorId(id);
|
|
||||||
if (cont == null) return BadRequest(new { message = ""});
|
|
||||||
string divisa ="";
|
string divisa ="";
|
||||||
if (cont.Iddivisa == 0) divisa = "AR$"; else if (cont.Iddivisa == 1) divisa = "US$";
|
if (cont.Iddivisa == 0) divisa = "AR$"; else if (cont.Iddivisa == 1) divisa = "US$";
|
||||||
|
|
||||||
@@ -125,7 +194,7 @@ public class ContratoController: ControllerBase {
|
|||||||
if (cli==null) return Unauthorized();
|
if (cli==null) return Unauthorized();
|
||||||
|
|
||||||
var list = RepositorioContratos.Singleton.ObtenerContratosDeInquilino(cli.Dni);
|
var list = RepositorioContratos.Singleton.ObtenerContratosDeInquilino(cli.Dni);
|
||||||
|
|
||||||
List<ContratoDto> dtos = new();
|
List<ContratoDto> dtos = new();
|
||||||
foreach (var i in list) {
|
foreach (var i in list) {
|
||||||
if (i.DniinquilinoNavigation == null || i.IdpropiedadNavigation == null
|
if (i.DniinquilinoNavigation == null || i.IdpropiedadNavigation == null
|
||||||
@@ -431,12 +500,56 @@ public class ContratoController: ControllerBase {
|
|||||||
Ok(new { message = "se notifico al futuro inquilino"}): BadRequest(new { message = "No se pudo enviar la notificacion"});
|
Ok(new { message = "se notifico al futuro inquilino"}): BadRequest(new { message = "No se pudo enviar la notificacion"});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[HttpGet("api/contrato/DocumentoFinal")]
|
||||||
|
public IActionResult ObtenerContratoFinal ([FromHeader(Name = "Auth")]string Auth, [FromQuery]long idcontrato) {
|
||||||
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false){
|
||||||
|
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
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);
|
||||||
|
if (contr == null || contr.Dniinquilino == 0) return BadRequest(new { message = "No hay un contrato por esa id"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new { message = "No hay un cliente por ese token"});
|
||||||
|
if (cli.Dni != contr.Dniinquilino && cli.Dni != contr.Dnipropietario) return BadRequest(new { message = "El token no corresponde con el del inquilino"});
|
||||||
|
|
||||||
|
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/contrato/getdocumento")]
|
[HttpGet("api/contrato/getdocumento")]
|
||||||
public IActionResult ObtenerContrato([FromHeader(Name = "Auth")]string Auth, [FromQuery]long idcontrato) {
|
public IActionResult ObtenerContrato([FromHeader(Name = "Auth")]string Auth, [FromQuery]long idcontrato) {
|
||||||
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
if (String.IsNullOrWhiteSpace(Auth)) return BadRequest("");
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
if (validacion1 == false) return Unauthorized();
|
if (validacion1 == false){
|
||||||
|
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false) return Unauthorized();
|
||||||
|
}
|
||||||
|
|
||||||
if (idcontrato <= 0) return BadRequest(new {message = "La id no puede ser igual o menor a 0"});
|
if (idcontrato <= 0) return BadRequest(new {message = "La id no puede ser igual o menor a 0"});
|
||||||
|
|
||||||
|
|||||||
6
Entidades/Dto/MarcarPagoDto.cs
Normal file
6
Entidades/Dto/MarcarPagoDto.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class MarcarPagoDto {
|
||||||
|
public long Idcontrato { get; set; }
|
||||||
|
public DateTime fecha { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
4
Front/.prettierrc
Normal file
4
Front/.prettierrc
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"tabWidth": 4,
|
||||||
|
"useTabs": false
|
||||||
|
}
|
||||||
@@ -1,7 +1,238 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import {urlG} from "../stores/urlStore";
|
||||||
|
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||||
|
|
||||||
|
|
||||||
|
let token:string = sessionStorage.getItem("token")||"";
|
||||||
|
|
||||||
|
let interes:number = $state(0);
|
||||||
|
|
||||||
|
let canons:CanonDto[] = $state([]);
|
||||||
|
let garantes: GaranteDto2[] = $state([]);
|
||||||
|
let prop:ContratoPropiedadDto = $state({
|
||||||
|
estado:"",
|
||||||
|
fechainicio:"",
|
||||||
|
id:0,
|
||||||
|
inquilino:"",
|
||||||
|
propietario:"",
|
||||||
|
tipoPropiedad:"",
|
||||||
|
ubicacion:"",
|
||||||
|
habitaciones:0,
|
||||||
|
piso:0,
|
||||||
|
letra:"",
|
||||||
|
mesesAumento:0,
|
||||||
|
mesesDuracion:0,
|
||||||
|
});
|
||||||
|
|
||||||
|
let modaldata:string = $state("");
|
||||||
|
let contratoid:string = $state("");
|
||||||
|
|
||||||
|
onMount(()=>{
|
||||||
|
getparams();
|
||||||
|
obtenerDatosACargar();
|
||||||
|
});
|
||||||
|
|
||||||
|
async function obtenerDatosACargar() {
|
||||||
|
try {
|
||||||
|
const respPropiedad = fetch($urlG+"/api/contrato/inquilino?id="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const respgarantes = fetch($urlG+"/api/contratos/garantes?idcontrato="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const respCanons = fetch($urlG+"/api/contratos/canon?id="+contratoid, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": String(token),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const [p, g, c] = await Promise.all([respPropiedad, respgarantes, respCanons]);
|
||||||
|
|
||||||
|
const datosPropiedad = await p.json();
|
||||||
|
const datosGarantes = await g.json();
|
||||||
|
const datosCanons = await c.json();
|
||||||
|
prop = datosPropiedad;
|
||||||
|
garantes = datosGarantes;
|
||||||
|
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 submitnuevosCanones() {
|
||||||
|
|
||||||
|
}
|
||||||
|
async function verContrato() {
|
||||||
|
if (prop.id <= 0) {
|
||||||
|
modaldata = "no hay contratos con id 0 o menor";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const resp = await fetch ($urlG+"/api/contrato/DocumentoFinal?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";
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||||
|
{/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"
|
||||||
|
type="button"
|
||||||
|
data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseOne"
|
||||||
|
aria-expanded="true"
|
||||||
|
aria-controls="collapseOne"
|
||||||
|
>
|
||||||
|
Garantes
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
id="collapseOne"
|
||||||
|
class="accordion-collapse collapse show"
|
||||||
|
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 collapsed"
|
||||||
|
type="button"
|
||||||
|
data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#collapseTwo"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-controls="collapseTwo"
|
||||||
|
>
|
||||||
|
Canons
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div
|
||||||
|
id="collapseTwo"
|
||||||
|
class="accordion-collapse collapse"
|
||||||
|
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 btn-xs" disabled={canon.pago}>
|
||||||
|
Pagar
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-info btn-xs" disabled={!canon.pago}>
|
||||||
|
Generar Tiket
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
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, GaranteDto2 } from "../types";
|
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||||
|
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||||
|
|
||||||
|
|
||||||
let token:string = sessionStorage.getItem("token")||"";
|
let token:string = sessionStorage.getItem("token")||"";
|
||||||
@@ -74,10 +75,37 @@
|
|||||||
contratoid = par.get("id")||"";
|
contratoid = par.get("id")||"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function submitnuevosCanones() {
|
||||||
function submitnuevosCanones() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function verContrato() {
|
||||||
|
if (prop.id <= 0) {
|
||||||
|
modaldata = "no hay contratos con id 0 o menor";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const resp = await fetch ($urlG+"/api/contrato/DocumentoFinal?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";
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
@@ -85,8 +113,9 @@
|
|||||||
{#if modaldata}
|
{#if modaldata}
|
||||||
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<ModalConfirm />
|
||||||
<div class="container-fluid mt-4 d-flex">
|
<div class="container-fluid mt-4 d-flex">
|
||||||
<!-- Columna de la Propiedad -->
|
|
||||||
<div class="col-md-4 me-4">
|
<div class="col-md-4 me-4">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header text-center">Propiedad</div>
|
<div class="card-header text-center">Propiedad</div>
|
||||||
@@ -100,16 +129,17 @@
|
|||||||
<p><b>Letra:</b> {prop.letra}</p>
|
<p><b>Letra:</b> {prop.letra}</p>
|
||||||
<p><b>Fecha Inicio:</b> {String(prop.fechainicio).split("T")[0]}</p>
|
<p><b>Fecha Inicio:</b> {String(prop.fechainicio).split("T")[0]}</p>
|
||||||
<p><b>Estado:</b> {prop.estado}</p>
|
<p><b>Estado:</b> {prop.estado}</p>
|
||||||
|
<button class="btn btn-secondary" onclick={verContrato}>
|
||||||
|
Ver Contrato
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer text-center">
|
<div class="card-footer text-center">
|
||||||
IdPropiedad: {prop.id}
|
IdContrato: {prop.id}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Contenedor principal del acordeón y el formulario -->
|
|
||||||
<div class="col d-flex flex-column">
|
<div class="col d-flex flex-column">
|
||||||
<!-- Acordeón -->
|
|
||||||
<div class="accordion mb-4" id="accordionExample">
|
<div class="accordion mb-4" id="accordionExample">
|
||||||
<div class="accordion-item">
|
<div class="accordion-item">
|
||||||
<h2 class="accordion-header" id="headingOne">
|
<h2 class="accordion-header" id="headingOne">
|
||||||
@@ -234,9 +264,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Formulario -->
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,5 +10,36 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
|||||||
if (l == null) return null;
|
if (l == null) return null;
|
||||||
return l.Idcanons;
|
return l.Idcanons;
|
||||||
}
|
}
|
||||||
|
public Canon? ObtenerCanonContrato(DateTime f, long idcont) {
|
||||||
|
var con = Context;
|
||||||
|
Canon? cc = null;
|
||||||
|
|
||||||
|
var c = con.Canons.FirstOrDefault(x => x.Idrecibo == null &&
|
||||||
|
x.Fecha == f );
|
||||||
|
if (c == null) return null;
|
||||||
|
//no deberia de tener que usar un foreach pero entity por algun motivo mapeo
|
||||||
|
//la entidad como muchos a muchos. no hay forma de que un canon tenga multiples
|
||||||
|
//contratos por como lo codifique pero igualmente
|
||||||
|
foreach (var i in c.Idcontratos) {
|
||||||
|
foreach (var j in i.Idcanons) {
|
||||||
|
if (j.Fecha == f) {
|
||||||
|
cc = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetRecibo(Canon c, Recibo re) {
|
||||||
|
var con = Context;
|
||||||
|
var cc = con.Canons.FirstOrDefault(x=>x.Id == c.Id);
|
||||||
|
if (cc == null) return false;
|
||||||
|
|
||||||
|
re.Id = (con.Recibos.Any()?con.Recibos.Max(x=>x.Id):0)+1;
|
||||||
|
con.Recibos.Add(re);
|
||||||
|
cc.Idrecibo = re.Id;
|
||||||
|
cc.Pagado = 1;
|
||||||
|
|
||||||
|
return Guardar(con);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contrato? ObtenerContratoPorId(int idcontrato) {
|
public Contrato? ObtenerContratoPorId(long idcontrato) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
var l = con.Contratos
|
var l = con.Contratos
|
||||||
.Include(x=>x.Idgarantes)
|
.Include(x=>x.Idgarantes)
|
||||||
|
|||||||
Reference in New Issue
Block a user