Code Monkey home page Code Monkey logo

python-cfdiclient's People

Contributors

dependabot[bot] avatar fatake avatar ivanguevaram avatar ivanporras avatar luisiturrios1 avatar marcozink avatar otamay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-cfdiclient's Issues

Error en Autenticacion

Hola Luis, tocayo por cierto!, estoy ejecuntado en arch y me da el siguiente error.
/.local/lib/python3.9/site-packages/cfdiclient/autenticacion.py", line 124, in obtener_token
raise Exception(ex)
Exception: An error occurred when verifying security for the message.
En Win2 no tuve problema pero en arch si.

Error de autenticación

Al correr ejemplo_autenticacion.py obtengo el siguiente error:

Traceback (most recent call last): File ".\ejemplo_autenticacion.py", line 19, in <module> token = auth.obtener_token() File "D:\Documentos\repos\python-cfdiclient\cfdiclient\autenticacion.py", line 124, in obtener_token raise Exception(ex) Exception: The message with Action 'http://DescargaMasivaTerceros.sat.gob.mx/IAutenticacion/Autentica' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Solo cloné el repositorio e instalé los requeriments.

XML mal formado

Hola buen dia fijate que me pasa con algunos sellos. no con todos que cuando hago la solicitud me devuelve

{'id_solicitud': None, 'cod_estatus': '301', 'mensaje': 'XML Mal Formado'}

los ellos estan correctamente vigentes y si funciona con otros sellos el programa cuando agarro los sellos de otrocontribuyente si funciona devolviendo

["['MLO160130FX4', 'MyL120391', 'MLO160130F8882.cer', …key', 'MLO160130EX2', '2021-03-01', '2021-03-17']", "TOKEN: eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLz…ubject%3d3030303031303030303030353031323137353639", "SOLICITUD: {'id_solicitud': '4cfd1dae-4227-4447-bb…status': '5000', 'mensaje': 'Solicitud Aceptada'}", "TOKEN: eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLz…ubject%3d3030303031303030303030353031323137353639", "SOLICITUD: {'cod_estatus': '5000', 'estado_solicit… 'mensaje': 'Solicitud Aceptada', 'paquetes': []}", "TOKEN: eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLz…ubject%3d3030303031303030303030353031323137353639", "SOLICITUD: {'cod_estatus': '5000', 'estado_solicit…es': ['4CFD1DAE-4227-4447-BB7C-9462212EA800_01']}", "PAQUETE: **4CFD1DAE-4227-4447-BB7C-9462212EA800_01"]**

alguien sabra que podria estar pasando y como mitigar ese error para que trabaje igual con todos los sellos?

Error al realizar obtener_token en autenticacion

Antes realize el ejemplo completo y funcionaba perfectamente. Mas tarde volvi a probarlo y ya no funcionaba en la parte de auth.obtener_token() porque el valor de response.status_code es 500. A que se debe esto?
image

No descarga completo los XML y METADA recibida

Al ejecutar el programa primero tengo la descarga de cfdis emitidos y descarga bien, pero al llegar a los
recibidos, solo descarga una cantidad muy pequeña, (por ejemplo, 16 y la cifra correcta son aprox 850).

Pero si ejecuto solo recibidos (comentando la ejecución de emitidos) , y luego vuelvo a ejecutar solo emitidos (comentando la ejecución de recibidos), si descarga la cantidad exacta tanto de recibidos, como de emitidos

Error al solicitar descarga

Hola @liturrios espero me puedas ayudar, al solicitar descarga me sale este error:

 raceback (most recent call last):
  File "main.py", line 41, in <module>
    result = descarga.solicitar_descarga(token, rfc_solicitante, fecha_inicial, fecha_final, rfc_emisor=rfc_emisor)
  File "/home/Jaguay/.local/lib/python2.7/site-packages/cfdiclient/solicitadescarga.py", line 104, in solicitar_descarga
    rfc_solicitante, fecha_inicial, fecha_final, rfc_emisor, rfc_receptor, tipo_solicitud
  File "/home/Jaguay/.local/lib/python2.7/site-packages/cfdiclient/solicitadescarga.py", line 92, in __generar_soapreq__
    x509issuername.text = self.fiel.cer_issuer()
  File "src/lxml/etree.pyx", line 1025, in lxml.etree._Element.text.__set__
  File "src/lxml/apihelpers.pxi", line 734, in lxml.etree._setNodeText
  File "src/lxml/apihelpers.pxi", line 722, in lxml.etree._createTextNode
  File "src/lxml/apihelpers.pxi", line 1527, in lxml.etree._utf8
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

Saludos, no hay paquetes que descargar hoy

¡Buenos dias!

Gusto saludarte, a decir verdad desde que nos conocimos no he actualizado el código que has seguido actualizando, y hoy el SAT no me devuelve ningún paquete para descargar ¿crees que deba de actualizar? o ¿mas bien es tema del SAT?

¡gracias y saludos!

