falta interfaz venta
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
import { onMount } from "svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { AltaDefectoDto, CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import type { AltaDefectoDto, CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2, OpcionVentaDto } from "../types";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import FormAltaDefecto from "../Componentes/FormAltaDefecto.svelte";
|
||||
import { navigate } from "svelte-routing";
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
|
||||
@@ -29,14 +30,60 @@
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
|
||||
let TieneOpcionVenta:boolean =$state(false);
|
||||
let dtoVenta:OpcionVentaDto =$state({divisa:"", id:0, monto:0, enOrden:false, fueEjercido:false});
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
|
||||
onMount(()=>{
|
||||
getparams();
|
||||
obtenerDatosACargar();
|
||||
opcionVenta();
|
||||
});
|
||||
|
||||
async function opcionVenta() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/contrato/tieneopcionventa?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (r.ok){
|
||||
let data = await r.json();
|
||||
TieneOpcionVenta = data.message;
|
||||
ObtenerOpcionVentaDto();
|
||||
return;
|
||||
}
|
||||
let data = await r.json();
|
||||
modaldata = data.message;
|
||||
return;
|
||||
}catch {
|
||||
modaldata = "Fallo hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function ObtenerOpcionVentaDto() {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/opcionventa?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (r.ok) {
|
||||
let data = await r.json();
|
||||
dtoVenta = data;
|
||||
return
|
||||
}
|
||||
let data = await r.json();
|
||||
modaldata = data.message;
|
||||
}catch{
|
||||
modaldata = "Fallo hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosACargar() {
|
||||
try {
|
||||
const respPropiedad = fetch($urlG+"/api/contrato/inquilino?id="+contratoid, {
|
||||
@@ -223,6 +270,25 @@
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function ejercerOpcionVenta() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/ventas/ejercerOpcionVenta?idcontrato="+contratoid, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
let data = await r.json();
|
||||
modaldata =data.message;
|
||||
if(r.ok){
|
||||
opcionVenta();
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -374,8 +440,10 @@
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="ht"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
>
|
||||
|
||||
<div class="accordion-body">
|
||||
{#if prop.estado != "Terminado"}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Notificar Defecto en Propiedad
|
||||
@@ -384,10 +452,11 @@
|
||||
<FormAltaDefecto onConfirm={cargarDefecto} idcontrato={prop.id} />
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
{/if}
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -419,6 +488,55 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if TieneOpcionVenta}
|
||||
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="hq">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#cq"
|
||||
aria-expanded="false"
|
||||
aria-controls="cq"
|
||||
>
|
||||
Opcion Venta
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="cq"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="hq"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Datos Opcion Venta
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<b>Monto</b>: {dtoVenta.divisa} {dtoVenta.monto}.
|
||||
|
||||
<p class="mt-2 text-muted">
|
||||
Para poder ejercer la opcion de venta necesitas estar en el mismo mes que el ultimo pago y haber pagado todos los canones
|
||||
</p>
|
||||
<div class="d-flex justify-content-between">
|
||||
<button class="btn btn-primary" disabled={dtoVenta.enOrden==false || dtoVenta.fueEjercido == true} onclick={()=>ejercerOpcionVenta()}>
|
||||
Ejercer
|
||||
</button>
|
||||
{#if dtoVenta.fueEjercido}
|
||||
<button class="btn btn-secondary" onclick={()=>navigate("/accion/13?idventa="+dtoVenta.id)}>
|
||||
Ir a la pagina de la Venta
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-center">IdOpcionVenta: {dtoVenta.id}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2, OpcionVentaDto } from "../types";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||
import { navigate } from "svelte-routing";
|
||||
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
@@ -35,6 +36,8 @@
|
||||
mesesDuracion:0,
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
let TieneOpcionVenta:boolean =$state(false);
|
||||
let dtoVenta:OpcionVentaDto =$state({divisa:"", id:0, monto:0, enOrden:false, fueEjercido:false});
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
@@ -43,8 +46,52 @@
|
||||
getparams();
|
||||
await obtenerDatosACargar();
|
||||
max = canons.at(-1).mesNum||0;
|
||||
opcionVenta();
|
||||
|
||||
});
|
||||
|
||||
async function opcionVenta() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/contrato/tieneopcionventa?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (r.ok){
|
||||
let data = await r.json();
|
||||
TieneOpcionVenta = data.message;
|
||||
ObtenerOpcionVentaDto();
|
||||
return;
|
||||
}
|
||||
let data = await r.json();
|
||||
modaldata = data.message;
|
||||
return;
|
||||
}catch {
|
||||
modaldata = "Fallo hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function ObtenerOpcionVentaDto() {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/opcionventa?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (r.ok) {
|
||||
let data = await r.json();
|
||||
dtoVenta = data;
|
||||
return
|
||||
}
|
||||
let data = await r.json();
|
||||
modaldata = data.message;
|
||||
}catch{
|
||||
modaldata = "Fallo hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function obtenerDatosACargar() {
|
||||
try {
|
||||
const respPropiedad = fetch($urlG+"/api/contrato/propietario?id="+contratoid, {
|
||||
@@ -511,6 +558,50 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if TieneOpcionVenta}
|
||||
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="hq">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#cq"
|
||||
aria-expanded="false"
|
||||
aria-controls="cq"
|
||||
>
|
||||
Opcion Venta
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="cq"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="hq"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Datos Opcion Venta
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<b>Monto</b>: {dtoVenta.divisa} {dtoVenta.monto}.
|
||||
|
||||
<p class="mt-2 text-muted">
|
||||
Para que el inquilino pueda ejercer la opcion de venta necesitas estar en el mismo mes que el ultimo pago y haber pagado todos los canones
|
||||
</p>
|
||||
<div class="d-flex">
|
||||
<button class="btn btn-primary" disabled={!dtoVenta.fueEjercido} onclick={()=>navigate("/accion/13?idventa="+dtoVenta.id)}>
|
||||
Ir a la pagina de la Venta
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer text-center">IdOpcionVenta: {dtoVenta.id}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -161,7 +161,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleEnviarmensaje2(data: {opcionVenta:boolean, cantGarantes:number, mesesHastaAumento:number, mesesDuracionContrato:number}) {
|
||||
async function handleEnviarmensaje2(data: {opcionVenta:boolean, cantGarantes:number,
|
||||
mesesHastaAumento:number, mesesDuracionContrato:number, montoOpcion:number, iddivisa:number}) {
|
||||
if (data.opcionVenta == null || data.cantGarantes <=0 || data.mesesHastaAumento<=0 || data.mesesDuracionContrato <=0) {
|
||||
modaldata = "Estan mal cargados los datos del form";
|
||||
return;
|
||||
@@ -177,7 +178,9 @@
|
||||
fechaprimernotificacion: fecha,
|
||||
emailInquilino: Selmens.remitente,
|
||||
emailPropietario: Selmens.receptor,
|
||||
mesesDuracionContrato: data.mesesDuracionContrato
|
||||
mesesDuracionContrato: data.mesesDuracionContrato,
|
||||
montoOpcion: data.montoOpcion,
|
||||
iddivisa: data.iddivisa
|
||||
};
|
||||
|
||||
let responce = await fetch($urlG+"/api/contratos/precontrato", {
|
||||
|
||||
Reference in New Issue
Block a user