XML Builder

class pynfse_nacional.xml_builder.XMLBuilder

Bases: object

Build DPS XML for NFSe Nacional submission.

__init__(ambiente=Ambiente.HOMOLOGACAO)
Parameters:

ambiente (Ambiente)

build_dps(dps)

Build DPS XML from model.

Parameters:

dps (DPS)

Return type:

str

build_cancel_event(chave_acesso, reason, codigo_motivo=1, cnpj_prestador='')

Build pedRegEvento XML for NFSe cancellation (event type e101101).

Parameters:
  • chave_acesso (str) – 50-digit NFSe access key.

  • reason (str) – Free-text cancellation reason (max 255 chars).

  • codigo_motivo (int) – Cancellation reason code (1=erro na emissão, 2=serviço não prestado, 4=duplicidade). Default 1.

  • cnpj_prestador (str) – CNPJ of the service provider (14 digits). Used in the CNPJAutor field. May be empty if not available.

Returns:

XML string for the cancellation event (unsigned).

Return type:

str