falta soporte para el menu de propietario de mostrar los archivos
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@
|
||||
/Entidades/obj/
|
||||
/Aspnet/obj/
|
||||
/Modelo/bin/
|
||||
Aspnet/bin/
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
|
||||
<PackageReference Include="minio" Version="6.0.3" />
|
||||
<PackageReference Include="QuestPDF" Version="2024.12.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Net;
|
||||
using System.Text.Json;
|
||||
using AlquilaFacil.Builder;
|
||||
using AlquilaFacil.Config;
|
||||
using AlquilaFacil.Facade;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -16,6 +17,51 @@ namespace AlquilaFacil.Controllers;
|
||||
[ApiController]
|
||||
public class ContratoController: ControllerBase {
|
||||
|
||||
[HttpPost("api/contrato/GenerarRecibo")]
|
||||
public ActionResult GenerarRecibo([FromHeader(Name="Auth")]string Auth, MarcarPagoDto dto, bool html= true) {
|
||||
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 (dto.Idcontrato <= 0) return BadRequest(new { message = "No puede tener un contrato con id 0 o menor"});
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.Idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "No hay un contrato por ese id"});
|
||||
|
||||
if (cont.DniinquilinoNavigation == null || cont.DnipropietarioNavigation == null || cont.IdpropiedadNavigation == null ||
|
||||
cont.IdpropiedadNavigation.IdtipropiedadNavigation == null) return BadRequest(new { message = "comunicate con el admin esta mal cargado el contratod de alguina forma"});
|
||||
|
||||
Canon? can = RepositorioCanons.Singleton.ObtenerCanonContrato(dto.fecha, dto.Idcontrato);
|
||||
if (can == null) return BadRequest(new { message = "no hay un canon para ese contrato con esa fecha"});
|
||||
if (can.IdreciboNavigation == null) return BadRequest(new { message = "No hay un recibo para ese canon"});
|
||||
|
||||
var cdb = new ContratoDtoBuilder()
|
||||
.SetInquilino($"{cont.DniinquilinoNavigation.Nombre} {cont.DniinquilinoNavigation.Apellido}")
|
||||
.SetUbicacion(cont.IdpropiedadNavigation.Ubicacion)
|
||||
.SetPropietario($"{cont.DnipropietarioNavigation.Nombre} {cont.DnipropietarioNavigation.Apellido}")
|
||||
.SetId(cont.Id)
|
||||
.SetTipo(cont.IdpropiedadNavigation.IdtipropiedadNavigation.Descripcion)
|
||||
.SetFechaInicio(cont.Fechainicio)
|
||||
.SetEstado(cont.Habilitado, cont.Cancelado)
|
||||
.Build();
|
||||
|
||||
var dof = new DocumentoFacade();
|
||||
MemoryStream? memstr = new();
|
||||
if (html){
|
||||
dof.GenerarHtml(cdb, can.IdreciboNavigation, memstr);
|
||||
return File(memstr, "text/html", "Recibo.html");
|
||||
} else {
|
||||
dof.GenerarPdf (cdb, can.IdreciboNavigation, memstr);
|
||||
return File(memstr, "application/pdf", "Recibo.pdf");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/marcarPago")]
|
||||
public IActionResult marcarPago([FromHeader(Name="Auth")]string Auth, MarcarPagoDto dto) {
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
@@ -73,7 +119,7 @@ public class ContratoController: ControllerBase {
|
||||
Ok(new { message = "Se guardo correctamente"}):BadRequest(new { message = "No se pudo guardar"});
|
||||
}
|
||||
|
||||
[HttpPost("api/contratos/crearcanons")] //WIP
|
||||
[HttpPost("api/contratos/crearcanons")]
|
||||
public IActionResult crearCanons([FromHeader(Name="Auth")]string Auth, CrearCanonsDto dto){
|
||||
if (String.IsNullOrEmpty(Auth)) return Unauthorized();
|
||||
var validacion1 = RepositorioGrupos.Singleton.CheckGrupos(Auth, "Propietario");
|
||||
@@ -81,7 +127,7 @@ public class ContratoController: ControllerBase {
|
||||
Cliente? cli = RepositorioUsuarios.Singleton.ObtenerClientePorToken(Auth);
|
||||
if (cli == null) return Unauthorized();
|
||||
|
||||
if (dto.aumento <=Decimal.Zero || dto.idcontrato <=0) return BadRequest(new { message ="estan mal cargados los datos"});
|
||||
if (dto.idcontrato <=0) return BadRequest(new { message ="estan mal cargados los datos"});
|
||||
|
||||
Contrato? cont = RepositorioContratos.Singleton.ObtenerContratoPorId(dto.idcontrato);
|
||||
if (cont == null) return BadRequest(new { message = "no hay un contrato por esa id"});
|
||||
|
||||
24
Aspnet/Facade/DocumentoFacade.cs
Normal file
24
Aspnet/Facade/DocumentoFacade.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
|
||||
namespace AlquilaFacil.Facade;
|
||||
|
||||
public class DocumentoFacade {
|
||||
private readonly DocumentoGeneradorHtml d1 = new();
|
||||
private readonly DocumentoGeneradorPdf d2 = new();
|
||||
|
||||
public void GenerarHtml(ContratoDto cd, Recibo r, MemoryStream memoryStream) {
|
||||
string str = d1.GenerarHTML(cd, r);
|
||||
StreamWriter writer = new StreamWriter(memoryStream, Encoding.UTF8);
|
||||
writer.WriteAsync(str).Wait();
|
||||
writer.FlushAsync().Wait();
|
||||
memoryStream.Position = 0;
|
||||
}
|
||||
public void GenerarPdf(ContratoDto cd, Recibo r, MemoryStream memoryStream) {
|
||||
var mem = d2.GenerarPdf(cd, r);
|
||||
mem.CopyToAsync(memoryStream).Wait();
|
||||
memoryStream.Position = 0;
|
||||
}
|
||||
}
|
||||
45
Aspnet/Facade/DocumentoGeneradorHtml.cs
Normal file
45
Aspnet/Facade/DocumentoGeneradorHtml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using Microsoft.AspNetCore.Routing.Template;
|
||||
|
||||
namespace AlquilaFacil.Facade;
|
||||
public class DocumentoGeneradorHtml {
|
||||
public string GenerarHTML(ContratoDto cd, Recibo r) {
|
||||
string tmpl =$"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<div class="card">
|
||||
<div class="card-header text-white bg-primary">
|
||||
AlquilaFácil
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Detalles</h5>
|
||||
<p class="card-text">
|
||||
<strong>ID:</strong> {cd.id}<br>
|
||||
<strong>Ubicación:</strong> {cd.Ubicacion}<br>
|
||||
<strong>Tipo de Propiedad:</strong> {cd.TipoPropiedad}<br>
|
||||
<strong>Fecha de Inicio:</strong> {cd.Fechainicio}<br>
|
||||
<strong>Inquilino:</strong> {cd.Inquilino}<br>
|
||||
<strong>Propietario:</strong> {cd.Propietario}<br>
|
||||
</p>
|
||||
<hr>
|
||||
<h5 class="card-title">Detalles del Recibo</h5>
|
||||
<p class="card-text">
|
||||
<strong>ID del Recibo:</strong> {r.Id}<br>
|
||||
<strong>Fecha:</strong> {r.Fecha}<br>
|
||||
<strong>Monto:</strong> {r.Monto}<br>
|
||||
<h2><b>PAGO</b></h2>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""; return tmpl;
|
||||
}
|
||||
}
|
||||
67
Aspnet/Facade/DocumentoGeneradorPdf.cs
Normal file
67
Aspnet/Facade/DocumentoGeneradorPdf.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Entidades;
|
||||
using Entidades.Dto;
|
||||
using QuestPDF.Fluent;
|
||||
using QuestPDF.Helpers;
|
||||
using QuestPDF.Infrastructure;
|
||||
using System.IO;
|
||||
|
||||
namespace AlquilaFacil.Facade;
|
||||
public class DocumentoGeneradorPdf {
|
||||
public MemoryStream GenerarPdf(ContratoDto cd, Recibo r)
|
||||
{
|
||||
var pdfStream = new MemoryStream();
|
||||
QuestPDF.Settings.License = LicenseType.Community;
|
||||
Document.Create(container =>
|
||||
{
|
||||
container.Page(page =>
|
||||
{
|
||||
page.Size(PageSizes.A4);
|
||||
page.Margin(2, Unit.Centimetre);
|
||||
page.Header().Text("AlquilaFácil").FontSize(20).SemiBold().FontColor(Colors.White);
|
||||
page.Content().Column(column =>
|
||||
{
|
||||
column.Spacing(10);
|
||||
|
||||
column.Item().Border(1).Padding(10).Column(card =>
|
||||
{
|
||||
card.Item().Row(row =>
|
||||
{
|
||||
row.RelativeItem().Text("Detalles").FontSize(16).SemiBold();
|
||||
});
|
||||
|
||||
card.Item().Column(body =>
|
||||
{
|
||||
body.Spacing(5);
|
||||
body.Item().Text($"ID: {cd.id}").FontSize(12).Bold();
|
||||
body.Item().Text($"Ubicación: {cd.Ubicacion}").FontSize(12);
|
||||
body.Item().Text($"Tipo de Propiedad: {cd.TipoPropiedad}").FontSize(12);
|
||||
body.Item().Text($"Fecha de Inicio: {cd.Fechainicio}").FontSize(12);
|
||||
body.Item().Text($"Inquilino: {cd.Inquilino}").FontSize(12);
|
||||
body.Item().Text($"Propietario: {cd.Propietario}").FontSize(12);
|
||||
});
|
||||
});
|
||||
|
||||
column.Item().Border(1).Padding(10).Column(card =>
|
||||
{
|
||||
card.Item().Row(row =>
|
||||
{
|
||||
row.RelativeItem().Text("Detalles del Recibo").FontSize(16).SemiBold();
|
||||
});
|
||||
|
||||
card.Item().Column(body =>
|
||||
{
|
||||
body.Spacing(5);
|
||||
body.Item().Text($"ID del Recibo: {r.Id}").FontSize(12).Bold();
|
||||
body.Item().Text($"Fecha: {r.Fecha}").FontSize(12);
|
||||
body.Item().Text($"Monto: {r.Monto}").FontSize(12);
|
||||
body.Item().AlignCenter().Text("PAGO").FontSize(20).Bold();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}).GeneratePdf(pdfStream);
|
||||
|
||||
pdfStream.Position = 0;
|
||||
return pdfStream;
|
||||
}
|
||||
}
|
||||
44
Front/src/Componentes/ModalPedirDoc.svelte
Normal file
44
Front/src/Componentes/ModalPedirDoc.svelte
Normal file
@@ -0,0 +1,44 @@
|
||||
<script lang="ts">
|
||||
let selectedOption = $state(false);
|
||||
|
||||
let {onClose, onSubmit}: {onClose:()=>void, onSubmit:(op:boolean)=>void} = $props();
|
||||
|
||||
const handleSubmit = (e:Event) => {
|
||||
e.preventDefault();
|
||||
onSubmit(selectedOption);
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
<div
|
||||
class="modal show d-block"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Selecciona una opción</h5>
|
||||
<button type="button" class="btn-close" aria-label="Close" onclick={onClose}></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={handleSubmit}>
|
||||
<div class="form-group mb-3">
|
||||
<label for="formatSelect">Formato</label>
|
||||
<select
|
||||
id="formatSelect"
|
||||
class="form-select"
|
||||
bind:value={selectedOption}
|
||||
>
|
||||
<option value="false">PDF</option>
|
||||
<option value="true">HTML</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary" onclick={handleSubmit}>Aceptar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,12 +4,12 @@
|
||||
import ModalEstatico from "../Componentes/ModalEstatico.svelte";
|
||||
import {urlG} from "../stores/urlStore";
|
||||
import type { CanonDto, ContratoDto, ContratoPropiedadDto, GaranteDto2 } from "../types";
|
||||
|
||||
import ModalPedirDoc from "../Componentes/ModalPedirDoc.svelte";
|
||||
|
||||
let token:string = sessionStorage.getItem("token")||"";
|
||||
|
||||
let interes:number = $state(0);
|
||||
|
||||
let selMod:any =$state();
|
||||
let showmodal:boolean = $state(false);
|
||||
let canons:CanonDto[] = $state([]);
|
||||
let garantes: GaranteDto2[] = $state([]);
|
||||
let prop:ContratoPropiedadDto = $state({
|
||||
@@ -74,11 +74,28 @@
|
||||
contratoid = par.get("id")||"";
|
||||
}
|
||||
|
||||
async function refreshCanon() {
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/canon?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (!ret.ok){
|
||||
let data = await ret.json();
|
||||
modaldata = data.message;
|
||||
return;
|
||||
}
|
||||
let data = await ret.json();
|
||||
canons = data;
|
||||
return;
|
||||
} catch {
|
||||
modaldata = "No se pudo obtener la lista de canones actualizada";
|
||||
}
|
||||
}
|
||||
|
||||
function submitnuevosCanones() {
|
||||
|
||||
}
|
||||
async function verContrato() {
|
||||
async function verContrato() {
|
||||
if (prop.id <= 0) {
|
||||
modaldata = "no hay contratos con id 0 o menor";
|
||||
return;
|
||||
@@ -105,6 +122,58 @@
|
||||
modaldata= "fallo intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function realizarpago(mes: Date) {
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/realizarPago", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({idcontrato:contratoid, fecha:mes}),
|
||||
});
|
||||
let data = await ret.json();
|
||||
modaldata = data.message;
|
||||
if (ret.ok){
|
||||
refreshCanon()
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generarTiket(mod) {
|
||||
selMod = mod;
|
||||
showmodal =true;
|
||||
}
|
||||
|
||||
async function pedirdocumento(op:boolean) {
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contrato/GenerarRecibo?html="+op, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
|
||||
body: JSON.stringify({fecha: selMod.mes, idcontrato: contratoid})
|
||||
});
|
||||
if (!ret.ok) {
|
||||
let blob = await ret.json();
|
||||
modaldata=blob.message;
|
||||
return;
|
||||
}
|
||||
let blob = await ret.blob();
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
window.open(blobUrl, '_blank');
|
||||
setTimeout(() => URL.revokeObjectURL(blobUrl), 100000);
|
||||
} catch {
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -112,6 +181,11 @@
|
||||
{#if modaldata}
|
||||
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||
{/if}
|
||||
|
||||
{#if showmodal}
|
||||
<ModalPedirDoc onClose={()=>showmodal=false} onSubmit={pedirdocumento} />
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid mt-4 d-flex">
|
||||
<div class="col-md-4 me-4">
|
||||
<div class="card">
|
||||
@@ -219,10 +293,10 @@
|
||||
<p><strong>Pago:</strong> {canon.pago ? "Sí" : "No"}</p>
|
||||
</div>
|
||||
<div class="card-footer d-flex justify-content-between">
|
||||
<button class="btn btn-primary btn-xs" disabled={canon.pago}>
|
||||
<button class="btn btn-primary btn-xs" disabled={canon.pago} onclick={()=>realizarpago(canon.mes)}>
|
||||
Pagar
|
||||
</button>
|
||||
<button class="btn btn-info btn-xs" disabled={!canon.pago}>
|
||||
<button class="btn btn-info btn-xs" disabled={!canon.pago} onclick={()=> generarTiket(canon)}>
|
||||
Generar Tiket
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -75,8 +75,24 @@
|
||||
contratoid = par.get("id")||"";
|
||||
}
|
||||
|
||||
function submitnuevosCanones() {
|
||||
async function submitnuevosCanones() {
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/crearcanons",{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth" : String(token),
|
||||
},
|
||||
body: JSON.stringify({idcontrato: contratoid, aumento: interes})
|
||||
});
|
||||
|
||||
let data = await ret.json();
|
||||
modaldata = data.message;
|
||||
if (ret.ok) {
|
||||
refreshCanon();
|
||||
}
|
||||
} catch {
|
||||
modaldata = "Fallo al intentar alcanzar el servidor";
|
||||
}
|
||||
}
|
||||
|
||||
async function verContrato() {
|
||||
@@ -106,6 +122,53 @@
|
||||
modaldata= "fallo intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshCanon() {
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/canon?id="+contratoid, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
}
|
||||
});
|
||||
if (!ret.ok){
|
||||
let data = await ret.json();
|
||||
modaldata = data.message;
|
||||
return;
|
||||
}
|
||||
let data = await ret.json();
|
||||
canons = data;
|
||||
return;
|
||||
} catch {
|
||||
modaldata = "No se pudo obtener la lista de canones actualizada";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function marcarPago(mes: Date) {
|
||||
try {
|
||||
const ret = await fetch($urlG+"/api/contratos/marcarPago", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Auth": String(token),
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({idcontrato:contratoid, fecha:mes}),
|
||||
});
|
||||
let data = await ret.json();
|
||||
modaldata = data.message;
|
||||
if (ret.ok){
|
||||
refreshCanon()
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
modaldata = "Fallo al intentar hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function generarTiket(mes: Date) { //WIP
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<NavBarAutocompletable/>
|
||||
@@ -114,7 +177,6 @@
|
||||
<ModalEstatico payload={modaldata} close={()=>!!(modaldata = "")}/>
|
||||
{/if}
|
||||
|
||||
<ModalConfirm />
|
||||
<div class="container-fluid mt-4 d-flex">
|
||||
<div class="col-md-4 me-4">
|
||||
<div class="card">
|
||||
@@ -222,10 +284,10 @@
|
||||
<p><strong>Pago:</strong> {canon.pago ? "Sí" : "No"}</p>
|
||||
</div>
|
||||
<div class="card-footer d-flex justify-content-between">
|
||||
<button class="btn btn-warning btn-xs" disabled={canon.pago}>
|
||||
<button class="btn btn-warning btn-xs" disabled={canon.pago} onclick={()=>marcarPago(canon.mes)}>
|
||||
Marcar Pago
|
||||
</button>
|
||||
<button class="btn btn-info btn-xs" disabled={!canon.pago}>
|
||||
<button class="btn btn-info btn-xs" disabled={!canon.pago} onclick={()=> generarTiket(canon.mes)}>
|
||||
Generar Tiket
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Entidades;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Org.BouncyCastle.Math.EC.Rfc7748;
|
||||
|
||||
namespace Modelo;
|
||||
|
||||
@@ -14,17 +15,13 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
||||
var con = Context;
|
||||
Canon? cc = null;
|
||||
|
||||
var c = con.Canons.FirstOrDefault(x => x.Idrecibo == null &&
|
||||
x.Fecha == f );
|
||||
var c = con.Contratos.Include(x=>x.Idcanons).ThenInclude(x=>x.IdreciboNavigation).FirstOrDefault(x => x.Id == idcont);
|
||||
if (c == null) return null;
|
||||
//no deberia de tener que usar un foreach pero entity por algun motivo mapeo
|
||||
//la entidad como muchos a muchos. no hay forma de que un canon tenga multiples
|
||||
//contratos por como lo codifique pero igualmente
|
||||
foreach (var i in c.Idcontratos) {
|
||||
foreach (var j in i.Idcanons) {
|
||||
if (j.Fecha == f) {
|
||||
cc = j;
|
||||
}
|
||||
|
||||
foreach (var j in c.Idcanons) {
|
||||
if (j.Fecha == f) {
|
||||
cc = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cc;
|
||||
@@ -52,6 +49,10 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
||||
if (cont == null) return false;
|
||||
|
||||
int exist = cont.Idcanons.Count();
|
||||
Canon? d = cont.Idcanons.OrderByDescending(x=>x.Fecha).FirstOrDefault();
|
||||
if (d == null) return false;
|
||||
|
||||
|
||||
if (exist+cont.MesesHastaAumento >= cont.MesesDurationContrato){
|
||||
exist = cont.MesesDurationContrato-exist;
|
||||
} else{
|
||||
@@ -62,8 +63,14 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
||||
|
||||
for (int i = 0; i < exist; i++){
|
||||
Canon c = new Canon{
|
||||
Fecha
|
||||
Fecha = d.Fecha.AddMonths(i==0?1:i+1),
|
||||
Id = con.Canons.Count()+i+1,
|
||||
Monto = cont.Monto,
|
||||
Pagado = 0,
|
||||
};
|
||||
con.Canons.Add(c);
|
||||
cont.Idcanons.Add(c);
|
||||
}
|
||||
return Guardar(con);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user