añadida informacion a la pantalla de añadirgarantes
This commit is contained in:
@@ -401,6 +401,38 @@ public class ContratoController : ControllerBase
|
|||||||
BadRequest(new { message = "No se pudo enviar la notificacion" });
|
BadRequest(new { message = "No se pudo enviar la notificacion" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("api/precontrato/preCargaGarantes/data")]
|
||||||
|
public IActionResult ObtenerDatosParaMostrarleAlInquilinoPreCargaGarantes([FromHeader(Name="Auth")]string Auth, int propiedadId){
|
||||||
|
if (propiedadId<=0) return BadRequest(new { message = "Numero de propiedad inexistente"});
|
||||||
|
|
||||||
|
var cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return BadRequest(new { message = "No hay cliente por ese token" });
|
||||||
|
|
||||||
|
Contrato? contrato = RepositorioContratos.Singleton.ObtenerPreContratoPorIdDePropiedadyCliente(cli, propiedadId);
|
||||||
|
|
||||||
|
if (contrato == null) return BadRequest(new {message = "no se pudo encontrar los datos del precontrato"});
|
||||||
|
|
||||||
|
PreContratoDataDto d = new PreContratoDataDto
|
||||||
|
{
|
||||||
|
TieneOpcionDeVenta = contrato.Tieneopcionventa == 1,
|
||||||
|
|
||||||
|
MontoOpcionDeVenta = contrato.Tieneopcionventa == 1 && contrato.IdventaNavigation != null
|
||||||
|
? contrato.IdventaNavigation.Monto
|
||||||
|
: null,
|
||||||
|
|
||||||
|
MonedaOpcionDeVenta = contrato.Tieneopcionventa == 1
|
||||||
|
&& contrato.IdventaNavigation != null
|
||||||
|
&& contrato.IdventaNavigation.IddivisaNavigation != null
|
||||||
|
? contrato.IdventaNavigation.IddivisaNavigation.Signo
|
||||||
|
: null,
|
||||||
|
|
||||||
|
DuracionEnMeses = contrato.MesesDurationContrato,
|
||||||
|
|
||||||
|
FrecuenciaAumentoEnMeses = contrato.MesesHastaAumento
|
||||||
|
};
|
||||||
|
return Ok(d);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPut("api/contratos/addGarantes")]
|
[HttpPut("api/contratos/addGarantes")]
|
||||||
public IActionResult AddGarantes([FromHeader(Name = "Auth")] string Auth, AltaGarantesDto dto)
|
public IActionResult AddGarantes([FromHeader(Name = "Auth")] string Auth, AltaGarantesDto dto)
|
||||||
{
|
{
|
||||||
|
|||||||
7
Entidades/Dto/PreContratoDataDto.cs
Normal file
7
Entidades/Dto/PreContratoDataDto.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
public class PreContratoDataDto{
|
||||||
|
public bool TieneOpcionDeVenta { get; set; }
|
||||||
|
public decimal? MontoOpcionDeVenta { get; set; }
|
||||||
|
public string? MonedaOpcionDeVenta { get; set; }
|
||||||
|
public int DuracionEnMeses { get; set; }
|
||||||
|
public int? FrecuenciaAumentoEnMeses { get; set; }
|
||||||
|
}
|
||||||
@@ -1,16 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GaranteDto } from "../types";
|
import type { GaranteDto, PreContratoData } from "../types";
|
||||||
|
|
||||||
let { onClose, onSubmit, maxGarantes }: {
|
let { onClose, onSubmit, maxGarantes, datosprecontrato }: {
|
||||||
onClose: () => void,
|
onClose: () => void,
|
||||||
onSubmit: (garantes: GaranteDto[]) => void,
|
onSubmit: (garantes: GaranteDto[]) => void,
|
||||||
maxGarantes: number
|
maxGarantes: number,
|
||||||
|
datosprecontrato: PreContratoData,
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
let cantGarantes: number = $state(0);
|
let cantGarantes: number = $state(0);
|
||||||
let garantes: GaranteDto[] = $state([]);
|
let garantes: GaranteDto[] = $state([]);
|
||||||
let showAddForm: boolean = $state(false);
|
let showAddForm: boolean = $state(false);
|
||||||
|
|
||||||
// Nuevo garante temporal para el formulario.
|
// Nuevo garante temporal para el formulario.
|
||||||
let newGarante: GaranteDto = $state({
|
let newGarante: GaranteDto = $state({
|
||||||
Dni: 0,
|
Dni: 0,
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
Domiciliolaboral: ""
|
Domiciliolaboral: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function handleSubmit(e: Event) {
|
function handleSubmit(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onSubmit(garantes);
|
onSubmit(garantes);
|
||||||
@@ -48,6 +50,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
<div class="modal fade show" tabindex="-1" role="dialog" style="display: block; background-color: rgba(0, 0, 0, 0.5);">
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
@@ -55,6 +58,43 @@
|
|||||||
<h5 class="modal-title">Nuevo Alquiler - Garantes</h5>
|
<h5 class="modal-title">Nuevo Alquiler - Garantes</h5>
|
||||||
<button class="btn-close" onclick={onClose} aria-label="Close"></button>
|
<button class="btn-close" onclick={onClose} aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5>Detalles del Precontrato</h5>
|
||||||
|
<hr />
|
||||||
|
<!-- Opción de Venta -->
|
||||||
|
<div class="mb-3">
|
||||||
|
<p class="form-label"><strong>Opción de Venta:</strong></p>
|
||||||
|
<div>
|
||||||
|
{#if datosprecontrato.tieneOpcionDeVenta}
|
||||||
|
<span class="badge bg-success" id="tieneOpcionDeVenta">Sí</span>
|
||||||
|
{:else}
|
||||||
|
<span class="badge bg-secondary" id="noTieneOpcionDeVenta">No</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if datosprecontrato.tieneOpcionDeVenta}
|
||||||
|
<!-- Monto y Moneda de Opción de Venta (visible solo si hay opción) -->
|
||||||
|
<div class="mb-3" id="opcionVentaDetalles">
|
||||||
|
<p class="form-label"><strong>Monto de Opción de Venta:</strong></p>
|
||||||
|
<p class="form-control-plaintext" id="montoOpcionDeVenta">{datosprecontrato.montoOpcionDeVenta} {datosprecontrato.monedaOpcionDeVenta}</p>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<!-- Duración del Contrato -->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><strong>Duración del Contrato:</strong></label>
|
||||||
|
<p class="form-control-plaintext" id="duracionEnMeses">{datosprecontrato.duracionEnMeses} Meses</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Frecuencia de Aumento -->
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label"><strong>Frecuencia de Aumento:</strong></label>
|
||||||
|
<p class="form-control-plaintext" id="frecuenciaAumentoEnMeses">Cada {datosprecontrato.frecuenciaAumentoEnMeses} meses</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<form onsubmit={handleSubmit}>
|
<form onsubmit={handleSubmit}>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
@@ -98,15 +138,8 @@
|
|||||||
<input type="text" class="form-control" bind:value={newGarante.Domiciliolaboral} required />
|
<input type="text" class="form-control" bind:value={newGarante.Domiciliolaboral} required />
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
<button
|
<button class="btn btn-success" type="button" onclick={addGarante}>
|
||||||
class="btn btn-secondary"
|
Añadir
|
||||||
type="button"
|
|
||||||
onclick={() => (showAddForm = false)}
|
|
||||||
>
|
|
||||||
Cancelar
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-primary" type="button" onclick={addGarante}>
|
|
||||||
Confirmar
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
import type { GaranteDto, MensajeDto } from "../types";
|
import type { GaranteDto, MensajeDto, PreContratoData } from "../types";
|
||||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
import { urlG } from "../stores/urlStore";
|
import { urlG } from "../stores/urlStore";
|
||||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||||
@@ -113,6 +113,7 @@
|
|||||||
if (mensaje.accion === "Carge Garantes") {
|
if (mensaje.accion === "Carge Garantes") {
|
||||||
Selmens = { ...mensaje };
|
Selmens = { ...mensaje };
|
||||||
setCantGarantes = Number(Selmens.mensaje.split(" ").reverse()[1]);
|
setCantGarantes = Number(Selmens.mensaje.split(" ").reverse()[1]);
|
||||||
|
ObtenerDatosPreContrato();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,6 +468,28 @@
|
|||||||
}
|
}
|
||||||
showConsultaCompra = false; Selmens.accion = "";
|
showConsultaCompra = false; Selmens.accion = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let datosprecontrato: PreContratoData = $state({});
|
||||||
|
async function ObtenerDatosPreContrato(){
|
||||||
|
try {
|
||||||
|
const req = await fetch($urlG + "/api/precontrato/preCargaGarantes/data?propiedadId="+Selmens.propiedad, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Auth": token || "",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const data = await req.json();
|
||||||
|
if (req.ok){
|
||||||
|
datosprecontrato = data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modaldata = data.message;
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
modaldata = "Fallo al obtener los datos del precontrato";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavBarAutocompletable/>
|
<NavBarAutocompletable/>
|
||||||
@@ -478,7 +501,7 @@
|
|||||||
{#if Selmens.accion == "Nuevo Alquiler" }
|
{#if Selmens.accion == "Nuevo Alquiler" }
|
||||||
<ModalPrecontrato onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje2} />
|
<ModalPrecontrato onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje2} />
|
||||||
{:else if Selmens.accion == "Carge Garantes"}
|
{:else if Selmens.accion == "Carge Garantes"}
|
||||||
<ModalAddGarantes maxGarantes={setCantGarantes} onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje3}/>
|
<ModalAddGarantes maxGarantes={setCantGarantes} onClose={() => (Selmens.accion = "")} onSubmit={handleEnviarmensaje3} {datosprecontrato}/>
|
||||||
{:else if Selmens.accion == "Check y Contrato"}
|
{:else if Selmens.accion == "Check y Contrato"}
|
||||||
<ModalCheckYContrato {garantes} men={Selmens} onCancel={handleCancelPrecontrato} onClose={() => (Selmens.accion = "")} onConfirm={handleEnviarmensaje4}/>
|
<ModalCheckYContrato {garantes} men={Selmens} onCancel={handleCancelPrecontrato} onClose={() => (Selmens.accion = "")} onConfirm={handleEnviarmensaje4}/>
|
||||||
{:else if Selmens.accion == "Aceptar Contrato"}
|
{:else if Selmens.accion == "Aceptar Contrato"}
|
||||||
@@ -565,4 +588,4 @@
|
|||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
34
Front/src/types.d.ts
vendored
34
Front/src/types.d.ts
vendored
@@ -244,20 +244,28 @@ export type ClientePanel = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type IngresosDto = {
|
export type IngresosDto = {
|
||||||
mes:number,
|
mes:number,
|
||||||
realizados:number,
|
realizados:number,
|
||||||
atrasados:number,
|
atrasados:number,
|
||||||
sin_realizar:number
|
sin_realizar:number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CrearUsuario = {
|
export type CrearUsuario = {
|
||||||
Dni: number;
|
Dni: number;
|
||||||
Nombre: string;
|
Nombre: string;
|
||||||
Apellido: string;
|
Apellido: string;
|
||||||
Domicilio: string;
|
Domicilio: string;
|
||||||
Celular: string;
|
Celular: string;
|
||||||
Email: string;
|
Email: string;
|
||||||
Contraseña: string;
|
Contraseña: string;
|
||||||
EmailRecuperacion?: string | null;
|
EmailRecuperacion?: string | null;
|
||||||
grupos: number[];
|
grupos: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PreContratoData = {
|
||||||
|
tieneOpcionDeVenta: boolean;
|
||||||
|
montoOpcionDeVenta?: number;
|
||||||
|
monedaOpcionDeVenta?: string;
|
||||||
|
duracionEnMeses: number;
|
||||||
|
frecuenciaAumentoEnMeses?: number | null;
|
||||||
|
};
|
||||||
|
|||||||
@@ -168,6 +168,16 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
|
|||||||
return Guardar(con);
|
return Guardar(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Contrato? ObtenerPreContratoPorIdDePropiedadyCliente(Cliente cli, int propiedadid){
|
||||||
|
var con = Context;
|
||||||
|
|
||||||
|
var cont = con.Contratos.Where(x=>x.Habilitado == 0ul && x.Cancelado == 0ul)
|
||||||
|
.Include(x=>x.IdventaNavigation)
|
||||||
|
.ThenInclude(x=>x.IddivisaNavigation)
|
||||||
|
.FirstOrDefault(x => x.Dniinquilino == cli.Dni && x.Idpropiedad == propiedadid);
|
||||||
|
return cont;
|
||||||
|
}
|
||||||
|
|
||||||
public IQueryable<Contrato> ObtenerContratosDePropietario(long dni) {
|
public IQueryable<Contrato> ObtenerContratosDePropietario(long dni) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
var l = con.Contratos
|
var l = con.Contratos
|
||||||
|
|||||||
Reference in New Issue
Block a user