finkok

class satcfdi.pacs.finkok.DocumentStatus(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

STAMPED = 'S'
FINISHED = 'F'
class satcfdi.pacs.finkok.PendingDocument(document_id: str, xml: bytes = None, pdf: bytes = None, status: satcfdi.pacs.finkok.DocumentStatus = None)[source]

Bases: Document

status: DocumentStatus = None
class satcfdi.pacs.finkok.Finkok(username: str, password: str, environment=Environment.PRODUCTION)[source]

Bases: PAC

Finkok, S.A.P.I. de C.V. Finkok

RFC = 'FIN1203015JA'
namespaces = {'apps': 'apps.services.soap.core.views', 'cancel': 'http://facturacion.finkok.com/cancel', 'soapenv': 'http://schemas.xmlsoap.org/soap/envelope/', 'stamp': 'http://facturacion.finkok.com/stamp'}
property host
get_service_url(operation: Literal['stamp', 'cancel'])[source]
property stamp_url
issue(cfdi: ~satcfdi.cfdi.CFDI, accept: ~satcfdi.pacs.Accept = <Accept.XML: 1>) Document[source]

Operation to request CFDI to be sealed and stamped by Finkok.

Parameters:
  • cfdi (CFDI) – The CFDI object to be sealed and stamped

  • accept (Accept, optional) – The type of response to accept. Defaults to Accept.XML.

Raises:
  • NotImplementedError – If the accept parameter includes Accept.PDF

  • ResponseError – If the response from the Finkok SOAP web service contains an error code

Returns:

The stamped CFDI as a Document object with the following fields:
  • document_id (str): The UUID of the stamped CFDI.

  • xml (bytes): The XML content of the stamped CFDI.

Return type:

Document

Notes

  • This function currently only supports accepting XML responses.

  • If the accept parameter includes Accept.PDF, a NotImplementedError is raised.

stamp(cfdi: ~satcfdi.cfdi.CFDI, accept: ~satcfdi.pacs.Accept = <Accept.XML: 1>) Document[source]

Operation to request sealed CFDI to be stamped by Finkok

Parameters:
  • cfdi (CFDI) – The CFDI object to be stamped

  • accept (Accept, optional) – The type of response to accept. Defaults to Accept.XML.

Raises:
  • NotImplementedError – If the accept parameter includes Accept.PDF

  • ResponseError – If the response from the Finkok SOAP web service contains an error code

Returns:

The stamped CFDI as a Document object with the following fields:
  • document_id (str): The UUID of the stamped CFDI.

  • xml (bytes): The XML content of the stamped CFDI.

Return type:

Document

Notes

  • This function currently only supports accepting XML responses.

  • If the accept parameter includes Accept.PDF, a NotImplementedError is raised.

quick_stamp(cfdi: ~satcfdi.cfdi.CFDI, accept: ~satcfdi.pacs.Accept = <Accept.XML: 1>) Document[source]

Operation to request sealed CFDI to be stamped by Finkok using the quick stamp service.

This operation is recommended for high amount of stamp requests per second.

Parameters:
  • cfdi (CFDI) – The CFDI object to be stamped

  • accept (Accept, optional) – The type of response to accept. Defaults to Accept.XML.

Raises:
  • NotImplementedError – If the accept parameter includes Accept.PDF

  • ResponseError – If the response from the Finkok SOAP web service contains an error code

Returns:

The stamped CFDI as a Document object with the following fields:
  • document_id (str): The UUID of the stamped CFDI.

  • xml (bytes): The XML content of the stamped CFDI.

Return type:

Document

Notes

  • This function currently only supports accepting XML responses.

  • If the accept parameter includes Accept.PDF, a NotImplementedError is raised.

stamped(cfdi: ~satcfdi.cfdi.CFDI, accept: ~satcfdi.pacs.Accept = <Accept.XML: 1>) Document[source]

Retrieves a previously stamped XML that failed to be retrieved in the first request.

Parameters:
  • cfdi (CFDI) – The CFDI object to be checked.

  • accept (Accept, optional) – The type of response to accept. Defaults to Accept.XML.

Raises:
  • NotImplementedError – If the accept parameter includes Accept.PDF

  • ResponseError – If the response from the Finkok SOAP web service contains an error code

Returns:

The document with the following fields:
  • document_id (str): The UUID of the document.

  • xml (bytes): The XML content of the document.

Return type:

Document

Notes

  • This function currently only supports accepting XML responses.

  • If the accept parameter includes Accept.PDF, a NotImplementedError is raised.

pending_stamp(document_id: str, accept: ~satcfdi.pacs.Accept = <Accept.XML: 1>) PendingDocument[source]

Check the status of a document that is pending to be sent to the SAT (by failure or quick stamp)

Parameters:
  • document_id (str) – The UUID of the document to recover.

  • accept (Accept, optional) – The type of response to accept. Defaults to Accept.XML.

Raises:
  • NotImplementedError – If the accept parameter includes Accept.PDF.

  • ResponseError – If the response from the Finkok SOAP web service contains an error code.

Returns:

The PendingDocument object with the following attributes: - document_id (str): The UUID of the document. - xml (bytes): The XML content of the document. - status (DocumentStatus): The status of the document.

  • STAMPED, the document has been stamped but not sent to the SAT.

  • FINISHED, the document has been stamped and sent to the SAT.

Return type:

PendingDocument

Notes

  • This function currently only supports accepting XML responses.

  • If the accept parameter includes Accept.PDF, a NotImplementedError is raised.

cancel(cfdi: CFDI, reason: CancelReason, substitution_id: str = None, signer: Signer = None) CancelationAcknowledgment[source]

Cancels a CFDI document using the Finkok API.

Parameters:
  • cfdi (CFDI) – The CFDI document to be canceled.

  • reason (CancelReason) – The reason for canceling the CFDI document.

  • substitution_id (str, optional) – The ID of the substitution document. Defaults to None.

  • signer (Signer) – The signer of the CFDI document.

Returns:

The acknowledgment of the cancellation.

Return type:

CancelationAcknowledgment

Raises:
  • ValueError – If the signer is not provided.

  • DocumentNotFoundError – If the CFDI document to cancel is not found.

  • ResponseError – If there is an error in the response from the API.

cancel_comprobante(cancelation: Cancelacion) CancelationAcknowledgment[source]

Operation to request the cancellation of a CFDI document using a Cancelacion object.

Parameters:

cancelation (cancelacion.Cancelacion) – The cancelation object.

Returns:

The acknowledgment of the cancellation.

Return type:

CancelationAcknowledgment

Raises:
accept_reject(request: SolicitudAceptacionRechazo) AcceptRejectAcknowledgment[source]

Operation to Accept Reject a Cancellation Request

Parameters:

request (SolicitudAceptacionRechazo) – The cancellation request.

Returns:

The acknowledgment of the cancellation.

Return type:

AcceptRejectAcknowledgment

Raises:

ResponseError – If there is an error in the response.

pending(rfc: str) list[str][source]

Operation to get pending cancellations