public override ListIndexModel GetListIndexModel(Type t, bool canEliminar, bool canModificar, string controller) { var model = CuentasService.GetTercerosIndexModel <AgentesModel>(_context, controller, canEliminar, canModificar); model.List = GetAll <CuentasBusqueda>(); return(model); }
public CuentasModel Cuentaabono2(string circuito) { var idcircuito = Int32.Parse(circuito); var cuentasService = new CuentasService(_context); var cuenta = _db.CircuitosTesoreriaCobros.Where(f => f.empresa == Empresa && f.id == idcircuito).Select(f => f.cuentaabono2).SingleOrDefault() ?? ""; return(!String.IsNullOrEmpty(cuenta) ? cuentasService.get(cuenta) as CuentasModel : null); }
public IEnumerable <CuentasModel> getCuentasTesoreriaExclusive(string tipoasignacion, string fkcuentas, string importe) { List <CuentasModel> cuentas = new List <CuentasModel>(); var vencimientosService = new VencimientosService(_context); List <VencimientosModel> vencimientos = new List <VencimientosModel>(); vencimientos.AddRange(vencimientosService.getVencimientos(tipoasignacion, "", fkcuentas, importe)); var cuentasService = new CuentasService(_context); foreach (var vencimiento in vencimientos) { cuentas.Add(cuentasService.get(vencimiento.Fkcuentatesoreria) as CuentasModel); } return(cuentas); }
public IEnumerable <CuentasModel> getCuentasTesoreria() { List <CuentasModel> cuentas = new List <CuentasModel>(); var cuentastesoreria = _db.Cuentastesoreria.Where(f => f.empresa == Empresa); var cuentasService = new CuentasService(_context); foreach (var cuenta in cuentastesoreria) { var cuentaModel = cuentasService.get(cuenta.fkcuentas) as CuentasModel; if (!cuentaModel.Bloqueado) { cuentas.Add(cuentaModel); } } return(cuentas); }
public void GenerarMovimiento(MovsModel model, TipoOperacionMaes tipo)// short multiplo) // multiplo 1 para alta -1 para baja { // nivel 0 foreach (var item in model.Lineas.GroupBy(l => l.Fkcuentas)) { string fkcuentas = item.Key; //Creamos la cuenta en caso de que no exista en el proceso de asignar a cartera if(!_db.Cuentas.Any(f => f.empresa == model.Empresa && f.id == fkcuentas) && model.Generar == GenerarMovimientoAPartirDe.AsignarCartera) { var nuevacuenta = new CuentasModel(_context); nuevacuenta.Empresa = model.Empresa; nuevacuenta.Id = fkcuentas; nuevacuenta.Descripcion = "**ALTA CUENTA AUTOMÁTICA**"; nuevacuenta.Descripcion2 = "**ALTA CUENTA AUTOMÁTICA**"; nuevacuenta.UsuarioId = _db.Usuarios.Where(f => f.usuario == _context.Usuario).Select(f => f.id.ToString()).SingleOrDefault() ?? ""; nuevacuenta.Nivel = 0; var id = model.Lineas[1].Fkcuentas.ToString(); var newNif = new NifCifModel { Nif = _db.Cuentas.Where(f => f.empresa == Empresa && f.id == id).Select(f => f.nif).SingleOrDefault() ?? "" }; nuevacuenta.Nif = newNif; nuevacuenta.FkPais = _db.Cuentas.Where(f => f.empresa == Empresa && f.id == id).Select(f => f.fkPais).SingleOrDefault() ?? ""; nuevacuenta.Fechaalta = DateTime.Now; var cuentaService = new CuentasService(_context); cuentaService.create(nuevacuenta); } var itemmaes = _db.Maes.SingleOrDefault(f => f.empresa == model.Empresa && f.fkcuentas == fkcuentas && f.fkejercicio == model.Fkejercicio) ?? _db.Maes.Create(); if (string.IsNullOrWhiteSpace(itemmaes.empresa)) { itemmaes.empresa = model.Empresa; itemmaes.fkcuentas = fkcuentas; itemmaes.fkejercicio = model.Fkejercicio; } int multiplo = (tipo == TipoOperacionMaes.Alta ? 1 : -1); itemmaes.debe = (itemmaes.debe ?? 0) + (item.Where(l=>l.Esdebe == 1).Sum(l=> l.Importe) * (multiplo)); itemmaes.haber = (itemmaes.haber ?? 0) + (item.Where(l => l.Esdebe == -1).Sum(l => l.Importe) * (multiplo)); itemmaes.saldo = (itemmaes.debe ?? 0) - (itemmaes.haber ?? 0); _db.Maes.AddOrUpdate(itemmaes); } // nivel 0 - 4 for (int nivel = 4; nivel > 0; nivel--) { foreach (var item in model.Lineas.GroupBy(l=> l.Fkcuentas.Substring(0, nivel))) { string fkcuentas = item.Key;//.Substring(0, nivel); var itemmaes = _db.Maes.SingleOrDefault(f => f.empresa == model.Empresa && f.fkcuentas == fkcuentas && f.fkejercicio == model.Fkejercicio) ?? _db.Maes.Create(); if(string.IsNullOrWhiteSpace(itemmaes.empresa)) { itemmaes.empresa = model.Empresa; itemmaes.fkcuentas = fkcuentas; itemmaes.fkejercicio = model.Fkejercicio; } int multiplo = (tipo == TipoOperacionMaes.Alta ? 1 : -1); itemmaes.debe = (itemmaes.debe ?? 0) + (item.Where(l => l.Esdebe == 1).Sum(l => l.Importe) * (multiplo)); itemmaes.haber = (itemmaes.haber ?? 0) + (item.Where(l => l.Esdebe == -1).Sum(l => l.Importe) * (multiplo)); itemmaes.saldo = (itemmaes.debe ?? 0) - (itemmaes.haber ?? 0); _db.Maes.AddOrUpdate(itemmaes); } } }
//Te devuelve una direccion a partir del numero de la cuenta public DireccionesLinModel getDireccion(string numcuenta) { DireccionesLinModel d = new DireccionesLinModel(_context); var appService = new ApplicationHelper(_context); var _paises = appService.GetListPaises(); var cuentasService = new CuentasService(_context); var clientesService = new ClientesService(_context); var proveedoresService = new ProveedoresService(_context); var acreedoresService = new AcreedoresService(_context); var tesoreriaService = new CuentastesoreriaService(_context); var transportistasService = new TransportistasService(_context); var agentesService = new AgentesService(_context); var aseguradorasService = new AseguradorasService(_context); var operariosService = new OperariosService(_context); var comercialesService = new ComercialesService(_context); var prospectosService = new ProspectosService(_context); var listaTerceros = cuentasService.GetCuentas(TiposCuentas.Todas).ToList(); var listaClientes = cuentasService.GetCuentas(TiposCuentas.Clientes).ToList(); var listaProveedores = cuentasService.GetCuentas(TiposCuentas.Proveedores).ToList(); var listaAcreedores = cuentasService.GetCuentas(TiposCuentas.Acreedores).ToList(); var listaTesoreria = cuentasService.GetCuentas(TiposCuentas.Cuentastesoreria).ToList(); var listaTransportistas = cuentasService.GetCuentas(TiposCuentas.Transportistas).ToList(); var listaAgentes = cuentasService.GetCuentas(TiposCuentas.Agentes).ToList(); var listaAseguradoras = cuentasService.GetCuentas(TiposCuentas.Aseguradoras).ToList(); var listaOperarios = cuentasService.GetCuentas(TiposCuentas.Operarios).ToList(); var listaComerciales = cuentasService.GetCuentas(TiposCuentas.Comerciales).ToList(); var listaProspectos = cuentasService.GetCuentas(TiposCuentas.Prospectos).ToList(); if (listaClientes.Any(f => f.Id == numcuenta)) { var clienteModel = clientesService.get(numcuenta) as ClientesModel; d.Empresa = clienteModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = clienteModel.Descripcion; d.Direccion = clienteModel.Direccion; d.Poblacion = clienteModel.Poblacion; d.Provincia = clienteModel.Provincia; d.Pais = clienteModel.Pais; d.Email = clienteModel.Email; d.Telefono = clienteModel.Telefono; } else if (listaProveedores.Any(f => f.Id == numcuenta)) { var proveedorModel = proveedoresService.get(numcuenta) as ProveedoresModel; d.Empresa = proveedorModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = proveedorModel.Descripcion; d.Direccion = proveedorModel.Direccion; d.Poblacion = proveedorModel.Poblacion; d.Provincia = proveedorModel.Provincia; d.Pais = proveedorModel.Pais; d.Email = proveedorModel.Email; d.Telefono = proveedorModel.Telefono; } else if (listaAcreedores.Any(f => f.Id == numcuenta)) { var acreedorModel = acreedoresService.get(numcuenta) as AcreedoresModel; d.Empresa = acreedorModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = acreedorModel.Descripcion; d.Direccion = acreedorModel.Direccion; d.Poblacion = acreedorModel.Poblacion; d.Provincia = acreedorModel.Provincia; d.Pais = acreedorModel.Pais; d.Email = acreedorModel.Email; d.Telefono = acreedorModel.Telefono; } else if (listaTesoreria.Any(f => f.Id == numcuenta)) { var tesoreriaModel = tesoreriaService.get(numcuenta) as CuentastesoreriaModel; d.Empresa = tesoreriaModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = tesoreriaModel.Descripcion; d.Direccion = tesoreriaModel.Direccion; d.Poblacion = tesoreriaModel.Poblacion; d.Provincia = tesoreriaModel.Provincia; d.Pais = tesoreriaModel.Pais; d.Email = tesoreriaModel.Email; d.Telefono = tesoreriaModel.Telefono; } else if (listaTransportistas.Any(f => f.Id == numcuenta)) { var transportistaModel = transportistasService.get(numcuenta) as TransportistasModel; d.Empresa = transportistaModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = transportistaModel.Descripcion; d.Direccion = transportistaModel.Direccion; d.Poblacion = transportistaModel.Poblacion; d.Provincia = transportistaModel.Provincia; d.Pais = transportistaModel.Pais; d.Email = transportistaModel.Email; d.Telefono = transportistaModel.Telefono; } else if (listaAgentes.Any(f => f.Id == numcuenta)) { var agenteModel = agentesService.get(numcuenta) as AgentesModel; d.Empresa = agenteModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = agenteModel.Descripcion; d.Direccion = agenteModel.Direccion; d.Poblacion = agenteModel.Poblacion; d.Provincia = agenteModel.Provincia; d.Pais = agenteModel.Pais; d.Email = agenteModel.Email; d.Telefono = agenteModel.Telefono; } else if (listaAseguradoras.Any(f => f.Id == numcuenta)) { var aseguradoraModel = aseguradorasService.get(numcuenta) as AseguradorasModel; d.Empresa = aseguradoraModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = aseguradoraModel.Descripcion; d.Direccion = aseguradoraModel.Direccion; d.Poblacion = aseguradoraModel.Poblacion; d.Provincia = aseguradoraModel.Provincia; d.Pais = aseguradoraModel.Pais; d.Email = aseguradoraModel.Email; d.Telefono = aseguradoraModel.Telefono; } else if (listaComerciales.Any(f => f.Id == numcuenta)) { var comercialModel = comercialesService.get(numcuenta) as ComercialesModel; d.Empresa = comercialModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = comercialModel.Descripcion; d.Direccion = comercialModel.Direccion; d.Poblacion = comercialModel.Poblacion; d.Provincia = comercialModel.Provincia; d.Pais = comercialModel.Pais; d.Email = comercialModel.Email; d.Telefono = comercialModel.Telefono; } else if (listaOperarios.Any(f => f.Id == numcuenta)) { var operarioModel = operariosService.get(numcuenta) as OperariosModel; d.Empresa = operarioModel.Empresa; d.Fkentidad = numcuenta; d.Descripcion = operarioModel.Descripcion; d.Direccion = operarioModel.Direccion; d.Poblacion = operarioModel.Poblacion; d.Provincia = operarioModel.Provincia; d.Pais = operarioModel.Pais; d.Email = operarioModel.Email; d.Telefono = operarioModel.Telefono; } return(d); }