Exemplo n.º 1
0
        public ActionResult Consultar(int IdEmpresa = 0, bool Exito = false)
        {
            tb_empresa_Info model = bus_empresa.get_info(IdEmpresa);

            if (model.em_logo == null)
            {
                model.em_logo = new byte[0];
            }
            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Empresa", "Index");
            if (model.Estado == "I")
            {
                info.Modificar = false;
                info.Anular    = false;
            }
            model.Nuevo     = (info.Nuevo == true ? 1 : 0);
            model.Modificar = (info.Modificar == true ? 1 : 0);
            model.Anular    = (info.Anular == true ? 1 : 0);
            #endregion

            if (Exito)
            {
                ViewBag.MensajeSuccess = MensajeSuccess;
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            #region Validar Session
            if (string.IsNullOrEmpty(SessionFixed.IdTransaccionSession))
            {
                return(RedirectToAction("Login", new { Area = "", Controller = "Account" }));
            }
            SessionFixed.IdTransaccionSession       = (Convert.ToDecimal(SessionFixed.IdTransaccionSession) + 1).ToString();
            SessionFixed.IdTransaccionSessionActual = SessionFixed.IdTransaccionSession;
            #endregion

            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Empresa", "Index");
            ViewBag.Nuevo = info.Nuevo;
            #endregion

            tb_empresa_Info model = new tb_empresa_Info
            {
                IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession),
                IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa),
            };

            var lst = bus_empresa.get_list(true);
            ListaEmpresa.set_list(lst, model.IdTransaccionSession);
            return(View(model));
        }
