Skip to content

Commit 21146a8

Browse files
ODBrenomarcelsavegnago
authored andcommitted
[ADD] CTe Adapter
1 parent 8ee2c2a commit 21146a8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

nfelib/nfe/ws/edoc_legacy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from erpbrasil.edoc.edoc import DocumentoEletronico
1616
from erpbrasil.edoc.mde import MDe
1717
from erpbrasil.edoc.mdfe import MDFe
18+
from erpbrasil.edoc.cte import CTe
1819
from erpbrasil.edoc.nfce import NFCe
1920
from erpbrasil.edoc.nfe import NFe, localizar_url, WS_NFE_CONSULTA
2021
from erpbrasil.edoc.resposta import RetornoSoap, analisar_retorno_raw
@@ -141,6 +142,24 @@ class MDeAdapter(DocumentoElectronicoAdapter, MDe):
141142
pass
142143

143144

145+
class CTeAdapter(DocumentoElectronicoAdapter, CTe):
146+
147+
def _post(self, raiz, url, operacao, classe):
148+
149+
if is_dataclass(raiz):
150+
xml_string, xml_etree = self.render_edoc_xsdata(raiz)
151+
else:
152+
xml_etree = xml_string = raiz
153+
with self._transmissao.cliente(url):
154+
retorno = self._transmissao.enviar(operacao, xml_etree)
155+
if is_dataclass(classe):
156+
return analisar_retorno_raw_xsdata(
157+
operacao, raiz, xml_string, retorno, classe
158+
)
159+
else:
160+
return analisar_retorno_raw(operacao, raiz, xml_string, retorno, classe)
161+
162+
144163
class MDFeAdapter(DocumentoElectronicoAdapter, MDFe):
145164
NAMESPACES = {
146165
"mdfe": "http://www.portalfiscal.inf.br/mdfe",

0 commit comments

Comments
 (0)