token = auth.obtener_token()

Que tal Luis buen día.
Disculpa al momento de hacer la ejecución de codigo en la linea de token = auth.obtener_token() me muestra el siguiente error.

`Traceback (most recent call last):
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
raise err
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
conn = self._new_conn()
File "/home/berlin/Documentos/Python/env/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f3191523820>: Failed to establish a new connection: [Errno 110] Connection timed out`

Veo que es un error de timed out pero estare haciendo algo mal en los procedimientos, tome tu ejemplo completo para la prueba y tambien estoy utilizando llaves y contraseña validas.

De antemano muchas gracias.

Saludos!

Descargar XML usando la contraseña ciec

me gustaria saber si se puede autenticar en el webservice del sat usando la contraseña CIEC y el RFC solamente y de esta manera hacer la solicitud de descarga y obtener los XML

la observacion es porque asi se evita guardar las llaves de los contribuyentes haciendo mas seguro el consumo de esta maravillosa libreria

saludos.

Solicitud de Descarga

Al intentar hacer la solicitud de descarga con el token generado, marca esta excepcion. Alguna idea?

Traceback (most recent call last):
File "solita_descarga_sat.py", line 22, in
result = descarga.solicitar_descarga(token, rfc_solicitante, fecha_inicial, fecha_final, rfc_emisor=rfc_emisor)
File "/home/ivan/.local/lib/python2.7/site-packages/cfdiclient/solicitadescarga.py", line 104, in solicitar_descarga
rfc_solicitante, fecha_inicial, fecha_final, rfc_emisor, rfc_receptor, tipo_solicitud
File "/home/ivan/.local/lib/python2.7/site-packages/cfdiclient/solicitadescarga.py", line 92, in generar_soapreq
x509issuername.text = self.fiel.cer_issuer()
File "src/lxml/etree.pyx", line 1023, in lxml.etree._Element.text.set
File "src/lxml/apihelpers.pxi", line 734, in lxml.etree._setNodeText
File "src/lxml/apihelpers.pxi", line 722, in lxml.etree._createTextNode
File "src/lxml/apihelpers.pxi", line 1527, in lxml.etree._utf8
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

Certificado Invalido

Hola. He estado probando los ejemplos y usando los certificados de prueba pero recibo respuesta 305 Certificado Invalido en cada solicitud. Agradeceria cualquier sugerencia. Gracias

Paquete_b64 error en decodificación

Hola Luis, me ayudó bastante tu código pero tengo problemas al traducir la respuesta (paqueteb64)
Me sale corrupto/dañado los datos que me arroja al momento de quererlos pasar a utf-8

¿ Sabes si hay que hacerle algo a esta respuesta que me esté faltando ?

Me sale así (este es un fragmento de la conversión a utf-8):

PK����nP^ƾu�M�,e2551eeb-3b7a-4b6c-809f-933cdfa04b0e.xml.xmlXɒL~�+S6@uvB@�H1mHB+ZAև~~ ʴCiҒTF{_܊|6DMV�}C注 0-ip_�骨.Qӥ4}."__h��E@Ţ)3(3zRQo32#WL@Tv�Tjc.��c[^]0.khPcO>ƺ*|~Ȗ5r�>ٝ�.�,@Ŷ@ YwFzAb
�u!Vw

Duda - Uso de cert y key

Si solo necesito los metadatos de las facturas y no todo lo demas, hay alguna manera de solamente utilizar mi email registrado y el password en lugar de usar todo el cert y el key?

Exception: The server was unable to process the request due to an internal error.

Hola, estoy tratando de hacer una descarga de metadata, sin embargo, me sale el error siguiente. Alguna sugerencia?

` from cfdiclient import (
Autenticacion,
SolicitaDescarga,
VerificaSolicitudDescarga,
DescargaMasiva,
)
from cfdiclient import Fiel

FIEL_KEY = 'data/certs/fiel_key.key'
FIEL_CER = 'data/certs/fiel_cer.cer'
FIEL_PAS = 'XXXXX'
RFC = "XXXXXXXXXXXX"
cer_der = open(FIEL_CER, 'rb').read()
key_der = open(FIEL_KEY, 'rb').read()
fiel = Fiel(cer_der, key_der, FIEL_PAS)

auth = Autenticacion(fiel)

token = auth.obtener_token()

FECHA_INICIAL = datetime.date(2018, 7, 1)
FECHA_FINAL = datetime.date(2018, 7, 20)

descarga = SolicitaDescarga(fiel)

solicitud = descarga.solicitar_descarga(
token,
RFC,
FECHA_INICIAL,
FECHA_FINAL,
rfc_receptor=RFC,
tipo_solicitud='METADATA',
) `

Exception: The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.

SOLICITUD: {'id_solicitud': '2ce5e153-f3ec-4007-b7a5-20d45d93c4b9', 'cod_estatus': '404', 'mensaje': 'Error no controlado.'}

