예제 #1
0
        private void ucGe_Menu_event_btn_Generar_XML_Click(object sender, EventArgs e)
        {
            try
            {
                oTb_Empresa_Info = oTb_Empresa_Bus.Get_Info_Empresa(param.IdEmpresa);


                if (oListRo_Empleado_Info != null)
                {
                    oRdep = oRo_Empleado_Bus.setInfoXML(oListRo_Empleado_Info, oTb_Empresa_Info.em_ruc, Convert.ToInt32(ucGe_Aniof1.get_anio()));
                    if (oRdep != null)
                    {
                        XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces();
                        NamespaceObject.Add("", "");
                        XmlSerializer mySerializer = new XmlSerializer(typeof(rdep));
                        StreamWriter  myWriter     = new StreamWriter(txtRutaERDP.Text + oTb_Empresa_Info.em_ruc + ".xml");
                        mySerializer.Serialize(myWriter, oRdep, NamespaceObject);
                        myWriter.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Log_Error_bus.Log_Error(ex.ToString());
            }
        }
예제 #2
0
        public FileResult Modificar(ro_rdep_Info model)
        {
            string nombre_file = "RDEP-" + model.pe_anio.ToString();
            string xml         = "";
            rdep   RDEP        = new rdep();
            int    IdEmpresa   = Convert.ToInt32(SessionFixed.IdEmpresa);

            RDEP = bus_ro_rpde.get_info_xml(model.IdEmpresa, model.Id_Rdep);
            var ms = new MemoryStream();
            var xw = XmlWriter.Create(ms);

            var serializer             = new XmlSerializer(RDEP.GetType());
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");
            serializer.Serialize(xw, RDEP, ns);
            xw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            using (var sr = new StreamReader(ms, Encoding.UTF8))
            {
                xml = sr.ReadToEnd();
            }
            byte[] fileBytes = ms.ToArray();
            return(File(fileBytes, "application/xml", nombre_file + ".xml"));
        }
예제 #3
0
        public ActionResult Index(Rdep_Info model)
        {
            string nombre_file = "RDEP";

            string xml        = "";
            rdep   rdep       = new rdep();
            int    IdEmpresa  = Convert.ToInt32(SessionFixed.IdEmpresa);
            int    IdSucursal = Convert.ToInt32(SessionFixed.IdSucursal);

            rdep = bus_rpde.get_list(IdEmpresa, Convert.ToInt32(model.pe_anio), model.IdEmpleado);
            var ms                     = new MemoryStream();
            var xw                     = XmlWriter.Create(ms);
            var serializer             = new XmlSerializer(rdep.GetType());
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");
            serializer.Serialize(xw, rdep, ns);
            xw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            using (var sr = new StreamReader(ms, Encoding.UTF8))
            {
                xml = sr.ReadToEnd();
            }
            byte[] fileBytes = ms.ToArray();
            return(File(fileBytes, "application/xml", nombre_file + ".xml"));
        }
예제 #4
0
        public Boolean pu_GenerarXMLRDEP(List <ro_Rdep_Info> info, int idEmpresa, int idPeriodo, ref string RutaDescarga, ref string msg)
        {
            try
            {
                Boolean valorRetornar = false;

                //OBTIENE LOS DATOS DE LA EMPRESA
                tb_Empresa_Bus  oTb_Empresa_Bus  = new Business.General.tb_Empresa_Bus();
                tb_Empresa_Info oTb_Empresa_Info = new tb_Empresa_Info();

                oTb_Empresa_Info = oTb_Empresa_Bus.Get_Info_Empresa(idEmpresa);

                //CONVIERTE LA CONSULTA EN EL OBJETO PARA EL XML
                rdep oRdep = new rdep();
                oRdep = setInfoXML(info, oTb_Empresa_Info.em_ruc.Trim(), idPeriodo);


                if (oRdep != null)
                {
                    string idRdep = oTb_Empresa_Info.em_nombre.Trim() + idPeriodo.ToString();
                    RutaDescarga = RutaDescarga + "RDEP_" + idRdep + ".xml";
                    XmlSerializerNamespaces NamespaceObject = new XmlSerializerNamespaces();
                    NamespaceObject.Add("", "");
                    XmlSerializer mySerializer = new XmlSerializer(typeof(rdep));
                    StreamWriter  myWriter     = new StreamWriter(RutaDescarga);
                    mySerializer.Serialize(myWriter, oRdep, NamespaceObject);
                    myWriter.Close();

                    return(true);
                }

                return(valorRetornar);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "pu_GenerarXMLRDEP", ex.Message), ex)
                      {
                          EntityType = typeof(ro_Rdep_Bus)
                      };
            }
        }
