falta interfaz venta

This commit is contained in:
2025-01-24 21:31:37 -03:00
parent f8692ccdf0
commit 2b481e2ae2
13 changed files with 457 additions and 15 deletions

View File

@@ -14,7 +14,7 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
}
}
public bool CargaPrecontrato(Contrato? c = null, Notificacione? n = null) {
public bool CargaPrecontrato( Contrato? c = null, Notificacione? n = null) {
if (c == null || c.Habilitado == 1) return false;
if (n == null) return false;
var con = Context;
@@ -201,4 +201,39 @@ public class RepositorioContratos: RepositorioBase<RepositorioContratos> {
var con = Context;
return con.Contratos.Where(x=>x.Fechainicio.Year == year).Any();
}
public bool SetOpcionVenta(Venta v, long idcontrato) {
var con = Context;
var cont = con.Contratos.Include(x=>x.IdventaNavigation).FirstOrDefault(x=>x.Id == idcontrato);
if (cont != null) return false;
v.Id = (con.Ventas.Any()?con.Ventas.Count():0)+1;
cont.IdventaNavigation = v;
con.Ventas.Add(v);
return Guardar(con);
}
public bool CargaPrecontratoOpcionVenta(Contrato c, Notificacione n, Venta v) {
if (c == null || c.Habilitado == 1) return false;
if (n == null) return false;
var con = Context;
var prop = con.Propiedades.FirstOrDefault(x=>x.Id==c.Idpropiedad);
if (prop == null) return false;
prop.Idestado = 2;
c.Iddivisa = prop.Iddivisa;
c.Id = (con.Contratos.Any() ? con.Contratos.Max(x => x.Id) : 0) + 1;
c.Monto = prop.Monto;
v.Id = (con.Ventas.Any()?con.Ventas.Count():0)+1;
c.Idventa = v.Id;
con.Ventas.Add(v);
con.Contratos.Add(c);
con.Notificaciones.Add(n);
return Guardar(con);
}
}

View File

@@ -0,0 +1,26 @@
using Entidades;
using Microsoft.EntityFrameworkCore;
namespace Modelo;
public class RepositorioVentas: RepositorioBase<RepositorioVentas> {
public Contrato? ObtenerVentaPorContrato(long idcontrato) {
var con = Context;
var c = con.Contratos.Include(x=>x.Idcanons).Include(x=>x.IdventaNavigation).ThenInclude(x=>x.IddivisaNavigation)
.FirstOrDefault(x=>x.Id == idcontrato);
if (c == null || c.IdventaNavigation == null) return null;
return c;
}
public bool PatchVenta(Venta venta) {
var con = Context;
var a = con.Ventas.FirstOrDefault(x=>x.Id == venta.Id);
a.IdVendedor = venta.IdVendedor;
a.IdComprador = venta.IdComprador;
a.Idpropiedad = venta.Idpropiedad;
a.Fechainicio = venta.Fechainicio;
a.Idestado=2;
return Guardar(con);
}
}