Exemplo n.º 3
0
 public ActionResult Anular(tb_empresa_Info model)
 {
     if (!bus_empresa.anularDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 4
0
 public ActionResult Modificar(tb_empresa_Info model)
 {
     model.em_logo = empresa_imagen.pr_imagen;
     if (!bus_empresa.modificarDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 5
0
 public ActionResult Modificar(tb_empresa_Info model)
 {
     model.em_logo = empresa_imagen.pr_imagen;
     if (!bus_empresa.modificarDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, Exito = true }));
 }
Exemplo n.º 6
0
        public ActionResult Nuevo()
        {
            tb_empresa_Info model = new tb_empresa_Info
            {
                em_fechaInicioContable = DateTime.Now.Date,
                em_logo = new byte[0]
            };

            return(View(model));
        }
Exemplo n.º 7
0
 public bool anularDB(tb_empresa_Info info)
 {
     try
     {
         return(odata.anularDB(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 8
0
        private void FAC_006_Rpt_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            tb_empresa_Info info_empresa = new tb_empresa_Info();
            int             IdEmpresa    = p_IdEmpresa.Value == null ? 0 : Convert.ToInt32(p_IdEmpresa.Value);
            int             IdSucursal   = p_IdSucursal.Value == null ? 0 : Convert.ToInt32(p_IdSucursal.Value);
            decimal         IdProforma   = p_IdProforma.Value == null ? 0 : Convert.ToDecimal(p_IdProforma.Value);

            FAC_006_Bus         bus_rpt = new FAC_006_Bus();
            List <FAC_006_Info> lst_rpt = bus_rpt.get_list(IdEmpresa, IdSucursal, IdProforma, false, false);

            this.DataSource = lst_rpt;
        }
Exemplo n.º 9
0
 public ActionResult Nuevo(tb_empresa_Info model)
 {
     model.em_logo = empresa_imagen.pr_imagen;
     if (Session["imagen"] != null)
     {
         model.em_logo = Session["imagen"] as byte[];
     }
     if (!bus_empresa.guardarDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Index"));
 }
Exemplo n.º 10
0
 public ActionResult Nuevo(tb_empresa_Info model)
 {
     model.em_logo = empresa_imagen.pr_imagen;
     if (Session["imagen"] != null)
     {
         model.em_logo = Session["imagen"] as byte[];
     }
     if (!bus_empresa.guardarDB(model))
     {
         return(View(model));
     }
     return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, Exito = true }));
 }
Exemplo n.º 11
0
        public ActionResult Importar(int IdEmpresa = 0)
        {
            #region Validar Session
            SessionFixed.IdTransaccionSession       = "999999";
            SessionFixed.IdTransaccionSessionActual = "999999";
            #endregion

            tb_empresa_Info model = new tb_empresa_Info
            {
                IdEmpresa            = IdEmpresa,
                IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual)
            };
            return(View(model));
        }
Exemplo n.º 12
0
        public ActionResult Anular(int IdEmpresa = 0)
        {
            tb_empresa_Info model = bus_empresa.get_info(IdEmpresa);

            if (model.em_logo == null)
            {
                model.em_logo = new byte[0];
            }
            if (model == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Exemplo n.º 13
0
        public tb_empresa_Info get_info(int IdEmpresa)
        {
            try
            {
                tb_empresa_Info info = new tb_empresa_Info();

                using (Entities_general Context = new Entities_general())
                {
                    tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == IdEmpresa);
                    if (Entity == null)
                    {
                        return(null);
                    }
                    info = new tb_empresa_Info
                    {
                        IdEmpresa                 = Entity.IdEmpresa,
                        codigo                    = Entity.codigo,
                        em_nombre                 = Entity.em_nombre,
                        RazonSocial               = Entity.RazonSocial,
                        NombreComercial           = Entity.NombreComercial,
                        ContribuyenteEspecial     = Entity.ContribuyenteEspecial,
                        ObligadoAllevarConta      = Entity.ObligadoAllevarConta,
                        em_ruc                    = Entity.em_ruc,
                        em_gerente                = Entity.em_gerente,
                        em_contador               = Entity.em_contador,
                        em_rucContador            = Entity.em_rucContador,
                        em_telefonos              = Entity.em_telefonos,
                        em_fax                    = Entity.em_fax,
                        em_notificacion           = Entity.em_notificacion,
                        em_direccion              = Entity.em_direccion,
                        em_tel_int                = Entity.em_tel_int,
                        em_logo                   = Entity.em_logo,
                        em_fondo                  = Entity.em_fondo,
                        em_fechaInicioContable    = Entity.em_fechaInicioContable,
                        Estado                    = Entity.Estado,
                        em_fechaInicioActividad   = Entity.em_fechaInicioActividad,
                        cod_entidad_dinardap      = Entity.cod_entidad_dinardap,
                        em_Email                  = Entity.em_Email,
                        ObligadoAllevarConta_bool = Entity.ObligadoAllevarConta == "S" ? true : false
                    };
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 14
0
        public ActionResult Nuevo()
        {
            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Empresa", "Index");
            if (!info.Nuevo)
            {
                return(RedirectToAction("Index"));
            }
            #endregion

            tb_empresa_Info model = new tb_empresa_Info
            {
                em_fechaInicioContable = DateTime.Now.Date,
                em_logo = new byte[0]
            };
            return(View(model));
        }
Exemplo n.º 15
0
        public tb_empresa_Info get_info_demanda(int value)
        {
            tb_empresa_Info info = new tb_empresa_Info();

            using (Entities_general Contex = new Entities_general())
            {
                info = (from q in Contex.tb_empresa
                        where q.IdEmpresa == value
                        select new tb_empresa_Info
                {
                    IdEmpresa = q.IdEmpresa,
                    codigo = q.codigo,
                    em_nombre = q.em_nombre
                }).FirstOrDefault();
            }
            return(info);
        }
Exemplo n.º 16
0
        public bool guardarDB(tb_empresa_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_empresa Entity = new tb_empresa
                    {
                        IdEmpresa               = info.IdEmpresa = get_id(),
                        codigo                  = info.codigo,
                        em_nombre               = info.em_nombre,
                        RazonSocial             = info.RazonSocial,
                        NombreComercial         = info.NombreComercial,
                        ContribuyenteEspecial   = info.ContribuyenteEspecial,
                        ObligadoAllevarConta    = info.ObligadoAllevarConta_bool == true ? "S" : "N",
                        em_ruc                  = info.em_ruc,
                        em_gerente              = info.em_gerente,
                        em_contador             = info.em_contador,
                        em_rucContador          = info.em_rucContador,
                        em_telefonos            = info.em_telefonos,
                        em_fax                  = info.em_fax,
                        em_notificacion         = info.em_notificacion,
                        em_direccion            = info.em_direccion,
                        em_tel_int              = info.em_tel_int,
                        em_logo                 = info.em_logo,
                        em_fondo                = info.em_fondo,
                        em_fechaInicioContable  = info.em_fechaInicioContable,
                        Estado                  = info.Estado = "A",
                        em_fechaInicioActividad = info.em_fechaInicioActividad,
                        cod_entidad_dinardap    = info.cod_entidad_dinardap,
                        em_Email                = info.em_Email,
                    };
                    Context.tb_empresa.Add(Entity);
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 17
0
        public bool modificarDB(tb_empresa_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.codigo                  = info.codigo;
                    Entity.em_nombre               = info.em_nombre;
                    Entity.RazonSocial             = info.RazonSocial;
                    Entity.NombreComercial         = info.NombreComercial;
                    Entity.ContribuyenteEspecial   = info.ContribuyenteEspecial;
                    Entity.ObligadoAllevarConta    = info.ObligadoAllevarConta_bool == true ? "S" : "N";
                    Entity.em_ruc                  = info.em_ruc;
                    Entity.em_gerente              = info.em_gerente;
                    Entity.em_contador             = info.em_contador;
                    Entity.em_rucContador          = info.em_rucContador;
                    Entity.em_telefonos            = info.em_telefonos;
                    Entity.em_fax                  = info.em_fax;
                    Entity.em_notificacion         = info.em_notificacion;
                    Entity.em_direccion            = info.em_direccion;
                    Entity.em_tel_int              = info.em_tel_int;
                    Entity.em_logo                 = info.em_logo;
                    Entity.em_fondo                = info.em_fondo;
                    Entity.em_fechaInicioContable  = info.em_fechaInicioContable;
                    Entity.em_fechaInicioActividad = info.em_fechaInicioActividad;
                    Entity.cod_entidad_dinardap    = info.cod_entidad_dinardap;
                    Entity.em_Email                = info.em_Email;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 18
0
        public ActionResult Anular(int IdEmpresa = 0)
        {
            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "General", "Empresa", "Index");
            if (!info.Anular)
            {
                return(RedirectToAction("Index"));
            }
            #endregion

            tb_empresa_Info model = bus_empresa.get_info(IdEmpresa);
            if (model.em_logo == null)
            {
                model.em_logo = new byte[0];
            }
            if (model == null)
            {
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Exemplo n.º 19
0
        public bool modificarDB(tb_empresa_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.codigo                = info.codigo;
                    Entity.em_nombre             = info.em_nombre;
                    Entity.RazonSocial           = info.RazonSocial;
                    Entity.NombreComercial       = info.NombreComercial;
                    Entity.ContribuyenteEspecial = info.ContribuyenteEspecial ?? "";
                    Entity.em_ruc                = info.em_ruc;
                    Entity.em_gerente            = info.em_gerente;
                    Entity.em_contador           = info.em_contador;
                    Entity.em_rucContador        = info.em_rucContador;
                    Entity.em_telefonos          = info.em_telefonos;
                    Entity.em_direccion          = info.em_direccion;
                    if (info.em_logo != null)
                    {
                        Entity.em_logo = info.em_logo;
                    }
                    Entity.em_fechaInicioContable  = info.em_fechaInicioContable;
                    Entity.em_fechaInicioActividad = Convert.ToDateTime(info.em_fechaInicioActividad);
                    Entity.cod_entidad_dinardap    = info.cod_entidad_dinardap;
                    Entity.em_Email = info.em_Email;
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 20
0
        public bool anularDB(tb_empresa_Info info)
        {
            try
            {
                using (Entities_general Context = new Entities_general())
                {
                    tb_empresa Entity = Context.tb_empresa.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa);
                    if (Entity == null)
                    {
                        return(false);
                    }
                    Entity.Estado = info.Estado = "I";
                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 21
0
        private void FAC_006_Rpt_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            tb_empresa_Info info_empresa = new tb_empresa_Info();
            int             IdEmpresa    = p_IdEmpresa.Value == null ? 0 : Convert.ToInt32(p_IdEmpresa.Value);
            int             IdSucursal   = p_IdSucursal.Value == null ? 0 : Convert.ToInt32(p_IdSucursal.Value);
            decimal         IdProforma   = p_IdProforma.Value == null ? 0 : Convert.ToDecimal(p_IdProforma.Value);

            FAC_006_Bus         bus_rpt = new FAC_006_Bus();
            List <FAC_006_Info> lst_rpt = bus_rpt.get_list(IdEmpresa, IdSucursal, IdProforma, false, false);

            this.DataSource = lst_rpt;

            tb_empresa_Bus bus_empresa = new tb_empresa_Bus();
            var            empresa     = bus_empresa.get_info(IdEmpresa);

            lbl_empresa.Text = empresa.em_nombre;
            if (empresa != null && empresa.em_logo != null)
            {
                ImageConverter obj = new ImageConverter();
                logo.Image = (Image)obj.ConvertFrom(empresa.em_logo);
            }
        }
Exemplo n.º 22
0
        public ActionResult Importar(tb_empresa_Info model)
        {
            try
            {
                var Lista_Empresa  = ListaEmpresa.get_list(model.IdTransaccionSession);
                var Lista_Sucursal = ListaSucursal.get_list(model.IdTransaccionSession);
                var Lista_Bodega   = ListaBodega.get_list(model.IdTransaccionSession);

                if (!bus_empresa.GuardarDbImportacion(Lista_Empresa, Lista_Sucursal, Lista_Bodega))
                {
                    ViewBag.mensaje = "Error al importar el archivo";
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                SisLogError.set_list((ex.InnerException) == null ? ex.Message.ToString() : ex.InnerException.ToString());

                ViewBag.error = ex.Message.ToString();
                return(View(model));
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 23
0
        public rdep get_list(int IdEmpresa, int Anio, decimal IdEmpleado)
        {
            try
            {
                info_empresa      = bus_empresa.get_info(IdEmpresa);
                list_base_calculo = odata_base_Calculo.get_list(Anio).OrderByDescending(v => v.Secuencia).ToList();
                rdp.anio          = Anio.ToString();
                rdp.numRuc        = info_empresa.em_ruc;
                datRetRelDepTyp detalle = new datRetRelDepTyp();
                rdp.retRelDep = new List <datRetRelDepTyp>();
                var lis = odata.gett_list(IdEmpresa, Anio, IdEmpleado);
                lis.ForEach(item =>
                {
                    if (item.pe_cedulaRuc == "0927181131")
                    {
                    }
                    datRetRelDepTyp info_det       = new datRetRelDepTyp();
                    info_det.empleado              = new datEmpTyp();
                    info_det.empleado.benGalpg     = benGalpgType.NO;
                    info_det.empleado.tipIdRet     = datEmpTypTipIdRet.C;
                    info_det.empleado.idRet        = item.pe_cedulaRuc;
                    info_det.empleado.apellidoTrab = item.pe_apellido.Replace("Ñ", "N").Trim();
                    info_det.empleado.nombreTrab   = item.pe_nombre.Replace("Ñ", "N").Trim();

                    info_det.empleado.apellidoTrab = info_det.empleado.apellidoTrab.Replace("  ", " ").Trim();
                    info_det.empleado.nombreTrab   = info_det.empleado.nombreTrab.Replace("  ", " ").Trim();


                    info_det.empleado.estab            = item.Su_CodigoEstablecimiento;
                    info_det.empleado.residenciaTrab   = resciTyp.Item01;
                    info_det.empleado.paisResidencia   = "593";
                    info_det.empleado.aplicaConvenio   = convImposTyp.NA;
                    info_det.empleado.tipIdDiscap      = tipIdDiscapTyp.N;
                    info_det.empleado.tipoTrabajDiscap = discapTyp.Item01;
                    info_det.empleado.porcentajeDiscap = "0";
                    info_det.empleado.idDiscap         = "999";
                    info_det.deducAliementSpecified    = true;
                    info_det.deducVestimSpecified      = true;
                    info_det.deducSaludSpecified       = true;
                    info_det.deducEducaSpecified       = true;
                    info_det.deducViviendaSpecified    = true;
                    info_det.deducArtycultSpecified    = true;
                    info_det.deducArtycult             = 0;
                    info_det.suelSal                  = (item.Sueldo) == null?Convert.ToDecimal(0.00):Convert.ToDecimal(item.Sueldo);
                    info_det.sobSuelComRemu           = (item.IngresoVarios) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.IngresoVarios);
                    info_det.partUtil                 = Convert.ToDecimal(item.Utilidades);
                    info_det.intGrabGen               = 0;
                    info_det.impRentEmpl              = 0;
                    info_det.decimTer                 = (item.DecimoTercerSueldo) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.DecimoTercerSueldo);
                    info_det.decimCuar                = (item.DecimoCuartoSueldo) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.DecimoCuartoSueldo);
                    info_det.fondoReserva             = (item.FondosReserva) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.FondosReserva);
                    info_det.salarioDigno             = 0;
                    info_det.otrosIngRenGrav          = 0;
                    info_det.sisSalNet                = "1";
                    info_det.apoPerIess               = Convert.ToDecimal(item.AportePErsonal);
                    info_det.aporPerIessConOtrosEmpls = 0;
                    info_det.deducVivienda            = Convert.ToDecimal(item.GastoVivienda);
                    info_det.deducSalud               = Convert.ToDecimal(item.GastoSalud);
                    info_det.deducEduca               = Convert.ToDecimal(item.GastoEucacion);
                    info_det.deducAliement            = Convert.ToDecimal(item.GastoAlimentacion);
                    info_det.deducVestim              = Convert.ToDecimal(item.GastoVestimenta);
                    info_det.deducArtycult            = 0;
                    info_det.exoDiscap                = 0;
                    info_det.exoTerEd                 = 0;
                    info_det.basImp              = Convert.ToDecimal((info_det.suelSal + info_det.sobSuelComRemu) - (info_det.deducVivienda + info_det.deducSalud + info_det.deducEduca + info_det.deducAliement + info_det.deducVestim + info_det.apoPerIess));
                    info_det.impRentCaus         = CalcularImpuestoRenta(info_det);
                    info_det.valRetAsuOtrosEmpls = 0;
                    info_det.valImpAsuEsteEmpl   = 0;
                    info_det.valRet              = 0;
                    info_det.ingGravConEsteEmpl  = info_det.suelSal + info_det.sobSuelComRemu;
                    info_det.intGrabGen          = 0;

                    rdp.retRelDep.Add(info_det);
                });
                return(rdp);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 24
0
        public rdep get_info_xml(int IdEmpresa, int IdRdep)
        {
            try
            {
                info_empresa = bus_empresa.get_info(IdEmpresa);
                rdep.numRuc  = info_empresa.em_ruc;

                datRetRelDepTyp detalle = new datRetRelDepTyp();
                rdep.retRelDep = new List <datRetRelDepTyp>();

                List <ro_rdep_det_Info> Lista_RDEP = new List <ro_rdep_det_Info>();

                Lista_RDEP = oData.get_info_xml(IdEmpresa, IdRdep);

                Lista_RDEP.ForEach(item =>
                {
                    rdep.anio = Convert.ToString(item.pe_anio);

                    datRetRelDepTyp info_det           = new datRetRelDepTyp();
                    info_det.empleado                  = new datEmpTyp();
                    info_det.empleado.benGalpg         = benGalpgType.NO;
                    info_det.empleado.tipIdRet         = datEmpTypTipIdRet.C;
                    info_det.empleado.idRet            = item.pe_cedulaRuc;
                    info_det.empleado.apellidoTrab     = item.pe_apellido.Replace("Ñ", "N").Trim();
                    info_det.empleado.nombreTrab       = item.pe_nombre.Replace("Ñ", "N").Trim();
                    info_det.empleado.apellidoTrab     = info_det.empleado.apellidoTrab.Replace("  ", " ").Trim();
                    info_det.empleado.nombreTrab       = info_det.empleado.nombreTrab.Replace("  ", " ").Trim();
                    info_det.empleado.estab            = item.Su_CodigoEstablecimiento;
                    info_det.empleado.residenciaTrab   = resciTyp.Item01;
                    info_det.empleado.paisResidencia   = "593";
                    info_det.empleado.aplicaConvenio   = convImposTyp.NA;
                    info_det.empleado.tipoTrabajDiscap = discapTyp.Item01;
                    info_det.empleado.porcentajeDiscap = "0";
                    info_det.empleado.tipIdDiscap      = tipIdDiscapTyp.N;
                    info_det.empleado.idDiscap         = "999";
                    info_det.deducAliementSpecified    = true;
                    info_det.deducVestimSpecified      = true;
                    info_det.deducSaludSpecified       = true;
                    info_det.deducEducaSpecified       = true;
                    info_det.deducViviendaSpecified    = true;
                    info_det.deducArtycultSpecified    = true;
                    info_det.suelSal                  = (item.Sueldo) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.Sueldo);
                    info_det.sobSuelComRemu           = (item.IngresoVarios) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.IngresoVarios);
                    info_det.partUtil                 = Convert.ToDecimal(item.Utilidades);
                    info_det.intGrabGen               = Convert.ToDecimal(item.IngresoPorOtrosEmpleaodres);
                    info_det.impRentEmpl              = Convert.ToDecimal(item.ImpuestoRentaAsumidoPorEsteEmpleador);
                    info_det.decimTer                 = (item.DecimoTercerSueldo) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.DecimoTercerSueldo);
                    info_det.decimCuar                = (item.DecimoCuartoSueldo) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.DecimoCuartoSueldo);
                    info_det.fondoReserva             = (item.FondosReserva) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(item.FondosReserva);
                    info_det.salarioDigno             = 0;
                    info_det.otrosIngRenGrav          = Convert.ToDecimal(item.OtrosIngresosRelacionDependencia);
                    info_det.ingGravConEsteEmpl       = Convert.ToDecimal(item.IngresosGravadorPorEsteEmpleador);
                    info_det.sisSalNet                = "1";
                    info_det.apoPerIess               = Convert.ToDecimal(item.AportePErsonal);
                    info_det.aporPerIessConOtrosEmpls = Convert.ToDecimal(item.IessPorOtrosEmpleadores);
                    info_det.deducVivienda            = Convert.ToDecimal(item.GastoVivienda);
                    info_det.deducSalud               = Convert.ToDecimal(item.GastoSalud);
                    info_det.deducEduca               = Convert.ToDecimal(item.GastoEucacion);
                    info_det.deducAliement            = Convert.ToDecimal(item.GastoAlimentacion);
                    info_det.deducVestim              = Convert.ToDecimal(item.GastoVestimenta);
                    info_det.deducArtycult            = 0;
                    info_det.basImp              = Convert.ToDecimal((item.BaseImponibleGravada));
                    info_det.impRentCaus         = Convert.ToDecimal((item.ImpuestoRentaCausado));
                    info_det.valRetAsuOtrosEmpls = Convert.ToDecimal((item.ValorImpuestoPorOtroEmplador));
                    info_det.valImpAsuEsteEmpl   = Convert.ToDecimal((item.ValorImpuestoPorEsteEmplador));
                    info_det.valRet              = Convert.ToDecimal((item.ValorImpuestoRetenidoTrabajador));
                    info_det.exoDiscap           = Convert.ToDecimal(item.ExoneraionPorDiscapacidad);
                    info_det.exoTerEd            = Convert.ToDecimal(item.ExoneracionPorTerceraEdad);

                    rdep.retRelDep.Add(info_det);
                });
                return(rdep);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 25
0
        public iva get_ats(int IdEmpresa, int IdPeriodo, int IdSucursal, int[] IntArray)
        {
            try
            {
                string registro = "";
                iva    ats      = new iva();
                info_periodo = data_periodo.get_info(IdEmpresa, IdPeriodo);
                info_empresa = data_empresa.get_info(IdEmpresa);
                ats_Info info_ats = get_info(IdEmpresa, IdPeriodo, IdSucursal, IntArray);

                #region cabecera del xml
                ats.IdInformante = info_empresa.em_ruc;
                ats.razonSocial  = info_empresa.RazonSocial.Replace(".", " ").Replace("ñ", "n").Replace("Ñ", "N");
                ats.Anio         = info_periodo.IdanioFiscal.ToString();
                ats.Mes          = info_periodo.pe_mes.ToString().PadLeft(2, '0');

                ats.TipoIDInformante = ivaTypeTipoIDInformante.R;
                ats.codigoOperativo  = codigoOperativoType.IVA;
                ats.totalVentas      = info_ats.lst_ventas.Sum(v => v.ventasEstab);
                #endregion

                #region listado de compras
                if (info_ats.lst_compras != null)
                {
                    if (info_ats.lst_compras.Count() > 0)
                    {
                        ats.compras = new List <detalleCompras>();
                    }
                    info_ats.lst_compras.ForEach(
                        comp =>
                    {
                        detalleCompras comp_det = new detalleCompras();

                        registro                           = comp.denopr + " " + comp.secuencial;
                        comp.denopr                        = cl_funciones.QuitartildesEspaciosPuntos(comp.denopr);
                        comp_det.codSustento               = comp.codSustento;
                        comp_det.tpIdProv                  = comp.tpIdProv;
                        comp_det.idProv                    = comp.idProv;
                        comp_det.tipoComprobante           = comp.tipoComprobante;
                        comp_det.parteRel                  = parteRelType.NO;
                        comp_det.fechaRegistro             = comp.fechaRegistro.ToString().Substring(0, 10);
                        comp_det.establecimiento           = comp.establecimiento;
                        comp_det.puntoEmision              = comp.puntoEmision;
                        comp_det.secuencial                = comp.secuencial;
                        comp_det.fechaEmision              = comp.fechaEmision.ToString().Substring(0, 10);
                        comp_det.autorizacion              = comp.autorizacion;
                        comp_det.baseNoGraIva              = comp.baseNoGraIva.ToString("n2");
                        comp_det.baseImponible             = comp.baseImponible.ToString("n2");
                        comp_det.baseImpGrav               = comp.baseImpGrav.ToString("n2");
                        comp_det.baseImpExe                = comp.baseImpExe.ToString("n2");
                        comp_det.montoIce                  = comp.montoIce.ToString("n2");
                        comp_det.montoIva                  = comp.montoIva.ToString("n2");
                        comp_det.valRetBien10              = "0.00";
                        comp_det.valRetServ20              = "0.00";
                        comp_det.valorRetBienes            = "0.00";
                        comp_det.valRetServ50              = "0.00";
                        comp_det.valorRetServicios         = "0.00";
                        comp_det.valRetServ100             = "0.00";
                        comp_det.totbasesImpReemb          = "0.00";
                        comp_det.valRetBien10Specified     = true;
                        comp_det.valRetServ20Specified     = true;
                        comp_det.valRetServ50Specified     = true;
                        comp_det.totbasesImpReembSpecified = true;
                        pagoExterior item_pago             = new pagoExterior();
                        item_pago.pagoLocExt               = (comp.pagoLocExt == "LOC") ? pagoLocExtType.Item01 : pagoLocExtType.Item02;
                        item_pago.paisEfecPago             = (item_pago.pagoLocExt == pagoLocExtType.Item01) ? "NA" : (comp.pagoLocExt != null || comp.pagoLocExt != "") ? comp.pagoLocExt : "NA";
                        item_pago.aplicConvDobTrib         = aplicConvDobTribType.NA;
                        item_pago.pagExtSujRetNorLeg       = aplicConvDobTribType.NA;
                        comp_det.pagoExterior              = item_pago;
                        if (comp_det.idProv == "0601895618001")
                        {
                        }
                        if ((Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav) + Convert.ToDecimal(comp.montoIva)) >= 1000)
                        {
                            comp_det.formasDePago = null;
                            string[] AFormaPago   = { "20" };
                            comp_det.formasDePago = AFormaPago;
                        }
                        #region Reembolso
                        if (comp.codSustento == "41")
                        {
                            comp_det.codSustento               = "01";
                            comp_det.reembolsos                = new List <reembolso>();
                            reembolso reem                     = new reembolso();
                            reem.tipoComprobanteReemb          = "01";
                            reem.tpIdProvReemb                 = comp.tpIdProv;
                            reem.idProvReemb                   = comp.idProv;
                            reem.establecimientoReemb          = comp.establecimiento;
                            reem.puntoEmisionReemb             = comp.puntoEmision;
                            reem.secuencialReemb               = comp.secuencial;
                            reem.fechaEmisionReemb             = comp.fechaEmision.ToString().Substring(0, 10);
                            reem.autorizacionReemb             = comp.autorizacion;
                            reem.baseImponibleReemb            = comp.baseImponible;
                            reem.baseImpGravReemb              = comp.baseImpGrav;
                            reem.baseImpExeReemb               = comp.baseImpExe;
                            reem.montoIceRemb                  = comp.montoIce;
                            reem.montoIvaRemb                  = comp.montoIva;
                            comp_det.totbasesImpReembSpecified = true;
                            comp_det.totbasesImpReemb          = Convert.ToString(Convert.ToDecimal(comp.baseImponible) + Convert.ToDecimal(comp.baseImpGrav));
                            comp_det.reembolsos.Add(reem);
                        }

                        #endregion

                        #region retencion por facturas
                        if (info_ats.lst_retenciones != null)
                        {
                            if (info_ats.lst_retenciones.Count() > 0)
                            {
                                var lstret_x_fac = info_ats.lst_retenciones.Where(r => r.Cedula_ruc == comp.idProv & r.co_serie == comp.establecimiento + "-" + comp.puntoEmision & comp.secuencial == r.co_factura);
                                if (lstret_x_fac != null)
                                {
                                    if (lstret_x_fac.Count() > 0)
                                    {
                                        comp_det.air = new List <detalleAir>();
                                        foreach (var item in lstret_x_fac)
                                        {
                                            if (item.re_tipo_Ret == "RTF")
                                            {
                                                comp_det.air.Add(new detalleAir
                                                {
                                                    codRetAir     = item.codRetAir.ToString(),
                                                    baseImpAir    = item.baseImpAir.ToString(),
                                                    porcentajeAir = item.porcentajeAir.ToString(),
                                                    valRetAir     = item.valRetAir.ToString(),
                                                });
                                            }
                                            else
                                            {
                                                if (item.porcentajeAir == "10")
                                                {
                                                    comp_det.valRetBien10 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "20")
                                                {
                                                    comp_det.valRetServ20 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "30")
                                                {
                                                    comp_det.valorRetBienes = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "50")
                                                {
                                                    comp_det.valRetServ50 = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "70")
                                                {
                                                    comp_det.valorRetServicios = item.valRetAir.ToString();
                                                }
                                                if (item.porcentajeAir == "100")
                                                {
                                                    comp_det.valRetServ100 = item.valRetAir.ToString();
                                                }
                                            }
                                        }
                                    }
                                    else   // si no tiene retencion
                                    {
                                        comp_det.air = new List <detalleAir>();
                                        comp_det.air.Add(new detalleAir
                                        {
                                            codRetAir     = "332",
                                            baseImpAir    = Convert.ToDecimal(comp.baseImpGrav + comp.baseImponible).ToString(),
                                            porcentajeAir = "0",
                                            valRetAir     = "0.00",
                                        });
                                    }
                                }
                            }
                        }
                        #endregion
                        ats.compras.Add(comp_det);
                    });
                }
                #endregion

                #region Ventas
                if (info_ats.lst_ventas != null)
                {
                    #region Agrupando clintes



                    var lst_ventas_x_cliente = (from q in info_ats.lst_ventas

                                                group q by new
                    {
                        q.idCliente,
                        q.DenoCli,
                        q.tipoCliente,
                        q.tipoComprobante,
                        q.tpIdCliente
                    }
                                                into g
                                                select new ventas_Info
                    {
                        idCliente = g.Key.idCliente,
                        DenoCli = g.Key.DenoCli,
                        tipoCliente = g.Key.tipoCliente,
                        tpIdCliente = g.Key.tpIdCliente,
                        tipoComprobante = g.Key.tipoComprobante,
                        baseNoGraIva = g.Sum(y => y.baseNoGraIva),
                        baseImponible = g.Sum(y => y.baseImponible),
                        baseImpGrav = g.Sum(y => y.baseImpGrav),
                        montoIva = g.Sum(y => y.montoIva),
                        montoIce = g.Sum(y => y.montoIce),
                        valorRetIva = g.Sum(y => y.valorRetIva),
                        valorRetRenta = g.Sum(y => y.valorRetRenta),
                        numeroComprobantes = info_ats.lst_ventas.Count()
                    }).ToList();


                    if (lst_ventas_x_cliente.Count > 0)
                    {
                        ats.ventas = new List <detalleVentas>();
                        lst_ventas_x_cliente.ForEach(
                            vent =>
                        {
                            detalleVentas det_ventas         = new detalleVentas();
                            det_ventas.tpIdCliente           = vent.tpIdCliente;
                            det_ventas.idCliente             = vent.idCliente;
                            det_ventas.parteRelVtas          = parteRelType.NO;
                            det_ventas.parteRelVtasSpecified = true;

                            if (vent.tipoCliente == " 01" && vent.idCliente != "9999999999999")
                            {
                                det_ventas.tipoCliente = vent.tipoCliente;
                            }

                            if (det_ventas.idCliente == "9999999999999")
                            {
                                det_ventas.tpIdCliente           = "07";
                                det_ventas.parteRelVtasSpecified = false;
                            }
                            if (det_ventas.tpIdCliente == "06")
                            {
                                det_ventas.tipoCliente = vent.tipoCliente;
                                det_ventas.denoCli     = vent.DenoCli;
                            }

                            vent.DenoCli = cl_funciones.QuitartildesEspaciosPuntos(vent.DenoCli);
                            det_ventas.tipoComprobante    = "18";
                            det_ventas.tipoEmision        = tipoEmisionType.F;
                            det_ventas.numeroComprobantes = vent.numeroComprobantes.ToString();
                            det_ventas.baseNoGraIva       = vent.baseNoGraIva;
                            det_ventas.baseImponible      = vent.baseImponible;
                            det_ventas.baseImpGrav        = vent.baseImpGrav;
                            det_ventas.montoIva           = vent.montoIva;
                            det_ventas.montoIce           = vent.montoIce;
                            det_ventas.valorRetIva        = vent.valorRetIva.ToString("n2");
                            det_ventas.valorRetRenta      = vent.valorRetRenta.ToString("n2");
                            det_ventas.montoIceSpecified  = true;
                            det_ventas.formasDePago       = null;
                            string[] AFormaPago           = { "20" };
                            det_ventas.formasDePago       = AFormaPago;

                            ats.ventas.Add(det_ventas);
                        }
                            );
                    }
                }



                #endregion



                #endregion

                #region ventas por establecimientos
                if (info_ats.lst_ventas != null)
                {
                    if (info_ats.lst_ventas.Count() > 0)
                    {
                        ats.ventasEstablecimiento = new List <ventaEst>();

                        var vtas = info_ats.lst_ventas.GroupBy(x => x.codEstab)
                                   .Select(x => new
                        {
                            codEstab    = x.Key,
                            ventasEstab = x.Sum(y => y.ventasEstab)
                        }).ToList();

                        foreach (var item in vtas)
                        {
                            ventaEst vtas_esta = new ventaEst();
                            vtas_esta.codEstab    = item.codEstab;
                            vtas_esta.ventasEstab = item.ventasEstab;
                            vtas_esta.ivaComp     = Convert.ToDecimal("0.00");
                            ats.ventasEstablecimiento.Add(vtas_esta);
                        }
                    }
                }
                #endregion

                #region exportaciones
                if (info_ats.lst_exportaciones != null)
                {
                    if (info_ats.lst_exportaciones.Count() > 0)
                    {
                        ats.exportaciones = new List <detalleExportacionesType>();
                        info_ats.lst_exportaciones.ForEach
                        (
                            exp =>
                        {
                            detalleExportacionesType exp_det = new detalleExportacionesType();
                            exp_det.tpIdClienteEx            = exp.tpIdClienteEx;
                            exp_det.idClienteEx         = exp.idClienteEx;
                            exp_det.parteRelExp         = parteRelType.NO;
                            exp_det.tipoCli             = "02";
                            exp_det.denoExpCli          = exp.denoExpCli = cl_funciones.QuitartildesEspaciosPuntos(exp.denoExpCli);
                            exp_det.tipoRegi            = tipoRegiType.Item01;
                            exp_det.paisEfecPagoGen     = exp.paisEfecPagoGen;
                            exp_det.paisEfecExp         = exp.paisEfecExp;
                            exp_det.exportacionDe       = exp.exportacionDe;
                            exp_det.tipoComprobante     = exp.tipoComprobante;
                            exp_det.fechaEmbarque       = exp.fechaEmbarque.ToString().Substring(0, 10);
                            exp_det.valorFOB            = (exp.valorFOB) == null?Convert.ToDecimal(0.00):Convert.ToDecimal(exp.valorFOB);
                            exp_det.valorFOBComprobante = (exp.valorFOB) == null ? Convert.ToDecimal(0.00) : Convert.ToDecimal(exp.valorFOBComprobante);
                            exp_det.establecimiento     = exp.establecimiento;
                            exp_det.puntoEmision        = exp.puntoEmision;
                            exp_det.secuencial          = exp.secuencial;
                            exp_det.autorizacion        = (exp.autorizacion) == null?"34345454656453":exp.autorizacion;
                            exp_det.fechaEmision        = exp.fechaEmision.ToString().Substring(0, 10);
                            //exp_det.pagoRegFisSpecified = true;
                            exp_det.parteRelExpSpecified = true;
                            exp_det.tipoRegiSpecified    = true;
                            //exp_det.impuestoOtroPaisSpecified = true;
                            //exp_det.ingExtGravOtroPaisSpecified = true;
                            ats.exportaciones.Add(exp_det);
                        }
                        );
                    }
                }
                #endregion

                #region Anulados
                if (info_ats.lst_anulados != null)
                {
                    if (info_ats.lst_anulados.Count() > 0)
                    {
                        ats.anulados = new List <detalleAnulados>();
                        info_ats.lst_anulados.ForEach
                        (
                            anu =>
                        {
                            detalleAnulados anula  = new detalleAnulados();
                            anula.tipoComprobante  = anu.tipoComprobante;
                            anula.establecimiento  = anu.Establecimiento;
                            anula.puntoEmision     = anu.puntoEmision;
                            anula.secuencialInicio = anu.secuencialInicio;
                            anula.secuencialFin    = anu.secuencialFin;
                            anula.autorizacion     = anu.Autorizacion;
                            ats.anulados.Add(anula);
                        }
                        );
                    }
                }
                #endregion


                if (info_ats.lst_ventas.Count == 0)
                {
                    ats.totalVentasSpecified = false;
                }
                else
                {
                    ats.numEstabRuc = info_ats.lst_ventas.GroupBy(x => x.codEstab)
                                      .Select(x => new
                    {
                        codEstab    = x.Key,
                        ventasEstab = x.Sum(y => y.ventasEstab)
                    }).Count().ToString().PadLeft(3, '0');
                    ats.totalVentasSpecified = true;
                }
                return(ats);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 26
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            #region Variables
            tb_empresa_List         ListaEmpresa   = new tb_empresa_List();
            List <tb_empresa_Info>  Lista_Empresa  = new List <tb_empresa_Info>();
            tb_sucursal_List        ListaSucursal  = new tb_sucursal_List();
            List <tb_sucursal_Info> Lista_Sucursal = new List <tb_sucursal_Info>();
            tb_bodega_List          ListaBodega    = new tb_bodega_List();
            List <tb_bodega_Info>   Lista_Bodega   = new List <tb_bodega_Info>();


            int     cont = 0;
            decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual);
            int     IdEmpresa            = Convert.ToInt32(SessionFixed.IdEmpresa);
            #endregion


            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);
            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);

                #region Empresa
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_empresa_Info info = new tb_empresa_Info
                        {
                            IdEmpresa              = Convert.ToInt32(reader.GetValue(0)),
                            codigo                 = Convert.ToString(reader.GetValue(1)),
                            em_nombre              = Convert.ToString(reader.GetValue(2)),
                            RazonSocial            = Convert.ToString(reader.GetValue(3)),
                            NombreComercial        = Convert.ToString(reader.GetValue(4)),
                            ContribuyenteEspecial  = Convert.ToString(reader.GetValue(5)),
                            em_ruc                 = Convert.ToString(reader.GetValue(6)),
                            em_gerente             = Convert.ToString(reader.GetValue(7)),
                            em_contador            = Convert.ToString(reader.GetValue(8)),
                            em_rucContador         = Convert.ToString(reader.GetValue(9)),
                            em_telefonos           = Convert.ToString(reader.GetValue(10)),
                            em_direccion           = Convert.ToString(reader.GetValue(11)),
                            em_fechaInicioContable = reader.GetDateTime(12),
                            cod_entidad_dinardap   = Convert.ToString(reader.GetValue(13)),
                            em_Email               = Convert.ToString(reader.GetValue(14))
                        };
                        info.em_fechaInicioActividad = info.em_fechaInicioContable;
                        Lista_Empresa.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaEmpresa.set_list(Lista_Empresa, IdTransaccionSession);
                #endregion

                cont = 0;
                reader.NextResult();

                #region Sucursal
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_sucursal_Info info = new tb_sucursal_Info
                        {
                            IdEmpresa                = Convert.ToInt32(reader.GetValue(0)),
                            IdSucursal               = Convert.ToInt32(reader.GetValue(1)),
                            codigo                   = Convert.ToString(reader.GetValue(2)),
                            Su_Descripcion           = Convert.ToString(reader.GetValue(3)),
                            Su_CodigoEstablecimiento = Convert.ToString(reader.GetValue(4)),
                            Su_Ruc                   = Convert.ToString(reader.GetValue(5)),
                            Su_JefeSucursal          = Convert.ToString(reader.GetValue(6)),
                            Su_Telefonos             = Convert.ToString(reader.GetValue(7)),
                            Su_Direccion             = Convert.ToString(reader.GetValue(8)),
                            IdUsuario                = SessionFixed.IdUsuario
                        };
                        Lista_Sucursal.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaSucursal.set_list(Lista_Sucursal, IdTransaccionSession);
                #endregion

                cont = 0;
                //Para avanzar a la siguiente hoja de excel
                reader.NextResult();

                #region Bodega
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0) && cont > 0)
                    {
                        tb_bodega_Info info = new tb_bodega_Info
                        {
                            IdEmpresa       = Convert.ToInt32(reader.GetValue(0)),
                            IdSucursal      = Convert.ToInt32(reader.GetValue(1)),
                            IdBodega        = Convert.ToInt32(reader.GetValue(2)),
                            cod_bodega      = Convert.ToString(reader.GetValue(3)),
                            bo_Descripcion  = Convert.ToString(reader.GetValue(4)),
                            IdCtaCtble_Inve = Convert.ToString(reader.GetValue(5)),
                            IdUsuario       = SessionFixed.IdUsuario
                        };
                        Lista_Bodega.Add(info);
                    }
                    else
                    {
                        cont++;
                    }
                }
                ListaBodega.set_list(Lista_Bodega, IdTransaccionSession);
                #endregion
            }
        }