Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature/cte][IMP] erpbrasil.edoc: imp cte cancel #80

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 38 additions & 8 deletions src/erpbrasil/edoc/cte.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ConsSitCte,
ConsStatServCte,
EvCancCte,
EventoCte,
RetConsSitCte,
RetConsStatServCte,
RetCte,
Expand Down Expand Up @@ -310,16 +311,45 @@ def envia_documento(self, edoc):
classe=RetCte,
)

def cancela_documento(self, doc_numero, justificativa):
raiz = EvCancCte(
descEvento="Cancelamento", nProt=doc_numero, xJust=justificativa
)
def enviar_lote_evento(self, lista_eventos, numero_lote=False):
for raiz_evento in lista_eventos:
evento = EventoCte(
versao="4.00",
infEvento=raiz_evento,
)
xml_assinado = self.assina_raiz(evento, evento.infEvento.Id)

return self._post(
raiz=raiz,
url=self._get_ws_endpoint(WS_CTE_RECEPCAO_EVENTO),
operacao="cteRecepcaoEvento",
classe=RetEventoCte,
xml_assinado,
self._get_ws_endpoint(WS_CTE_RECEPCAO_EVENTO),
"cteRecepcaoEvento",
RetEventoCte,
)

def cancela_documento(
self, chave, protocolo_autorizacao, justificativa, data_hora_evento=False
):
tipo_evento = "110111"
sequencia = "1"
raiz = EventoCte.InfEvento(
Id="ID" + tipo_evento + chave + sequencia.zfill(3),
cOrgao=self.uf,
tpAmb=self.ambiente,
CNPJ=chave[6:20],
chCTe=chave,
dhEvento=data_hora_evento or self._hora_agora(),
tpEvento=tipo_evento,
nSeqEvento=sequencia,
detEvento=EventoCte.InfEvento.DetEvento(
EvCancCte(
descEvento="Cancelamento",
nProt=protocolo_autorizacao,
xJust=justificativa,
),
versaoEvento="4.00",
),
)
return raiz

def consulta_recibo(self):
pass
Expand Down
Loading