public bool ModificarEstado_aprobacion(FacturasEventos_Info info)
 {
     try
     {
         using (Entity_Eventos context = new Entity_Eventos())
         {
             var entity = context.Facturas.Where(v => v.cod_evento == info.cod_evento && v.cod_fact == info.cod_fact).FirstOrDefault();
             if (entity != null)
             {
                 entity.estado_aprobacion = "APRO";
                 context.SaveChanges();
             }
         }
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public List <FacturasEventos_Info> get_lis(DateTime FechaInicio, DateTime FechaFin)
        {
            try
            {
                DateTime Fi = FechaInicio.Date;
                DateTime ff = FechaFin.Date;
                List <FacturasEventos_Info> lista;
                using (Entity_Eventos context = new Entity_Eventos())

                {
                    lista = (from q in context.vwFacturas_sin_aprobar
                             where q.fecha >= Fi &&
                             q.fecha <= ff &&
                             q.estado_aprobacion == null &&
                             q.bd_est == 1
                             select new FacturasEventos_Info
                    {
                        cod_fact = q.cod_fact,
                        cod_evento = q.cod_evento,
                        nu_ced_ruc = q.nu_ced_ruc,
                        nombres = q.nombres,
                        apellidos = q.apellidos,
                        cant = q.cant,
                        v_unit = q.v_unit,
                        subtotal = q.subtotal,
                        v_iva = q.v_iva,
                        total = q.total,
                        fecha = q.fecha,
                    }
                             ).ToList();
                }

                return(lista);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        /*private void Migrar_ats(int IdEmpresa, string Ruc, DateTime FechaInicio, DateTime FechaFin,int IdPeriodo)
         * {
         *  try
         *  {
         *      int secuancia = 200000;
         *      Entities_contabilidad context_cont = new Entities_contabilidad();
         *      using (Entity_migracion_ats Conexion_ats = new Entity_migracion_ats())
         *      {
         *          var Entity = Conexion_ats.vw_importacion_ats_fixed.Where(v => v.RUC_LCG == Ruc && v.fe_factura >= FechaInicio.Date && v.fe_factura <= FechaFin.Date).ToList();
         *
         *          if (Entity!=null)
         *          {
         *              Entity.ForEach(item =>
         *              {
         *                  ATS_ventas ventas = new ATS_ventas
         *                  {
         *                      IdEmpresa=IdEmpresa,
         *                      IdPeriodo=IdPeriodo,
         *                      Secuencia=secuancia,
         *                      idCliente=item.cedulaRuc,
         *                      parteRel="NO",
         *                      DenoCli="",
         *                      tipoComprobante="18",
         *                      tipoEm="F",
         *                      numeroComprobantes = Convert.ToInt32( item.nu_comp),
         *                      baseNoGraIva = 0,
         *                      baseImponible = Convert.ToDecimal(item.valorBaseIva),
         *                      baseImpGrav = 0,
         *                      montoIva= 0,
         *                      montoIce=0,
         *                      valorRetIva= 0,
         *                      valorRetRenta= 0,
         *                      formaPago="01",
         *                      codEstab="001",
         *                      ventasEstab=Convert.ToDecimal( item.valorBaseIva),
         *                      IdSucursal=1
         *                  };
         *                  if(item.cedulaRuc.Length==13)
         *                  {
         *                      ventas.tpIdCliente = "04";
         *                      ventas.tipoCliente = "02";
         *                  }
         *                  else
         *                  {
         *                      ventas.tpIdCliente = "05";
         *                      ventas.tipoCliente = "01";
         *                  }
         *                  context_cont.ATS_ventas.Add(ventas);
         *                  context_cont.SaveChanges();
         *                  secuancia++;
         *              });
         *          }
         *
         *      }
         *  }
         *  catch (Exception)
         *  {
         *
         *  }
         *
         * }*/

        private void Migrar_ats_CCG(int IdEmpresa, string Ruc, DateTime FechaInicio, DateTime FechaFin, int IdPeriodo, int IdSucursal)
        {
            try
            {
                if (IdSucursal != 8)
                {
                    return;
                }
                FechaInicio = FechaInicio.Date;
                var FechaFin1 = FechaFin.Date.AddDays(1);

                Entity_Eventos db = new Entity_Eventos();

                var queryLinq = (from fac in db.Facturas
                                 where fac.fecha >= FechaInicio &&
                                 fac.fecha <= FechaFin1 &&
                                 fac.bd_est == 1 &&
                                 ((fac.nu_ced_ruc).Length > 9)
                                 group fac by new
                {
                    ID = fac.nu_ced_ruc.Trim()
                } into g
                                 select new ATS_ventas_eventos
                {
                    IdEmpresa = IdEmpresa,
                    IdPeriodo = IdPeriodo,
                    //idCliente = fac.nu_ced_ruc.Trim(),//g.Key.ID,
                    idCliente = g.Key.ID,
                    parteRel = "NO",
                    DenoCli = "",
                    tipoComprobante = "18",
                    tipoEm = "F",
                    //numeroComprobantes = 1,//g.Count(),
                    numeroComprobantes = g.Count(),
                    baseNoGraIva = 0,
                    baseImponible = 0,
                    //baseImpGrav = fac.subtotal ?? 0, //g.Sum(q=> q.subtotal ?? 0),
                    baseImpGrav = g.Sum(q => q.subtotal ?? 0),
                    //montoIva = fac.v_iva ?? 0,//g.Sum(q => q.v_iva ?? 0),
                    montoIva = g.Sum(q => q.v_iva ?? 0),
                    montoIce = 0,
                    valorRetIva = 0,
                    valorRetRenta = 0,
                    formaPago = "01",
                    codEstab = "001",
                    //ventasEstab = fac.subtotal?? 0,//g.Sum(q => q.subtotal ?? 0),
                    ventasEstab = g.Sum(q => q.subtotal ?? 0),
                    IdSucursal = 8,
                    //tpIdCliente = fac.nu_ced_ruc.Length == 13 ? "04" : fac.nu_ced_ruc.Length == 10 ? "05" : "0",//g.Key.ID.Length == 13 ? "04" : g.Key.ID.Length == 10 ? "05" : "0",
                    //tipoCliente = fac.nu_ced_ruc.Length == 13 ? "02" : fac.nu_ced_ruc.Length == 10 ? "01" : "0",//g.Key.ID.Length == 13 ? "02" : g.Key.ID.Length == 10 ? "01" : "0"
                    tpIdCliente = g.Key.ID.Length == 13 ? "04" : g.Key.ID.Length == 10 ? "05" : "0",
                    tipoCliente = g.Key.ID.Length == 13 ? "02" : g.Key.ID.Length == 10 ? "01" : "0"
                }).ToList();

                using (Entities_contabilidad Context = new Entities_contabilidad())
                {
                    var lst_ccg = Context.ATS_ventas_eventos.ToList();
                    Context.ATS_ventas_eventos.RemoveRange(lst_ccg);

                    int Secuencia = Context.ATS_ventas.Max(q => q.Secuencia) + 1;
                    queryLinq.ForEach(q => q.Secuencia = Secuencia++);
                    Context.ATS_ventas_eventos.RemoveRange(Context.ATS_ventas_eventos.ToList());
                    Context.ATS_ventas_eventos.AddRange(queryLinq);
                    Context.SaveChanges();

                    Context.SPATS_MigrarEventos();
                }
            }
            catch (Exception)
            {
            }
        }