Browse Source
[WIP] Cleanup of useless code, using zeep for NFe soap, adjust xml files
pull/147/head
[WIP] Cleanup of useless code, using zeep for NFe soap, adjust xml files
pull/147/head
12 changed files with 83 additions and 256 deletions
-
86pytrustnfe/Servidores.py
-
63pytrustnfe/nfe/__init__.py
-
32pytrustnfe/nfe/comunicacao.py
-
5pytrustnfe/nfe/templates/NfeConsultaProtocolo.xml
-
5pytrustnfe/nfe/templates/RecepcaoEvento.xml
-
21pytrustnfe/nfe/templates/RecepcaoEventoCarta.xml
-
31pytrustnfe/nfe/templates/RecepcaoEventoEPEC.xml
-
9pytrustnfe/utils.py
-
15pytrustnfe/xml/__init__.py
-
20tests/test_comunicacao.py
-
12tests/test_servidores.py
@ -1,32 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Danimar Ribeiro, Trustcode |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
|
|||
from pytrustnfe.client import HttpClient |
|||
from pytrustnfe.certificado import save_cert_key, extract_cert_and_key_from_pfx |
|||
|
|||
from ..xml import sanitize_response |
|||
|
|||
|
|||
def _soap_xml(body, cabecalho): |
|||
xml = '<?xml version="1.0" encoding="utf-8"?>' |
|||
xml += '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><soap:Body>' |
|||
xml += '<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/' + cabecalho.method + '">' |
|||
xml += body |
|||
xml += '</nfeDadosMsg></soap:Body></soap:Envelope>' |
|||
return xml.rstrip('\n') |
|||
|
|||
|
|||
def executar_consulta(certificado, url, cabecalho, xmlEnviar, send_raw=False): |
|||
cert, key = extract_cert_and_key_from_pfx( |
|||
certificado.pfx, certificado.password) |
|||
cert_path, key_path = save_cert_key(cert, key) |
|||
client = HttpClient(url, cert_path, key_path) |
|||
|
|||
xml_enviar = _soap_xml(xmlEnviar, cabecalho) |
|||
if send_raw: |
|||
xml = '<?xml version="1.0" encoding="utf-8"?>' + xmlEnviar.rstrip('\n') |
|||
xml_enviar = xml |
|||
xml_retorno = client.post_soap(xml_enviar, cabecalho, send_raw) |
|||
return sanitize_response(xml_retorno.encode()) |
|||
@ -1,6 +1,5 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<consSitNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.01"> |
|||
<consSitNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"> |
|||
<tpAmb>{{ obj.ambiente }}</tpAmb> |
|||
<xServ>CONSULTAR</xServ> |
|||
<chNFe>{{ obj.chave_nfe }}</chNFe> |
|||
</consSitNFe> |
|||
</consSitNFe> |
|||
@ -1,21 +0,0 @@ |
|||
<envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|||
<idLote>{{ idLote }}</idLote> |
|||
<evento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|||
<infEvento Id="{{ Id }}"> |
|||
<cOrgao>{{ cOrgao }}</cOrgao> |
|||
<tpAmb>{{ tpAmb }}</tpAmb> |
|||
<CNPJ>{{ CNPJ }}</CNPJ> |
|||
<CPF>{{ CPF }}</CPF> |
|||
<chNFe>{{ chNFe }}</chNFe> |
|||
<dhEvento>{{ dhEvento }}</dhEvento> |
|||
<tpEvento>{{ tpEvento }}</tpEvento> |
|||
<nSeqEvento>{{ nSeqEvento }}</nSeqEvento> |
|||
<verEvento>1.00</verEvento> |
|||
<detEvento versao="1.00"> |
|||
<descEvento>Carta de Correcao</descEvento> |
|||
<xCorrecao>{{ xCorrecao|normalize|escape }}</xCorrecao> |
|||
<xCondUso>A Carta de Correcao e disciplinada pelo paragrafo 1o-A do art. 7o do Convenio S/N, de 15 de dezembro de 1970 e pode ser utilizada para regularizacao de erro ocorrido na emissao de documento fiscal, desde que o erro nao esteja relacionado com: I - as variaveis que determinam o valor do imposto tais como: base de calculo, aliquota, diferenca de preco, quantidade, valor da operacao ou da prestacao; II - a correcao de dados cadastrais que implique mudanca do remetente ou do destinatario; III - a data de emissao ou de saida.</xCondUso> |
|||
</detEvento> |
|||
</infEvento> |
|||
</evento> |
|||
</envEvento> |
|||
@ -1,31 +0,0 @@ |
|||
<envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|||
<idLote>00106151340701</idLote> |
|||
<evento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|||
<infEvento Id="ID1101403514081014278500019055001001061513407959995201"> |
|||
<cOrgao>91</cOrgao> |
|||
<tpAmb>2</tpAmb> |
|||
<CNPJ>10142785000190</CNPJ> |
|||
<chNFe>35140810142785000190550010010615134079599952</chNFe> |
|||
<dhEvento>2014-08-07T04:52:51-03:00</dhEvento> |
|||
<tpEvento>110140</tpEvento> |
|||
<nSeqEvento>1</nSeqEvento> |
|||
<verEvento>1.00</verEvento> |
|||
<detEvento versao="1.00"> |
|||
<descEvento>EPEC</descEvento> |
|||
<cOrgaoAutor>35</cOrgaoAutor> |
|||
<tpAutor>1</tpAutor> |
|||
<verAplic>1.26</verAplic> |
|||
<dhEmi>2014-08-07T00:00:00-03:00</dhEmi> |
|||
<tpNF>1</tpNF> |
|||
<IE>495171423115</IE> |
|||
<dest> |
|||
<UF>SP</UF> |
|||
<CPF>00000000191</CPF> |
|||
<vNF>86.00</vNF> |
|||
<vICMS>6.02</vICMS> |
|||
<vST>0</vST> |
|||
</dest> |
|||
</detEvento> |
|||
</infEvento> |
|||
</evento> |
|||
</envEvento> |
|||
@ -1,20 +0,0 @@ |
|||
# coding=utf-8 |
|||
''' |
|||
Created on Jun 16, 2015 |
|||
|
|||
@author: danimar |
|||
''' |
|||
import unittest |
|||
import os.path |
|||
|
|||
|
|||
XML_RETORNO = '<retEnviNFe><cStat>103</cStat>' \ |
|||
'<cUF>42</cUF></retEnviNFe>' |
|||
|
|||
|
|||
class test_comunicacao(unittest.TestCase): |
|||
|
|||
caminho = os.path.dirname(__file__) |
|||
|
|||
def test_envio_nfe(self): |
|||
pass |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue