una cosa más hecha
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
using Entidades.Dto;
|
||||||
|
|
||||||
|
namespace AlquilaFacil.Builder;
|
||||||
|
public class VentasDtoBuilder: Builder<VentasDto> {
|
||||||
|
public VentasDtoBuilder SetId(long id) {
|
||||||
|
data.Id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetMonto(decimal monto) {
|
||||||
|
data.Monto = monto;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetDivisa(string divisa) {
|
||||||
|
data.Divisa = divisa;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetUbicacion(string ubicacion) {
|
||||||
|
data.Ubicacion = ubicacion;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetNombreVendedor(string nombre) {
|
||||||
|
data.NombreVendedor = nombre;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetIdVendedor(long idVendedor) {
|
||||||
|
data.Id = idVendedor;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetNombreComprador(string nombre) {
|
||||||
|
data.NombreComprador = nombre;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetIdComprador(long Id) {
|
||||||
|
data.IdComprador = Id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public VentasDtoBuilder SetEstado(string estado) {
|
||||||
|
data.Estado = estado;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,17 +47,74 @@ public class VentaController:ControllerBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
[HttpGet("/api/venta")]
|
[HttpGet("/api/venta")]
|
||||||
public IActionResult ObtenerVenta(long idventa) {
|
public IActionResult ObtenerVenta([FromHeader(Name="Auth")]string Auth, long idventa=0) {
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false){
|
||||||
|
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false) {
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idventa <= 0) return BadRequest(new { message = "No existen ventas validas para la id 0"});
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return Unauthorized();
|
||||||
|
|
||||||
|
var ventas = RepositorioVentas.Singleton.ObtenerVentaPorId(idventa);
|
||||||
|
if (ventas == null) return BadRequest(new { message ="No hay una venta con ese id"});
|
||||||
|
if (ventas.IdVendedor !=cli.Dni && ventas.IdComprador != cli.Dni) return Unauthorized();
|
||||||
|
|
||||||
|
var v = new VentasDtoBuilder()
|
||||||
|
.SetId(ventas.Id)
|
||||||
|
.SetMonto(ventas.Monto)
|
||||||
|
.SetDivisa(ventas.IddivisaNavigation.Signo)
|
||||||
|
.SetUbicacion(ventas.IdpropiedadNavigation.Ubicacion)
|
||||||
|
.SetNombreVendedor($"{ventas.IdVendedorNavigation.Nombre} {ventas.IdVendedorNavigation.Apellido}")
|
||||||
|
.SetIdVendedor(ventas.IdVendedor??0)
|
||||||
|
.SetNombreComprador($"{ventas.IdCompradorNavigation.Nombre} {ventas.IdCompradorNavigation.Apellido}")
|
||||||
|
.SetIdComprador(ventas.IdComprador??0)
|
||||||
|
.SetEstado(ventas.IdestadoNavigation.Descripcion??"")
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return Ok(new { data = v, iscomprador = (ventas.IdComprador==cli.Dni)?true:false});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("/api/ventas")]
|
[HttpGet("/api/ventas")]
|
||||||
public IActionResult ObtenerVenta(long idventa) {
|
public IActionResult ObtenerVenta([FromHeader(Name="Auth")]string Auth) {
|
||||||
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
if (validacion1 == false){
|
||||||
|
validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Inquilino");
|
||||||
|
if (validacion1 == false) {
|
||||||
|
return Unauthorized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||||
|
if (cli == null) return Unauthorized();
|
||||||
|
|
||||||
|
var ventas = RepositorioVentas.Singleton.ObtenerVentasPorDni(cli.Dni);
|
||||||
|
if (ventas == null) return BadRequest(new { message ="no estas involucrado en ninguna venta o compra"});
|
||||||
|
|
||||||
|
List<VentasDto> lista = new();
|
||||||
|
foreach (var i in ventas) {
|
||||||
|
var v = new VentasDtoBuilder()
|
||||||
|
.SetId(i.Id)
|
||||||
|
.SetMonto(i.Monto)
|
||||||
|
.SetDivisa(i.IddivisaNavigation.Signo)
|
||||||
|
.SetUbicacion(i.IdpropiedadNavigation.Ubicacion)
|
||||||
|
.SetNombreVendedor($"{i.IdVendedorNavigation.Nombre} {i.IdVendedorNavigation.Apellido}")
|
||||||
|
.SetIdVendedor(i.IdVendedor??0)
|
||||||
|
.SetNombreComprador($"{i.IdCompradorNavigation.Nombre} {i.IdCompradorNavigation.Apellido}")
|
||||||
|
.SetIdComprador(i.IdComprador??0)
|
||||||
|
.SetEstado(i.IdestadoNavigation.Descripcion??"")
|
||||||
|
.Build();
|
||||||
|
lista.Add(v);
|
||||||
|
}
|
||||||
|
return Ok(lista);
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
[HttpGet("/api/opcionventa")]
|
[HttpGet("/api/opcionventa")]
|
||||||
public IActionResult ObtenerDto([FromHeader(Name="Auth")]string Auth, long idcontrato=0) {
|
public IActionResult ObtenerDto([FromHeader(Name="Auth")]string Auth, long idcontrato=0) {
|
||||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Entidades.Dto;
|
||||||
|
public class VentasDto {
|
||||||
|
public long Id { get; set; }
|
||||||
|
public decimal Monto { get; set; }
|
||||||
|
public string Divisa { get; set; }="";
|
||||||
|
public string Ubicacion { get; set; }="";
|
||||||
|
public string NombreVendedor { get; set; }="";
|
||||||
|
public long IdVendedor { get; set; }
|
||||||
|
public string NombreComprador { get; set; }="";
|
||||||
|
public long IdComprador { get; set; }
|
||||||
|
public string Estado { get; set; }="";
|
||||||
|
}
|
||||||
+13
-1
@@ -21,7 +21,9 @@
|
|||||||
import ControlAlquileresPropietario from "./paginas/ControlAlquileresPropietario.svelte";
|
import ControlAlquileresPropietario from "./paginas/ControlAlquileresPropietario.svelte";
|
||||||
import ContratosPropietario from "./paginas/ContratosPropietario.svelte";
|
import ContratosPropietario from "./paginas/ContratosPropietario.svelte";
|
||||||
import ContratoInquilino from "./paginas/ContratoInquilino.svelte";
|
import ContratoInquilino from "./paginas/ContratoInquilino.svelte";
|
||||||
import Informes from "./paginas/Informes.svelte";
|
import Informes from "./paginas/Informes.svelte";
|
||||||
|
import CompraYVentas from "./paginas/CompraYVenta.svelte";
|
||||||
|
import Ventas from "./paginas/Ventas.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Router>
|
<Router>
|
||||||
@@ -95,6 +97,16 @@
|
|||||||
<ProteRoute componente={ControlAlquileresPropietario}/>
|
<ProteRoute componente={ControlAlquileresPropietario}/>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
<!-- Compra y Ventas -->
|
||||||
|
<Route path="/accion/13">
|
||||||
|
<ProteRoute componente={CompraYVentas}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
|
<!-- Pagina Ventas -->
|
||||||
|
<Route path="/Ventas">
|
||||||
|
<ProteRoute componente={Ventas}/>
|
||||||
|
</Route>
|
||||||
|
|
||||||
<!--Paginas info Grupo-->
|
<!--Paginas info Grupo-->
|
||||||
<Route path="/grupo/Inquilino">
|
<Route path="/grupo/Inquilino">
|
||||||
<ProteRoute componente={FrontInquilino}/>
|
<ProteRoute componente={FrontInquilino}/>
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
import type { VentasDto } from "../types";
|
||||||
|
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||||
|
import { urlG } from "../stores/urlStore";
|
||||||
|
import Ventas from "./Ventas.svelte";
|
||||||
|
import { navigate } from "svelte-routing";
|
||||||
|
|
||||||
|
let token:string = sessionStorage.getItem("token")||"";
|
||||||
|
let modaldata:string = $state("");
|
||||||
|
|
||||||
|
let ventas:VentasDto[] = $state([]);
|
||||||
|
|
||||||
|
onMount(()=>{
|
||||||
|
obtenerVentas();
|
||||||
|
});
|
||||||
|
|
||||||
|
async function obtenerVentas() {
|
||||||
|
try{
|
||||||
|
const r = await fetch($urlG+"/api/ventas", {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Auth": token
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let data = await r.json();
|
||||||
|
if (!r.ok){
|
||||||
|
modaldata = data;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ventas = data;
|
||||||
|
}catch{
|
||||||
|
modaldata = "Fallo al hacer la request";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
|
|
||||||
|
{#if modaldata}
|
||||||
|
<ModalEstatico payload={modaldata} close={()=> !!(modaldata = "")} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<div class="container-fluid mt-3">
|
||||||
|
<div class="row">
|
||||||
|
{#each ventas as venta (venta.id)}
|
||||||
|
<div class="col-md-6 mb-4">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h5>{venta.nombreVendedor} → {venta.nombreComprador}</h5>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p class="card-text">
|
||||||
|
<strong>Monto:</strong> {venta.monto} {venta.divisa}<br>
|
||||||
|
<strong>Ubicación:</strong> {venta.ubicacion}<br>
|
||||||
|
<strong>Estado:</strong> {venta.estado}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer d-flex justify-content-center">
|
||||||
|
<button class="btn btn-secondary" onclick={()=>navigate("/Ventas?idventa="+venta.id)}>Ver</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.card {
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -525,7 +525,7 @@
|
|||||||
Ejercer
|
Ejercer
|
||||||
</button>
|
</button>
|
||||||
{#if dtoVenta.fueEjercido}
|
{#if dtoVenta.fueEjercido}
|
||||||
<button class="btn btn-secondary" onclick={()=>navigate("/accion/13?idventa="+dtoVenta.id)}>
|
<button class="btn btn-secondary" onclick={()=>navigate("/Ventas?idventa="+dtoVenta.id)}>
|
||||||
Ir a la pagina de la Venta
|
Ir a la pagina de la Venta
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -591,7 +591,7 @@
|
|||||||
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
|
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>
|
</p>
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<button class="btn btn-primary" disabled={!dtoVenta.fueEjercido} onclick={()=>navigate("/accion/13?idventa="+dtoVenta.id)}>
|
<button class="btn btn-primary" disabled={!dtoVenta.fueEjercido} onclick={()=>navigate("/Ventas?idventa="+dtoVenta.id)}>
|
||||||
Ir a la pagina de la Venta
|
Ir a la pagina de la Venta
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import NavBarAutocompletable from "../Componentes/NavBarAutocompletable.svelte";
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<NavBarAutocompletable/>
|
||||||
Vendored
+12
@@ -153,3 +153,15 @@ export type OpcionVentaDto = {
|
|||||||
enOrden:boolean,
|
enOrden:boolean,
|
||||||
fueEjercido:boolean
|
fueEjercido:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type VentasDto = {
|
||||||
|
id:number,
|
||||||
|
monto:numver,
|
||||||
|
divisa:string,
|
||||||
|
ubicacion:string,
|
||||||
|
nombreVendedor:string,
|
||||||
|
idVendedor:number,
|
||||||
|
nombreComprador:string,
|
||||||
|
idComprador:number,
|
||||||
|
estado:string,
|
||||||
|
}
|
||||||
@@ -11,6 +11,33 @@ public class RepositorioVentas: RepositorioBase<RepositorioVentas> {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Venta? ObtenerVentaPorId(long idventa) {
|
||||||
|
var con = Context;
|
||||||
|
var vent = con.Ventas
|
||||||
|
.Include(x=>x.IddivisaNavigation)
|
||||||
|
.Include(x=>x.IdestadoNavigation)
|
||||||
|
.Include(x=>x.IdVendedorNavigation)
|
||||||
|
.Include(x=>x.IdCompradorNavigation)
|
||||||
|
.Include(x=>x.IdpropiedadNavigation)
|
||||||
|
.Where(x=>x.Idestado != 1)
|
||||||
|
.FirstOrDefault(x=>x.Id == idventa);
|
||||||
|
if (vent == null) return null;
|
||||||
|
return vent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IQueryable<Venta>? ObtenerVentasPorDni(long dni) {
|
||||||
|
var con = Context;
|
||||||
|
var venta = con.Ventas
|
||||||
|
.Include(x=>x.IddivisaNavigation)
|
||||||
|
.Include(x=>x.IdestadoNavigation)
|
||||||
|
.Include(x=>x.IdVendedorNavigation)
|
||||||
|
.Include(x=>x.IdCompradorNavigation)
|
||||||
|
.Include(x=>x.IdpropiedadNavigation)
|
||||||
|
.Where(x=>(x.IdComprador == dni || x.IdVendedor == dni) && x.Idestado!=1 )
|
||||||
|
.Distinct();
|
||||||
|
return venta;
|
||||||
|
}
|
||||||
|
|
||||||
public bool PatchVenta(Venta venta) {
|
public bool PatchVenta(Venta venta) {
|
||||||
var con = Context;
|
var con = Context;
|
||||||
var a = con.Ventas.FirstOrDefault(x=>x.Id == venta.Id);
|
var a = con.Ventas.FirstOrDefault(x=>x.Id == venta.Id);
|
||||||
|
|||||||
Reference in New Issue
Block a user