implementado defectos
This commit is contained in:
@@ -19,11 +19,12 @@ public class DefectoDtoBuilder: Builder<DefectoDto> {
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetIdContrato(long id){
|
||||
data.IdContrato = id;
|
||||
data.Id = id;
|
||||
data.Idcontrato = id;
|
||||
return this;
|
||||
|
||||
}
|
||||
public DefectoDtoBuilder SetPagaInquilino(ulong pag){
|
||||
data.Pagainquilino=pag==1?"Si":"no";
|
||||
data.Pagainquilino=pag==1?"Si":"No";
|
||||
return this;
|
||||
}
|
||||
public DefectoDtoBuilder SetDivisa(string divisa){
|
||||
|
||||
@@ -47,16 +47,12 @@ public class DefectoController: ControllerBase {
|
||||
return Ok(ll);
|
||||
}
|
||||
|
||||
[HttpPost("api/defecto")] // WIP no se que permisos se necesitan
|
||||
[HttpPost("api/defecto")]
|
||||
public IActionResult AltaDefecto([FromHeader(Name = "Auth")] string Auth, AltaDefectoDto data) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false){
|
||||
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
if (validacion1 == false) {
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
string r = ValidarDto(data);
|
||||
if (r != "") return BadRequest(new { message = r });
|
||||
|
||||
@@ -65,7 +61,7 @@ public class DefectoController: ControllerBase {
|
||||
Descripcion = data.Descripcion,
|
||||
Idcontrato = data.Idcontrato,
|
||||
Iddivisa = data.Iddivisa,
|
||||
Pagainquilino = data.Pagainquilino,
|
||||
Pagainquilino = data.Pagainquilino==0?0Lu:1Lu,
|
||||
Idestado = 1,
|
||||
|
||||
};
|
||||
@@ -79,21 +75,17 @@ public class DefectoController: ControllerBase {
|
||||
if (d == null) return "Dto nulo";
|
||||
if (d.Iddivisa <0 || d.Iddivisa>1) ret +="No son divisas validas\n";
|
||||
if (d.Descripcion == "") ret+="La descripcion no puede estar vacia\n";
|
||||
if (d.Idcontrato<=0)ret += "No puede haber un id de contrato iguao o menor a 0\n";
|
||||
if (d.Idcontrato<=0)ret += "No puede haber un id de contrato igual o menor a 0\n";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[HttpPut("api/defecto/marcarpago")] //WIP no se que permisos se necesitan
|
||||
[HttpPut("api/defecto/marcarpago")]
|
||||
public IActionResult MarcarPago([FromHeader(Name = "Auth")] string Auth, long iddefecto = 0) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
if (validacion1 == false){
|
||||
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||
if (validacion1 == false) {
|
||||
return Unauthorized();
|
||||
}
|
||||
}
|
||||
if (validacion1 == false) return Unauthorized();
|
||||
|
||||
if (iddefecto<=0) return BadRequest(new { message = "No hay canones con id 0 o menor"});
|
||||
bool ret = RepositorioDefectos.Singleton.MarcarPago(iddefecto);
|
||||
|
||||
|
||||
94
Front/src/Componentes/FormAltaDefecto.svelte
Normal file
94
Front/src/Componentes/FormAltaDefecto.svelte
Normal file
@@ -0,0 +1,94 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import type { AltaDefectoDto } from "../types";
|
||||
let { idcontrato, onConfirm
|
||||
} : {
|
||||
idcontrato: number, onConfirm:(data: AltaDefectoDto)=>void} = $props();
|
||||
|
||||
let formData: AltaDefectoDto = $state({
|
||||
descripcion:"",
|
||||
costo:0,
|
||||
idcontrato:idcontrato,
|
||||
iddivisa:0,
|
||||
pagainquilino:0
|
||||
});
|
||||
async function handle(e:Event){
|
||||
e.preventDefault();
|
||||
onConfirm(formData);
|
||||
}
|
||||
let n:number = $state(0);
|
||||
$effect(()=> {n = formData.descripcion.length});
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<form>
|
||||
<div class="mb-3">
|
||||
<label for="descripcion" class="form-label">Descripción</label>
|
||||
<input
|
||||
type="text"
|
||||
id="descripcion"
|
||||
class="form-control"
|
||||
bind:value={formData.descripcion}
|
||||
placeholder="Ingrese la descripción"
|
||||
required
|
||||
maxlength="100"
|
||||
/>
|
||||
<small class="form-text text-muted">
|
||||
{n}/100
|
||||
</small>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb-3 input-group">
|
||||
<span class="input-group-text">$</span>
|
||||
<input
|
||||
type="number"
|
||||
id="costo"
|
||||
class="form-control"
|
||||
bind:value={formData.costo}
|
||||
placeholder="Ingrese el costo"
|
||||
step="0.01"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<div class="form-check">
|
||||
<input
|
||||
type="radio"
|
||||
id="danioUso"
|
||||
class="form-check-input"
|
||||
bind:group={formData.pagainquilino}
|
||||
value="0"
|
||||
required
|
||||
/>
|
||||
<label for="danioUso" class="form-check-label">Daño por uso</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input
|
||||
type="radio"
|
||||
id="danioEstructural"
|
||||
class="form-check-input"
|
||||
bind:group={formData.pagainquilino}
|
||||
value="1"
|
||||
/>
|
||||
<label for="danioEstructural" class="form-check-label">Daño Estructural</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="iddivisa" class="form-label">Divisa</label>
|
||||
<select
|
||||
id="iddivisa"
|
||||
class="form-select"
|
||||
bind:value={formData.iddivisa}
|
||||
required
|
||||
>
|
||||
<option value="0">ARS</option>
|
||||
<option value="1">USD</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary" onclick={(e)=> handle(e)}>Subir</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -3,8 +3,9 @@
|
||||
import { onMount } from "svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import type { AltaDefectoDto, CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import FormAltaDefecto from "../Componentes/FormAltaDefecto.svelte";
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
|
||||
@@ -26,6 +27,7 @@
|
||||
mesesAumento:0,
|
||||
mesesDuracion:0,
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
@@ -55,14 +57,24 @@
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
const [p, g, c] = await Promise.all([respPropiedad, respgarantes, respCanons]);
|
||||
const respoDefect = fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c, d] = await Promise.all([respPropiedad, respgarantes, respCanons, respoDefect]);
|
||||
|
||||
const datosPropiedad = await p.json();
|
||||
const datosGarantes = await g.json();
|
||||
const datosCanons = await c.json();
|
||||
const datosDefect = await d.json();
|
||||
|
||||
prop = datosPropiedad;
|
||||
garantes = datosGarantes;
|
||||
canons = datosCanons;
|
||||
defectos = datosDefect;
|
||||
|
||||
} catch {
|
||||
modaldata = "Fallo hacer las request";
|
||||
}
|
||||
@@ -145,7 +157,7 @@
|
||||
}
|
||||
|
||||
|
||||
function generarTiket(mod) {
|
||||
function generarTiket(mod:any) {
|
||||
selMod = mod;
|
||||
showmodal =true;
|
||||
}
|
||||
@@ -174,6 +186,43 @@
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function cargarDefecto(data: AltaDefectoDto) {
|
||||
if(data.idcontrato ==0) data.idcontrato = prop.id;
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defecto", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
let dr = await r.json();
|
||||
modaldata = dr.message;
|
||||
if (r.ok) {
|
||||
refreshDefectos();
|
||||
}
|
||||
}catch{
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDefectos() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
let rr =await r.json();
|
||||
defectos = rr;
|
||||
} catch {
|
||||
modaldata ="No se pudo pedir la lista de Defectos";
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -307,6 +356,69 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="ht">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#ct"
|
||||
aria-expanded="false"
|
||||
aria-controls="ct"
|
||||
>
|
||||
Defectos
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="ct"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="ht"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Notificar Defecto en Propiedad
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<FormAltaDefecto onConfirm={cargarDefecto} idcontrato={prop.id} />
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descripción</th>
|
||||
<th>Costo</th>
|
||||
<th>Estado</th>
|
||||
<th>Paga Inquilino</th>
|
||||
<th>Divisa</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if defectos.length == 0}
|
||||
<tr>
|
||||
<td colspan="6">No hay defectos que mostrar</td>
|
||||
</tr>
|
||||
{:else}
|
||||
{#each defectos as defecto}
|
||||
<tr>
|
||||
<td>{defecto.descripcion}</td>
|
||||
<td>{defecto.costo}</td>
|
||||
<td>{defecto.estado}</td>
|
||||
<td>{defecto.pagainquilino}</td>
|
||||
<td>{defecto.divisa}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, DefectoDto, GaranteDto2 } from "../types";
|
||||
import ModalConfirm from "../Componentes/ModalConfirm.svelte";
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
import ModalNotificacion from "../Componentes/ModalNotificacion.svelte";
|
||||
@@ -34,6 +34,7 @@
|
||||
mesesAumento:0,
|
||||
mesesDuracion:0,
|
||||
});
|
||||
let defectos:DefectoDto[] = $state([]);
|
||||
|
||||
let modaldata:string = $state("");
|
||||
let contratoid:string = $state("");
|
||||
@@ -49,29 +50,38 @@
|
||||
const respPropiedad = fetch($urlG+"/api/contrato/propietario?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const respgarantes = fetch($urlG+"/api/contratos/garantes?idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const respCanons = fetch($urlG+"/api/contratos/canon?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c] = await Promise.all([respPropiedad, respgarantes, respCanons]);
|
||||
const respoDefect = fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
const [p, g, c, d] = await Promise.all([respPropiedad, respgarantes, respCanons, respoDefect]);
|
||||
|
||||
const datosPropiedad = await p.json();
|
||||
const datosGarantes = await g.json();
|
||||
const datosCanons = await c.json();
|
||||
const datosDefect = await d.json();
|
||||
|
||||
prop = datosPropiedad;
|
||||
garantes = datosGarantes;
|
||||
canons = datosCanons;
|
||||
defectos = datosDefect;
|
||||
} catch {
|
||||
modaldata = "Fallo hacer las request";
|
||||
}
|
||||
@@ -233,6 +243,44 @@
|
||||
function abrirModalNotif() {
|
||||
shownotif = true;
|
||||
}
|
||||
|
||||
|
||||
async function marcarDefectoPago(defecto: DefectoDto) {
|
||||
try{
|
||||
const r = await fetch($urlG+"/api/defecto/marcarpago?iddefecto="+defecto.id, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
let dr = await r.json();
|
||||
modaldata = dr.message;
|
||||
if (r.ok) {
|
||||
refreshDefectos();
|
||||
}
|
||||
|
||||
}catch {
|
||||
modaldata = "No se pudo marcar como pago";
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshDefectos() {
|
||||
try {
|
||||
const r = await fetch($urlG+"/api/defectos?Idcontrato="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": token,
|
||||
}
|
||||
});
|
||||
let rr =await r.json();
|
||||
defectos = rr;
|
||||
} catch {
|
||||
modaldata ="No se pudo pedir la lista de Defectos";
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -405,6 +453,64 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header" id="ht">
|
||||
<button
|
||||
class="accordion-button collapsed"
|
||||
type="button"
|
||||
data-bs-toggle="collapse"
|
||||
data-bs-target="#ct"
|
||||
aria-expanded="false"
|
||||
aria-controls="ct"
|
||||
>
|
||||
Defectos
|
||||
</button>
|
||||
</h2>
|
||||
<div
|
||||
id="ct"
|
||||
class="accordion-collapse collapse"
|
||||
aria-labelledby="ht"
|
||||
data-bs-parent="#accordionExample"
|
||||
>
|
||||
<div class="accordion-body">
|
||||
<table class="table table-hover table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Descripción</th>
|
||||
<th>Costo</th>
|
||||
<th>Estado</th>
|
||||
<th>Paga Inquilino</th>
|
||||
<th>Divisa</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if defectos.length == 0}
|
||||
<tr>
|
||||
<td colspan="6">No hay defectos que mostrar</td>
|
||||
</tr>
|
||||
{:else}
|
||||
{#each defectos as defecto}
|
||||
<tr>
|
||||
<td>{defecto.descripcion}</td>
|
||||
<td>{defecto.costo}</td>
|
||||
<td>{defecto.estado}</td>
|
||||
<td>{defecto.pagainquilino}</td>
|
||||
<td>{defecto.divisa}</td>
|
||||
<td>
|
||||
{#if defecto.estado !== "Pagado"}
|
||||
<button class="btn btn-secondary" onclick={()=>marcarDefectoPago(defecto)}>Marcar Pago</button>
|
||||
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
18
Front/src/types.d.ts
vendored
18
Front/src/types.d.ts
vendored
@@ -119,3 +119,21 @@ export type ContratoPropiedadDto ={
|
||||
mesesAumento:number,
|
||||
mesesDuracion:number
|
||||
}
|
||||
|
||||
export type DefectoDto ={
|
||||
id:number,
|
||||
descripcion:string,
|
||||
costo:number,
|
||||
estado:string,
|
||||
idcontrato:number,
|
||||
pagainquilino:string,
|
||||
divisa:string,
|
||||
}
|
||||
|
||||
export type AltaDefectoDto ={
|
||||
descripcion:string,
|
||||
costo:number,
|
||||
pagainquilino:number,
|
||||
iddivisa:number,
|
||||
idcontrato:number
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Modelo;
|
||||
|
||||
@@ -21,7 +22,10 @@ public class RepositorioDefectos: RepositorioBase<RepositorioDefectos> {
|
||||
public IQueryable<Defecto> ObtenerDefectosPorIdContrato(long idcontrato){
|
||||
var con = Context;
|
||||
|
||||
var l = con.Defectos.Where(x=>x.Idcontrato == idcontrato);
|
||||
var l = con.Defectos
|
||||
.Include(x=>x.IdestadoNavigation)
|
||||
.Include(x=>x.IddivisaNavigation)
|
||||
.Where(x=>x.Idcontrato == idcontrato);
|
||||
return l;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user