Example #1
0
        public ProformaController()
        {
            UsuarioDTO user = getCurrentUser();
            if (user != null)
            {
                this.navbar = new Navbar();
                ViewBag.currentUser = user;
                ViewBag.NombreEmpresa = user.nombreEmpresa;
                ViewBag.Title = "";

                ViewBag.EsAdmin = isAdministrator();
                ViewBag.EsSuperAdmin = isSuperAdministrator();
                ViewBag.EsUsuarioInterno = isUsuarioInterno();
                ViewBag.EsUsuarioExterno = isUsuarioExterno();
                ViewBag.IdRol = user.IdRol;

                EmpresaBL empBL = new EmpresaBL();
                ViewBag.Empresas = empBL.getEmpresasViewBag();
            }
            else { ViewBag.EsAdmin = false; ViewBag.EsSuperAdmin = false; }
            CultureInfo[] cultures = { new CultureInfo("es-PE") };
        }
Example #2
0
        public ActionResult Movimiento(int? id = null, int? idLibro = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            ViewBag.Title = "Movimiento";
            MenuNavBarSelected(1);
            UsuarioDTO miUsuario = getCurrentUser();

            EmpresaBL empBL = new EmpresaBL();
            EmpresaDTO empresa = empBL.getEmpresa(miUsuario.IdEmpresa);

            ViewBag.SimboloMoneda = empresa.SimboloMoneda;

            MovimientoBL objBL = new MovimientoBL();
            ViewBag.IdMovimiento = id;
            ViewBag.EstadosMovimientos = objBL.getEstadosMovimientos(false);

            CuentaBancariaBL objCuentaBL = new CuentaBancariaBL();
            CuentaBancariaDTO objLibro = objCuentaBL.getCuentaBancariaSoloEnEmpresa(miUsuario.IdEmpresa, idLibro.GetValueOrDefault());
            if (objLibro == null) { return RedirectToAction("Index", "Admin"); }

            ViewBag.IdTipoCuenta = objLibro.IdTipoCuenta;
            ViewBag.lstTipoMovs = objBL.getTiposMovimientos();
            ViewBag.lstFormaMovs = ViewBag.IdTipoCuenta == 1 ? objBL.getListaFormaDeMovimientos() : objBL.getListaFormaDeMovimientosBasic();

            EntidadResponsableBL entBL = new EntidadResponsableBL();
            ViewBag.TipoEntidades = entBL.getTipoDeEntidades();
            ViewBag.EntidadesResponsables = objBL.getEntidadesResponsablesEnEmpresa(miUsuario.IdEmpresa, false);

            ViewBag.lstTiposDeDocumento = objBL.getListaTiposDeDocumentoVB(true);
            ViewBag.NombreCategoria = "Sin Categoría";
            ViewBag.Categorias = CategoriasBucle(empresa.IdEmpresa, (int)empresa.IdPeriodo, null, null);
            ViewBag.Comprobantes = objBL.getComprobantesPendientesEnEmpresa(miUsuario.IdEmpresa);

            var objSent = TempData["Movimiento"];
            if (objSent != null) { TempData["Movimiento"] = null; return View(objSent); }
            if (id == 0 && idLibro != null)
            {
                MovimientoDTO nuevo = new MovimientoDTO();
                nuevo.IdCuentaBancaria = (int)idLibro;
                nuevo.Fecha = DateTime.Now;
                nuevo.TipoCambio = (new EmpresaBL()).getEmpresa(miUsuario.IdEmpresa).TipoCambio;
                nuevo.NumeroDocumento = null;
                //nuevo.Comentario = "No existe comentario";
                nuevo.Estado = true;
                nuevo.UsuarioCreacion = miUsuario.IdUsuario;
                nuevo.FechaCreacion = DateTime.Now;
                return View(nuevo);
            }
            else
            {
                if (id != null)
                {
                    MovimientoDTO obj = objBL.getMovimiento((int)id);
                    if (obj == null) return RedirectToAction("Libro", "Admin", new { id = objLibro.IdCuentaBancaria });
                    if (obj.IdCuentaBancaria != objLibro.IdCuentaBancaria) return RedirectToAction("Libro", "Admin", new { id = objLibro.IdCuentaBancaria });

                    CuentaBancariaDTO objLibroMov = objCuentaBL.getCuentaBancariaEnEmpresa(miUsuario.IdEmpresa, obj.IdCuentaBancaria);
                    if (objLibroMov == null) return RedirectToAction("Index", "Admin");
                    if (objLibroMov.IdEmpresa != miUsuario.IdEmpresa) return RedirectToAction("Index", "Admin");

                    obj.UsuarioCreacion = miUsuario.IdUsuario;
                    ViewBag.NombreCategoria = objBL.getNombreCategoria(obj.IdCategoria.GetValueOrDefault());
                    return View(obj);
                }
            }
            return View();
        }
