Esempio n. 1
0
        public List<EntidadResumen> IngresosEgresosByUn(EntidadResumen parFiltros)
        {

            /* VARIABLES
            -----------------------------------------------------------*/
            int anio = parFiltros.Anio;
            string compania = parFiltros.Compania;
            string unidadNegocio = parFiltros.UnidadNegocio;
            string proyecto = parFiltros.Proyecto;

            EntidadResumen control = new EntidadResumen();


            /* FILTROS
            -----------------------------------------------------------*/
            EntidadUnidadNegocio entidadCentro = new EntidadUnidadNegocio();
            entidadCentro.Compania = compania;
            entidadCentro.Clave = unidadNegocio;
            //entidadCentro.ProyectoTipo = "D";
            entidadCentro.Proyecto = proyecto;

            EntidadFactura entidadFactura = new EntidadFactura();
            entidadFactura.Anio = anio;
            entidadFactura.Compania = compania;


            /* Obtener Centros de Costos
            -----------------------------------------------------------*/
            TablaUnidadesNegocio tablaCentros = new TablaUnidadesNegocio(entidadCentro);
            List<EntidadUnidadNegocio> listaCentros = tablaCentros.Obtener();
            if (tablaCentros.Log == "OK")
            {

                /* Preparar la lista a devolver
                -----------------------------------------------------------*/
                List<EntidadResumen> listaResumen = new List<EntidadResumen>();

                foreach (EntidadUnidadNegocio centro in listaCentros)
                {
                    /* Prepara linea
                    -----------------------------------------------------------*/
                    EntidadResumen resumen = new EntidadResumen();
                    resumen.Anio = anio;
                    resumen.Compania = compania;
                    resumen.UnidadNegocio = centro.Clave;
                    resumen.UnidadNegocioDesc = centro.Descripcion;
                    resumen.Proyecto = centro.Proyecto;
                    resumen.ProyectoDesc = centro.ProyectoDesc;
                    resumen.Log = "-";

                    /* Obtener Ingreso
                    -----------------------------------------------------------*/
                    entidadFactura.CuentaFlujo = "ING";
                    entidadFactura.UnidadNegocio = centro.Clave;
                    VisMaCuentasCobradas vistaCC = new VisMaCuentasCobradas(entidadFactura);
                    List<EntidadFactura> listaCC = vistaCC.GroupByUn();
                    if (vistaCC.Log == "OK" || vistaCC.Log == "VACIO")
                    {
                        if (listaCC != null)
                        {
                            resumen.IngresoEnero = (from registro in listaCC select registro.Enero).Sum();
                            resumen.IngresoFebrero = (from registro in listaCC select registro.Febrero).Sum();
                            resumen.IngresoMarzo = (from registro in listaCC select registro.Marzo).Sum();
                            resumen.IngresoAbril = (from registro in listaCC select registro.Abril).Sum();
                            resumen.IngresoMayo = (from registro in listaCC select registro.Mayo).Sum();
                            resumen.IngresoJunio = (from registro in listaCC select registro.Junio).Sum();
                            resumen.IngresoJulio = (from registro in listaCC select registro.Julio).Sum();
                            resumen.IngresoAgosto = (from registro in listaCC select registro.Agosto).Sum();
                            resumen.IngresoSeptiembre = (from registro in listaCC select registro.Septiembre).Sum();
                            resumen.IngresoOctubre = (from registro in listaCC select registro.Octubre).Sum();
                            resumen.IngresoNoviembre = (from registro in listaCC select registro.Noviembre).Sum();
                            resumen.IngresoDiciembre = (from registro in listaCC select registro.Diciembre).Sum();

                            resumen.IngresoTotal = (from registro in listaCC select registro.Total).Sum();
                        }
                        else
                        {
                            resumen.IngresoEnero = 0.0f;
                            resumen.IngresoFebrero = 0.0f;
                            resumen.IngresoMarzo = 0.0f;
                            resumen.IngresoAbril = 0.0f;
                            resumen.IngresoMayo = 0.0f;
                            resumen.IngresoJunio = 0.0f;
                            resumen.IngresoJulio = 0.0f;
                            resumen.IngresoAgosto = 0.0f;
                            resumen.IngresoSeptiembre = 0.0f;
                            resumen.IngresoOctubre = 0.0f;
                            resumen.IngresoNoviembre = 0.0f;
                            resumen.IngresoDiciembre = 0.0f;

                            resumen.IngresoTotal = 0.0f;
                        }
                    }
                    else
                    {

                        control.Log = vistaCC.Log;
                        return this.Error(control);
                    }

                    /* Obtener Egreso
                    -----------------------------------------------------------*/
                    entidadFactura.CuentaFlujo = "EGR";
                    entidadFactura.UnidadNegocio = centro.Clave;
                    VisMaCuentasPagadas vistaCP = new VisMaCuentasPagadas(entidadFactura);
                    List<EntidadFactura> listaCP = vistaCP.GroupByUn();
                    if (vistaCP.Log == "OK" || vistaCP.Log == "VACIO")
                    {
                        if (listaCP != null)
                        {
                            resumen.EgresoEnero = (from registro in listaCP select registro.Enero).Sum();
                            resumen.EgresoFebrero = (from registro in listaCP select registro.Febrero).Sum();
                            resumen.EgresoMarzo = (from registro in listaCP select registro.Marzo).Sum();
                            resumen.EgresoAbril = (from registro in listaCP select registro.Abril).Sum();
                            resumen.EgresoMayo = (from registro in listaCP select registro.Mayo).Sum();
                            resumen.EgresoJunio = (from registro in listaCP select registro.Junio).Sum();
                            resumen.EgresoJulio = (from registro in listaCP select registro.Julio).Sum();
                            resumen.EgresoAgosto = (from registro in listaCP select registro.Agosto).Sum();
                            resumen.EgresoSeptiembre = (from registro in listaCP select registro.Septiembre).Sum();
                            resumen.EgresoOctubre = (from registro in listaCP select registro.Octubre).Sum();
                            resumen.EgresoNoviembre = (from registro in listaCP select registro.Noviembre).Sum();
                            resumen.EgresoDiciembre = (from registro in listaCP select registro.Diciembre).Sum();

                            resumen.EgresoTotal = (from registro in listaCP select registro.Total).Sum();
                        }
                        else
                        {
                            resumen.EgresoEnero = 0.0f;
                            resumen.EgresoFebrero = 0.0f;
                            resumen.EgresoMarzo = 0.0f;
                            resumen.EgresoAbril = 0.0f;
                            resumen.EgresoMayo = 0.0f;
                            resumen.EgresoJunio = 0.0f;
                            resumen.EgresoJulio = 0.0f;
                            resumen.EgresoAgosto = 0.0f;
                            resumen.EgresoSeptiembre = 0.0f;
                            resumen.EgresoOctubre = 0.0f;
                            resumen.EgresoNoviembre = 0.0f;
                            resumen.EgresoDiciembre = 0.0f;
                            resumen.EgresoTotal = 0.0f;
                        }
                    }
                    else
                    {
                        control.Log = vistaCC.Log;
                        return this.Error(control);
                    }

                    /* Obtener CXC
                    -----------------------------------------------------------*/
                    entidadFactura.CuentaFlujo = "ING";
                    entidadFactura.UnidadNegocio = centro.Clave;
                    VisMaCuentasXCobrar vistaCxc = new VisMaCuentasXCobrar(entidadFactura);
                    List<EntidadFactura> listaCxc = vistaCxc.GroupByUn();
                    if (vistaCxc.Log == "OK" || vistaCxc.Log == "VACIO")
                    {
                        if (listaCxc != null)
                        {
                            resumen.Cxc = (from registro in listaCxc select registro.Total).Sum();
                        }
                        else
                        {
                            resumen.Cxc = 0.0f;
                        }
                    }
                    else
                    {
                        control.Log = vistaCxc.Log;
                        return this.Error(control);
                    }

                    /* Obtener CXP
                    -----------------------------------------------------------*/
                    entidadFactura.CuentaFlujo = "EGR";
                    entidadFactura.UnidadNegocio = centro.Clave;
                    VisMaCuentasXPagar vistaCxp = new VisMaCuentasXPagar(entidadFactura);
                    List<EntidadFactura> listaCxp = vistaCxp.GroupByUn();
                    if (vistaCxp.Log == "OK" || vistaCxp.Log == "VACIO")
                    {
                        if (listaCxp != null)
                        {
                            resumen.Cxp = (from registro in listaCxp select registro.Total).Sum();
                        }
                        else
                        {
                            resumen.Cxp = 0.0f;
                        }

                    }
                    else
                    {
                        control.Log = vistaCxp.Log;
                        return this.Error(control);
                    }

                    // Agrega linea a lista a devolver
                    listaResumen.Add(resumen);
                }

                return listaResumen;
            }
            else
            {
                EntidadResumen error = new EntidadResumen();
                error.Log = tablaCentros.Log;
                return this.Error(error);
            }
        }
