Avances hasta las 16

This commit is contained in:
2025-01-17 16:05:31 -03:00
parent 2b757e527f
commit 9a088a37b2
7 changed files with 428 additions and 17 deletions

View File

@@ -10,5 +10,36 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
if (l == null) return null;
return l.Idcanons;
}
public Canon? ObtenerCanonContrato(DateTime f, long idcont) {
var con = Context;
Canon? cc = null;
var c = con.Canons.FirstOrDefault(x => x.Idrecibo == null &&
x.Fecha == f );
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;
}
}
}
return cc;
}
public bool SetRecibo(Canon c, Recibo re) {
var con = Context;
var cc = con.Canons.FirstOrDefault(x=>x.Id == c.Id);
if (cc == null) return false;
re.Id = (con.Recibos.Any()?con.Recibos.Max(x=>x.Id):0)+1;
con.Recibos.Add(re);
cc.Idrecibo = re.Id;
cc.Pagado = 1;
return Guardar(con);
}
}