Attribute VB_Name = "modWSFEXV1Ejemplos"
Option Explicit
Public Sub Ejemplo_xRegistrarConNumero()
' ==========================================================================
' Ejemplo VB6: xRegistrarConNumero / xRegistrarConNumeroS (FEXAuthorize)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' Nota: Emision unitaria (1 comprobante por solicitud). Modalidad RECOMENDADA
' porque el cliente controla nNumero e identificador (cId) para lograr
' idempotencia limpia (Reproceso = "S") ante cortes de red.
' Incluye bloques excluyentes/condicionales y cuadre aritmetico exacto
' entre la tabla de items (xITEMPro_precio_item) y xImp_total.
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nPtoVta As Integer
Dim nTipoCbte As Integer
Dim cIdentificador As String
Dim cNumero As String
Dim nVarianteMetodo As Integer
Dim nTipoExpo As Integer
Dim bTienePermiso As Boolean
Dim nModoMoneda As Integer
Dim bInformarIncoterms As Boolean
Dim nRegimenEspecial As Integer
Dim bIncluirDescuentoGlobal As Boolean
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
' Obligatorio para conectar exclusivamente a WSFEXv1 (excluye WSFEX v0)
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLEnviado = "C:\temp\wsfexv1_registrar_enviado.xml"
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_registrar_recibido.xml"
' Opciones de prueba para mostrar variantes excluyentes / condicionales
nPtoVta = 3
nTipoCbte = 19 ' 19 = Factura E | 20 = Nota de Debito E | 21 = Nota de Credito E
nTipoExpo = 1 ' 1 = Bienes | 2 = Servicios | 4 = Otros
bTienePermiso = True ' Solo aplica si nTipoCbte = 19, nTipoExpo = 1 y nRegimenEspecial <> 1
nModoMoneda = 1 ' 1 = Moneda Extranjera ("S") | 2 = Moneda Extranjera ("N") | 3 = Pesos ("PES")
bInformarIncoterms = True ' Obligatorio en 19 + Bienes (error 1640); opcional en el resto
nRegimenEspecial = 0 ' 0 = Regimen General | 1 = Exporta Simple (RGC 4458) | 2 = Harinero/Tabaco (RG 5264)
bIncluirDescuentoGlobal = False ' True = agrega item negativo Pro_umed = 99 (Manual ARCA Ejemplo Request 4)
nVarianteMetodo = 1 ' 1 = xRegistrarConNumeroS (String 64 bits) | 2 = xRegistrarConNumero (Long 32 bits VB6)
cIdentificador = "202611210000001" ' Entero positivo unico de hasta 15 digitos
cNumero = "1" ' Correlativo exacto: xFEGetLastCMPS + 1
' --- Datos de Cabecera del Comprobante ---
' Asignar tambien xPunto_vta / xtipo_cbte permite calcular luego xCodigoDeBarraAFIP
fe.xPunto_vta = nPtoVta
fe.xtipo_cbte = nTipoCbte
fe.xCbte_nroS = cNumero
fe.xFecha_cbte = "20261121" ' Formato yyyyMMdd (+/- 5 dias de la fecha actual)
fe.xtipo_expo = nTipoExpo
fe.xDst_cmp = 203 ' 203 = Brasil (segun xFEGetPARAM_DST_PAIS)
fe.xCliente = "Joao Da Silva S.A." ' Max. 200 caracteres
fe.xDomicilio_cliente = "Rua 76 km 34.5 Alagoas, Brasil" ' Max. 300 caracteres
fe.xCuit_pais_clienteS = "50000000016" ' Segun xFEGetPARAM_DST_CUIT (si se informa, Id_impositivo es opcional)
fe.xId_impositivo = "PJ54482221-1" ' Obligatorio solo si Cuit_pais_cliente = 0
fe.xIdioma_cbte = "1" ' "1" = Espanol | "2" = Ingles | "3" = Portugues
fe.xObs_comerciales = "Mercaderia de exportacion certificada ISO 9001"
fe.xObs = "Operacion de prueba WSFEXv1"
' --- Bloque Excluyente 1: Tipo de Comprobante, Exportacion, Permisos y Fecha_pago ---
Select Case nTipoCbte
Case 19
' Factura E: Forma_pago obligatoria (error 1620)
fe.xForma_pago = "Transferencia bancaria 30 dias"
Select Case nTipoExpo
Case 1
' Exportacion definitiva de Bienes
fe.xFecha_pago = ""
If nRegimenEspecial = 1 Then
' Exporta Simple (RGC 4458/2019): PROHIBIDO informar <Permisos> (error 2056)
fe.xPermiso_existenteS = "N"
fe.xPermisoNoInformar = 1
fe.xPermisoCantidad = 0
ElseIf bTienePermiso Then
' Bienes con permiso de embarque: informar tabla Permisos
fe.xPermiso_existenteS = "S"
fe.xPermisoNoInformar = 0
fe.xPermisoCantidad = 1
fe.xIndiceItem = 0
fe.xPERMISO_id_permiso = "09052EC01006154G"
fe.xPERMISO_dst_merc = 203
Else
' Bienes sin permiso de embarque aun: omitir nodo <Permisos> (error 1720)
fe.xPermiso_existenteS = "N"
fe.xPermisoNoInformar = 1
fe.xPermisoCantidad = 0
End If
Case 2, 4
' Servicios (2) u Otros (4): Fecha_pago obligatoria (>= Fecha_cbte, errores 1672/1674)
' y NO corresponde informar permisos (errores 1550 / 1720 / 1736)
fe.xFecha_pago = "20261221"
fe.xPermiso_existenteS = ""
fe.xPermisoNoInformar = 1
fe.xPermisoCantidad = 0
End Select
Case 20, 21
' Nota de Debito E (20) o Nota de Credito E (21):
' Fecha_pago y Permiso_existente deben quedar vacios; omitir <Permisos> (errores 1550 / 1673)
fe.xForma_pago = "Cuenta corriente"
fe.xFecha_pago = ""
fe.xPermiso_existenteS = ""
fe.xPermisoNoInformar = 1
fe.xPermisoCantidad = 0
End Select
' --- Bloque Excluyente 2: Moneda, Cotizacion y CanMisMonExt (RG 5616 / v3.0.0) ---
' Nota ARCA error 1605: CanMisMonExt SOLO corresponde a Factura 19 en moneda <> "PES".
' En Factura 19 con "PES", o en ND/NC (20/21), CanMisMonExt debe quedar vacio "".
Select Case nModoMoneda
Case 1
' Moneda extranjera cancelada en la misma moneda extranjera ("S" solo en Cbte 19)
' Si xMoneda_ctz = 0 con CanMisMonExt = "S", ARCA aplica cotizacion BNA de oficio
fe.xMoneda_idS = "DOL"
If nTipoCbte = 19 Then
fe.xCanMisMonExt = "S"
Else
fe.xCanMisMonExt = ""
End If
fe.xMoneda_ctzS = "1050.5"
Case 2
' Moneda extranjera cancelada en pesos ("N" solo en Cbte 19): cotizacion obligatoria (> 0)
fe.xMoneda_idS = "DOL"
If nTipoCbte = 19 Then
fe.xCanMisMonExt = "N"
Else
fe.xCanMisMonExt = ""
End If
fe.xMoneda_ctzS = "1050.5"
Case 3
' Pesos argentinos ("PES"): CanMisMonExt debe omitirse ("") y cotizacion = 1 (error 1601/1605)
fe.xMoneda_idS = "PES"
fe.xCanMisMonExt = ""
fe.xMoneda_ctz = 1
End Select
' --- Bloque Condicional 3: Incoterms e Incoterms_Ds ---
' Error ARCA 1640: Incoterms es OBLIGATORIO si Cbte_Tipo = 19 y Tipo_expo = 1 (Bienes).
If bInformarIncoterms Or (nTipoCbte = 19 And nTipoExpo = 1) Then
fe.xIncoTerms = "CIF" ' Segun xFEGetPARAM_IncoTerms
fe.xIncoTerms_ds = "Puerto de Santos" ' Solo valido si xIncoTerms <> "" (max. 20 car., errores 1641/1642)
Else
fe.xIncoTerms = ""
fe.xIncoTerms_ds = ""
End If
' --- Subtabla 1: Items (<Items> - Obligatorio al menos 1 item) ---
' Cuadre aritmetico exacto:
' Item 0: (2 * 150.00) - 50.00 = 250.00
' Item 1: (1 * 250.00) - 0.00 = 250.00
' Si bIncluirDescuentoGlobal = True -> Item 2 (Pro_umed = 99): -20.00 -> Total = 480.00
' Si bIncluirDescuentoGlobal = False -> Total = 500.00
If bIncluirDescuentoGlobal Then
fe.xItemCantidad = 3
Else
fe.xItemCantidad = 2
End If
fe.xIndiceItem = 0
fe.xITEMPro_codigo = "PRO-001"
fe.xITEMPro_ds = "Producto industrial tipo A - exportacion"
fe.xITEMPro_qty = 2#
fe.xITEMPro_umed = 7 ' 7 = Unidades (segun xFEGetPARAM_uMed)
fe.xITEMPro_precio_uni = 150#
fe.xITEMPro_bonificacion = 50#
fe.xITEMPro_precio_item = 250# ' (2 * 150) - 50 = 250
fe.xIndiceItem = 1
fe.xITEMPro_codigo = "PRO-002"
fe.xITEMPro_ds = "Producto industrial tipo B - exportacion"
fe.xITEMPro_qty = 1#
fe.xITEMPro_umed = 7
fe.xITEMPro_precio_uni = 250#
fe.xITEMPro_bonificacion = 0#
fe.xITEMPro_precio_item = 250# ' (1 * 250) - 0 = 250
If bIncluirDescuentoGlobal Then
' Descuento/Bonificacion global (Manual ARCA Ejemplo Request 4, reglas 1775 y 1810):
' Con Pro_umed = 99: qty, precio_uni y bonificacion deben ser 0 y precio_item < 0.
fe.xIndiceItem = 2
fe.xITEMPro_codigo = "DESC-01"
fe.xITEMPro_ds = "Bonificacion comercial global"
fe.xITEMPro_qty = 0#
fe.xITEMPro_umed = 99 ' 99 = Bonificacion | 97 = Anticipo/Sena
fe.xITEMPro_precio_uni = 0#
fe.xITEMPro_bonificacion = 0#
fe.xITEMPro_precio_item = -20#
fe.xImp_total = 480# ' 250.00 + 250.00 - 20.00 = 480.00
Else
' Importe total del comprobante (coincide con la suma de xITEMPro_precio_item)
fe.xImp_total = 500#
End If
' --- Subtablas Condicionales 2, 3 y 4: Asociados, Actividades y Opcionales ---
' Se manejan como regimenes mutuamente excluyentes para cumplir ARCA v3.1.1:
' 0 = Regimen General | 1 = Exporta Simple (RGC 4458) | 2 = Harinero/Tabaco (RG 5264)
fe.xCmps_asocCantidad = 0
fe.xActividadItemCantidad = 0
fe.xOpcionalItemCantidad = 0
If nTipoCbte = 20 Or nTipoCbte = 21 Then
' ND / NC E: asocia comprobante Clase E valido (nunca a si mismo: error 2009)
fe.xCmps_asocCantidad = 1
fe.xIndiceItem = 0
fe.xCMPS_ASOC_cbte_tipo = 19
fe.xCMPS_ASOC_cbte_punto_venta = nPtoVta
fe.xCMPS_ASOC_cbte_nroS = "1"
fe.xCMPS_ASOC_cbte_cuit = "20111111112"
End If
Select Case nRegimenEspecial
Case 0
' Regimen General: sin opcionales ni remitos sectoriales en Factura 19
Case 1
' Exporta Simple (RGC 4458/2019): solo aplica a Tipo_expo = 1 (error 2011)
' y Moneda_Id = "DOL" (error 2016), sin <Permisos> (error 2056).
If nTipoExpo = 1 And fe.xMoneda_idS = "DOL" Then
If nTipoCbte = 19 Then
' Factura 19: informar 2401 (Doc. Exporta Simple, 11 car.) y 2402 (Monto FOB USD)
fe.xOpcionalItemCantidad = 2
fe.xIndiceItem = 0
fe.xOpcionalId = "2401"
fe.xOpcionalValor = "26001ES0101"
fe.xIndiceItem = 1
fe.xOpcionalId = "2402"
fe.xOpcionalValor = "500.00"
Else
' ND/NC (20/21): PROHIBIDO informar 2401 (error 2057); solo 2402 (Monto FOB USD)
fe.xOpcionalItemCantidad = 1
fe.xIndiceItem = 0
fe.xOpcionalId = "2402"
fe.xOpcionalValor = "500.00"
End If
End If
Case 2
' Regimen Harinero / Tabaco (RG 5264/2022 - errores 1755, 2108, 2109, 2111, 2113):
' En Factura 19 solo se admiten remitos sectoriales:
' 993 = Remito Electronico Harinero Automotor | 994 = Ferroviario
' 88/89 = Tabaco Acondicionado | 91 = Remito R
' La actividad Harinera (ej. 107110) exige asociar remito 993 o 994 (error 2108).
If nTipoCbte = 19 Then
fe.xCmps_asocCantidad = 1
fe.xIndiceItem = 0
fe.xCMPS_ASOC_cbte_tipo = 993 ' 993 = Remito Electronico Harinero - Automotor
fe.xCMPS_ASOC_cbte_punto_venta = nPtoVta
fe.xCMPS_ASOC_cbte_nroS = "1234"
fe.xCMPS_ASOC_cbte_cuit = "20111111112"
End If
fe.xActividadItemCantidad = 1
fe.xIndiceItem = 0
fe.xActividadId = "107110" ' Codigo CLAE de 6 digitos (segun xFEXGetPARAMActividades)
End Select
' --- Ejecutar autorizacion ---
Select Case nVarianteMetodo
Case 1
' Recomendado: recibe cNumero como String (soporta 64 bits)
bResultado = fe.xRegistrarConNumeroS(nPtoVta, nTipoCbte, cIdentificador, cNumero)
Case 2
' En VB6 usar CLng (32 bits = Integer .NET); CInt desborda a partir del comprobante 32768
bResultado = fe.xRegistrarConNumero(nPtoVta, nTipoCbte, cIdentificador, CLng(cNumero))
End Select
' --- Evaluar errores de red/interfaz/servidor ARCA y resultado del CAE ---
If fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
If bResultado And fe.xRespuestaResultado = "A" And fe.xRespuestaCAE <> "" Then
MsgBox "Comprobante Autorizado (xRegistrarConNumero)" & vbCrLf & _
"Resultado: " & fe.xRespuestaResultado & vbCrLf & _
"CAE: " & fe.xRespuestaCAE & vbCrLf & _
"Vencimiento CAE: " & fe.xRespuestaFch_venc_cae & vbCrLf & _
"Nro. Comprobante: " & fe.xRespuestacbte_numeroS & vbCrLf & _
"Reproceso: " & fe.xRespuestaReproceso & vbCrLf & _
"Motivos Obs.: " & fe.xRespuestaMotivos_obs & vbCrLf & _
"Codigo de Barras: " & fe.xCodigoDeBarraAFIP, vbInformation, "WSFEXv1"
Else
MsgBox "Comprobante Rechazado por ARCA" & vbCrLf & _
"Resultado: " & fe.xRespuestaResultado & vbCrLf & _
"Reproceso: " & fe.xRespuestaReproceso & vbCrLf & _
"Motivos Obs./Rechazo: " & fe.xRespuestaMotivos_obs, vbExclamation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xRegistrar()
' ==========================================================================
' Ejemplo VB6: xRegistrar - Autorizacion autonumerada (FEXAuthorize)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' Nota: Calcula internamente xFEGetLastCMP(PtoVta, TipoCbte) + 1 y delega en
' xRegistrarConNumero. Ante timeouts puede impedir reproceso limpio, por
' lo que en produccion se recomienda xRegistrarConNumeroS.
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nPtoVta As Integer
Dim nTipoCbte As Integer
Dim cIdentificador As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLEnviado = "C:\temp\wsfexv1_xregistrar_enviado.xml"
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_xregistrar_recibido.xml"
nPtoVta = 3
nTipoCbte = 19 ' 19 = Factura de Exportacion E
cIdentificador = "202611210000002" ' Entero positivo unico (max. 15 digitos)
' Cabecera basica para Factura E de Servicios (Tipo_expo = 2)
fe.xPunto_vta = nPtoVta
fe.xtipo_cbte = nTipoCbte
fe.xFecha_cbte = "20261121"
fe.xFecha_pago = "20261221" ' Obligatoria en Factura 19 con Tipo_expo = 2 o 4
fe.xtipo_expo = 2 ' 2 = Servicios
fe.xPermiso_existenteS = "" ' Obligatorio "" en Tipo_expo = 2 o 4
fe.xPermisoNoInformar = 1 ' Omite nodo <Permisos>
fe.xPermisoCantidad = 0
fe.xDst_cmp = 212 ' 212 = Estados Unidos
fe.xCliente = "Acme Consulting LLC"
fe.xCuit_pais_clienteS = "55000002126"
fe.xDomicilio_cliente = "742 Evergreen Terrace, Miami FL"
fe.xId_impositivo = ""
fe.xMoneda_idS = "DOL"
fe.xCanMisMonExt = "S"
fe.xMoneda_ctzS = "1050.5"
fe.xObs_comerciales = "Consultoria de software"
fe.xObs = ""
fe.xForma_pago = "Transferencia SWIFT"
fe.xIncoTerms = ""
fe.xIncoTerms_ds = ""
fe.xIdioma_cbte = "2" ' "2" = Ingles
' Subtabla Items (1 item = 500.00 -> coincide con xImp_total = 500.00)
fe.xItemCantidad = 1
fe.xIndiceItem = 0
fe.xITEMPro_codigo = "SRV-01"
fe.xITEMPro_ds = "Desarrollo y soporte de software"
fe.xITEMPro_qty = 10#
fe.xITEMPro_umed = 7
fe.xITEMPro_precio_uni = 50#
fe.xITEMPro_bonificacion = 0#
fe.xITEMPro_precio_item = 500# ' 10 * 50 - 0 = 500
fe.xImp_total = 500#
fe.xCmps_asocCantidad = 0
fe.xActividadItemCantidad = 1
fe.xIndiceItem = 0
fe.xActividadId = "620100"
fe.xOpcionalItemCantidad = 0
bResultado = fe.xRegistrar(nPtoVta, nTipoCbte, cIdentificador)
If fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
If bResultado And fe.xRespuestaResultado = "A" And fe.xRespuestaCAE <> "" Then
MsgBox "Comprobante Autorizado (xRegistrar)" & vbCrLf & _
"Resultado: " & fe.xRespuestaResultado & vbCrLf & _
"CAE: " & fe.xRespuestaCAE & vbCrLf & _
"Vencimiento CAE: " & fe.xRespuestaFch_venc_cae & vbCrLf & _
"Nro. Asignado: " & fe.xRespuestacbte_numeroS & vbCrLf & _
"Reproceso: " & fe.xRespuestaReproceso, vbInformation, "WSFEXv1"
Else
MsgBox "Comprobante Rechazado (" & fe.xRespuestaResultado & ")" & vbCrLf & _
"Motivos Obs.: " & fe.xRespuestaMotivos_obs, vbExclamation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetCMP()
' ==========================================================================
' Ejemplo VB6: xFEGetCMP / xFEGetCMPS - Consulta de comprobante emitido
' (FEXGetCMP)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nPtoVta As Integer
Dim nTipoCbte As Integer
Dim cCbteNro As String
Dim nVariante As Integer
Dim cPrimerItem As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_getcmp_recibido.xml"
nPtoVta = 3
nTipoCbte = 19
cCbteNro = "1"
nVariante = 1 ' 1 = xFEGetCMPS (String 64 bits) | 2 = xFEGetCMP (Long 32 bits en VB6)
Select Case nVariante
Case 1
bResultado = fe.xFEGetCMPS(nPtoVta, nTipoCbte, cCbteNro)
Case 2
bResultado = fe.xFEGetCMP(nPtoVta, nTipoCbte, CLng(cCbteNro))
End Select
' Nota: xFEGetCMP1/1S copia FEXErr.ErrMsg ("OK" en exito) a UltimoMensajeError
If bResultado And (fe.UltimoMensajeError = "" Or UCase$(fe.UltimoMensajeError) = "OK") And fe.xerrcode = 0 Then
cPrimerItem = ""
If fe.xItemCantidad > 0 Then
fe.xIndiceItem = 0
cPrimerItem = fe.xITEMPro_codigo & " - " & fe.xITEMPro_ds & _
" (" & CStr(fe.xITEMPro_precio_item) & ")"
End If
MsgBox "Comprobante WSFEXv1 Consultado" & vbCrLf & _
"CAE: " & fe.xRespuestaCAE & vbCrLf & _
"Resultado: " & fe.xRespuestaResultado & vbCrLf & _
"Vencimiento CAE: " & fe.xRespuestaFch_venc_cae & vbCrLf & _
"Nro. Comprobante: " & fe.xCbte_nroS & vbCrLf & _
"Cliente: " & fe.xCliente & vbCrLf & _
"Moneda / CanMisMonExt: " & fe.xMoneda_id & " / " & fe.xCanMisMonExt & vbCrLf & _
"Total: " & CStr(fe.xImp_total) & vbCrLf & _
"Items (" & CStr(fe.xItemCantidad) & "): " & cPrimerItem & vbCrLf & _
"Permisos: " & CStr(fe.xPermisoCantidad) & _
" | Asoc: " & CStr(fe.xCmps_asocCantidad) & _
" | Act: " & CStr(fe.xActividadItemCantidad) & _
" | Opc: " & CStr(fe.xOpcionalItemCantidad), vbInformation, "WSFEXv1"
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetLastCMP()
' ==========================================================================
' Ejemplo VB6: xFEGetLastCMP / xFEGetLastCMPS - Ultimo comprobante autorizado
' (FEXGetLast_CMP)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim nPtoVta As Integer
Dim nTipoCbte As Integer
Dim nVariante As Integer
Dim cUltimoNro As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
nPtoVta = 3
nTipoCbte = 19
nVariante = 1 ' 1 = xFEGetLastCMPS (String 64 bits) | 2 = xFEGetLastCMP (Long 32 bits en VB6)
Select Case nVariante
Case 1
cUltimoNro = fe.xFEGetLastCMPS(nPtoVta, nTipoCbte)
Case 2
cUltimoNro = CStr(fe.xFEGetLastCMP(nPtoVta, nTipoCbte))
End Select
' Nota: xFEGetLastCMP1/1s copia FEXErr.ErrMsg ("OK" en exito) a UltimoMensajeError
If (fe.UltimoMensajeError = "" Or UCase$(fe.UltimoMensajeError) = "OK") And fe.xerrcode = 0 Then
MsgBox "Ultimo Comprobante WSFEXv1 Autorizado" & vbCrLf & _
"PtoVta: " & CStr(nPtoVta) & " | TipoCbte: " & CStr(nTipoCbte) & vbCrLf & _
"Ultimo Nro.: " & cUltimoNro & vbCrLf & _
"Fecha Ultimo Cbte: " & fe.xRespuestaFch_cbte, vbInformation, "WSFEXv1"
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetLast_ID()
' ==========================================================================
' Ejemplo VB6: xFEGetLast_ID - Ultimo Id de requerimiento procesado
' (FEXGetLast_ID)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim cUltimoId As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
cUltimoId = fe.xFEGetLast_ID()
' Nota: xFEGetLast_ID1 copia FEXErr.ErrMsg ("OK" en exito) a UltimoMensajeError
If (fe.UltimoMensajeError = "" Or UCase$(fe.UltimoMensajeError) = "OK") And fe.xerrcode = 0 Then
MsgBox "Ultimo Id Procesado (FEXGetLast_ID)" & vbCrLf & _
"Ultimo Id: " & cUltimoId, vbInformation, "WSFEXv1"
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xDummy()
' ==========================================================================
' Ejemplo VB6: xDummy - Verificacion de estado de servidores ARCA (FEXDummy)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - (xDummy no requiere Ticket de Acceso WSAA)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xDummy()
If bResultado And fe.UltimoMensajeError = "" Then
MsgBox "Estado Servidores WSFEXv1" & vbCrLf & _
"AppServer: " & fe.xRespuestaDummyAppServer & vbCrLf & _
"DbServer: " & fe.xRespuestaDummyDbServer & vbCrLf & _
"AuthServer: " & fe.xRespuestaDummyAuthServer, vbInformation, "WSFEXv1"
Else
MsgBox "Error en xDummy: " & fe.UltimoMensajeError, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_CTZ()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_CTZ2 / xFEGetPARAM_CTZ / xFEGetPARAM_CTZS
' Cotizacion BNA de moneda (FEXGetPARAM_Ctz)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim dCotiz As Double
Dim nModoConsulta As Integer
Dim strMonId As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
strMonId = "DOL"
nModoConsulta = 1 ' 1 = xFEGetPARAM_CTZ2 (fecha YYYY-MM-DD) | 2 = xFEGetPARAM_CTZ (hoy) | 3 = xFEGetPARAM_CTZS
Select Case nModoConsulta
Case 1
' FEXGetPARAM_Ctz en WSFEXv1 exige formato "YYYY-MM-DD" (error 1003 si es invalido)
dCotiz = fe.xFEGetPARAM_CTZ2(strMonId, "2026-11-20")
Case 2
' Envia automaticamente la fecha del dia en formato "yyyy-MM-dd"
dCotiz = fe.xFEGetPARAM_CTZ(strMonId)
Case 3
' Completa ceros a la izquierda hasta 3 caracteres (ej. "12" -> "012")
dCotiz = fe.xFEGetPARAM_CTZS("12")
End Select
If fe.UltimoMensajeError = "" And fe.xerrcode = 0 And dCotiz > 0 Then
MsgBox "Cotizacion Obtenida (FEXGetPARAM_Ctz)" & vbCrLf & _
"Retorno metodo: " & CStr(dCotiz) & vbCrLf & _
"Cotizacion (xRespuestaMonedaCtz): " & CStr(fe.xRespuestaMonedaCtz) & vbCrLf & _
"Fecha (xRespuestaMonedaCtzFecha): " & fe.xRespuestaMonedaCtzFecha, vbInformation, "WSFEXv1"
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEXGetPARAM_MON_CON_COTIZACION()
' ==========================================================================
' Ejemplo VB6: xFEXGetPARAM_MON_CON_COTIZACION - Lista de monedas con su
' cotizacion vigente para una fecha (FEXGetPARAM_MON_CON_COTIZACION)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' Nota: El argumento recibe la FECHA en formato "YYYYMMDD" (no un codigo de moneda).
' Devuelve 1 en exito (-1 ante error) y puebla xMonedaItemCantidad.
' ==========================================================================
Dim fe As Object
Dim dResultado As Double
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_mon_con_ctz_recibido.xml"
dResultado = fe.xFEXGetPARAM_MON_CON_COTIZACION("20261120")
' Nota: xFEXGetPARAM_MON_CON_COTIZACION copia FEXErr.ErrMsg ("OK" en exito) a UltimoMensajeError
If dResultado = 1 And (fe.UltimoMensajeError = "" Or UCase$(fe.UltimoMensajeError) = "OK") And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xMonedaItemCantidad
nCantidad = fe.xMonedaItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Monedas con Cotizacion" & vbCrLf & _
"Cantidad (xMonedaItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & fe.xMonedaId & vbCrLf & _
"Descripcion: " & fe.xMonedaDS & vbCrLf & _
"Cotizacion: " & fe.xMonedaMon_ctz & vbCrLf & _
"Fecha Cotiz.: " & fe.xMonedaFecha_ctz, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xMonedaItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFECheck_Permiso()
' ==========================================================================
' Ejemplo VB6: xFECheck_Permiso - Validar permiso de embarque y pais destino
' en Aduana/SIM (FEXCheck_Permiso)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim cEstado As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_checkpermiso_recibido.xml"
' Parametros: Id_permiso (16 caracteres SIM) y codigo de pais destino (Dst_merc)
cEstado = fe.xFECheck_Permiso("09052EC01006154G", 203)
If cEstado <> "" And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
MsgBox "Verificacion de Permiso de Embarque" & vbCrLf & _
"Estado (OK / NO): " & cEstado, vbInformation, "WSFEXv1"
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_MON()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_MON - Lista de monedas (FEXGetPARAM_MON)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_MON()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xMonedaItemCantidad
nCantidad = fe.xMonedaItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Monedas Habilitadas" & vbCrLf & _
"Cantidad (xMonedaItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & fe.xMonedaId & vbCrLf & _
"Descripcion: " & fe.xMonedaDS & vbCrLf & _
"Vigencia Desde: " & fe.xMonedaVig_desde & vbCrLf & _
"Vigencia Hasta: " & fe.xMonedaVig_HASTA, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xMonedaItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_tipo_cbte()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_tipo_cbte - Lista de tipos de comprobante
' (FEXGetPARAM_Cbte_Tipo)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_tipo_cbte()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xTipo_CbteItemCantidad
nCantidad = fe.xTipo_CbteItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Tipos de Comprobante WSFEXv1" & vbCrLf & _
"Cantidad (xTipo_CbteItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & CStr(fe.xTipo_cbte_Id) & vbCrLf & _
"Descripcion: " & fe.xTipo_cbte_DS & vbCrLf & _
"Vigencia Desde: " & fe.xTipo_cbte_Vig_desde & vbCrLf & _
"Vigencia Hasta: " & fe.xTipo_cbte_Vig_hasta, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xTipo_CbteItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_Tipo_expo()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_Tipo_expo - Lista de tipos de exportacion
' (FEXGetPARAM_Tipo_Expo)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_Tipo_expo()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xTipo_expoItemCantidad
nCantidad = fe.xTipo_expoItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Tipos de Exportacion" & vbCrLf & _
"Cantidad (xTipo_expoItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & fe.xTipo_expo_tex_Id & vbCrLf & _
"Descripcion: " & fe.xTipo_expo_tex_ds & vbCrLf & _
"Vigencia Desde: " & fe.xTipo_expo_tex_Vig_desde & vbCrLf & _
"Vigencia Hasta: " & fe.xTipo_expo_tex_Vig_hasta, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xTipo_expoItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_uMed()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_uMed - Lista de unidades de medida (FEXGetPARAM_UMed)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_uMed()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xUMedItemCantidad
nCantidad = fe.xUMedItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Unidades de Medida" & vbCrLf & _
"Cantidad (xUMedItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & CStr(fe.xUMed_Id) & vbCrLf & _
"Descripcion: " & fe.xUMed_DS & vbCrLf & _
"Vigencia Desde: " & fe.xUMed_Vig_desde & vbCrLf & _
"Vigencia Hasta: " & fe.xUMed_Vig_hasta, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xUMedItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_Idiomas()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_Idiomas - Lista de idiomas (FEXGetPARAM_Idiomas)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_Idiomas()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xIdiomaItemCantidad
nCantidad = fe.xIdiomaItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Idiomas del Comprobante" & vbCrLf & _
"Cantidad (xIdiomaItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & fe.xIdioma_idi_Id & vbCrLf & _
"Descripcion: " & fe.xIdioma_idi_ds & vbCrLf & _
"Vigencia Desde: " & fe.xIdioma_idi_Vig_desde & vbCrLf & _
"Vigencia Hasta: " & fe.xIdioma_idi_Vig_hasta, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xIdiomaItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_DST_PAIS()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_DST_PAIS - Lista de paises destino (FEXGetPARAM_DST_pais)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_DST_PAIS()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xPaisItemCantidad
nCantidad = fe.xPaisItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Paises de Destino" & vbCrLf & _
"Cantidad (xPaisItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Codigo: " & fe.xPais_dst_codigo & vbCrLf & _
"Descripcion: " & fe.xPais_dst_ds, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xPaisItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_IncoTerms()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_IncoTerms - Lista de Incoterms (FEXGetPARAM_Incoterms)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_incoterms_recibido.xml"
bResultado = fe.xFEGetPARAM_IncoTerms()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xIncoTermsItemCantidad
nCantidad = fe.xIncoTermsItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Clausulas Incoterms" & vbCrLf & _
"Cantidad (xIncoTermsItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & fe.xIncoTErms_inc_Id & vbCrLf & _
"Descripcion: " & fe.xIncoTErms_inc_ds & vbCrLf & _
"Vigencia Desde: " & fe.xIncoTErms_inc_Vig_desde & vbCrLf & _
"Vigencia Hasta: " & fe.xIncoTErms_inc_Vig_hasta, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xIncoTermsItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_DST_CUIT()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_DST_CUIT - Lista de CUITs pais (FEXGetPARAM_DST_CUIT)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_DST_CUIT()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xCuitItemCantidad
nCantidad = fe.xCuitItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "CUITs Pais Receptor" & vbCrLf & _
"Cantidad (xCuitItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> CUIT: " & fe.xCuit_dst_cuit & vbCrLf & _
"Descripcion: " & fe.xCuit_dst_ds, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xCuitItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_PtoVenta()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_PtoVenta - Puntos de venta habilitados para
' exportacion WS (FEXGetPARAM_PtoVenta)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
bResultado = fe.xFEGetPARAM_PtoVenta()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xPtoVentaItemCantidad
nCantidad = fe.xPtoVentaItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Puntos de Venta WSFEXv1" & vbCrLf & _
"Cantidad (xPtoVentaItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Nro: " & CStr(fe.xPtoVenta_pve_nro) & vbCrLf & _
"Bloqueado: " & fe.xPtoVenta_pvo_bloqueado & vbCrLf & _
"Fecha Baja: " & fe.xPtoVenta_pvo_fchbaja, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xPtoVentaItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEGetPARAM_Opcionales()
' ==========================================================================
' Ejemplo VB6: xFEGetPARAM_Opcionales - Lista de campos opcionales vigentes
' (FEXGetPARAM_Opcionales - RGC 4458/2019 Exporta Simple)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_opcionales_recibido.xml"
bResultado = fe.xFEGetPARAM_Opcionales()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xTiposOpcionalItemCantidad
nCantidad = fe.xTiposOpcionalItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Tipos de Opcionales WSFEXv1" & vbCrLf & _
"Cantidad (xTiposOpcionalItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> Id: " & fe.xTiposOpcional_Id & vbCrLf & _
"Descripcion: " & fe.xTiposOpcional_Desc & vbCrLf & _
"Vigencia Desde: " & fe.xTiposOpcional_fchDesde & vbCrLf & _
"Vigencia Hasta: " & fe.xTiposOpcional_fchHasta, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xTiposOpcionalItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
Public Sub Ejemplo_xFEXGetPARAMActividades()
' ==========================================================================
' Ejemplo VB6: xFEXGetPARAMActividades - Lista de actividades CLAE del emisor
' (FEXGetPARAM_Actividades - RG 5264/2022)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' Nota: Existe tambien el alias fe.xFEXGetPARAM_Actividades() que delega en este metodo.
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Dim nCantidad As Integer
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(Modo, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' - fe.xObtenerTicketAcceso() (o restaurado con xRestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.xVersion = 1
fe.tls = 12
fe.ArchivoXMLRecibido = "C:\temp\wsfexv1_actividades_recibido.xml"
bResultado = fe.xFEXGetPARAMActividades()
If bResultado And fe.UltimoMensajeError = "" And fe.xerrcode = 0 Then
' Cantidad de items devueltos: se obtiene de fe.xTiposActividadItemCantidad
nCantidad = fe.xTiposActividadItemCantidad
If nCantidad > 0 Then
fe.xIndiceItem = 0
MsgBox "Actividades Economicas WSFEXv1" & vbCrLf & _
"Cantidad (xTiposActividadItemCantidad): " & CStr(nCantidad) & vbCrLf & _
"Primer item -> IdS: " & fe.xTiposActividad_IdS & vbCrLf & _
"Orden: " & CStr(fe.xTiposActividad_Orden) & vbCrLf & _
"Descripcion: " & fe.xTiposActividad_Desc, vbInformation, "WSFEXv1"
Else
MsgBox "Cantidad (xTiposActividadItemCantidad): 0", vbInformation, "WSFEXv1"
End If
Else
MsgBox "Error interfaz/SOAP: " & fe.UltimoMensajeError & vbCrLf & _
"Error servidor ARCA (" & CStr(fe.xerrcode) & "): " & fe.xerrmsg & vbCrLf & _
"Evento (" & CStr(fe.xEventCode) & "): " & fe.xEventMsg, vbCritical, "WSFEXv1"
End If
End Sub
' ==============================================================================
' EXTRA: METODO AUXILIAR LOCAL DE CODIGO QR (RG 4892 / RG 5003)
' ==============================================================================
Public Sub Ejemplo_Extra_xQRGenerar()
' ==========================================================================
' Extra VB6: f1qrGenerar(99) + xCodigoDeBarraAFIP - Generacion local de QR
' para comprobantes de exportacion (19, 20, 21)
' Servicio: WSFEXv1 (ARCA / ex-AFIP - xVersion = 1) - Interfaz COM WSAFIPFE.Factura
' Nota: xRegistrarConNumero no invoca f1qrGenerar automaticamente; tras obtener
' el CAE, se cargan las propiedades F1Detalle* y se llama a f1qrGenerar(99).
' En Modo = 1 (Produccion) requiere licencia 2020.
' ==========================================================================
Dim fe As Object
Dim bResultado As Boolean
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA: Se asume que los siguientes metodos ya fueron ejecutados
' previamente y sin errores en la sesion actual:
' - fe.iniciar(1, CUIT, RutaCertificadoPFX, ArchivoLicencia)
' - fe.xVersion = 1
' --------------------------------------------------------------------------
fe.xVersion = 1
' Cargar datos minimos en propiedades F1Detalle* para armar el JSON QR (RG 4892)
fe.F1CabeceraCantReg = 1
fe.F1CabeceraPtoVta = 3
fe.F1CabeceraCbteTipo = 19 ' 19 = Factura E (20 = ND E | 21 = NC E)
fe.f1Indice = 0
fe.F1DetalleCbteDesdeS = "1"
fe.F1DetalleCbteFch = "20261121"
fe.F1DetalleImpTotal = 500#
fe.F1DetalleMonIdS = "DOL"
fe.F1DetalleMonCotiz = 1050.5
fe.F1DetalleDocTipo = 80 ' 80 = CUIT Pais receptor
fe.F1DetalleDocNro = "50000000016"
fe.F1Detalleqrtipocodigo = "E" ' "E" = CAE
fe.F1DetalleCAEA = "74451234567890" ' CAE de 14 digitos devuelto por xRespuestaCAE
fe.F1DetalleQRArchivo = "C:\temp\QR_FactE_1.jpg"
fe.f1detalleqrformato = 6 ' 6 = JPEG (1 = BMP, 8 = PNG)
fe.f1detalleqrresolucion = 4
fe.f1detalleqrtolerancia = 0
bResultado = fe.f1qrGenerar(99)
If bResultado And fe.UltimoMensajeError = "" And fe.ArchivoQRError = "" Then
MsgBox "QR Factura de Exportacion Generado" & vbCrLf & _
"Archivo: " & fe.F1DetalleQRArchivo & vbCrLf & _
"URL: " & fe.f1qrURL & "?p=" & fe.f1qrmanualTexto64, vbInformation, "WSFEXv1 QR"
Else
MsgBox "Error QR: " & fe.UltimoMensajeError & vbCrLf & _
"Error archivo QR: " & fe.ArchivoQRError, vbCritical, "WSFEXv1 QR"
End If
End Sub