Example #3
0
        public ActionResult AddCategoria(CategoriaDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }

            try
            {
                CategoriaBL objBL = new CategoriaBL();
                if (dto.IdCategoria == 0)
                {
                    if (objBL.add(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Categorias");
                    }
                }
                else if (dto.IdCategoria != 0)
                {
                    EmpresaBL empBL = new EmpresaBL();
                    int vPeriodo = empBL.getEmpresa(getCurrentUser().IdEmpresa).IdPeriodo.GetValueOrDefault();

                    if (objBL.update(dto, vPeriodo))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Categorias");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }

                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }
            catch (Exception e)
            {
                if (dto.IdCategoria != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Categoria"] = dto;
            return RedirectToAction("Categoria");
        }
Example #4
0
        public AdminController()
        {
            UsuarioDTO user = getCurrentUser();
            if (user != null)
            {
                this.navbar = new Navbar();
                ViewBag.currentUser = user;
                ViewBag.NombreEmpresa = user.nombreEmpresa;
                //ViewBag.Title = "NubeBooks";

                ViewBag.EsAdmin = isAdministrator();
                ViewBag.EsSuperAdmin = isSuperAdministrator();
                ViewBag.EsUsuarioInterno = isUsuarioInterno();
                ViewBag.EsUsuarioExterno = isUsuarioExterno();
                ViewBag.IdRol = user.IdRol;

                EmpresaBL empBL = new EmpresaBL();
                ViewBag.Empresas = empBL.getEmpresasViewBag();
            }
            else { ViewBag.EsAdmin = false; ViewBag.EsSuperAdmin = false; }
        }
Example #5
0
        public string ActualizarTipoCambio(Decimal tipoCambio)
        {
            if (!this.currentUser() || !isAdministrator()) { return "false"; }

            EmpresaBL objBL = new EmpresaBL();
            UsuarioDTO miUsuario = getCurrentUser();
            EmpresaDTO obj = new EmpresaDTO() { IdEmpresa = miUsuario.IdEmpresa, TipoCambio = tipoCambio };
            if (objBL.updateTipoCambio(obj))
            {
                return "true";
            }
            return "false";
        }
Example #6
0
        public ActionResult Categorias()
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!isAdministrator()) { return RedirectToAction("Index"); }

            ViewBag.Title = "Partidas de Presupuesto";

            MenuNavBarSelected(8, 0);
            EmpresaBL empBL = new EmpresaBL();

            UsuarioDTO miUsuario = getCurrentUser();
            EmpresaDTO empresa = empBL.getEmpresa(miUsuario.IdEmpresa);
            ViewBag.IdPeriodo = empresa.IdPeriodo.GetValueOrDefault();
            ViewBag.SimboloMoneda = empresa.SimboloMoneda;

            CategoriaBL objBL = new CategoriaBL();
            ViewBag.Periodos = objBL.GetPeriodosEnEmpresaViewBag(miUsuario.IdEmpresa);
            List<CategoriaDTO> listaCategorias = new List<CategoriaDTO>();
            if (empresa.IdEmpresa > 0 && empresa.IdPeriodo > 0)
            {
                //listaCategorias = objBL.getCategoriasPorPeriodo_ArbolEnEmpresa(empresa.IdEmpresa, (int)empresa.IdPeriodo);
                listaCategorias = objBL.getCategoriasTreeEnEmpresa(empresa.IdEmpresa);
            }

            return View(listaCategorias);
        }
Example #7
0
        public JsonResult ActualizarPresupuesto(int idCategoria, Decimal Monto)
        {
            if (!this.currentUser() || !isAdministrator()) { return Json(false, JsonRequestBehavior.AllowGet); }

            CategoriaBL objBL = new CategoriaBL();
            EmpresaBL empBL = new EmpresaBL();
            int pPeriodo = empBL.getEmpresa(getCurrentUser().IdEmpresa).IdPeriodo.GetValueOrDefault();
            if (pPeriodo == 0) { return Json(false, JsonRequestBehavior.AllowGet); }

            CategoriaPorPeriodoDTO dto = new CategoriaPorPeriodoDTO() { IdCategoria = idCategoria, IdPeriodo = pPeriodo, Monto = Monto };
            objBL.updatePresupuesto(dto);

            return Json(true, JsonRequestBehavior.AllowGet);
        }
Example #8
0
        public ActionResult Libros(int? idTipoCuenta = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            ViewBag.Title = "Libros";
            MenuNavBarSelected(1);

            UsuarioDTO miUsuario = getCurrentUser();

            CuentaBancariaBL objBL = new CuentaBancariaBL();
            ViewBag.lstTipoCuentas = objBL.getTipoDeCuentas();
            ViewBag.idTipoCuenta = idTipoCuenta;
            List<CuentaBancariaDTO> listaLibros = new List<CuentaBancariaDTO>();

            if (miUsuario.IdEmpresa != 0)
            {
                EmpresaBL empBL = new EmpresaBL();
                Decimal miTipoCambio = empBL.getEmpresa((int)miUsuario.IdEmpresa).TipoCambio;

                listaLibros = objBL.getCuentasBancariasEnEmpresa(miUsuario.IdEmpresa);
                ViewBag.TotalSoles = DameTotalSoles(listaLibros);
                ViewBag.TotalDolares = DameTotalDolares(listaLibros);

                ViewBag.TotalConsolidado = DameTotalConsolidado(listaLibros, miTipoCambio);
                ViewBag.TipoCambio = miTipoCambio;
            }
            else
            {
                ViewBag.TotalSoles = 0.0;
                ViewBag.TotalDolares = 0.0;
                ViewBag.TotalConsolidado = 0.0;
                ViewBag.TipoCambio = 1.0;
            }

            return View("Libros", listaLibros);
        }
Example #9
0
        public string ActualizarPeriodo(int idPeriodo)
        {
            if (!this.currentUser() || !isAdministrator()) { return "false"; }

            EmpresaBL objBL = new EmpresaBL();
            UsuarioDTO miUsuario = getCurrentUser();
            EmpresaDTO obj = new EmpresaDTO() { IdEmpresa = miUsuario.IdEmpresa, IdPeriodo = idPeriodo };
            if (objBL.updatePeriodo(obj))
            {
                return "true";
            }
            return "false";
        }
Example #10
0
        public ActionResult AddEmpresa(EmpresaDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            try
            {
                EmpresaBL objBL = new EmpresaBL();
                if (dto.IdEmpresa == 0)
                {
                    if (objBL.add(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Index");
                    }
                }
                else if (dto.IdEmpresa != 0)
                {
                    if (objBL.update(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Index");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }

                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }
            catch (Exception e)
            {
                if (dto.IdEmpresa != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Empresa"] = dto;
            return RedirectToAction("Empresa");
        }
Example #11
0
        public ActionResult Empresa()
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (!this.isAdministrator()) { return RedirectToAction("Index"); }
            MenuNavBarSelected(0);
            UsuarioDTO currentUser = getCurrentUser();

            EmpresaBL objBL = new EmpresaBL();
            ViewBag.lstMonedas = objBL.getListaMonedas();

            var objSent = TempData["Empresa"];
            if (objSent != null) { TempData["Empresa"] = null; return View(objSent); }
            
            EmpresaDTO obj = objBL.getEmpresaBasic(getCurrentUser().IdEmpresa);
            if (obj == null) return RedirectToAction("Index");
            return View(obj);
        }
Example #12
0
        public ActionResult Index()
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            MenuNavBarSelected(0);

            UsuarioDTO user = getCurrentUser();

            EmpresaBL objBL = new EmpresaBL();

            EmpresaDTO empresaOld = objBL.getEmpresa(user.IdEmpresa);
            EmpresaDTO empresa = objBL.getEmpresa(user.IdEmpresa);
            ViewBag.FechaConciliacion = empresa.FechaConciliacion.GetValueOrDefault().ToString("dd/MM/yy", CultureInfo.CreateSpecificCulture("en-GB"));
            ViewBag.TotalSoles = empresa.TotalSoles.GetValueOrDefault();
            ViewBag.TotalDolares = empresa.TotalDolares.GetValueOrDefault();
            ViewBag.TotalSolesOld = empresa.TotalSolesOld.GetValueOrDefault();
            ViewBag.TotalDolaresOld = empresa.TotalDolaresOld.GetValueOrDefault();

            if (empresa.IdMoneda == 1)
            { ViewBag.TotalConsolidado = empresa.TotalSoles.GetValueOrDefault() + empresa.TotalDolares.GetValueOrDefault() * empresa.TipoCambio; }
            else
            { ViewBag.TotalConsolidado = empresa.TotalDolares.GetValueOrDefault() + empresa.TotalSoles.GetValueOrDefault() / empresa.TipoCambio; }

            ViewBag.TipoCambio = empresa.TipoCambio;
            ViewBag.TipoMoneda = empresa.IdMoneda;
            ViewBag.sMoneda = empresa.SimboloMoneda;
            //Liquidez
            ViewBag.lstLiquidezSoles = objBL.getLiquidezEnEmpresaPorMoneda(user.IdEmpresa, 1);
            ViewBag.lstLiquidezDolares = objBL.getLiquidezEnEmpresaPorMoneda(user.IdEmpresa, 2);
            //Rentabilidad
            ViewBag.lstRentabilidad = objBL.getRentabilidadEnEmpresaSegunMoneda(user.IdEmpresa, empresa.IdMoneda);
            //Facturacion y Variacion Porcentual
            List<LiquidezDTO> lista1 = objBL.getFacturacionEnEmpresaPorMoneda(user.IdEmpresa, empresa.IdMoneda, DateTime.Now);
            List<LiquidezDTO> lista2 = objBL.getFacturacionEnEmpresaPorMoneda(user.IdEmpresa, empresa.IdMoneda, DateTime.Now.AddYears(-1));
            ViewBag.lstFacturacion = lista1; ViewBag.lstFacturacionLastYear = lista2;
            ViewBag.lstVPorcentual = objBL.getVariacionPorcentual_12Meses(lista1, lista2);
            //Ejecucion de Presupuesto
            ViewBag.EjecucionIngresos = objBL.getEjecucionDePresupuestoEnEmpresa(user.IdEmpresa, empresa.IdMoneda, empresa.IdPeriodo.GetValueOrDefault(), 1);
            ViewBag.EjecucionEgresos = objBL.getEjecucionDePresupuestoEnEmpresa(user.IdEmpresa, empresa.IdMoneda, empresa.IdPeriodo.GetValueOrDefault(), 2);
            //Cuentas por Cobrar y Cuentas por Pagar
            ViewBag.CuentasXCobrar_Soles = objBL.Get_CuentasPorCobrar(empresa.IdEmpresa, 1);
            ViewBag.CuentasXCobrar_Dolares = objBL.Get_CuentasPorCobrar(empresa.IdEmpresa, 2);
            ViewBag.CuentasXPagar_Soles = objBL.Get_CuentasPorPagar(empresa.IdEmpresa, 1);
            ViewBag.CuentasXPagar_Dolares = objBL.Get_CuentasPorPagar(empresa.IdEmpresa, 2);
            //Cartera Morosa - dias vencidos
            ComprobanteBL cmpBL = new ComprobanteBL();
            List<ComprobanteDTO> lstCarteraMorosa = cmpBL.getComprobantesIngresosYEgresosEnEmpresa_diasVencidos(empresa.IdEmpresa, 1);
            ViewBag.CarteraM_Soles = cmpBL.CarteraMorosa_porMoneda(1, lstCarteraMorosa);
            ViewBag.CarteraM_Dolares = cmpBL.CarteraMorosa_porMoneda(2, lstCarteraMorosa);
            ViewBag.CarteraM_Soles_Count = cmpBL.CarteraMorosa_Count_porMoneda(1, lstCarteraMorosa);
            ViewBag.CarteraM_Dolares_Count = cmpBL.CarteraMorosa_Count_porMoneda(2, lstCarteraMorosa);

            //Principales clientes y proveedores
            ViewBag.top5Clientes = objBL.getTop5Clientes(user.IdEmpresa, empresa.IdPeriodo.GetValueOrDefault());
            ViewBag.top5Proveedores = objBL.getTop5Proveedores(user.IdEmpresa, empresa.IdPeriodo.GetValueOrDefault());
            //Ingresos por Area
            ViewBag.topIngAreas = objBL.getTopIngArea(user.IdEmpresa, empresa.IdPeriodo.GetValueOrDefault());
            ViewBag.topEgrAreas = objBL.getTopEgrArea(user.IdEmpresa, empresa.IdPeriodo.GetValueOrDefault());
            //Contador de Movimientos y Comprobantes en los meses
            //ViewBag.contMovimientos = objBL.getContadorDeMovimientos(user.IdEmpresa);
            //ViewBag.contComprobantes = objBL.getContadorDeComprobantes(user.IdEmpresa);

            return View();
        }
Example #13
0
        public ActionResult Proforma(int? id)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar", "Admin", new { Area = string.Empty }); }
            ViewBag.Title += "Proforma";
            MenuNavBarSelected(12);

            UsuarioDTO user = getCurrentUser();


            EntidadResponsableBL entBL = new EntidadResponsableBL();
            ViewBag.lstClientes = entBL.getEntidadesResponsablesActivasPorTipoEnEmpresa(user.IdEmpresa, 1);
            EmpresaBL empBL = new EmpresaBL();
            ViewBag.lstMonedas = empBL.getListaMonedasAll();
            MovimientoInvBL movItmBL = new MovimientoInvBL();
            ViewBag.lstItems = movItmBL.getItemsEnEmpresa_PorTipoMov(user.IdEmpresa, 1);
            CuentaBancariaBL cbBL = new CuentaBancariaBL();
            ViewBag.lstCuentasBancarias = cbBL.getCuentasBancariasActivasPorTipoEnEmpresa(user.IdEmpresa, 1);
            ViewBag.lstContactos = new List<ContactoDTO>();

            var objSent = TempData["Proforma"];
            if (objSent != null) { TempData["Proforma"] = null; return View(objSent); }

            ProformaDTO obj;
            if(id != null && id > 0)
            {
                obj = new ProformaBL().getProformaId((int)id);
                return View(obj);
            }
            obj = new ProformaDTO();
            obj.IdEmpresa = user.IdEmpresa;
            obj.FechaProforma = DateTime.Now;
            obj.DetalleProforma = new List<DetalleProformaDTO>();

            return View(obj);
        }