Buenos días Luis,
A partir del 3 de marzo las solicitudes regresa éste mensaje de error:
SOLICITUD: {'id_solicitud': '2ce5e153-f3ec-4007-b7a5-20d45d93c4b9', 'cod_estatus': '404', 'mensaje': 'Error no controlado.'}
SOLICITUD: {'cod_estatus': '5004', 'estado_solicitud': '0', 'codigo_estado_solicitud': None, 'numero_cfdis': '0', 'mensaje': 'No se encontro la informacion', 'paquetes': []}

¿Sabrás si hubo algún cambio en el SAT por el cuál la solicitud regresa error? ¿Alguna actualización para 4.0?

Saludos y muchas gracias

Hugo Martínez

Metadatos de los CFDI

Hola. Gracias por la herramienta. Está maravillosa.
Intenté de varias formas descargar los metadatos de las facturas de un cierto periodo sin éxito. ¿Crees que sea posible hacerlo con cfdiclient?

Recibo error 301 desde hace tres semanas

Buenas tardes. Desde hace tres semanas (inicio Marzo) estoy recibiendo error en todas las solicitudes:
{'cod_estatus': '301', 'id_solicitud': None, 'mensaje': 'XML Mal Formado'}
Hay ago reportado o tienen sugerencia para revisar? Gracias !

Encoding issue

Hola,

Antes que nada gracias por compartir este cliente para interactuar con el WebService del SAT.
Actualmente estoy probando la solicitud de la descarga masiva pero me regresa un error al crear la solicitud. Al parecer es un problema con los acentos en el issuer del certificado.

Agrego el trace

File "/home/ferroblesh/.local/lib/python2.7/site-packages/cfdiclient/solicitadescarga.py", line 92, in __generar_soapreq__
    x509issuername.text = self.fiel.cer_issuer()
  File "src/lxml/etree.pyx", line 1023, in lxml.etree._Element.text.__set__
  File "src/lxml/apihelpers.pxi", line 734, in lxml.etree._setNodeText
  File "src/lxml/apihelpers.pxi", line 722, in lxml.etree._createTextNode
  File "src/lxml/apihelpers.pxi", line 1527, in lxml.etree._utf8
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

Expresión impresa no válida. Expresión: 601

Hola @luisiturrios1 al intentar validar el estatus de un XML arroja el mensaje:

{'codigo_estatus': 'Expresión impresa no válida. Expresión: 601', 'es_cancelable': None, 'estado': None}

usando el siguiente código:
`
from cfdiclient import Validacion
validacion = Validacion()

validacion.obtener_estado('LOAM9002065L1', 'SDC180921GL8', '33552.45', '7974074A-E45E-4D9C-8A64-02B4BB64A052')

`

Tendrás alguna idea?

Sistema se queda en loop

Que tal,

Esta ultima semana el sistema ha estado muy lento, al grado de que este nunca regresa ningunn xml inclusive despues de horas de correr. A alguno de ustedes le funciona ?

Se queda trabado aqui: SOLICITUD: {'cod_estatus': '5000', 'estado_solicitud': '2', 'codigo_estado_solicitud': '5000', 'numero_cfdis': '0', 'mensaje': 'Solicitud Aceptada', 'paquetes': []}

Gracias!

el webservice de verificacion nunca devuelve la lista de paquetes

Hola Luis,
Muchísimas gracias por su librería. Yo la llevaba usando varios meses, hasta que empezó a fallar por los cambios del SAT. Y ya actualicé a la nueva versión que publicaste y funciona la autenticación, la solicitud de descarga, pero no pasa de la verificación, ya que el webservice de verificación siempre responde que la solicitud es correcta, pero nunca devuelve la lista de paquetes para descargar con el webservice de descarga. Y luego de un tiempo da un error interno del webservice de verificación, pero no describe el error. Ya han pasado más de una semana que lo intento todos los días con tres FIEL pero sigue en el mismo estado.
¿Ustedes pueden descargar bien del SAT después de los cambios que hizo el SAT?
Gracias de antemano,
Roberto

Python 2.7

ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

python-cfdiclient lxml.etree.XMLSyntaxError: internal error: Huge input lookup

En algunas ocaciones se esta regresando este error al utilizar el método DescargaMasiva

traceback:

File "/usr/local/lib/python3.6/site-packages/cfdiclient/webservicerequest.py", line 83, in request
    response_xml = etree.fromstring(response.text)
File "src/lxml/etree.pyx", line 3252, in lxml.etree.fromstring
File "src/lxml/parser.pxi", line 1913, in lxml.etree._parseMemoryDocument
File "src/lxml/parser.pxi", line 1793, in lxml.etree._parseDoc
File "src/lxml/parser.pxi", line 1082, in lxml.etree._BaseParser._parseUnicodeDoc
File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
File "src/lxml/parser.pxi", line 654, in lxml.etree._raiseParseError
File "<string>", line 1
lxml.etree.XMLSyntaxError: internal error: Huge input lookup, line 1, column 13833586

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.