예제 #1
0
        public List<EntidadFlujo> EgresosByCuentaDesc(EntidadFlujo parFiltros)
        {
            /* VARIABLES
            -----------------------------------------------------------*/
            int anio = parFiltros.Anio;
            int periodo = parFiltros.Periodo;
            string proyecto = parFiltros.Proyecto;
            string compania = parFiltros.Compania;
            string un = parFiltros.UnidadNegocio;
            string cuentaClaseDesc = parFiltros.CuentaClaseDesc;
            string cuentaFlujo = "EGR";

            /* FILTROS
            -----------------------------------------------------------*/
            // Se preparan los filtros de Cuentas
            EntidadCuenta entidadCuenta = new EntidadCuenta();
            entidadCuenta.Proyecto = proyecto;
            entidadCuenta.Compania = compania;
            entidadCuenta.UnidadNegocio = un;
            entidadCuenta.ClaseDesc = cuentaClaseDesc;
            entidadCuenta.Flujo = cuentaFlujo;

            // Se preparan los filtros de Presupuestos
            EntidadBudget entidadBudget = new EntidadBudget();
            entidadBudget.Anio = anio;
            entidadBudget.Proyecto = proyecto;
            entidadBudget.Compania = compania;
            entidadBudget.UnidadNegocio = un;
            entidadBudget.CuentaClaseDesc = cuentaClaseDesc;
            entidadBudget.CuentaFlujo = cuentaFlujo;

            // Se preparan los filtros de Factura
            EntidadFactura entidadFactura = new EntidadFactura();
            entidadFactura.Anio = anio;
            entidadFactura.Proyecto = proyecto;
            entidadFactura.Compania = compania;
            entidadFactura.UnidadNegocio = un;
            entidadFactura.Periodo = periodo;
            entidadFactura.CuentaClaseDesc = cuentaClaseDesc;
            entidadFactura.CuentaFlujo = cuentaFlujo;


            /* SE OBTIENEN LAS CUENTAS
            -----------------------------------------------------------*/
            VistaCuentas vistaCuentas = new VistaCuentas(entidadCuenta);
            List<EntidadCuenta> listaCuentas = new List<EntidadCuenta>();

            // Se agregan cuentas virtuales de clasificación
            if (entidadCuenta.ClaseDesc == "ANTICIPOS SIN FACTURA")
            {
                EntidadCuenta auxCuenta = new EntidadCuenta();
                auxCuenta.ClaseDesc = "ANTICIPOS SIN FACTURA";
                auxCuenta.Descripcion = "COMPRAS";
                listaCuentas.Add(auxCuenta);

                EntidadCuenta auxCuenta2 = new EntidadCuenta();
                auxCuenta2.ClaseDesc = "ANTICIPOS SIN FACTURA";
                auxCuenta2.Descripcion = "OTROS";
                listaCuentas.Add(auxCuenta2);

                EntidadCuenta auxCuenta3 = new EntidadCuenta();
                auxCuenta3.ClaseDesc = "ANTICIPOS SIN FACTURA";
                auxCuenta3.Descripcion = "DEPOSITOS EN GARANTIA";
                listaCuentas.Add(auxCuenta3);

                EntidadCuenta auxCuenta4 = new EntidadCuenta();
                auxCuenta4.ClaseDesc = "ANTICIPOS SIN FACTURA";
                auxCuenta4.Descripcion = "VIATICOS SIN COMPROBAR";
                listaCuentas.Add(auxCuenta4);
            }
            else
            {
                listaCuentas = vistaCuentas.GroupByDesc();
            }

            if (listaCuentas != null)
            {

                /* SE OBTIENEN LOS PRESUPUESTOS
                -----------------------------------------------------------*/
                VistaBudgets vistaBudgets = new VistaBudgets(entidadBudget);
                List<EntidadBudget> listaBudgets = vistaBudgets.GroupByCuentaDesc();
                if (vistaBudgets.Log == "VACIO")
                {
                    listaBudgets = new List<EntidadBudget>();
                }
                else if (vistaBudgets.Log != "OK")
                {
                    EntidadFlujo error = new EntidadFlujo();
                    error.Log = vistaBudgets.Log;
                    return this.Error(error);
                }


                /* SE OBTIENEN LAS CUENTAS PAGADAS
                -----------------------------------------------------------*/
                VisMaCuentasPagadas vistaCuentasPagadas = new VisMaCuentasPagadas(entidadFactura);
                List<EntidadFactura> listaPagos = vistaCuentasPagadas.GroupByCuentaDesc();
                if (vistaCuentasPagadas.Log == "VACIO")
                {
                    listaPagos = new List<EntidadFactura>();
                }
                else if (vistaCuentasPagadas.Log != "OK")
                {
                    EntidadFlujo error = new EntidadFlujo();
                    error.Log = vistaCuentasPagadas.Log;
                    return this.Error(error);
                }


                /* SE GRENERAN LOS JOINS ENTE RESULTADOS
                -----------------------------------------------------------*/
                var query = (
                                from CuBu in
                                    (
                                        from Cu in listaCuentas
                                        join Bu in listaBudgets
                                        on Cu.Descripcion equals Bu.CuentaDesc into JCuBu
                                        from Bu in JCuBu.DefaultIfEmpty()
                                        select new
                                        {
                                            CuentaDesc = Cu.Descripcion,
                                            EneroPresu = Bu != null ? Bu.Enero : 0,
                                            FebreroPresu = Bu != null ? Bu.Febrero : 0,
                                            MarzoPresu = Bu != null ? Bu.Marzo : 0,
                                            AbrilPresu = Bu != null ? Bu.Abril : 0,
                                            MayoPresu = Bu != null ? Bu.Mayo : 0,
                                            JunioPresu = Bu != null ? Bu.Junio : 0,
                                            JulioPresu = Bu != null ? Bu.Julio : 0,
                                            AgostoPresu = Bu != null ? Bu.Agosto : 0,
                                            SeptiembrePresu = Bu != null ? Bu.Septiembre : 0,
                                            OctubrePresu = Bu != null ? Bu.Octubre : 0,
                                            NoviembrePresu = Bu != null ? Bu.Noviembre : 0,
                                            DiciembrePresu = Bu != null ? Bu.Diciembre : 0,
                                            TotalPresu = Bu != null ? Bu.Total : 0
                                        }
                                     )
                                join Co in listaPagos
                                on CuBu.CuentaDesc equals Co.CuentaDesc into JCuBuCo
                                from Co in JCuBuCo.DefaultIfEmpty()
                                select new
                                {
                                    CuentaDesc = CuBu.CuentaDesc,
                                    EneroPresu = CuBu.EneroPresu,
                                    FebreroPresu = CuBu.FebreroPresu,
                                    MarzoPresu = CuBu.MarzoPresu,
                                    AbrilPresu = CuBu.AbrilPresu,
                                    MayoPresu = CuBu.MayoPresu,
                                    JunioPresu = CuBu.JunioPresu,
                                    JulioPresu = CuBu.JulioPresu,
                                    AgostoPresu = CuBu.AgostoPresu,
                                    SeptiembrePresu = CuBu.SeptiembrePresu,
                                    OctubrePresu = CuBu.OctubrePresu,
                                    NoviembrePresu = CuBu.NoviembrePresu,
                                    DiciembrePresu = CuBu.DiciembrePresu,
                                    TotalPresu = CuBu.TotalPresu,

                                    EneroEjer = Co != null ? Co.Enero : 0,
                                    FebreroEjer = Co != null ? Co.Febrero : 0,
                                    MarzoEjer = Co != null ? Co.Marzo : 0,
                                    AbrilEjer = Co != null ? Co.Abril : 0,
                                    MayoEjer = Co != null ? Co.Mayo : 0,
                                    JunioEjer = Co != null ? Co.Junio : 0,
                                    JulioEjer = Co != null ? Co.Julio : 0,
                                    AgostoEjer = Co != null ? Co.Agosto : 0,
                                    SeptiembreEjer = Co != null ? Co.Septiembre : 0,
                                    OctubreEjer = Co != null ? Co.Octubre : 0,
                                    NoviembreEjer = Co != null ? Co.Noviembre : 0,
                                    DiciembreEjer = Co != null ? Co.Diciembre : 0,
                                    TotalEjer = Co != null ? Co.Total : 0,

                                    EneroDif = Co != null ? CuBu.EneroPresu - Co.Enero : CuBu.EneroPresu,
                                    FebreroDif = Co != null ? CuBu.FebreroPresu - Co.Febrero : CuBu.FebreroPresu,
                                    MarzoDif = Co != null ? CuBu.MarzoPresu - Co.Marzo : CuBu.MarzoPresu,
                                    AbrilDif = Co != null ? CuBu.AbrilPresu - Co.Abril : CuBu.AbrilPresu,
                                    MayoDif = Co != null ? CuBu.MayoPresu - Co.Mayo : CuBu.MayoPresu,
                                    JunioDif = Co != null ? CuBu.JunioPresu - Co.Junio : CuBu.JunioPresu,
                                    JulioDif = Co != null ? CuBu.JulioPresu - Co.Julio : CuBu.JulioPresu,
                                    AgostoDif = Co != null ? CuBu.AgostoPresu - Co.Agosto : CuBu.AgostoPresu,
                                    SeptiembreDif = Co != null ? CuBu.SeptiembrePresu - Co.Septiembre : CuBu.SeptiembrePresu,
                                    OctubreDif = Co != null ? CuBu.OctubrePresu - Co.Octubre : CuBu.OctubrePresu,
                                    NoviembreDif = Co != null ? CuBu.NoviembrePresu - Co.Noviembre : CuBu.NoviembrePresu,
                                    DiciembreDif = Co != null ? CuBu.DiciembrePresu - Co.Diciembre : CuBu.DiciembrePresu,
                                    TotalDif = Co != null ? CuBu.TotalPresu - Co.Total : CuBu.TotalPresu
                                }

                            ).ToList().OrderBy(a => a.CuentaDesc);


                /* CREAR LISTA DE EGRESOS
                -----------------------------------------------------------*/
                List<EntidadFlujo> listaEgresos = new List<EntidadFlujo>();

                foreach (var item in query)
                {
                    if (item.TotalEjer != 0 || item.TotalPresu != 0)
                    {
                        EntidadFlujo aux = new EntidadFlujo();
                        aux.Anio = anio;
                        aux.Proyecto = proyecto;
                        aux.UnidadNegocio = un;
                        aux.Compania = compania;
                        aux.CuentaClaseDesc = cuentaClaseDesc;
                        aux.CuentaDesc = item.CuentaDesc;
                        aux.Periodo = parFiltros.Periodo;
                        aux.EneroEjercido = item.EneroEjer;
                        aux.FebreroEjercido = item.FebreroEjer;
                        aux.MarzoEjercido = item.MarzoEjer;
                        aux.AbrilEjercido = item.AbrilEjer;
                        aux.MayoEjercido = item.MayoEjer;
                        aux.JunioEjercido = item.JunioEjer;
                        aux.JulioEjercido = item.JulioEjer;
                        aux.AgostoEjercido = item.AgostoEjer;
                        aux.SeptiembreEjercido = item.SeptiembreEjer;
                        aux.OctubreEjercido = item.OctubreEjer;
                        aux.NoviembreEjercido = item.NoviembreEjer;
                        aux.DiciembreEjercido = item.DiciembreEjer;
                        aux.EneroBudget = item.EneroPresu;
                        aux.FebreroBudget = item.FebreroPresu;
                        aux.MarzoBudget = item.MarzoPresu;
                        aux.AbrilBudget = item.AbrilPresu;
                        aux.MayoBudget = item.MayoPresu;
                        aux.JunioBudget = item.JunioPresu;
                        aux.JulioBudget = item.JulioPresu;
                        aux.AgostoBudget = item.AgostoPresu;
                        aux.SeptiembreBudget = item.SeptiembrePresu;
                        aux.OctubreBudget = item.OctubrePresu;
                        aux.NoviembreBudget = item.NoviembrePresu;
                        aux.DiciembreBudget = item.DiciembrePresu;
                        aux.EneroDesviacion = item.EneroDif;
                        aux.FebreroDesviacion = item.FebreroDif;
                        aux.MarzoDesviacion = item.MarzoDif;
                        aux.AbrilDesviacion = item.AbrilDif;
                        aux.MayoDesviacion = item.MayoDif;
                        aux.JunioDesviacion = item.JunioDif;
                        aux.JulioDesviacion = item.JulioDif;
                        aux.AgostoDesviacion = item.AgostoDif;
                        aux.SeptiembreDesviacion = item.SeptiembreDif;
                        aux.OctubreDesviacion = item.OctubreDif;
                        aux.NoviembreDesviacion = item.NoviembreDif;
                        aux.DiciembreDesviacion = item.DiciembreDif;
                        aux.TotalEjercido = item.TotalEjer;
                        aux.TotalBudget = item.TotalPresu;
                        aux.TotalDesviacion = item.TotalDif;
                        aux.Log = "-";

                        listaEgresos.Add(aux);
                    }
                }

                if (listaEgresos.Count != 0)
                {
                    return listaEgresos;
                }
                else
                {
                    EntidadFlujo error = new EntidadFlujo();
                    error.Log = "VACIO";
                    return this.Error(error);
                }
            }
            else
            {
                EntidadFlujo error = new EntidadFlujo();
                error.Log = vistaCuentas.Log;
                return this.Error(error);
            }
        }
예제 #2
0
        /*===================================================*\
            CUENTAS PAGADAS
        \*===================================================*/

        public List<EntidadFactura> CuentasPagadasByCuentaDesc(EntidadFactura parFiltros)
        {
            // Se preparan los filtros de Factura
            EntidadFactura entidad = new EntidadFactura();
            entidad.Anio = parFiltros.Anio;
            entidad.Proyecto = parFiltros.Proyecto;
            entidad.Compania = parFiltros.Compania;

            entidad.CuentaClaseDesc = parFiltros.CuentaClaseDesc;
            entidad.CuentaDesc = parFiltros.CuentaDesc;
            entidad.Periodo = parFiltros.Periodo;

            entidad.UnidadNegocio = parFiltros.UnidadNegocio;
            entidad.CuentaFlujo = "EGR";

            VisMaCuentasPagadas tabla = new VisMaCuentasPagadas(entidad);
            List<EntidadFactura> lista = tabla.GroupByCuentaDesc();

            if (tabla.Log == "OK")
            {
                return lista;
            }
            else
            {
                entidad.Log = tabla.Log;
                return this.Error(entidad);
            }
        }