Attribute VB_Name = "modWSPUCEjemplos"
Option Explicit
' ==============================================================================
' WSAFIPFE - EJEMPLOS DE PRODUCCION VISUAL BASIC 6: WSPUC CONSTANCIA DE INSCRIPCION
' Servicio ARCA: ws_sr_constancia_inscripcion (Manual Oficial v4.1 - Marzo 2026)
' Interfaz COM: WSAFIPFE.Factura - Prefijo "p1" EXCLUSIVAMENTE con p1Version = 55
' Guia maestra: GUIA_WSPUC.md
'
' DIRECTIVAS CRITICAS DE ESTA SUITE:
' 1. Rama unica y obligatoria: fe.p1Version = 55 ("ws_sr_constancia_inscripcion",
' antes llamado Alcance 5; p1Version = 5 y 52 estan deprecados por ARCA).
' 2. Se omiten las llamadas ejecutables a fe.iniciar(...) y fe.p1ObtenerTicketAcceso():
' se asumen ejecutadas previamente en la sesion actual (con fe.p1Version = 55
' asignado ANTES de fe.p1ObtenerTicketAcceso) y figuran solo como nota aclaratoria.
' 3. Codificacion ASCII puro de 7 bits para importacion directa en el IDE de VB6.
'
' INDICE DE PROCEDIMIENTOS (100% de metodos p1* en rama p1Version = 55):
' 1. Ejemplo_p1Dummy -> p1Dummy + p1RespuestaDummy*
' 2. Ejemplo_p1GetPersona_DatosPrincipales -> p1GetPersona (getPersona_v2) + datos clave cliente
' 3. Ejemplo_p1GetPersona2_LecturaCompleta -> p1GetPersona2 / p1GetPersona_v2 + todos los nodos v4.1
' 4. Ejemplo_p1VerificarImpuesto -> p1VerificarImpuesto / p1VerificarImpuesto2
' 5. Ejemplo_p1GetPersonaList_Atajo -> p1GetPersonaList (lote hasta 250 CUITs) + p1VerificarImpuestoLista
' 6. Ejemplo_p1CargarPropiedad_GetPersonaList_v2 -> p1CargarPropiedad + p1GetPersonaList_v2 / p1GetPersonaList2
' 7. Ejemplo_p1GuardarRestaurarTicketAcceso -> p1TicketEsValido + p1GuardarTicketAcceso + p1RestaurarTicketAcceso
' ==============================================================================
' ==============================================================================
' 1. VERIFICACION DE ESTADO DEL SERVICIO (SOAP: dummy - Sec. 3.1 Manual ARCA)
' Metodo COM: fe.p1Dummy() As Boolean
' Nota: El metodo dummy es el unico que NO requiere Ticket de Acceso (WSAA).
' ==============================================================================
Public Sub Ejemplo_p1Dummy()
Dim fe As Object
Dim bResultado As Boolean
Dim sApp As String
Dim sAuth As String
Dim sDb As String
Dim sMsg As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que fe.iniciar(Modo, CUIT, RutaPFX, Licencia)
' ya fue ejecutado previamente en la sesion actual.
' (Para p1Dummy no es necesario haber ejecutado fe.p1ObtenerTicketAcceso).
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
fe.ArchivoXMLEnviado = "C:\temp\wspuc_dummy_enviado.xml"
fe.ArchivoXMLRecibido = "C:\temp\wspuc_dummy_recibido.xml"
bResultado = fe.p1Dummy()
If bResultado Then
' Lectura directa mediante propiedades ReadOnly con prefijo p1
sApp = fe.p1RespuestaDummyAppServer
sAuth = fe.p1RespuestaDummyAuthServer
sDb = fe.p1RespuestaDummyDbServer
' Alternativa equivalente por diccionario:
' sApp = fe.p1LeerPropiedad("p1Dummy", "appserver", "", 0, 0)
' sAuth = fe.p1LeerPropiedad("p1Dummy", "authserver", "", 0, 0)
' sDb = fe.p1LeerPropiedad("p1Dummy", "dbserver", "", 0, 0)
sMsg = "Estado WSPUC (ws_sr_constancia_inscripcion):" & vbCrLf & _
" AppServer : " & sApp & vbCrLf & _
" AuthServer: " & sAuth & vbCrLf & _
" DbServer : " & sDb
MsgBox sMsg, vbInformation, "p1Dummy OK"
Else
MsgBox "Fallo p1Dummy (" & CStr(fe.UltimoNumeroError) & "): " & _
fe.UltimoMensajeError, vbCritical, "Error WSPUC"
End If
End Sub
' ==============================================================================
' 2. CONSULTA UNITARIA DE UN CUIT Y RECUPERACION DE DATOS PRINCIPALES
' (SOAP: getPersona_v2 - Sec. 3.2 Manual ARCA v4.1)
' Metodos COM: fe.p1GetPersona(sCuit), fe.p1LeerPropiedad(...), fe.p1VerificarImpuesto(...)
' Recupera: Nombre/Apellido o Razon Social, Estado Clave, Domicilio, Localidad,
' CP, Provincia, Condicion IVA (RG 5616), Actividad Principal e Impuestos.
' ==============================================================================
Public Sub Ejemplo_p1GetPersona_DatosPrincipales()
Dim fe As Object
Dim bResultado As Boolean
Dim sCuitConsulta As String
Dim nCantErr As Long
Dim sTipoPersona As String
Dim sDenominacion As String
Dim sEstadoClave As String
Dim sDireccion As String
Dim sLocalidad As String
Dim sCodPostal As String
Dim sIdProvincia As String
Dim sProvincia As String
Dim sCondicionIvaDesc As String
Dim nCondicionIvaRG5616 As Integer
Dim sActPrincipalCod As String
Dim sActPrincipalDesc As String
Dim nCantActRG As Long
Dim i As Long
Dim nCantImp As Long
Dim sListaImpuestos As String
Dim sResumen As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que en la sesion actual ya fueron ejecutados
' previamente y sin errores:
' - fe.iniciar(Modo, CUITEmisor, RutaCertificadoPFX, ArchivoLicencia)
' - fe.tls = 12
' - fe.p1Version = 55 ' CRITICO: asignar 55 ANTES de p1ObtenerTicketAcceso()
' - fe.p1ObtenerTicketAcceso() (o restaurado con p1RestaurarTicketAcceso)
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
fe.ArchivoXMLEnviado = "C:\temp\wspuc_getpersona_enviado.xml"
fe.ArchivoXMLRecibido = "C:\temp\wspuc_getpersona_recibido.xml"
' CUIT a consultar (ejemplo oficial Manual ARCA v4.1 pag. 9: 20164755100)
sCuitConsulta = "20164755100"
' Con p1Version = 55, p1GetPersona invoca automaticamente getPersona_v2 en ARCA
bResultado = fe.p1GetPersona(sCuitConsulta)
If Not bResultado Or fe.UltimoMensajeError <> "" Then
MsgBox "Error de comunicacion/validacion (" & CStr(fe.UltimoNumeroError) & "): " & _
fe.UltimoMensajeError, vbCritical, "Error p1GetPersona"
Exit Sub
End If
' 1) Verificar si ARCA informo bloqueo de constancia o CUIT inexistente
nCantErr = Val(fe.p1LeerPropiedad("p1getPersona", "errorConstancia.error.itemcantidad", "", 0, 0))
If nCantErr > 0 Then
MsgBox "Constancia con error para CUIT " & sCuitConsulta & ":" & vbCrLf & _
fe.p1LeerPropiedad("p1getPersona", "errorConstancia.error", "", 0, 0), _
vbExclamation, "Error de Constancia ARCA"
Exit Sub
End If
' 2) Nombre y Apellido (Persona Fisica) o Razon Social (Persona Juridica)
sTipoPersona = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.tipoPersona", "", 0, 0)
sEstadoClave = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.estadoClave", "", 0, 0)
If UCase$(Trim$(sTipoPersona)) = "JURIDICA" Then
sDenominacion = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.razonSocial", "", 0, 0)
Else
sDenominacion = Trim$(fe.p1LeerPropiedad("p1getPersona", "datosGenerales.apellido", "", 0, 0) & " " & _
fe.p1LeerPropiedad("p1getPersona", "datosGenerales.nombre", "", 0, 0))
End If
' 3) Domicilio Fiscal: Direccion, Localidad, Codigo Postal y Provincia
sDireccion = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.domicilioFiscal.direccion", "", 0, 0)
sLocalidad = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.domicilioFiscal.localidad", "", 0, 0)
sCodPostal = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.domicilioFiscal.codPostal", "", 0, 0)
sIdProvincia = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.domicilioFiscal.idProvincia", "", 0, 0)
sProvincia = fe.p1LeerPropiedad("p1getPersona", "datosGenerales.domicilioFiscal.descripcionProvincia", "", 0, 0)
' 4) Determinar Condicion frente al IVA (y codigo CondicionIvaReceptor RG 5616)
If fe.p1VerificarImpuesto(30, "AC") Then
sCondicionIvaDesc = "IVA Responsable Inscripto"
nCondicionIvaRG5616 = 1
ElseIf fe.p1VerificarImpuesto(20, "AC") Then
sCondicionIvaDesc = "Responsable Monotributo (Cat. " & _
fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.categoriaMonotributo.descripcionCategoria", "", 0, 0) & ")"
nCondicionIvaRG5616 = 6
ElseIf fe.p1VerificarImpuesto(32, "AC") Then
sCondicionIvaDesc = "IVA Sujeto Exento"
nCondicionIvaRG5616 = 4
ElseIf fe.p1VerificarImpuesto(34, "AC") Then
sCondicionIvaDesc = "IVA No Alcanzado"
nCondicionIvaRG5616 = 15
Else
sCondicionIvaDesc = "Consumidor Final / Sin IVA activo"
nCondicionIvaRG5616 = 5
End If
' 5) Actividad economica principal (busca orden = 1 en Regimen General, o toma Monotributo)
sActPrincipalCod = ""
sActPrincipalDesc = ""
nCantActRG = Val(fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.actividad.itemcantidad", "", 0, 0))
If nCantActRG > 0 Then
For i = 0 To nCantActRG - 1
If Val(fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.actividad.orden", "", CLng(i), 0)) = 1 Or i = 0 Then
sActPrincipalCod = fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.actividad.idActividad", "", CLng(i), 0)
sActPrincipalDesc = fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.actividad.descripcionActividad", "", CLng(i), 0)
If Val(fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.actividad.orden", "", CLng(i), 0)) = 1 Then Exit For
End If
Next i
Else
sActPrincipalCod = fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.actividadMonotributista.idActividad", "", 0, 0)
sActPrincipalDesc = fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.actividadMonotributista.descripcionActividad", "", 0, 0)
End If
' 6) Resumen de impuestos inscriptos (Regimen General + Monotributo)
sListaImpuestos = ""
nCantImp = Val(fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.impuesto.itemcantidad", "", 0, 0))
For i = 0 To nCantImp - 1
sListaImpuestos = sListaImpuestos & " - [" & _
fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.impuesto.idImpuesto", "", CLng(i), 0) & "] " & _
fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.impuesto.descripcionImpuesto", "", CLng(i), 0) & _
" (" & fe.p1LeerPropiedad("p1getPersona", "datosRegimenGeneral.impuesto.estadoImpuesto", "", CLng(i), 0) & ")" & vbCrLf
Next i
nCantImp = Val(fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.impuesto.itemcantidad", "", 0, 0))
For i = 0 To nCantImp - 1
sListaImpuestos = sListaImpuestos & " - [" & _
fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.impuesto.idImpuesto", "", CLng(i), 0) & "] " & _
fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.impuesto.descripcionImpuesto", "", CLng(i), 0) & _
" (" & fe.p1LeerPropiedad("p1getPersona", "datosMonotributo.impuesto.estadoImpuesto", "", CLng(i), 0) & ")" & vbCrLf
Next i
sResumen = "CUIT: " & sCuitConsulta & " (" & sTipoPersona & " - " & sEstadoClave & ")" & vbCrLf & _
"Denominacion : " & sDenominacion & vbCrLf & _
"Domicilio : " & sDireccion & vbCrLf & _
"Localidad : " & sLocalidad & " (CP " & sCodPostal & ") - Prov. [" & sIdProvincia & "] " & sProvincia & vbCrLf & _
"Condicion IVA: " & sCondicionIvaDesc & " (RG 5616 Cod. " & CStr(nCondicionIvaRG5616) & ")" & vbCrLf & _
"Actividad : [" & sActPrincipalCod & "] " & sActPrincipalDesc & vbCrLf & _
"Impuestos :" & vbCrLf & sListaImpuestos
MsgBox sResumen, vbInformation, "Datos Principales WSPUC (p1Version = 55)"
End Sub
' ==============================================================================
' 3. CONSULTA EXHAUSTIVA DE TODOS LOS GRUPOS Y SUBTABLAS DEL MANUAL ARCA v4.1
' (SOAP: getPersona_v2 - Sec. 3.2 y Sec. 4 Manual ARCA v4.1)
' Metodos COM: fe.p1GetPersona2(sCuit) [alias equivalente: fe.p1GetPersona_v2(sCuit)]
' Recorre: metadata, datosGenerales (dependencia, domicilioFiscal, caracterizacion
' con fechaSolicitud e idCaracterizacion 639 Ley 27.779), datosRegimenGeneral
' (impuesto con motivo, categoriaAutonomo, regimen, actividad),
' datosMonotributo (categoriaMonotributo, actividadMonotributista,
' actividad completa v2, impuesto, componenteDeSociedad) y errores parciales.
' ==============================================================================
Public Sub Ejemplo_p1GetPersona2_LecturaCompleta()
Dim fe As Object
Dim bOk As Boolean
Dim sCuit As String
Dim i As Long
Dim nCant As Long
Dim sReporte As String
Dim sIdCar As String
Dim bAdheridoGananciasSimplificada As Boolean
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que en la sesion actual ya fueron ejecutados:
' - fe.iniciar(Modo, CUITEmisor, RutaCertificadoPFX, ArchivoLicencia)
' - fe.tls = 12
' - fe.p1Version = 55 ' OBLIGATORIO antes de p1ObtenerTicketAcceso()
' - fe.p1ObtenerTicketAcceso()
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
sCuit = "20164755100"
' Invocacion explicita a p1GetPersona2 (tambien disponible como fe.p1GetPersona_v2(sCuit))
bOk = fe.p1GetPersona2(sCuit)
If Not bOk Then
MsgBox "Error (" & CStr(fe.UltimoNumeroError) & "): " & fe.UltimoMensajeError, vbCritical
Exit Sub
End If
sReporte = ""
' --- A) Bloque metadata ---
sReporte = sReporte & "[METADATA] FechaHora=" & _
fe.p1LeerPropiedad("p1GetPersona2", "metadata.fechaHora", "", 0, 0) & _
" | Servidor=" & fe.p1LeerPropiedad("p1GetPersona2", "metadata.servidor", "", 0, 0) & vbCrLf
' --- B) Bloque datosGenerales y subgrupos ---
sReporte = sReporte & "[DATOS GENERALES] idPersona=" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.idPersona", "", 0, 0) & _
" | TipoClave=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.tipoClave", "", 0, 0) & _
" | Estado=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.estadoClave", "", 0, 0) & _
" | TipoPersona=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.tipoPersona", "", 0, 0) & _
" | MesCierre=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.mesCierre", "", 0, 0) & _
" | EsSucesion=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.esSucesion", "", 0, 0) & _
" | FecFallec=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.fechaFallecimiento", "", 0, 0) & _
" | FecContrato=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.fechaContratoSocial", "", 0, 0) & vbCrLf
' Dependencia ARCA
sReporte = sReporte & "[DEPENDENCIA] [" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.dependencia.idDependencia", "", 0, 0) & "] " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.dependencia.descripcionDependencia", "", 0, 0) & " - " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.dependencia.localidad", "", 0, 0) & vbCrLf
' Domicilio Fiscal (incluyendo datoAdicional / tipoDatoAdicional Anexo 5.2)
sReporte = sReporte & "[DOMICILIO] (" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.tipoDomicilio", "", 0, 0) & ") " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.direccion", "", 0, 0) & " | " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.tipoDatoAdicional", "", 0, 0) & ": " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.datoAdicional", "", 0, 0) & " | " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.localidad", "", 0, 0) & " (" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.codPostal", "", 0, 0) & ") - " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.domicilioFiscal.descripcionProvincia", "", 0, 0) & vbCrLf
' Caracterizaciones (incluye novedad v4.1: fechaSolicitud e idCaracterizacion 639 Dto. 93/26)
bAdheridoGananciasSimplificada = False
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.caracterizacion.itemcantidad", "", 0, 0))
For i = 0 To nCant - 1
sIdCar = fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.caracterizacion.idCaracterizacion", "", CLng(i), 0)
If sIdCar = "639" Then bAdheridoGananciasSimplificada = True
sReporte = sReporte & " [CARACT " & CStr(i) & "] id=" & sIdCar & " - " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.caracterizacion.descripcionCaracterizacion", "", CLng(i), 0) & _
" | periodo=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.caracterizacion.periodo", "", CLng(i), 0) & _
" | fechaSolicitud=" & fe.p1LeerPropiedad("p1GetPersona2", "datosGenerales.caracterizacion.fechaSolicitud", "", CLng(i), 0) & vbCrLf
Next i
If bAdheridoGananciasSimplificada Then
sReporte = sReporte & " -> Adherido a Regimen DJ Simplificada Ganancias Ley 27.779 (Cod. 639)" & vbCrLf
End If
' --- C) Bloque datosRegimenGeneral ---
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.impuesto.itemcantidad", "", 0, 0))
For i = 0 To nCant - 1
sReporte = sReporte & " [IMP RG " & CStr(i) & "] id=" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.impuesto.idImpuesto", "", CLng(i), 0) & " " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.impuesto.descripcionImpuesto", "", CLng(i), 0) & _
" | estado=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.impuesto.estadoImpuesto", "", CLng(i), 0) & _
" | periodo=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.impuesto.periodo", "", CLng(i), 0) & _
" | motivo=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.impuesto.motivo", "", CLng(i), 0) & vbCrLf
Next i
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.actividad.itemcantidad", "", 0, 0))
For i = 0 To nCant - 1
sReporte = sReporte & " [ACT RG " & CStr(i) & "] orden=" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.actividad.orden", "", CLng(i), 0) & _
" | id=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.actividad.idActividad", "", CLng(i), 0) & _
" (Nom. " & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.actividad.nomenclador", "", CLng(i), 0) & ") " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.actividad.descripcionActividad", "", CLng(i), 0) & _
" | periodo=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.actividad.periodo", "", CLng(i), 0) & vbCrLf
Next i
If fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.categoriaAutonomo.idCategoria", "", 0, 0) <> "" Then
sReporte = sReporte & " [AUTONOMO] Cat=" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.categoriaAutonomo.idCategoria", "", 0, 0) & " - " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.categoriaAutonomo.descripcionCategoria", "", 0, 0) & vbCrLf
End If
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.regimen.itemcantidad", "", 0, 0))
For i = 0 To nCant - 1
sReporte = sReporte & " [REGIMEN " & CStr(i) & "] idReg=" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.regimen.idRegimen", "", CLng(i), 0) & _
" (tipo=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.regimen.tipoRegimen", "", CLng(i), 0) & _
", imp=" & fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.regimen.idImpuesto", "", CLng(i), 0) & ") " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosRegimenGeneral.regimen.descripcionRegimen", "", CLng(i), 0) & vbCrLf
Next i
' --- D) Bloque datosMonotributo (incluye todas las actividades v2) ---
If fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.categoriaMonotributo.idCategoria", "", 0, 0) <> "" Then
sReporte = sReporte & " [MONOTRIBUTO CAT] " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.categoriaMonotributo.descripcionCategoria", "", 0, 0) & _
" (periodo " & fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.categoriaMonotributo.periodo", "", 0, 0) & ")" & vbCrLf
End If
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.actividad.itemcantidad", "", 0, 0))
For i = 0 To nCant - 1
sReporte = sReporte & " [ACT MONO " & CStr(i) & "] orden=" & _
fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.actividad.orden", "", CLng(i), 0) & _
" | id=" & fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.actividad.idActividad", "", CLng(i), 0) & " " & _
fe.p1LeerPropiedad("p1GetPersona2", "datosMonotributo.actividad.descripcionActividad", "", CLng(i), 0) & vbCrLf
Next i
' --- E) Bloques de errores parciales (Regimen General / Monotributo / Constancia) ---
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "errorRegimenGeneral.error.itemcantidad", "", 0, 0))
If nCant > 0 Then
sReporte = sReporte & " [AVISO RG] " & _
fe.p1LeerPropiedad("p1GetPersona2", "errorRegimenGeneral.mensaje", "", 0, 0) & ": " & _
fe.p1LeerPropiedad("p1GetPersona2", "errorRegimenGeneral.error", "", 0, 0) & vbCrLf
End If
nCant = Val(fe.p1LeerPropiedad("p1GetPersona2", "errorMonotributo.error.itemcantidad", "", 0, 0))
If nCant > 0 Then
sReporte = sReporte & " [AVISO MONO] " & _
fe.p1LeerPropiedad("p1GetPersona2", "errorMonotributo.mensaje", "", 0, 0) & ": " & _
fe.p1LeerPropiedad("p1GetPersona2", "errorMonotributo.error", "", 0, 0) & vbCrLf
End If
Debug.Print sReporte
MsgBox Left$(sReporte, 1000), vbInformation, "Lectura Completa getPersona_v2"
End Sub
' ==============================================================================
' 4. VERIFICACION RAPIDA DE IMPUESTOS SOBRE UN CUIT CONSULTADO
' Metodos COM: fe.p1VerificarImpuesto(codigo, estado)
' fe.p1VerificarImpuesto2(codigo, estado) As Boolean
' Nota: Estado "" o "ACTIVO" equivale a "AC". Usar "*" para cualquier estado
' (ej. detectar impuestos con Baja de Oficio "BO" o Baja Definitiva "BD").
' ==============================================================================
Public Sub Ejemplo_p1VerificarImpuesto()
Dim fe As Object
Dim sCuit As String
Dim sDetalle As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que en la sesion actual ya fueron ejecutados:
' - fe.iniciar(Modo, CUITEmisor, RutaCertificadoPFX, ArchivoLicencia)
' - fe.tls = 12
' - fe.p1Version = 55 ' OBLIGATORIO antes de p1ObtenerTicketAcceso()
' - fe.p1ObtenerTicketAcceso()
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
sCuit = "20164755100"
If Not fe.p1GetPersona(sCuit) Then
MsgBox "Error en consulta: " & fe.UltimoMensajeError, vbCritical
Exit Sub
End If
sDetalle = "Verificacion de Impuestos para CUIT " & sCuit & ":" & vbCrLf & _
" - IVA Resp. Inscripto (30, AC) : " & IIf(fe.p1VerificarImpuesto2(30, "AC"), "SI", "NO") & vbCrLf & _
" - Monotributo (20, activo) : " & IIf(fe.p1VerificarImpuesto(20, "activo"), "SI", "NO") & vbCrLf & _
" - IVA Sujeto Exento (32, AC) : " & IIf(fe.p1VerificarImpuesto2(32, "AC"), "SI", "NO") & vbCrLf & _
" - IVA No Alcanzado (34, AC) : " & IIf(fe.p1VerificarImpuesto2(34, "AC"), "SI", "NO") & vbCrLf & _
" - Ganancias Sociedades (10, AC) : " & IIf(fe.p1VerificarImpuesto2(10, "AC"), "SI", "NO") & vbCrLf & _
" - Ganancias Pers. Fis. (11, AC) : " & IIf(fe.p1VerificarImpuesto2(11, "AC"), "SI", "NO") & vbCrLf & _
" - Empleador SIPA (301, AC) : " & IIf(fe.p1VerificarImpuesto2(301, "AC"), "SI", "NO") & vbCrLf & _
" - Autonomos (308, AC) : " & IIf(fe.p1VerificarImpuesto2(308, "AC"), "SI", "NO") & vbCrLf & _
" - IVA en cualquier estado (30, *): " & IIf(fe.p1VerificarImpuesto2(30, "*"), "SI", "NO")
MsgBox sDetalle, vbInformation, "p1VerificarImpuesto / p1VerificarImpuesto2"
End Sub
' ==============================================================================
' 5. CONSULTA MASIVA POR LOTE (HASTA 250 CUITS) - ATAJO EN UNA SOLA LINEA
' (SOAP: getPersonaList_v2 - Sec. 3.3 Manual ARCA v4.1)
' Metodos COM: fe.p1GetPersonaList(sListaCuits) As Boolean
' fe.p1VerificarImpuestoLista(nIndicePersona, codigo, estado) As Boolean
' fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.<ruta>", "", iPersona, iSub)
' ==============================================================================
Public Sub Ejemplo_p1GetPersonaList_Atajo()
Dim fe As Object
Dim bOk As Boolean
Dim sListaCuits As String
Dim nPersonas As Long
Dim i As Long
Dim nErrPersona As Long
Dim sId As String
Dim sNombreCompleto As String
Dim sLocalidad As String
Dim sCondIva As String
Dim sAct1 As String
Dim sSalida As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que en la sesion actual ya fueron ejecutados:
' - fe.iniciar(Modo, CUITEmisor, RutaCertificadoPFX, ArchivoLicencia)
' - fe.tls = 12
' - fe.p1Version = 55 ' OBLIGATORIO antes de p1ObtenerTicketAcceso()
' - fe.p1ObtenerTicketAcceso()
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
fe.ArchivoXMLEnviado = "C:\temp\wspuc_lista_atajo_env.xml"
fe.ArchivoXMLRecibido = "C:\temp\wspuc_lista_atajo_rec.xml"
' Hasta 250 CUITs separados por coma, punto y coma, pipe o salto de linea
' (Ejemplo oficial Manual ARCA v4.1 pag. 15: 2 CUITs validos + 1 inexistente)
sListaCuits = "20224107030,27015942210,12345678901"
bOk = fe.p1GetPersonaList(sListaCuits)
If Not bOk Then
MsgBox "Error en p1GetPersonaList (" & CStr(fe.UltimoNumeroError) & "): " & _
fe.UltimoMensajeError, vbCritical
Exit Sub
End If
nPersonas = Val(fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.itemcantidad", "", 0, 0))
sSalida = "Lote procesado en servidor " & _
fe.p1LeerPropiedad("p1GetPersonaList_v2", "metadata.servidor", "", 0, 0) & _
" - Cantidad devuelta: " & CStr(nPersonas) & vbCrLf & vbCrLf
' Recorrido por persona: nIndice = i (0..nPersonas-1), nSubIndice = indice de sublista
For i = 0 To nPersonas - 1
nErrPersona = Val(fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.errorConstancia.error.itemcantidad", "", CLng(i), 0))
If nErrPersona > 0 Then
sId = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.errorConstancia.idPersona", "", CLng(i), 0)
sSalida = sSalida & "#" & CStr(i) & " CUIT " & sId & " -> ERROR: " & _
fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.errorConstancia.error", "", CLng(i), 0) & vbCrLf
Else
sId = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.idPersona", "", CLng(i), 0)
If UCase$(fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.tipoPersona", "", CLng(i), 0)) = "JURIDICA" Then
sNombreCompleto = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.razonSocial", "", CLng(i), 0)
Else
sNombreCompleto = Trim$(fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.apellido", "", CLng(i), 0) & " " & _
fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.nombre", "", CLng(i), 0))
End If
sLocalidad = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.domicilioFiscal.localidad", "", CLng(i), 0)
' Condicion frente al IVA de la fila i mediante p1VerificarImpuestoLista
If fe.p1VerificarImpuestoLista(CLng(i), 30, "AC") Then
sCondIva = "RI"
sAct1 = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosRegimenGeneral.actividad.descripcionActividad", "", CLng(i), 0)
ElseIf fe.p1VerificarImpuestoLista(CLng(i), 20, "AC") Then
sCondIva = "Monotributo"
sAct1 = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosMonotributo.actividad.descripcionActividad", "", CLng(i), 0)
ElseIf fe.p1VerificarImpuestoLista(CLng(i), 32, "AC") Then
sCondIva = "Exento"
sAct1 = fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosRegimenGeneral.actividad.descripcionActividad", "", CLng(i), 0)
Else
sCondIva = "Otro"
sAct1 = ""
End If
sSalida = sSalida & "#" & CStr(i) & " CUIT " & sId & " | " & sNombreCompleto & _
" | Loc: " & sLocalidad & " | IVA: " & sCondIva & _
" | Act[0]: " & sAct1 & vbCrLf
End If
Next i
MsgBox sSalida, vbInformation, "p1GetPersonaList (getPersonaList_v2)"
End Sub
' ==============================================================================
' 6. CONSULTA MASIVA POR LOTE USANDO DICCIONARIO p1CargarPropiedad
' (SOAP: getPersonaList_v2 - Sec. 3.3 Manual ARCA v4.1)
' Metodos COM: fe.p1CargarPropiedad("LIMPIAR" / "idPersona.itemcantidad" / "idPersona", ...)
' fe.p1GetPersonaList_v2() As Boolean [alias: fe.p1GetPersonaList2()]
' ==============================================================================
Public Sub Ejemplo_p1CargarPropiedad_GetPersonaList_v2()
Dim fe As Object
Dim bOk As Boolean
Dim aCuits(0 To 2) As String
Dim i As Long
Dim j As Long
Dim nPersonas As Long
Dim nCantImp As Long
Dim sLinea As String
Dim sResumen As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que en la sesion actual ya fueron ejecutados:
' - fe.iniciar(Modo, CUITEmisor, RutaCertificadoPFX, ArchivoLicencia)
' - fe.tls = 12
' - fe.p1Version = 55 ' OBLIGATORIO antes de p1ObtenerTicketAcceso()
' - fe.p1ObtenerTicketAcceso()
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
fe.ArchivoXMLEnviado = "C:\temp\wspuc_lista_diccionario_env.xml"
fe.ArchivoXMLRecibido = "C:\temp\wspuc_lista_diccionario_rec.xml"
aCuits(0) = "20164755100"
aCuits(1) = "20224107030"
aCuits(2) = "27015942210"
' 1) Limpiar y dimensionar el lote (1..250 claves tributarias)
bOk = fe.p1CargarPropiedad("LIMPIAR", "", 0, 0)
bOk = bOk And fe.p1CargarPropiedad("idPersona.itemcantidad", CStr(UBound(aCuits) - LBound(aCuits) + 1), 0, 0)
For i = LBound(aCuits) To UBound(aCuits)
bOk = bOk And fe.p1CargarPropiedad("idPersona", aCuits(i), CLng(i), 0)
Next i
If Not bOk Then
MsgBox "Error cargando lote (" & CStr(fe.UltimoNumeroError) & "): " & fe.UltimoMensajeError, vbCritical
Exit Sub
End If
' 2) Ejecutar getPersonaList_v2 (tambien disponible como fe.p1GetPersonaList2())
If Not fe.p1GetPersonaList_v2() Then
MsgBox "Error ejecutando p1GetPersonaList_v2 (" & CStr(fe.UltimoNumeroError) & "): " & _
fe.UltimoMensajeError, vbCritical
Exit Sub
End If
' 3) Recorrer personas (nIndice = i) e impuestos internos (nSubIndice = j)
nPersonas = Val(fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.itemcantidad", "", 0, 0))
sResumen = "Resultados p1GetPersonaList_v2 (" & CStr(nPersonas) & " registros):" & vbCrLf
For i = 0 To nPersonas - 1
sLinea = "CUIT " & fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.idPersona", "", CLng(i), 0) & ": " & _
fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.apellido", "", CLng(i), 0) & " " & _
fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosGenerales.razonSocial", "", CLng(i), 0)
nCantImp = Val(fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosRegimenGeneral.impuesto.itemcantidad", "", CLng(i), 0))
If nCantImp > 0 Then
sLinea = sLinea & " | Impuestos RG: "
For j = 0 To nCantImp - 1
sLinea = sLinea & fe.p1LeerPropiedad("p1GetPersonaList_v2", "persona.datosRegimenGeneral.impuesto.idImpuesto", "", CLng(i), CLng(j)) & " "
Next j
End If
sResumen = sResumen & sLinea & vbCrLf
Next i
MsgBox sResumen, vbInformation, "p1CargarPropiedad + p1GetPersonaList_v2"
End Sub
' ==============================================================================
' 7. PERSISTENCIA Y REUTILIZACION EN CACHE DEL TICKET DE ACCESO WSPUC (12 HORAS)
' Metodos COM: fe.p1TicketEsValido, fe.p1GuardarTicketAcceso(),
' fe.p1RestaurarTicketAcceso(sTicketXML), fe.p1TicketHoraVencimiento
' ==============================================================================
Public Sub Ejemplo_p1GuardarRestaurarTicketAcceso()
Dim fe As Object
Dim sTicketXML As String
Set fe = CreateObject("WSAFIPFE.Factura")
' --------------------------------------------------------------------------
' NOTA ACLARATORIA: Se asume que en la sesion actual ya fueron ejecutados:
' - fe.iniciar(Modo, CUITEmisor, RutaCertificadoPFX, ArchivoLicencia)
' - fe.tls = 12
' - fe.p1Version = 55
' - fe.p1ObtenerTicketAcceso()
' --------------------------------------------------------------------------
fe.tls = 12
fe.p1Version = 55
' Exportar el Ticket de Acceso vigente a un String XML (para guardar en archivo/BD)
If fe.p1TicketEsValido Then
sTicketXML = fe.p1GuardarTicketAcceso()
' En futuras consultas (mientras no haya expirado p1TicketHoraVencimiento),
' se restaura directamente sin volver a llamar a p1ObtenerTicketAcceso():
If fe.p1RestaurarTicketAcceso(sTicketXML) Then
MsgBox "Ticket WSPUC restaurado correctamente. Vence: " & _
CStr(fe.p1TicketHoraVencimiento), vbInformation, "Cache Ticket WSPUC"
Else
MsgBox "No se pudo restaurar el ticket: " & fe.UltimoMensajeError, vbExclamation
End If
End If
End Sub