Tempo aproximado para lectura: 00:15:00 min
Duda
¿Cómo detonar la consulta de estatus de un timbre fiscal desde una función de usuario?
Ambiente
Cross Segmentos - TOTVS Backoffice (Línea Protheus) MI - Facturación (SIGAFAT) - Todas las versiones
Solución
Para consultar el estatus de un timbre fiscal desde una función de usuario, se puede invocar directamente el archivo ejecutable del PAC tomando en cuenta lo siguiente:
1.- Detonación
nOpc := WAITRUN( cRutaSmr + cRutina + Trim(cParametros), nCFDiCmd )
2.- Variables
cRutaSmr := &(SuperGetmv( "MV_CFDSMAR" , .F. , "GetClientDir()" ))
cCfdUser := SuperGetmv( "MV_CFDI_US" , .F. , "" )
cCfdPass := SuperGetmv( "MV_CFDI_CO" , .F. , "" )
cCFDiPAC := SuperGetmv( "MV_CFDI_PA" , .F. , "" )
cCFDiAmb := SuperGetmv( "MV_CFDI_AM" , .F. , "T" )
cCFDiCer := SuperGetmv( "MV_CFDI_CE" , .F. , "" )
cCFDiKey := SuperGetmv( "MV_CFDI_PR" , .F. , "" )
cCFDiCve := SuperGetmv( "MV_CFDI_CL" , .F. , "" )
nCFDiCmd := SuperGetmv( "MV_CFDICMD" , .F. , 0 )
cCFDiSF1 := SuperGetmv( "MV_CFDNAF1" , .F. , "" )
cCFDiSF2 := SuperGetmv( "MV_CFDNAF2" , .F. , "" )
cLogWS := SuperGetmv( "MV_CFDILOG" , .F. , "LOG" )
cRutina := "Timbrado" + Trim(cCFDiPAC) + ".exe "
cOpcion := "E"
3.- Armado de cParametros
cParametros = cCFDUser + " " + cCFDPass + " " + cIniFile + " " +cCFDiAmb + " "
cParametros += cCFDiCer + " " + cCFDiKey + " " + cCFDiCve + " . " + cOpcion + " "
cParametros += cProxy + " " + cLogWS
Nota: cIniFile corresponde al archivo ini con el listado de XML a consultar o en su defecto el nombre del XML.
4.- Parámetros para el Proxy Server
lProxySr := SuperGetmv( "MV_PROXYSR" , .F. , .F. )
cProxyIP := Trim(SuperGetmv( "MV_PROXYIP" , .F. , "" ))
nProxyPt := SuperGetmv( "MV_PROXYPT" , .F. , 0 )
lProxyAW := SuperGetmv( "MV_PROXYAW" , .F. , .F. )
cProxyUr := Trim(SuperGetmv( "MV_PROXYUR" , .F. , "" ))
cProxyPw := Trim(SuperGetmv( "MV_PROXYPW" , .F. , "" ))
cProxyDm := Trim(SuperGetmv( "MV_PROXYDM" , .F. , "" ))
cProxy += "[" + If( lProxySr , "1" , "0" ) + "]"
cProxy += "[" + cProxyIP + "]"
cProxy += "[" + lTrim( Str( nProxyPt ) ) + "]"
cProxy += "[" + If( lProxyAW , "1" , "0" ) + "]"
cProxy += "[" + If( lProxyAW , "" , cProxyUr ) + "]"
cProxy += "[" + If( lProxyAW , "" , cProxyPw ) + "]"
cProxy += "[" + If( lProxyAW , "" , cProxyDm ) + "]"
5.- Retorno
Se genera un archivo .OUT, por estándar se copia este archivo y se almacena en el servidor con la extensión .XML.CON. Posteriormente se lee el archivo almacenado en el servidor utilizando la clase XmlParserFile (Ver documentación) y a partir de ahí se realizan las validaciones sobre los códigos o mensajes obtenidos.
0 Comentarios