Esempio n. 2
0
        public List<EntidadFlujo> FlujosEfectivoByUn(EntidadFlujo parFiltros)
        {

            /* VARIABLES
            -----------------------------------------------------------*/
            int anio = parFiltros.Anio;
            string compania = parFiltros.Compania;
            string un = parFiltros.UnidadNegocio;

            float ingresoEjercido = 0.0f;
            float ingresoPendiente = 0.0f;
            float ingresoBudget = 0.0f;
            float ingresoBalance = 0.0f;
            float ingresoDesviacion = 0.0f;

            float egresoEjercido = 0.0f;
            float egresoPendiente = 0.0f;
            float egresoBudget = 0.0f;
            float egresoBalance = 0.0f;
            float egresoDesviacion = 0.0f;


            /* FILTROS
            -----------------------------------------------------------*/
            // Se preparan los filtros de entidades Factura
            EntidadFactura entidadFactura = new EntidadFactura();
            entidadFactura.Anio = anio;
            entidadFactura.Compania = compania;
            entidadFactura.UnidadNegocio = un;


            /* INGRESOS
            -----------------------------------------------------------*/
            // Se obtiene las Cuentas Cobradas
            entidadFactura.CuentaFlujo = "ING";
            VisMaCuentasCobradas vistaCuentasCobradas = new VisMaCuentasCobradas(entidadFactura);
            List<EntidadFactura> listaCuentasCobradas = vistaCuentasCobradas.GroupByUn();
            if (vistaCuentasCobradas.Log == "OK" || vistaCuentasCobradas.Log == "VACIO")
            {
                if (listaCuentasCobradas != null)
                {
                    ingresoEjercido = (from a in listaCuentasCobradas select a.Total).Sum();
                }
                else
                {
                    ingresoEjercido = 0.0f;
                }
            }
            else
            {
                EntidadFlujo error = new EntidadFlujo();
                error.Log = vistaCuentasCobradas.Log;
                return this.Error(error);
            }

            // Se obtiene las Cuentas X Cobrar
            VisMaCuentasXCobrar vistaCuentasXCobrar = new VisMaCuentasXCobrar(entidadFactura);
            List<EntidadFactura> listaCuentasXCobrar = vistaCuentasXCobrar.GroupByUn();
            if (vistaCuentasXCobrar.Log == "OK" || vistaCuentasXCobrar.Log == "VACIO")
            {
                if (listaCuentasXCobrar != null)
                {
                    ingresoPendiente = (from a in listaCuentasXCobrar select a.Total).Sum();
                }
                else
                {
                    ingresoPendiente = 0.0f;
                }
            }
            else
            {
                EntidadFlujo error = new EntidadFlujo();
                error.Log = vistaCuentasXCobrar.Log;
                return this.Error(error);
            }

            //Se Calcula la Balance y Desviacion
            ingresoBalance = ingresoEjercido + ingresoPendiente;
            ingresoDesviacion = ingresoBudget - ingresoBalance;


            /* EGRESOS
             -----------------------------------------------------------*/
            // Se obtiene las Cuentas Pagadas
            entidadFactura.CuentaFlujo = "EGR";
            VisMaCuentasPagadas vistaCuentasPagadas = new VisMaCuentasPagadas(entidadFactura);
            List<EntidadFactura> listaCuentasPagadas = vistaCuentasPagadas.GroupByUn();
            if (vistaCuentasPagadas.Log == "OK" || vistaCuentasPagadas.Log == "VACIO")
            {
                if (listaCuentasPagadas != null)
                {
                    egresoEjercido = (from a in listaCuentasPagadas select a.Total).Sum();
                }
                else
                {
                    egresoEjercido = 0.0f;
                }
            }
            else
            {
                EntidadFlujo error = new EntidadFlujo();
                error.Log = vistaCuentasPagadas.Log;
                return this.Error(error);
            }

            // Se obtiene las Cuentas X Pagar
            VisMaCuentasXPagar vistaCuentasXPagar = new VisMaCuentasXPagar(entidadFactura);
            List<EntidadFactura> listaCuentasXPagar = vistaCuentasXPagar.GroupByUn();
            if (vistaCuentasXPagar.Log == "OK" || vistaCuentasXPagar.Log == "VACIO")
            {
                if (listaCuentasXPagar != null)
                {
                    egresoPendiente = (from a in listaCuentasXPagar select a.Total).Sum();
                }
                else
                {
                    egresoPendiente = 0.0f;
                }
            }
            else
            {
                EntidadFlujo error = new EntidadFlujo();
                error.Log = vistaCuentasXPagar.Log;
                return this.Error(error);
            }

            // Se Calcula el Balance y Desviacion
            egresoBalance = egresoEjercido + egresoPendiente;
            egresoDesviacion = egresoBudget - egresoBalance;


            /* RESULTADOS (Lista de Ingresos y Egresos)
            -----------------------------------------------------------*/
            // Fila de Ingresos
            EntidadFlujo ingresos = new EntidadFlujo();
            ingresos.CuentaTipo = "INGRESO";
            ingresos.UnidadNegocio = un;
            ingresos.TotalEjercido = ingresoEjercido;
            ingresos.TotalPendiente = ingresoPendiente;
            ingresos.TotalBudget = ingresoBudget;
            ingresos.TotalBalance = ingresoBalance;
            ingresos.TotalDesviacion = ingresoDesviacion;
            ingresos.Log = "-";

            // Fila de Egresos
            EntidadFlujo egresos = new EntidadFlujo();
            egresos.CuentaTipo = "EGRESO";
            egresos.UnidadNegocio = un;
            egresos.TotalEjercido = egresoEjercido;
            egresos.TotalPendiente = egresoPendiente;
            egresos.TotalBudget = egresoBudget;
            egresos.TotalBalance = egresoBalance;
            egresos.TotalDesviacion = egresoDesviacion;
            egresos.Log = "-";

            // Lista de Ingresos y Egresos
            List<EntidadFlujo> datos = new List<EntidadFlujo>();

            datos.Add(ingresos);
            datos.Add(egresos);

            return datos;
        }