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

[ADD] CTe Adapter #111

Merged
merged 1 commit into from
Jul 18, 2024
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
19 changes: 19 additions & 0 deletions nfelib/nfe/ws/edoc_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from erpbrasil.edoc.edoc import DocumentoEletronico
from erpbrasil.edoc.mde import MDe
from erpbrasil.edoc.mdfe import MDFe
from erpbrasil.edoc.cte import CTe
from erpbrasil.edoc.nfce import NFCe
from erpbrasil.edoc.nfe import NFe, localizar_url, WS_NFE_CONSULTA
from erpbrasil.edoc.resposta import RetornoSoap, analisar_retorno_raw
Expand Down Expand Up @@ -141,6 +142,24 @@ class MDeAdapter(DocumentoElectronicoAdapter, MDe):
pass


class CTeAdapter(DocumentoElectronicoAdapter, CTe):

def _post(self, raiz, url, operacao, classe):

if is_dataclass(raiz):
xml_string, xml_etree = self.render_edoc_xsdata(raiz)
else:
xml_etree = xml_string = raiz
with self._transmissao.cliente(url):
retorno = self._transmissao.enviar(operacao, xml_etree)
if is_dataclass(classe):
return analisar_retorno_raw_xsdata(
operacao, raiz, xml_string, retorno, classe
)
else:
return analisar_retorno_raw(operacao, raiz, xml_string, retorno, classe)


class MDFeAdapter(DocumentoElectronicoAdapter, MDFe):
NAMESPACES = {
"mdfe": "http://www.portalfiscal.inf.br/mdfe",
Expand Down