inicio soporte informe
This commit is contained in:
@@ -29,14 +29,28 @@ public class RepositorioCanons: RepositorioBase<RepositorioCanons> {
|
||||
|
||||
public bool SetRecibo(Canon c, Recibo re) {
|
||||
var con = Context;
|
||||
var cc = con.Canons.FirstOrDefault(x=>x.Id == c.Id);
|
||||
var cc = con.Canons
|
||||
.Include(x=>x.Idcontratos)
|
||||
.ThenInclude(x=>x.Idcanons)
|
||||
.FirstOrDefault(x=>x.Id == c.Id);
|
||||
if (cc == null) return false;
|
||||
|
||||
if (cc.Idcontratos.Count()!=1) return false;
|
||||
Contrato ccc = cc.Idcontratos.First();
|
||||
if (ccc.Cancelado == 1 || ccc.Habilitado == 0) return false;
|
||||
con.Entry(ccc).Reference(x=>x.IdpropiedadNavigation).Load();
|
||||
|
||||
re.Id = (con.Recibos.Any()?con.Recibos.Max(x=>x.Id):0)+1;
|
||||
con.Recibos.Add(re);
|
||||
cc.Idrecibo = re.Id;
|
||||
cc.Pagado = 1;
|
||||
|
||||
|
||||
if (ccc.Idcanons.Where(x=>x.Pagado==1).Count() == ccc.MesesDurationContrato){
|
||||
ccc.Cancelado = 1;
|
||||
ccc.IdpropiedadNavigation.Idestado = 3;
|
||||
}
|
||||
|
||||
return Guardar(con);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user