예제 #5
0
        public rdep setInfoXML(List <ro_Rdep_Info> info, string ruc, int idPeriodo)
        {
            try
            {
                //CAMBIAR LA CULTURA REGIONAL PARA SETEAR EL PUNTO DECIMAL
                System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

                //DATOS DE LA EMPRESA
                rdep oRdep = new rdep();
                oRdep.anio   = idPeriodo.ToString();
                oRdep.numRuc = ruc;

                oRdep.retRelDep = new List <rdepRetRelDepDatRetRelDep>();


                foreach (ro_Rdep_Info item in info)
                {
                    rdepRetRelDepDatRetRelDep detalleRDEP = new rdepRetRelDepDatRetRelDep();

                    detalleRDEP.empleado = new List <rdepRetRelDepDatRetRelDepEmpleado>();
                    rdepRetRelDepDatRetRelDepEmpleado datosEmpleado = new rdepRetRelDepDatRetRelDepEmpleado();


                    //CONSULTAR DATOS DEL EMPLEADO
                    ro_Empleado_Info ro_Empleado_Info = new ro_Empleado_Info();
                    ro_Empleado_Info = oRo_Empleado_Bus.Get_Info_Empleado(item.IdEmpresa, item.IdEmpleado);

                    #region Empleado

                    //Tipo de identificación del trabajador
                    switch (ro_Empleado_Info.InfoPersona.IdTipoDocumento)
                    {
                    case "CED":
                        datosEmpleado.tipIdRet = "C";

                        break;

                    case "PAS":
                        datosEmpleado.tipIdRet = "P";
                        break;

                    default:
                        //Identificación Tributaria del Exterior
                        datosEmpleado.tipIdRet = "E";
                        break;
                    }

                    //Número de identificación del trabajador
                    datosEmpleado.idRet = ro_Empleado_Info.InfoPersona.pe_cedulaRuc;

                    //Apellidos del trabajador
                    datosEmpleado.apellidoTrab = ro_Empleado_Info.InfoPersona.pe_apellido;

                    //Nombres del trabajador
                    datosEmpleado.nombreTrab = ro_Empleado_Info.InfoPersona.pe_nombre;

                    //Código del establecimiento
                    tb_Sucursal_Bus  oTb_Sucursal_Bus  = new tb_Sucursal_Bus();
                    tb_Sucursal_Info oTb_Sucursal_Info = new Info.General.tb_Sucursal_Info();
                    oTb_Sucursal_Info   = oTb_Sucursal_Bus.Get_Info_Sucursal(param.IdEmpresa, param.IdSucursal);
                    datosEmpleado.estab = oTb_Sucursal_Info.Su_CodigoEstablecimiento;

                    //Residencia del trabajador
                    datosEmpleado.residenciaTrab = pu_Right(ro_Empleado_Info.IdTipoResidenciaSRI, 2);

                    //País de residencia del trabajador
                    datosEmpleado.paisResidencia = "593";

                    //Aplica convenio para evitar doble imposición
                    datosEmpleado.aplicaConvenio = pu_Right(ro_Empleado_Info.IdAplicaConvenioDobleImposicionSRI, 2);

                    //Condición del trabajador respecto a discapacidades
                    //if (item.em_empEspecial == "S") {datosEmpleado.tipoTrabajDiscap = "02"; } else {datosEmpleado.tipoTrabajDiscap = "01"; }
                    datosEmpleado.tipoTrabajDiscap = "NO";//= pu_Right(ro_Empleado_Info.IdCondicionDiscapacidadSRI, 2);

                    //Porcentaje de discapacidad
                    datosEmpleado.porcentajeDiscap = ro_Empleado_Info.por_discapacidad.ToString();

                    //Tipo de identificación de la persona con discapacidad a quien sustituye o representa
                    datosEmpleado.tipIdDiscap = pu_Right(ro_Empleado_Info.IdTipoIdentDiscapacitadoSustitutoSRI, 1);

                    //Número de identificación de la persona con discapacidad a quien sustituye o representa
                    datosEmpleado.idDiscap = ro_Empleado_Info.IdentDiscapacitadoSustitutoSRI;

                    //AGREGAR DATOS DEL DETALLE DE EMPLEADOS
                    detalleRDEP.empleado.Add(datosEmpleado);


                    #endregion

                    #region detalle

                    //Sueldos y salarios
                    detalleRDEP.suelSal = item.suelSal;

                    //Sobresueldos, comisiones, bonos y otros ingresos gravados
                    detalleRDEP.sobSuelComRemu = item.sobSuelComRemu;

                    //Participación de utilidades
                    detalleRDEP.partUtil = item.partUtil;

                    //Ingresos gravados generados con otros empleadores
                    detalleRDEP.intGrabGen = item.intGrabGen;

                    //Impuesto a la renta asumido por este empleador
                    detalleRDEP.impRentEmpl = item.impRentEmpl;

                    //Décimo tercer sueldo
                    detalleRDEP.decimTer = item.decimTer;

                    //Décimo cuarto sueldo
                    detalleRDEP.decimCuar = item.decimCuar;

                    //Fondo de reserva
                    detalleRDEP.fondoReserva = item.fondoReserva;

                    //Compensación Económica Salario Digno
                    detalleRDEP.salarioDigno = item.salarioDigno;

                    //Otros ingresos en relación de dependencia que no constituyen renta gravada
                    detalleRDEP.otrosIngRenGrav = item.otrosIngRenGrav;

                    //Ingresos gravados con este empleador (Informativo)
                    detalleRDEP.ingGravConEsteEmpl = item.ingGravConEsteEmpl;

                    //Sistema de salario neto
                    detalleRDEP.sisSalNet = item.sisSalNet;

                    //Aporte personal al IESS con este empleador (únicamente pagado por el trabajador)
                    detalleRDEP.apoPerIess = item.apoPerIess;

                    //Aporte personal al IESS con otros empleadores (únicamente pagado por el trabajador)
                    detalleRDEP.aporPerIessConOtrosEmpls = item.aporPerIessConOtrosEmpls;


                    //*****************DEDUCCION POR GASTOS PERSONALES***********************

                    //Deducción de gastos personales por Vivienda
                    detalleRDEP.deducVivienda = item.deducVivienda;

                    //Deducción de gastos personales por Salud
                    detalleRDEP.deducSalud = item.deducSalud;

                    //Deducción de gastos personales por Educación
                    detalleRDEP.deducEduca = item.deducEduca;

                    //Deducción de gastos personales por Alimentación
                    detalleRDEP.deducAliement = item.deducAliement;

                    //Deducción de gastos personales por Vestimenta
                    //detalleRDEP. = "0.00";

                    //*************************************************************************


                    //Exoneración por Discapacidad
                    detalleRDEP.exoDiscap = item.exoDiscap;

                    //Exoneración por Tercera Edad
                    detalleRDEP.exoTerEd = item.exoTerEd;

                    //Base imponible gravada
                    detalleRDEP.basImp = item.basImp;

                    //Impuesto a la renta causado
                    detalleRDEP.impRentCaus = item.impRentCaus;

                    //Valor del impuesto retenido y asumido por otros empleadores durante el período declarado
                    detalleRDEP.valRetAsuOtrosEmpls = item.valRetAsuOtrosEmpls;

                    //Valor del impuesto asumido por este empleador
                    detalleRDEP.valImpAsuEsteEmpl = item.valImpAsuEsteEmpl;

                    //Valor del impuesto retenido al trabajador por este empleador
                    detalleRDEP.valRet = item.valRet;

                    #endregion

                    oRdep.retRelDep.Add(detalleRDEP);
                }

                return(oRdep);
            }
            catch (Exception ex)
            {
                Core.Erp.Info.Log_Exception.LoggingManager.Logger.Log(Core.Erp.Info.Log_Exception.LoggingCategory.Error, ex.Message);
                throw new Core.Erp.Info.Log_Exception.DalException(string.Format("", "setInfoXML", ex.Message), ex)
                      {
                          EntityType = typeof(ro_Rdep_Bus)
                      };
            }
        }