meta data de esta página
  •  

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anterior Revisión previa
Próxima revisión
Revisión previa
ejemploenviarfactura [2022/03/29 19:52]
scastillo
ejemploenviarfactura [2024/03/30 08:56] (actual)
47.128.21.134 se ha restaurado la vieja versión (2022/03/29 19:44)
Línea 4: Línea 4:
  
 <code csharp Enviar> <code csharp Enviar>
- try +var url "https://testemision.thefactoryhka.com.do/api/Autenticacion";
-            { +
-                Cuerpo cuerpo new Cuerpo() +
-                { +
-                    token = textBox161.Text, +
-                    documentoElectronico = new DocumentoElectronico()+
  
-                }; 
  
-                cuerpo.documentoElectronico.encabezado = new Encabezado(+            Autent autenticacion = new Autent()
-                { +
-                    identificacionDocumento = new IdentificacionDocumento() +
-                    { +
-                        tipoDocumento = textBox4.Text, +
-                        ncf = textBox5.Text, +
-                        fechaVencimientoSecuencia = textBox6.Text, +
-                        indicadorEnvioDiferido = textBox7.Text, +
-                        indicadorMontoGravado = textBox8.Text, +
-                        tipoIngresos = textBox10.Text, +
-                        tipoPago = textBox11.Text, +
-                        tablaFormasPago = new List<TablaFormasPago>() +
-                         +
- +
-                    }, +
-                    emisor = new Emisor() +
-                    { +
-                        rnc = textBox19.Text, +
-                        razonSocial = textBox20.Text, +
-                        nombreComercial = textBox21.Text, +
-                        sucursal = textBox22.Text, +
-                        direccion = textBox23.Text, +
-                        municipio = textBox24.Text, +
-                        provincia = textBox25.Text, +
-                        tablaTelefono = new List<string>(), +
-                        correo = textBox26.Text, +
-                        webSite = textBox27.Text, +
-                        codigoVendedor = textBox29.Text, +
-                        numeroFacturaInterna = textBox30.Text, +
-                        numeroPedidoInterno = textBox31.Text, +
-                        zonaVenta = textBox32.Text, +
-                        //fechaEmision = textBox35.Text; +
-                        fechaEmision = dateTimePicker1.Value.ToShortDateString().Replace("/","-"+
-                    }, +
-                     +
- +
-                    comprador = new Comprador() +
-                    { +
-                        rnc = textBox39.Text, +
-                        razonSocial = textBox41.Text, +
-                        contacto = textBox42.Text, +
-                        correo = textBox43.Text, +
-                        direccion = textBox44.Text, +
-                        municipio = textBox45.Text, +
-                        provincia = textBox46.Text, +
-                        pais = textBox47.Text, +
-                        fechaEntrega = textBox48.Text, +
-                        fechaOrden = textBox52.Text, +
-                        numeroOrden = textBox53.Text, +
-                        codigoInterno = textBox54.Text, +
- +
-                    }, +
-                    informacionesAdicionales = new InformacionesAdicionales() +
-                    { +
-                        numeroContenedor = textBox59.Text, +
-                        numeroReferencia = textBox60.Text, +
-                    }, +
- +
-                    totales = new Totales() +
-                    { +
-                        montoGravadoTotal = textBox94.Text, +
-                        montoGravadoI1 = textBox95.Text, +
-                        itbiS1 = textBox99.Text, +
-                        totalITBIS = textBox102.Text, +
-                        totalITBIS1 = textBox103.Text, +
-                        montoTotal = textBox107.Text, +
-                    }, +
- +
-                }; +
-                TablaFormasPago item = new TablaFormasPago() +
-                { +
-                    forma = "1", +
-                    monto = textBox107.Text +
-                }; +
- +
-               +
-                cuerpo.documentoElectronico.encabezado.identificacionDocumento.tablaFormasPago.Add(item); +
- +
- +
-                cuerpo.documentoElectronico.encabezado.emisor.tablaTelefono.Add("809-472-7676"); +
-                cuerpo.documentoElectronico.encabezado.emisor.tablaTelefono.Add("809-491-1918"); +
- +
-                DetallesItem detalles = new DetallesItem() +
-                { +
-                    numeroLinea = "1", +
-                    indicadorFacturacion = "1", +
-                    nombre = "ASW DTU", +
-                    indicadorBienoServicio = "1", +
-                    cantidad = "15", +
-                    unidadMedida = "31", +
-                    precioUnitario = "400.00", +
-                    monto = "6000.00", +
-                    descripcion="Una descripcion normal" +
-                     +
-                }; +
-                 +
-               DataGridViewButtonColumn edit=new DataGridViewButtonColumn(); +
-                edit.Visible = true; +
-                edit.Name = "Editar"; +
-                edit.Text = "Editar"; +
-                edit.UseColumnTextForButtonValue = true; +
- +
-                dataGridView1.Columns.Add(edit); +
- +
-                detallesItemBindingSource.DataSource = detalles; +
-                cuerpo.documentoElectronico.detallesItems = new List<DetallesItem>(); +
-                cuerpo.documentoElectronico.detallesItems.Add(detalles); +
-                HttpClient cliente = new HttpClient(); +
-                cliente.BaseAddress = new Uri("https://testemision.thefactoryhka.com.do"); +
-                cliente.DefaultRequestHeaders.Add("Authorization", "Bearer " + textBox161.Text); +
-                string jsonObject = JsonSerializer.Serialize(cuerpo); +
-                var content = new StringContent(jsonObject.ToString(), Encoding.UTF8, "application/json"); +
-                var resp = cliente.PostAsync("api/Enviar", content).Result;                +
-                var resultado = resp.Content.ReadAsStringAsync();                   +
-                string dame = resultado.Result; +
-                var Respuesta = JsonSerializer.Deserialize<Recibido>(dame); +
-                if (Respuesta.procesado == true) +
-                { +
-                    richTextBox1.Text = Respuesta.codigo.ToString() + "\r\n" + Respuesta.mensaje + "\r\n" + Respuesta.procesado.ToString() + "\r\n" + Encoding.UTF8.GetString(Convert.FromBase64String(Respuesta.xmlBase64)); +
-                } +
-                else +
-                { +
-                    richTextBox1.Text = Respuesta.codigo.ToString() + "\r\n" + Respuesta.mensaje + "\r\n" + Respuesta.procesado.ToString(); +
- +
-                } +
-     +
- +
-               +
- +
-            } +
-             +
-            catch (Exception b)+
             {             {
-                MessageBox.Show(b.ToString()); +                rnc = "130960054", 
-                 +                clave = "130960054", 
-            } +                usuario = "130960054_int"
- +
-</code> +
- +
-Donde se encuentran las siguientes clases: +
- +
-<code csharp Clases > +
- public class Autent +
-    { +
-        public string rnc { get; set; } +
-        public string clave { get; set; } +
-        public string usuario { get; set; }+
  
-    }+            };
  
 +            var resultado = Post(autenticacion, url);
  
- public class RespAutent +            RespAutent Respuesta = new RespAutent()
-    { +            Respuesta = JsonSerializer.Deserialize<RespAutent>(resultado);
-        public string token { getset; } +
-        public string fechaExpiracion { get; set}+
  
-        public double codigo { get; set; } 
-        public string mensaje { get; set; } 
  
-    }+            textBox161.Text = Respuesta.token;
 </code> </code>