Skip to content

Commit

Permalink
Merge pull request #80 from Escodoo/feature/cte-cancelamento
Browse files Browse the repository at this point in the history
[feature/cte][IMP] erpbrasil.edoc: imp cte cancel
  • Loading branch information
marcelsavegnago authored Jul 10, 2024
2 parents 7cf9314 + 8066cf7 commit 7787f3f
Showing 1 changed file with 38 additions and 8 deletions.
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

0 comments on commit 7787f3f

Please sign in to comment.