Browse Source

Merge branch 'master3' into master3

pull/263/head
Isabela Morais 6 years ago
committed by GitHub
parent
commit
9c4650d5da
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 99
      README.md
  2. 117
      pytrustnfe/Servidores.py
  3. 32
      pytrustnfe/nfe/__init__.py
  4. 52
      pytrustnfe/nfe/danfce.py
  5. 19
      pytrustnfe/nfe/danfe.py
  6. 3
      pytrustnfe/nfe/templates/NFeDistribuicaoDFe.xml
  7. 40
      pytrustnfe/nfe/templates/NfeAutorizacao.xml
  8. 81
      pytrustnfe/nfse/aparecida/__init__.py
  9. 91
      pytrustnfe/nfse/aparecida/templates/Rps.xml
  10. 15
      pytrustnfe/nfse/aparecida/templates/cancelarNfse.xml
  11. 7
      pytrustnfe/nfse/aparecida/templates/consultarLoteRps.xml
  12. 13
      pytrustnfe/nfse/aparecida/templates/recepcionarLoteRps.xml
  13. 70
      pytrustnfe/nfse/imperial/__init__.py
  14. 17
      pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml
  15. 9
      pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml
  16. 9
      pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml
  17. 14
      pytrustnfe/nfse/imperial/templates/CancelarNota.xml
  18. 43
      pytrustnfe/nfse/imperial/templates/GerarNota.xml
  19. 81
      pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml
  20. 5
      pytrustnfe/nfse/imperial/templates/SoapRequest.xml
  21. 2
      pytrustnfe/nfse/simpliss/__init__.py
  22. 6
      pytrustnfe/urls.py
  23. 297
      pytrustnfe/xml/schemas/distDFeInt_v1.01.xsd
  24. 289
      pytrustnfe/xml/schemas/leiauteNFe_v4.00.xsd
  25. 5
      pytrustnfe/xml/validate.py
  26. 4
      setup.py
  27. 2
      tests/test_servidores.py

99
README.md

@ -17,7 +17,7 @@ Dependências:
NFSe - Cidades atendidas NFSe - Cidades atendidas
--------------
-----------------------------
* **Paulistana** - São Paulo/SP * **Paulistana** - São Paulo/SP
* **Nota Carioca** - Rio de Janeiro/RJ * **Nota Carioca** - Rio de Janeiro/RJ
* **Imperial** - Petrópolis/RH * **Imperial** - Petrópolis/RH
@ -39,7 +39,7 @@ Implementar novos provedores de NFSe
Exemplos de uso da NFe Exemplos de uso da NFe
---------------
-----------------------------
Consulta Cadastro por CNPJ: Consulta Cadastro por CNPJ:
@ -52,7 +52,102 @@ certificado = Certificado(certificado, 'senha_pfx')
obj = {'cnpj': '12345678901234', 'estado': '42'} obj = {'cnpj': '12345678901234', 'estado': '42'}
resposta = consulta_cadastro(certificado, obj=obj, ambiente=1, estado='42') resposta = consulta_cadastro(certificado, obj=obj, ambiente=1, estado='42')
``` ```
Consulta Distribuição NF-e sem Validação de Esquema:
```python
from pytrustnfe.certificado import Certificado
from pytrustnfe.nfe import consulta_distribuicao_nfe, xml_consulta_distribuicao_nfe
certificado = open("/path/certificado.pfx", "r").read()
certificado = Certificado(certificado, 'senha_pfx')
# Gerando xml e enviado consulta por Ultimo NSU
response1 = consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
modelo='55',
cnpj_cpf='12345678901234',
ultimo_nsu='123456789101213'
)
# Gerando xml e enviado consulta por Chave
response2 = consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
modelo='55',
cnpj_cpf='12345678901234',
chave_nfe='012345678901234567890123456789012345678912'
)
# Gerando xml e enviado consulta por NSU
response3 = consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
modelo='55',
cnpj_cpf='12345678901234',
nsu='123456789101213'
)
```
Consulta Distribuição NF-e com Validação de Esquema:
```python
from pytrustnfe.certificado import Certificado
from pytrustnfe.nfe import consulta_distribuicao_nfe, xml_consulta_distribuicao_nfe
from pytrustnfe.xml.validate import valida_nfe, SCHEMA_DFE
certificado = open("/path/certificado.pfx", "r").read()
certificado = Certificado(certificado, 'senha_pfx')
# Gerando XML para Consulta por Ultimo NSU
xml1 = xml_consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
cnpj_cpf='12345678901234',
ultimo_nsu='123456789101213'
)
# Validando o XML com Esquema
if valida_nfe(xml1, SCHEMA_DFE):
Warning("Erro na validação do esquema")
# Gerando XML para Consulta por Chave
xml2 = xml_consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
cnpj_cpf='12345678901234',
chave_nfe='012345678901234567890123456789012345678912'
)
# Validando o XML com Esquema
if valida_nfe(xml2, SCHEMA_DFE):
Warning("Erro na validação do esquema")
# Gerando XML para Consulta por NSU
xml3 = xml_consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
cnpj_cpf='12345678901234',
nsu='123456789101213'
)
# Validando o XML com Esquema
if valida_nfe(xml3, SCHEMA_DFE):
Warning("Erro na validação do esquema")
# Enviando xml de consulta para sefaz
response = consulta_distribuicao_nfe(
certificado,
ambiente=1,
estado='42',
modelo='55',
xml=xml1
)
```
Exemplo de uso da NFSe Paulistana Exemplo de uso da NFSe Paulistana
--------------------------------- ---------------------------------

117
pytrustnfe/Servidores.py

@ -132,7 +132,7 @@ SVRS = {
WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento/recepcaoevento4.asmx?wsdl', # noqa WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento/recepcaoevento4.asmx?wsdl', # noqa
WS_NFE_AUTORIZACAO: 'ws/NfeAutorizacao/NFeAutorizacao4.asmx?wsdl', WS_NFE_AUTORIZACAO: 'ws/NfeAutorizacao/NFeAutorizacao4.asmx?wsdl',
WS_NFE_RET_AUTORIZACAO: 'ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx?wsdl', # noqa WS_NFE_RET_AUTORIZACAO: 'ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx?wsdl', # noqa
WS_NFE_CADASTRO: 'ws/cadconsultacadastro/cadconsultacadastro2.asmx?wsdl', # noqa
WS_NFE_CADASTRO: 'ws/cadconsultacadastro/cadconsultacadastro4.asmx?wsdl', # noqa
}, },
AMBIENTE_HOMOLOGACAO: { AMBIENTE_HOMOLOGACAO: {
'servidor': 'nfe-homologacao.svrs.rs.gov.br', 'servidor': 'nfe-homologacao.svrs.rs.gov.br',
@ -142,7 +142,7 @@ SVRS = {
WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento/recepcaoevento4.asmx?wsdl', # noqa WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento/recepcaoevento4.asmx?wsdl', # noqa
WS_NFE_AUTORIZACAO: 'ws/NfeAutorizacao/NFeAutorizacao4.asmx?wsdl', WS_NFE_AUTORIZACAO: 'ws/NfeAutorizacao/NFeAutorizacao4.asmx?wsdl',
WS_NFE_RET_AUTORIZACAO: 'ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx?wsdl', # noqa WS_NFE_RET_AUTORIZACAO: 'ws/NfeRetAutorizacao/NFeRetAutorizacao4.asmx?wsdl', # noqa
WS_NFE_CADASTRO: 'ws/cadconsultacadastro/cadconsultacadastro2.asmx?wsdl', # noqa
WS_NFE_CADASTRO: 'ws/cadconsultacadastro/cadconsultacadastro4.asmx?wsdl', # noqa
} }
}, },
NFCE_MODELO: { NFCE_MODELO: {
@ -268,23 +268,22 @@ UFAM = {
}, },
NFCE_MODELO: { NFCE_MODELO: {
AMBIENTE_PRODUCAO: { AMBIENTE_PRODUCAO: {
'servidor': 'nfe.sefaz.am.gov.br',
WS_NFE_RECEPCAO_EVENTO: 'services2/services/RecepcaoEvento',
WS_NFE_AUTORIZACAO: 'services2/services/NfeAutorizacao',
WS_NFE_RET_AUTORIZACAO: 'services2/services/NfeRetAutorizacao',
WS_NFE_INUTILIZACAO: 'services2/services/NfeInutilizacao2',
WS_NFE_CONSULTA: 'services2/services/NfeConsulta2',
WS_NFE_SITUACAO: 'services2/services/NfeStatusServico2',
WS_NFE_CADASTRO: 'services2/services/cadconsultacadastro2',
'servidor': 'nfce.sefaz.am.gov.br',
WS_NFE_RECEPCAO_EVENTO: 'nfce-services/services/RecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfce-services/services/NfeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfce-services/services/NfeRetAutorizacao4?wsdl',
WS_NFE_INUTILIZACAO: 'nfce-services/services/NfeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfce-services/services/NfeConsulta4?wsdl',
WS_NFE_SITUACAO: 'nfce-services/services/NfeStatusServico4?wsdl',
}, },
AMBIENTE_HOMOLOGACAO: { AMBIENTE_HOMOLOGACAO: {
'servidor': 'homnfce.sefaz.am.gov.br', 'servidor': 'homnfce.sefaz.am.gov.br',
WS_NFE_RECEPCAO_EVENTO: 'nfce-services-nac/services/RecepcaoEvento',
WS_NFE_AUTORIZACAO: 'nfce-services-nac/services/NfeAutorizacao',
WS_NFE_RET_AUTORIZACAO: 'nfce-services-nac/services/NfeRetAutorizacao',
WS_NFE_INUTILIZACAO: 'nfce-services-nac/services/NfeInutilizacao2',
WS_NFE_CONSULTA: 'nfce-services-nac/services/NfeConsulta2',
WS_NFE_SITUACAO: 'nfce-services-nac/services/NfeStatusServico2',
WS_NFE_RECEPCAO_EVENTO: 'nfce-services/services/RecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfce-services/services/NfeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfce-services/services/NfeRetAutorizacao4?wsdl',
WS_NFE_INUTILIZACAO: 'nfce-services/services/NfeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfce-services/services/NfeConsulta4?wsdl',
WS_NFE_SITUACAO: 'nfce-services/services/NfeStatusServico4?wsdl',
WS_NFCE_QR_CODE: 'http://homnfce.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp', WS_NFCE_QR_CODE: 'http://homnfce.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp',
} }
} }
@ -482,27 +481,51 @@ UFMS = {
} }
UFMG = { UFMG = {
AMBIENTE_PRODUCAO: {
'servidor': 'nfe.fazenda.mg.gov.br',
WS_NFE_INUTILIZACAO: 'nfe2/services/NFeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfe2/services/NFeConsultaProtocolo4?wsdl',
WS_NFE_SITUACAO: 'nfe2/services/NFeStatusServico4?wsdl',
WS_NFE_RECEPCAO_EVENTO: 'nfe2/services/NFeRecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfe2/services/NFeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfe2/services/NFeRetAutorizacao4?wsdl',
WS_NFE_CADASTRO: 'nfe2/services/cadconsultacadastro2?wsdl',
NFE_MODELO: {
AMBIENTE_PRODUCAO: {
'servidor': 'nfe.fazenda.mg.gov.br',
WS_NFE_INUTILIZACAO: 'nfe2/services/NFeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfe2/services/NFeConsultaProtocolo4?wsdl',
WS_NFE_SITUACAO: 'nfe2/services/NFeStatusServico4?wsdl',
WS_NFE_RECEPCAO_EVENTO: 'nfe2/services/NFeRecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfe2/services/NFeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfe2/services/NFeRetAutorizacao4?wsdl',
WS_NFE_CADASTRO: 'nfe2/services/CadConsultaCadastro4?wsdl',
},
AMBIENTE_HOMOLOGACAO: {
'servidor': 'hnfe.fazenda.mg.gov.br',
WS_NFE_INUTILIZACAO: 'nfe2/services/NFeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfe2/services/NFeConsultaProtocolo4?wsdl',
WS_NFE_SITUACAO: 'nfe2/services/NFeStatusServico4?wsdl',
WS_NFE_RECEPCAO_EVENTO: 'nfe2/services/NFeRecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfe2/services/NFeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfe2/services/NFeRetAutorizacao4?wsdl',
WS_NFE_CADASTRO: 'nfe2/services/CadConsultaCadastro4?wsdl',
},
},
NFCE_MODELO: {
AMBIENTE_PRODUCAO: {
'servidor': 'nfce.fazenda.mg.gov.br',
WS_NFE_INUTILIZACAO: 'nfce/services/NFeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfce/services/NFeConsultaProtocolo4?wsdl',
WS_NFE_SITUACAO: 'nfce/services/NFeStatusServico4?wsdl',
WS_NFE_RECEPCAO_EVENTO: 'nfce/services/NFeRecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfce/services/NFeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfce/services/NFeRetAutorizacao4?wsdl',
WS_NFCE_QR_CODE: 'nfce.fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml?'
},
AMBIENTE_HOMOLOGACAO: {
'servidor': 'hnfce.fazenda.mg.gov.br',
WS_NFE_INUTILIZACAO: 'nfce/services/NFeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfce/services/NFeConsultaProtocolo4?wsdl',
WS_NFE_SITUACAO: 'nfce/services/NFeStatusServico4?wsdl',
WS_NFE_RECEPCAO_EVENTO: 'nfce/services/NFeRecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfce/services/NFeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfce/services/NFeRetAutorizacao4?wsdl',
WS_NFCE_QR_CODE: 'nfce.fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml?'
},
}, },
AMBIENTE_HOMOLOGACAO: {
'servidor': 'hnfe.fazenda.mg.gov.br',
WS_NFE_INUTILIZACAO: 'nfe2/services/NFeInutilizacao4?wsdl',
WS_NFE_CONSULTA: 'nfe2/services/NFeConsultaProtocolo4?wsdl',
WS_NFE_SITUACAO: 'nfe2/services/NFeStatusServico4?wsdl',
WS_NFE_RECEPCAO_EVENTO: 'nfe2/services/NFeRecepcaoEvento4?wsdl',
WS_NFE_AUTORIZACAO: 'nfe2/services/NFeAutorizacao4?wsdl',
WS_NFE_RET_AUTORIZACAO: 'nfe2/services/NFeRetAutorizacao4?wsdl',
WS_NFE_CADASTRO: 'nfe2/services/cadconsultacadastro2?wsdl',
}
} }
UFPR = { UFPR = {
@ -653,24 +676,24 @@ UFSP = {
NFCE_MODELO: { NFCE_MODELO: {
AMBIENTE_PRODUCAO: { AMBIENTE_PRODUCAO: {
'servidor': 'nfce.fazenda.sp.gov.br', 'servidor': 'nfce.fazenda.sp.gov.br',
WS_NFE_AUTORIZACAO: 'ws/nfeautorizacao.asmx',
WS_NFE_RET_AUTORIZACAO: 'ws/nferetautorizacao.asmx',
WS_NFE_INUTILIZACAO: 'ws/nfeinutilizacao2.asmx',
WS_NFE_CONSULTA: 'ws/nfeconsulta2.asmx',
WS_NFE_SITUACAO: 'ws/nfestatusservico2.asmx',
WS_NFE_AUTORIZACAO: 'ws/NFeAutorizacao4.asmx?wsdl',
WS_NFE_RET_AUTORIZACAO: 'ws/NFeRetAutorizacao4.asmx?wsdl',
WS_NFE_INUTILIZACAO: 'ws/NFeInutilizacao4.asmx?wsdl',
WS_NFE_CONSULTA: 'ws/NFeConsultaProtocolo4.asmx?wsdl',
WS_NFE_SITUACAO: 'ws/NFeStatusServico4.asmx?wsdl',
WS_NFE_CADASTRO: 'ws/cadconsultacadastro2.asmx', WS_NFE_CADASTRO: 'ws/cadconsultacadastro2.asmx',
WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento.asmx',
WS_NFE_RECEPCAO_EVENTO: 'ws/NFeRecepcaoEvento4.asmx?wsdl',
WS_NFCE_QR_CODE: '', WS_NFCE_QR_CODE: '',
}, },
AMBIENTE_HOMOLOGACAO: { AMBIENTE_HOMOLOGACAO: {
'servidor': 'homologacao.nfce.fazenda.sp.gov.br', 'servidor': 'homologacao.nfce.fazenda.sp.gov.br',
WS_NFE_AUTORIZACAO: 'ws/nfeautorizacao.asmx',
WS_NFE_RET_AUTORIZACAO: 'ws/nferetautorizacao.asmx',
WS_NFE_INUTILIZACAO: 'ws/nfeinutilizacao2.asmx',
WS_NFE_CONSULTA: 'ws/nfeconsulta2.asmx',
WS_NFE_SITUACAO: 'ws/nfestatusservico2.asmx',
WS_NFE_AUTORIZACAO: 'ws/NFeAutorizacao4.asmx?wsdl',
WS_NFE_RET_AUTORIZACAO: 'ws/NFeRetAutorizacao4.asmx?wsdl',
WS_NFE_INUTILIZACAO: 'ws/NFeInutilizacao4.asmx?wsdl',
WS_NFE_CONSULTA: 'ws/NFeConsultaProtocolo4.asmx?wsdl',
WS_NFE_SITUACAO: 'ws/NFeStatusServico4.asmx?wsdl',
WS_NFE_CADASTRO: 'ws/cadconsultacadastro2.asmx', WS_NFE_CADASTRO: 'ws/cadconsultacadastro2.asmx',
WS_NFE_RECEPCAO_EVENTO: 'ws/recepcaoevento.asmx',
WS_NFE_RECEPCAO_EVENTO: 'ws/NFeRecepcaoEvento4.asmx?wsdl',
WS_NFCE_QR_CODE: 'https://homologacao.nfce.fazenda.sp.gov.br/NFCEConsultaPublica/Paginas/ConstultaQRCode.aspx', WS_NFCE_QR_CODE: 'https://homologacao.nfce.fazenda.sp.gov.br/NFCEConsultaPublica/Paginas/ConstultaQRCode.aspx',
} }
} }

32
pytrustnfe/nfe/__init__.py

@ -214,6 +214,22 @@ def xml_consulta_distribuicao_nfe(certificado, **kwargs): # Assinar
return _render(certificado, 'NFeDistribuicaoDFe', False, **kwargs) return _render(certificado, 'NFeDistribuicaoDFe', False, **kwargs)
def consulta_distribuicao_nfe(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_consulta_distribuicao_nfe(certificado, **kwargs)
return _send_v310(certificado, **kwargs)
def xml_download_nfe(certificado, **kwargs): # Assinar
return _render(certificado, 'NFeDistribuicaoDFe', False, **kwargs)
def download_nfe(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_download_nfe(certificado, **kwargs)
return _send_v310(certificado, **kwargs)
def _send_v310(certificado, **kwargs): def _send_v310(certificado, **kwargs):
xml_send = kwargs["xml"] xml_send = kwargs["xml"]
base_url = localizar_url( base_url = localizar_url(
@ -243,19 +259,3 @@ def _send_v310(certificado, **kwargs):
'received_xml': response, 'received_xml': response,
'object': obj.Body.nfeDistDFeInteresseResponse.nfeDistDFeInteresseResult 'object': obj.Body.nfeDistDFeInteresseResponse.nfeDistDFeInteresseResult
} }
def consulta_distribuicao_nfe(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_consulta_distribuicao_nfe(certificado, **kwargs)
return _send_v310(certificado, **kwargs)
def xml_download_nfe(certificado, **kwargs): # Assinar
return _render(certificado, 'NFeDistribuicaoDFe', False, **kwargs)
def download_nfe(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_download_nfe(certificado, **kwargs)
return _send_v310(certificado, **kwargs)

52
pytrustnfe/nfe/danfce.py

@ -122,16 +122,24 @@ class danfce(object):
self._drawCenteredParagraph(cEnd) self._drawCenteredParagraph(cEnd)
self.drawLine() self.drawLine()
def danfce_information(self):
self.drawTitle(
"DANFE NFC-e - Documento Auxiliar da Nota Fiscal de",
7, 'NimbusSanL-Bold')
def danfce_information(self, oXML=None):
el_ide = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}ide")
tipo_emissao = tagtext(oNode=el_ide, cTag='tpEmis')
if tipo_emissao in ('5', '9'):
self.current_height -= 5
self.drawTitle("EMITIDA EM CONTINGÊNCIA",9, 'NimbusSanL-Bold')
self.drawTitle("Pendente de autorização", 7, 'NimbusSanL-Bold')
self.drawLine()
else:
self.drawTitle(
"DANFE NFC-e - Documento Auxiliar da Nota Fiscal de",
7, 'NimbusSanL-Bold')
self.drawTitle("Consumidor Eletrônica", 7, 'NimbusSanL-Bold')
self.drawTitle("Consumidor Eletrônica", 7, 'NimbusSanL-Bold')
self.drawString(
"NFC-e não permite aproveitamento de crédito de ICMS", True)
self.drawLine()
self.drawString(
"NFC-e não permite aproveitamento de crédito de ICMS", True)
self.drawLine()
def produtos(self, oXML=None, el_det=None, oPaginator=None, def produtos(self, oXML=None, el_det=None, oPaginator=None,
list_desc=None, list_cod_prod=None): list_desc=None, list_cod_prod=None):
@ -309,18 +317,26 @@ class danfce(object):
dataSolicitacao = getdateUTC(tagtext(oNode=el_ide, cTag="dhEmi")) dataSolicitacao = getdateUTC(tagtext(oNode=el_ide, cTag="dhEmi"))
dataSolicitacao = dataSolicitacao[0] + " " + dataSolicitacao[1] dataSolicitacao = dataSolicitacao[0] + " " + dataSolicitacao[1]
numProtocolo = tagtext(oNode=el_prot_nfe, cTag="nProt")
text = u"%s <br />%s <br />NFC-e nº%s Série %s %s<br />" % (
frase_chave_acesso, cnpj_cpf, nNFC, serie, dataSolicitacao)
dataAutorizacao = getdateUTC(tagtext(oNode=el_prot_nfe,
cTag='dhRecbto'))
dataAutorizacao = dataAutorizacao[0] + " " + dataAutorizacao[1]
self._drawCenteredParagraph(text)
tipo_emissao = tagtext(oNode=el_ide, cTag='tpEmis')
if tipo_emissao in ('5', '9'):
self.current_height -= 8
self.drawTitle("EMITIDA EM CONTINGÊNCIA",9, 'NimbusSanL-Bold')
self.drawTitle("Pendente de autorização - Via Consumidor", 7, 'NimbusSanL-Bold')
else:
numProtocolo = tagtext(oNode=el_prot_nfe, cTag="nProt")
text = u"%s <br />%s <br />NFC-e nº%s Série %s %s<br />\
Protocolo de autorização: %s<br />Data de autorização %s<br />\
" % (frase_chave_acesso, cnpj_cpf, nNFC, serie, dataSolicitacao,
numProtocolo, dataAutorizacao)
dataAutorizacao = getdateUTC(tagtext(oNode=el_prot_nfe,
cTag='dhRecbto'))
dataAutorizacao = dataAutorizacao[0] + " " + dataAutorizacao[1]
self._drawCenteredParagraph(text)
text = "Protocolo de autorização: %s<br />Data de autorização %s<br />" % (
numProtocolo, dataAutorizacao)
self._drawCenteredParagraph(text)
self.draw_qr_code(qrcode) self.draw_qr_code(qrcode)
@ -428,7 +444,7 @@ Protocolo de autorização: %s<br />Data de autorização %s<br />\
self.ide_emit(oXML=oXML) self.ide_emit(oXML=oXML)
# self.destinatario(oXML=oXML) # self.destinatario(oXML=oXML)
self.danfce_information()
self.danfce_information(oXML=oXML)
self.produtos(oXML=oXML, el_det=el_det, oPaginator=oPaginator[0], self.produtos(oXML=oXML, el_det=el_det, oPaginator=oPaginator[0],
list_desc=list_desc, list_cod_prod=list_cod_prod) list_desc=list_desc, list_cod_prod=list_cod_prod)

19
pytrustnfe/nfe/danfe.py

@ -170,9 +170,9 @@ class danfe(object):
infAdProd = item.find( infAdProd = item.find(
".//{http://www.portalfiscal.inf.br/nfe}infAdProd") ".//{http://www.portalfiscal.inf.br/nfe}infAdProd")
list_ = wrap(tagtext(oNode=el_prod, cTag='xProd'), 56)
list_ = wrap(tagtext(oNode=el_prod, cTag='xProd'), 50)
if infAdProd is not None: if infAdProd is not None:
list_.extend(wrap(infAdProd.text, 56))
list_.extend(wrap(infAdProd.text, 50))
list_desc.append(list_) list_desc.append(list_)
list_cProd = wrap(tagtext(oNode=el_prod, cTag='cProd'), 14) list_cProd = wrap(tagtext(oNode=el_prod, cTag='cProd'), 14)
@ -202,7 +202,9 @@ class danfe(object):
self.adicionais(oXML=oXML, tamanho_diminuir=tamanho_ocupado) self.adicionais(oXML=oXML, tamanho_diminuir=tamanho_ocupado)
# Gera o restante das páginas do XML # Gera o restante das páginas do XML
while index <= nId:
while index < nId:
if index < 0:
index = index * -1
self.newpage() self.newpage()
self.ide_emit(oXML=oXML, timezone=timezone) self.ide_emit(oXML=oXML, timezone=timezone)
index = self.produtos( index = self.produtos(
@ -357,7 +359,7 @@ class danfe(object):
self.canvas.restoreState() self.canvas.restoreState()
# Cancelado # Cancelado
if tagtext(oNode=elem_evento, cTag='cStat') == '135':
if tagtext(oNode=elem_evento, cTag='cStat') in ('135', '155'):
self.canvas.saveState() self.canvas.saveState()
self.canvas.rotate(45) self.canvas.rotate(45)
self.canvas.setFont('NimbusSanL-Bold', 60) self.canvas.setFont('NimbusSanL-Bold', 60)
@ -725,6 +727,7 @@ obsCont[@xCampo='NomeVendedor']")
line_height = max(len(list_cod_prod[id]), len(list_desc[id])) line_height = max(len(list_cod_prod[id]), len(list_desc[id]))
line_height *= nStep line_height *= nStep
if nLin + line_height > maxHeight: if nLin + line_height > maxHeight:
id = id * -1
break break
item = el_det[id] item = el_det[id]
@ -759,9 +762,9 @@ obsCont[@xCampo='NomeVendedor']")
tagtext(oNode=el_prod, cTag='vUnCom'))) tagtext(oNode=el_prod, cTag='vUnCom')))
self.stringRight(nMr - 50.5, nLin, format_number( self.stringRight(nMr - 50.5, nLin, format_number(
tagtext(oNode=el_prod, cTag='vProd'))) tagtext(oNode=el_prod, cTag='vProd')))
self.stringRight(nMr - 38.5, nLin, format_number(vBC))
self.stringRight(nMr - 26.5, nLin, format_number(vICMS))
self.stringRight(nMr - 7.5, nLin, format_number(pICMS))
self.stringRight(nMr - 38.5, nLin, format_number(vBC or '0.00'))
self.stringRight(nMr - 26.5, nLin, format_number(vICMS or '0.00'))
self.stringRight(nMr - 7.5, nLin, format_number(pICMS or '0.00'))
self.stringRight(nMr - 14.5, nLin, format_number(vIPI or '0.00')) self.stringRight(nMr - 14.5, nLin, format_number(vIPI or '0.00'))
self.stringRight(nMr - 0.5, nLin, format_number(pIPI or '0.00')) self.stringRight(nMr - 0.5, nLin, format_number(pIPI or '0.00'))
@ -784,8 +787,6 @@ obsCont[@xCampo='NomeVendedor']")
self.canvas.setStrokeColor(black) self.canvas.setStrokeColor(black)
self.nlin += nH + 3 self.nlin += nH + 3
if (index == max_index):
id += 1
return id return id
def calculo_issqn(self, oXML=None): def calculo_issqn(self, oXML=None):

3
pytrustnfe/nfe/templates/NFeDistribuicaoDFe.xml

@ -8,4 +8,7 @@
<consChNFe> <consChNFe>
<chNFe>{{ chave_nfe }}</chNFe> <chNFe>{{ chave_nfe }}</chNFe>
</consChNFe> </consChNFe>
<consNSU>
<NSU>{{ nsu }}</NSU>
</consNSU>
</distDFeInt> </distDFeInt>

40
pytrustnfe/nfe/templates/NfeAutorizacao.xml

@ -27,7 +27,7 @@
<indFinal>{{ ide.indFinal }}</indFinal> <indFinal>{{ ide.indFinal }}</indFinal>
<indPres>{{ ide.indPres }}</indPres> <indPres>{{ ide.indPres }}</indPres>
<procEmi>{{ ide.procEmi }}</procEmi> <procEmi>{{ ide.procEmi }}</procEmi>
<verProc>Odoo Brasil 10</verProc>
<verProc>{{ ide.verProc }}</verProc>
{% if ide.NFref is defined -%} {% if ide.NFref is defined -%}
{% for ref in ide.NFref %} {% for ref in ide.NFref %}
<NFref> <NFref>
@ -143,6 +143,7 @@
<retirada> <retirada>
<CNPJ>{{ NFe.infNFe.retirada.CNPJ }}</CNPJ> <CNPJ>{{ NFe.infNFe.retirada.CNPJ }}</CNPJ>
<CPF>{{ NFe.infNFe.retirada.CPF }}</CPF> <CPF>{{ NFe.infNFe.retirada.CPF }}</CPF>
<xNome>{{ NFe.infNFe.retirada.xNome|normalize|escape }}</xNome>
<xLgr>{{ NFe.infNFe.retirada.xLgr|normalize|escape }}</xLgr> <xLgr>{{ NFe.infNFe.retirada.xLgr|normalize|escape }}</xLgr>
<nro>{{ NFe.infNFe.retirada.nro }}</nro> <nro>{{ NFe.infNFe.retirada.nro }}</nro>
<xCpl>{{ NFe.infNFe.retirada.xCpl|normalize|escape }}</xCpl> <xCpl>{{ NFe.infNFe.retirada.xCpl|normalize|escape }}</xCpl>
@ -150,12 +151,19 @@
<cMun>{{ NFe.infNFe.retirada.cMun }}</cMun> <cMun>{{ NFe.infNFe.retirada.cMun }}</cMun>
<xMun>{{ NFe.infNFe.retirada.xMun|normalize }}</xMun> <xMun>{{ NFe.infNFe.retirada.xMun|normalize }}</xMun>
<UF>{{ NFe.infNFe.retirada.UF }}</UF> <UF>{{ NFe.infNFe.retirada.UF }}</UF>
<CEP>{{ NFe.infNFe.retirada.CEP }}</CEP>
<cPais>{{ NFe.infNFe.retirada.cPais }}</cPais>
<xPais>{{ NFe.infNFe.retirada.xPais|normalize|escape }}</xPais>
<fone>{{ NFe.infNFe.retirada.fone }}</fone>
<email>{{ NFe.infNFe.retirada.email }}</email>
<IE>{{ NFe.infNFe.retirada.IE }}</IE>
</retirada> </retirada>
{% endif %} {% endif %}
{% if NFe.infNFe.entrega is defined %} {% if NFe.infNFe.entrega is defined %}
<entrega> <entrega>
<CNPJ>{{ NFe.infNFe.entrega.CNPJ }}</CNPJ> <CNPJ>{{ NFe.infNFe.entrega.CNPJ }}</CNPJ>
<CPF>{{ NFe.infNFe.entrega.CPF }}</CPF> <CPF>{{ NFe.infNFe.entrega.CPF }}</CPF>
<xNome>{{ NFe.infNFe.entrega.xNome|normalize|escape }}</xNome>
<xLgr>{{ NFe.infNFe.entrega.xLgr|normalize|escape }}</xLgr> <xLgr>{{ NFe.infNFe.entrega.xLgr|normalize|escape }}</xLgr>
<nro>{{ NFe.infNFe.entrega.nro }}</nro> <nro>{{ NFe.infNFe.entrega.nro }}</nro>
<xCpl>{{ NFe.infNFe.entrega.xCpl|normalize|escape }}</xCpl> <xCpl>{{ NFe.infNFe.entrega.xCpl|normalize|escape }}</xCpl>
@ -163,6 +171,12 @@
<cMun>{{ NFe.infNFe.entrega.cMun }}</cMun> <cMun>{{ NFe.infNFe.entrega.cMun }}</cMun>
<xMun>{{ NFe.infNFe.entrega.xMun }}</xMun> <xMun>{{ NFe.infNFe.entrega.xMun }}</xMun>
<UF>{{ NFe.infNFe.entrega.UF }}</UF> <UF>{{ NFe.infNFe.entrega.UF }}</UF>
<CEP>{{ NFe.infNFe.entrega.CEP }}</CEP>
<cPais>{{ NFe.infNFe.entrega.cPais }}</cPais>
<xPais>{{ NFe.infNFe.entrega.xPais|normalize|escape }}</xPais>
<fone>{{ NFe.infNFe.entrega.fone }}</fone>
<email>{{ NFe.infNFe.entrega.email }}</email>
<IE>{{ NFe.infNFe.entrega.IE }}</IE>
</entrega> </entrega>
{% endif %} {% endif %}
{% if NFe.infNFe.autXML %} {% if NFe.infNFe.autXML %}
@ -260,6 +274,7 @@
{% for med in prod.med %} {% for med in prod.med %}
<med> <med>
<cProdANVISA>{{ med.cProdANVISA }}</cProdANVISA> <cProdANVISA>{{ med.cProdANVISA }}</cProdANVISA>
<xMotivoIsencao>{{ med.xMotivoIsencao }}</xMotivoIsencao>
<vPMC>{{ med.vPMC }}</vPMC> <vPMC>{{ med.vPMC }}</vPMC>
</med> </med>
{% endfor %} {% endfor %}
@ -368,6 +383,7 @@
<CST>{{ imposto.ICMS.CST }}</CST> <CST>{{ imposto.ICMS.CST }}</CST>
<vBCSTRet>{{ imposto.ICMS.vBCSTRet }}</vBCSTRet> <vBCSTRet>{{ imposto.ICMS.vBCSTRet }}</vBCSTRet>
<pST>{{ imposto.ICMS.pST }}</pST> <pST>{{ imposto.ICMS.pST }}</pST>
<vICMSSubstituto>{{ imposto.ICMS.vICMSSubstituto }}</vICMSSubstituto>
<vICMSSTRet>{{ imposto.ICMS.vICMSSTRet }}</vICMSSTRet> <vICMSSTRet>{{ imposto.ICMS.vICMSSTRet }}</vICMSSTRet>
<vBCFCPSTRet>{{ imposto.ICMS.vBCFCPSTRet }}</vBCFCPSTRet> <vBCFCPSTRet>{{ imposto.ICMS.vBCFCPSTRet }}</vBCFCPSTRet>
<pFCPSTRet>{{ imposto.ICMS.pFCPSTRet }}</pFCPSTRet> <pFCPSTRet>{{ imposto.ICMS.pFCPSTRet }}</pFCPSTRet>
@ -446,9 +462,18 @@
<orig>{{ imposto.ICMSST.orig }}</orig> <orig>{{ imposto.ICMSST.orig }}</orig>
<CST>{{ imposto.ICMSST.CST }}</CST> <CST>{{ imposto.ICMSST.CST }}</CST>
<vBCSTRet>{{ imposto.ICMSST.vBCSTRet }}</vBCSTRet> <vBCSTRet>{{ imposto.ICMSST.vBCSTRet }}</vBCSTRet>
<pST>{{ imposto.ICMSST.pST }}</pST>
<vICMSSubstituto>{{ imposto.ICMSST.vICMSSubstituto }}</vICMSSubstituto>
<vICMSSTRet>{{ imposto.ICMSST.vICMSSTRet }}</vICMSSTRet> <vICMSSTRet>{{ imposto.ICMSST.vICMSSTRet }}</vICMSSTRet>
<vBCFCPSTRet>{{ imposto.ICMSST.vBCFCPSTRet }}</vBCFCPSTRet>
<pFCPSTRet>{{ imposto.ICMSST.pFCPSTRet }}</pFCPSTRet>
<vFCPSTRet>{{ imposto.ICMSST.vFCPSTRet }}</vFCPSTRet>
<vBCSTDest>{{ imposto.ICMSST.vBCSTDest }}</vBCSTDest> <vBCSTDest>{{ imposto.ICMSST.vBCSTDest }}</vBCSTDest>
<vICMSSTDest>{{ imposto.ICMSST.vICMSSTDest }}</vICMSSTDest> <vICMSSTDest>{{ imposto.ICMSST.vICMSSTDest }}</vICMSSTDest>
<pRedBCEfet>{{ imposto.ICMSST.pRedBCEfet }}</pRedBCEfet>
<vBCEfet>{{ imposto.ICMSST.vBCEfet }}</vBCEfet>
<pICMSEfet>{{ imposto.ICMSST.pICMSEfet }}</pICMSEfet>
<vICMSEfet>{{ imposto.ICMSST.vICMSEfet }}</vICMSEfet>
</ICMSST> </ICMSST>
{% endif %} {% endif %}
{% if imposto.ICMS.CST == '101' -%} {% if imposto.ICMS.CST == '101' -%}
@ -503,6 +528,7 @@
<CSOSN>{{ imposto.ICMS.CST }}</CSOSN> <CSOSN>{{ imposto.ICMS.CST }}</CSOSN>
<vBCSTRet>{{ imposto.ICMS.vBCSTRet }}</vBCSTRet> <vBCSTRet>{{ imposto.ICMS.vBCSTRet }}</vBCSTRet>
<pST>{{ imposto.ICMS.pST }}</pST> <pST>{{ imposto.ICMS.pST }}</pST>
<vICMSSubstituto>{{ imposto.ICMS.vICMSSubstituto }}</vICMSSubstituto>
<vICMSSTRet>{{ imposto.ICMS.vICMSSTRet }}</vICMSSTRet> <vICMSSTRet>{{ imposto.ICMS.vICMSSTRet }}</vICMSSTRet>
<vBCFCPSTRet>{{ imposto.ICMS.vBCFCPSTRet }}</vBCFCPSTRet> <vBCFCPSTRet>{{ imposto.ICMS.vBCFCPSTRet }}</vBCFCPSTRet>
<pFCPSTRet>{{ imposto.ICMS.pFCPSTRet }}</pFCPSTRet> <pFCPSTRet>{{ imposto.ICMS.pFCPSTRet }}</pFCPSTRet>
@ -576,7 +602,7 @@
<vOutro>{{ imposto.ISSQN.vOutro }}</vOutro> <vOutro>{{ imposto.ISSQN.vOutro }}</vOutro>
<vDescIncond>{{ imposto.ISSQN.vDescIncond }}</vDescIncond> <vDescIncond>{{ imposto.ISSQN.vDescIncond }}</vDescIncond>
<vDescCond>{{ imposto.ISSQN.vDescCond }}</vDescCond> <vDescCond>{{ imposto.ISSQN.vDescCond }}</vDescCond>
<vISSRet>{{ imposto.ISSQN.vDeducao }}</vISSRet>
<vISSRet>{{ imposto.ISSQN.vISSRet }}</vISSRet>
<indISS>{{ imposto.ISSQN.indISS }}</indISS> <indISS>{{ imposto.ISSQN.indISS }}</indISS>
<cServico>{{ imposto.ISSQN.cServico }}</cServico> <cServico>{{ imposto.ISSQN.cServico }}</cServico>
<cMun>{{ imposto.ISSQN.cMun }}</cMun> <cMun>{{ imposto.ISSQN.cMun }}</cMun>
@ -859,6 +885,16 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</infAdic> </infAdic>
{% if NFe.infNFe.infRespTec is defined %}
<infRespTec>
<CNPJ>{{ NFe.infNFe.infRespTec.CNPJ }}</CNPJ>
<xContato>{{ NFe.infNFe.infRespTec.xContato }}</xContato>
<email>{{ NFe.infNFe.infRespTec.email }}</email>
<fone>{{ NFe.infNFe.infRespTec.fone }}</fone>
<idCSRT>{{ NFe.infNFe.infRespTec.idCSRT }}</idCSRT>
<hashCSRT>{{ NFe.infNFe.infRespTec.hashCSRT }}</hashCSRT>
</infRespTec>
{% endif %}
{% if NFe.infNFe.exporta is defined %} {% if NFe.infNFe.exporta is defined %}
<exporta> <exporta>
<UFSaidaPais>{{ NFe.infNFe.exporta.UFSaidaPais }}</UFSaidaPais> <UFSaidaPais>{{ NFe.infNFe.exporta.UFSaidaPais }}</UFSaidaPais>

81
pytrustnfe/nfse/aparecida/__init__.py

@ -0,0 +1,81 @@
# © 2019 Danimar Ribeiro, Trustcode
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import os
from requests import Session
from zeep import Client
from zeep.transports import Transport
from requests.packages.urllib3 import disable_warnings
from pytrustnfe.xml import render_xml, sanitize_response
from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key
from pytrustnfe.nfe.assinatura import Assinatura
def _render(certificado, method, **kwargs):
path = os.path.join(os.path.dirname(__file__), 'templates')
xml_send = render_xml(path, '%s.xml' % method, True, **kwargs)
reference = ''
signer = Assinatura(certificado.pfx, certificado.password)
xml_send = signer.assina_xml(xml_send, reference)
return xml_send
def _send(certificado, method, **kwargs):
base_url = ''
if kwargs['ambiente'] == 'producao':
base_url = 'https://aparecida.siltecnologia.com.br/tbw/services/Abrasf10?wsdl'
else:
base_url = 'https://aparecida.siltecnologia.com.br/tbwhomologacao/services/Abrasf10?wsdl'
cert, key = extract_cert_and_key_from_pfx(
certificado.pfx, certificado.password)
cert, key = save_cert_key(cert, key)
disable_warnings()
session = Session()
session.cert = (cert, key)
session.verify = False
transport = Transport(session=session)
client = Client(base_url, transport=transport)
xml_send = kwargs['xml']
response = client.service[method](xml_send)
response, obj = sanitize_response(response)
return {
'sent_xml': xml_send,
'received_xml': response,
'object': obj
}
def xml_recepcionar_lote_rps(certificado, **kwargs):
return _render(certificado, 'recepcionarLoteRps', **kwargs)
def recepcionar_lote_rps(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_recepcionar_lote_rps(certificado, **kwargs)
return _send(certificado, 'recepcionarLoteRps', **kwargs)
def xml_consultar_lote_rps(certificado, **kwargs):
return _render(certificado, 'consultarLoteRps', **kwargs)
def consultar_lote_rps(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_consultar_lote_rps(certificado, **kwargs)
return _send(certificado, 'consultarLoteRps', **kwargs)
def xml_cancelar_nfse(certificado, **kwargs):
return _render(certificado, 'cancelarNfse', **kwargs)
def cancelar_nfse(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs)
return _send(certificado, 'cancelarNfse', **kwargs)

91
pytrustnfe/nfse/aparecida/templates/Rps.xml

@ -0,0 +1,91 @@
<Rps>
<InfRps Id="rps{{ rps.numero }}">
<IdentificacaoRps>
<Numero>{{ rps.numero }}</Numero>
<Serie>{{ rps.serie }}</Serie>
<Tipo>{{ rps.tipo_rps }}</Tipo>
</IdentificacaoRps>
<DataEmissao>{{ rps.data_emissao }}</DataEmissao>
<NaturezaOperacao>{{ rps.natureza_operacao }}</NaturezaOperacao>
<RegimeEspecialTributacao>{{ rps.regime_tributacao }}</RegimeEspecialTributacao>
<OptanteSimplesNacional>{{ rps.optante_simples }}</OptanteSimplesNacional>
<IncentivadorCultural>{{ rps.incentivador_cultural }}</IncentivadorCultural>
<Status>{{ rps.status }}</Status>
<RpsSubstituido>
<Numero>{{ rps.numero_substituido }}</Numero>
<Serie>{{ rps.serie_substituido }}</Serie>
<Tipo>{{ rps.tipo_substituido }}</Tipo>
</RpsSubstituido>
<Servico>
<Valores>
<ValorServicos>{{ rps.valor_servico }}</ValorServicos>
<ValorDeducoes>{{ rps.valor_deducao }}</ValorDeducoes>
<ValorPis>{{ rps.valor_pis }}</ValorPis>
<ValorCofins>{{ rps.valor_cofins }}</ValorCofins>
<ValorInss>{{ rps.valor_inss }}</ValorInss>
<ValorIr>{{ rps.valor_ir }}</ValorIr>
<ValorCsll>{{ rps.valor_csll }}</ValorCsll>
<IssRetido>{{ rps.iss_retido }}</IssRetido>
<ValorIss>{{ rps.valor_iss }}</ValorIss>
<ValorIssRetido>{{ rps.valor_iss_retido }}</ValorIssRetido>
<OutrasRetencoes>{{ rps.outras_retencoes }}</OutrasRetencoes>
<BaseCalculo>{{ rps.base_calculo }}</BaseCalculo>
<Aliquota>{{ rps.aliquota_issqn }}</Aliquota>
<ValorLiquidoNfse>{{ rps.valor_liquido_nfse }}</ValorLiquidoNfse>
<DescontoIncondicionado>{{ rps.desconto_incondicionado }}</DescontoIncondicionado>
<DescontoCondicionado>{{ rps.desconto_condicionado }}</DescontoCondicionado>
</Valores>
<ItemListaServico>{{ rps.codigo_servico }}</ItemListaServico>
<CodigoCnae>{{ rps.cnae_servico }}</CodigoCnae>
<CodigoTributacaoMunicipio>{{ rps.codigo_tributacao_municipio }}</CodigoTributacaoMunicipio>
<Discriminacao>{{ rps.descricao }}</Discriminacao>
<CodigoMunicipio>{{ rps.codigo_municipio }}</CodigoMunicipio>
</Servico>
<Prestador>
<Cnpj>{{ rps.prestador.cnpj }}</Cnpj>
<InscricaoMunicipal>{{ rps.prestador.inscricao_municipal }}</InscricaoMunicipal>
</Prestador>
<Tomador>
<IdentificacaoTomador>
<CpfCnpj>
{% if rps.tomador.cnpj_cpf|length == 14 %}
<Cnpj>{{ rps.tomador.cnpj_cpf }}</Cnpj>
{% endif %}
{% if rps.tomador.cnpj_cpf|length == 11 %}
<Cpf>{{ rps.tomador.cnpj_cpf }}</Cpf>
{% endif %}
</CpfCnpj>
<InscricaoMunicipal>{{ rps.tomador.inscricao_municipal }}</InscricaoMunicipal>
</IdentificacaoTomador>
<RazaoSocial>{{ rps.tomador.razao_social }}</RazaoSocial>
<Endereco>
<Endereco>{{ rps.tomador.logradouro }}</Endereco>
<Numero>{{ rps.tomador.numero }}</Numero>
<Complemento>{{ rps.tomador.complemento }}</Complemento>
<Bairro>{{ rps.tomador.bairro }}</Bairro>
<CodigoMunicipio>{{ rps.tomador.cidade }}</CodigoMunicipio>
<Uf>{{ rps.tomador.uf }}</Uf>
<Cep>{{ rps.tomador.cep }}</Cep>
</Endereco>
<Contato>
<Telefone>{{ rps.tomador.telefone }}</Telefone>
<Email>{{ rps.tomador.email }}</Email>
</Contato>
</Tomador>
{% if rps.intermediario is defined -%}
<IntermediarioServico>
<RazaoSocial>{{ rps.intermediario.razao_social }}</RazaoSocial>
<CpfCnpj>
<Cnpj>{{ rps.intermediario.cnpj }}</Cnpj>
</CpfCnpj>
<InscricaoMunicipal>{{ rps.intermediario.inscricao_municipal }}</InscricaoMunicipal>
</IntermediarioServico>
{% endif %}
{% if rps.construcao_civil is defined -%}
<ContrucaoCivil>
<CodigoObra>{{ rps.construcao_civil.codigo_obra }}</CodigoObra>
<Art>{{ rps.construcao_civil.art }}</Art>
</ContrucaoCivil>
{% endif %}
</InfRps>
</Rps>

15
pytrustnfe/nfse/aparecida/templates/cancelarNfse.xml

@ -0,0 +1,15 @@
<CancelarNfseEnvio xmlns="http://nfse.abrasf.org.br">
<Pedido>
<InfPedidoCancelamento Id="1">
<IdentificacaoNfse>
<Numero>{{ cancelamento.numero_nfse }}</Numero>
<CpfCnpj>
<Cnpj>{{ cancelamento.cnpj_prestador }}</Cnpj>
</CpfCnpj>
<InscricaoMunicipal>{{ cancelamento.inscricao_municipal }}</InscricaoMunicipal>
<CodigoMunicipio>{{ cancelamento.cidade }}</CodigoMunicipio>
</IdentificacaoNfse>
<CodigoCancelamento>{{ cancelamento.codigo_cancelamento }}</CodigoCancelamento>
</InfPedidoCancelamento>
</Pedido>
</CancelarNfseEnvio>

7
pytrustnfe/nfse/aparecida/templates/consultarLoteRps.xml

@ -0,0 +1,7 @@
<ConsultarLoteRpsEnvio xmlns="http://nfse.abrasf.org.br">
<Prestador>
<Cnpj>{{ consulta.cnpj_prestador }}</Cnpj>
<InscricaoMunicipal>{{ consulta.inscricao_municipal }}</InscricaoMunicipal>
</Prestador>
<Protocolo>{{ consulta.protocolo }}</Protocolo>
</ConsultarLoteRpsEnvio>

13
pytrustnfe/nfse/aparecida/templates/recepcionarLoteRps.xml

@ -0,0 +1,13 @@
<EnviarLoteRpsEnvio>
<LoteRps Id="lote{{ nfse.numero_lote }}">
<NumeroLote>{{ nfse.numero_lote }}</NumeroLote>
<Cnpj>{{ nfse.cnpj_prestador }}</Cnpj>
<InscricaoMunicipal>{{ nfse.inscricao_municipal }}</InscricaoMunicipal>
<QuantidadeRps>{{ nfse.lista_rps|length }}</QuantidadeRps>
<ListaRps>
{% for rps in nfse.lista_rps -%}
{% include 'Rps.xml' %}
{% endfor %}
</ListaRps>
</LoteRps>
</EnviarLoteRpsEnvio>

70
pytrustnfe/nfse/imperial/__init__.py

@ -3,8 +3,11 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import os import os
import requests
from lxml import etree from lxml import etree
from pytrustnfe import HttpClient
from requests import Session
from zeep import Client
from zeep.transports import Transport
from pytrustnfe.xml import render_xml, sanitize_response from pytrustnfe.xml import render_xml, sanitize_response
@ -17,58 +20,41 @@ def _render(certificado, method, **kwargs):
def _send(certificado, method, **kwargs): def _send(certificado, method, **kwargs):
base_url = '' base_url = ''
if kwargs['ambiente'] == 'producao': if kwargs['ambiente'] == 'producao':
base_url = 'https://nfe.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa
base_url = 'https://petropolis.sigiss.com.br/petropolis/ws/sigiss_ws.php' # noqa
else: else:
base_url = 'https://nfehomologacao.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa
xml_send = kwargs["xml"]
path = os.path.join(os.path.dirname(__file__), 'templates')
soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send.decode())
client = HttpClient(base_url)
response = client.post_soap(soap, 'NFeaction/AWS_NFE.%s' % method)
response, obj = sanitize_response(response)
return {
'sent_xml': xml_send.decode(),
'received_xml': response,
'object': obj
}
def xml_processa_rps(certificado, **kwargs):
return _render(certificado, 'PROCESSARPS', **kwargs)
def processa_rps(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_processa_rps(certificado, **kwargs)
return _send(certificado, 'PROCESSARPS', **kwargs)
raise Exception('Não existe ambiente de homologação!')
def xml_consulta_protocolo(certificado, **kwargs):
return _render(certificado, 'CONSULTAPROTOCOLO', **kwargs)
xml_send = kwargs["xml"].decode('utf-8')
headers = {
'SOAPAction': "urn:sigiss_ws#%s" % method,
'Content-Type': 'text/xml; charset="utf-8"'
}
r = requests.post(base_url, data=xml_send, headers=headers)
response, obj = sanitize_response(r.text.strip())
def consulta_protocolo(certificado, **kwargs):
if "xml" not in kwargs:
kwargs['xml'] = xml_consulta_protocolo(certificado, **kwargs)
return _send(certificado, 'CONSULTAPROTOCOLO', **kwargs)
return {
'sent_xml': xml_send,
'received_xml': response,
'object': obj.Body
}
def xml_consulta_notas_protocolo(certificado, **kwargs):
return _render(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs)
def xml_gerar_nota(certificado, **kwargs):
return _render(certificado, 'GerarNota', **kwargs)
def consulta_notas_protocolo(certificado, **kwargs):
def gerar_nota(certificado, **kwargs):
if "xml" not in kwargs: if "xml" not in kwargs:
kwargs['xml'] = xml_consulta_notas_protocolo(certificado, **kwargs)
return _send(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs)
kwargs['xml'] = xml_gerar_nota(certificado, **kwargs)
return _send(certificado, 'GerarNota', **kwargs)
def xml_cancelar_nfse(certificado, **kwargs):
return _render(certificado, 'CANCELANOTAELETRONICA', **kwargs)
def xml_cancelar_nota(certificado, **kwargs):
return _render(certificado, 'CancelarNota', **kwargs)
def cancelar_nfse(certificado, **kwargs):
def cancelar_nota(certificado, **kwargs):
if "xml" not in kwargs: if "xml" not in kwargs:
kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs)
return _send(certificado, 'CANCELANOTAELETRONICA', **kwargs)
kwargs['xml'] = xml_cancelar_nota(certificado, **kwargs)
return _send(certificado, 'CancelarNota', **kwargs)

17
pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml

@ -1,17 +0,0 @@
<ws_nfe.CANCELANOTAELETRONICA xmlns="NFe">
<Sdt_cancelanfe>
<Login>
<CodigoUsuario>{{ cancelamento.codigo_usuario }}</CodigoUsuario>
<CodigoContribuinte>{{ cancelamento.codigo_contribuinte }}</CodigoContribuinte>
</Login>
<Nota>
<SerieNota>{{ cancelamento.serie_nota }}</SerieNota>
<NumeroNota>{{ cancelamento.numero_nota }}</NumeroNota>
<SerieRPS>{{ cancelamento.serie_rps }}</SerieRPS>
<NumeroRps>{{ cancelamento.numero_rps }}</NumeroRps>
<ValorNota>{{ cancelamento.valor }}</ValorNota>
<MotivoCancelamento>{{ cancelamento.motivo }}</MotivoCancelamento>
<PodeCancelarGuia>{{ cancelamento.cancelar_guia }}</PodeCancelarGuia>
</Nota>
</Sdt_cancelanfe>
</ws_nfe.CANCELANOTAELETRONICA>

9
pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml

@ -1,9 +0,0 @@
<ws_nfe.CONSULTANOTASPROTOCOLO xmlns="NFe">
<Sdt_consultanotasprotocoloin>
<Protocolo>{{ consulta.protocolo }}</Protocolo>
<Login>
<CodigoUsuario>{{ consulta.codigo_usuario }}</CodigoUsuario>
<CodigoContribuinte>{{ consulta.codigo_contribuinte }}</CodigoContribuinte>
</Login>
</Sdt_consultanotasprotocoloin>
</ws_nfe.CONSULTANOTASPROTOCOLO>

9
pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml

@ -1,9 +0,0 @@
<ws_nfe.CONSULTAPROTOCOLO xmlns="NFe">
<Sdt_consultaprotocoloin>
<Protocolo>{{ consulta.protocolo }}</Protocolo>
<Login>
<CodigoUsuario>{{ consulta.codigo_usuario }}</CodigoUsuario>
<CodigoContribuinte>{{ consulta.codigo_contribuinte }}</CodigoContribuinte>
</Login>
</Sdt_consultaprotocoloin>
</ws_nfe.CONSULTAPROTOCOLO>

14
pytrustnfe/nfse/imperial/templates/CancelarNota.xml

@ -0,0 +1,14 @@
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<CancelarNota xmlns="urn:sigiss_ws">
<DadosCancelaNota>
<ccm>{{ cancelamento.ccm }}</ccm>
<cnpj>{{ cancelamento.cnpj }}</cnpj>
<senha>{{ cancelamento.senha }}</senha>
<nota>{{ cancelamento.nota }}</nota>
<motivo>{{ cancelamento.motivo }}</motivo>
<email>{{ cancelamento.email }}</email>
</DadosCancelaNota>
</CancelarNota>
</Body>
</Envelope>

43
pytrustnfe/nfse/imperial/templates/GerarNota.xml

@ -0,0 +1,43 @@
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<GerarNota xmlns="urn:sigiss_ws">
<DescricaoRps>
<ccm>{{ nfse.ccm }}</ccm>
<cnpj>{{ nfse.cnpj }}</cnpj>
<senha>{{ nfse.senha }}</senha>
<crc>{{ nfse.crc }}</crc>
<crc_estado>{{ nfse.crc_estado }}</crc_estado>
<aliquota_simples>{{ nfse.aliquota_simples }}</aliquota_simples>
<id_sis_legado>{{ nfse.id_sis_legado }}</id_sis_legado>
<servico>{{ nfse.servico }}</servico>
<situacao>{{ nfse.situacao }}</situacao>
<valor>{{ nfse.valor }}</valor>
<base>{{ nfse.base }}</base>
<descricaoNF>{{ nfse.descricaoNF }}</descricaoNF>
<tomador_tipo>{{ nfse.tomador_tipo }}</tomador_tipo>
<tomador_cnpj>{{ nfse.tomador_cnpj }}</tomador_cnpj>
<tomador_email>{{ nfse.tomador_email }}</tomador_email>
<tomador_ie>{{ nfse.tomador_ie }}</tomador_ie>
<tomador_razao>{{ nfse.tomador_razao }}</tomador_razao>
<tomador_fantasia>{{ nfse.tomador_fantasia }}</tomador_fantasia>
<tomador_endereco>{{ nfse.tomador_endereco }}</tomador_endereco>
<tomador_numero>{{ nfse.tomador_endereco }}</tomador_numero>
<tomador_complemento>{{ nfse.tomador_complemento }}</tomador_complemento>
<tomador_bairro>{{ nfse.tomador_bairro }}</tomador_bairro>
<tomador_CEP>{{ nfse.tomador_CEP }}</tomador_CEP>
<tomador_cod_cidade>{{ nfse.tomador_cod_cidade }}</tomador_cod_cidade>
<tomador_fone>{{ nfse.tomador_fone }}</tomador_fone>
<tomador_ramal>{{ nfse.tomador_ramal }}</tomador_ramal>
<tomador_fax>{{ nfse.tomador_fax }}</tomador_fax>
<outro_municipio>{{ nfse.outro_municipio }}</outro_municipio>
<cod_outro_municipio>{{ nfse.cod_outro_municipio }}</cod_outro_municipio>
<retencao_iss>{{ nfse.retencao_iss }}</retencao_iss>
<pis>{{ nfse.pis }}</pis>
<cofins>{{ nfse.cofins }}</cofins>
<inss>{{ nfse.inss }}</inss>
<irrf>{{ nfse.irrf }}</irrf>
<csll>{{ nfse.csll }}</csll>
</DescricaoRps>
</GerarNota>
</Body>
</Envelope>

81
pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml

@ -1,81 +0,0 @@
<ws_nfe.PROCESSARPS xmlns="NFe">
<Sdt_processarpsin>
<Login>
<CodigoUsuario>{{ nfse.codigo_usuario }}</CodigoUsuario>
<CodigoContribuinte>{{ nfse.codigo_contribuinte }}</CodigoContribuinte>
</Login>
<SDTRPS>
<Ano>{{ nfse.ano }}</Ano>
<Mes>{{ nfse.mes }}</Mes>
<CPFCNPJ>{{ nfse.cnpj_prestador }}</CPFCNPJ>
<DTIni>{{ nfse.data_emissao }}</DTIni>
<DTFin>{{ nfse.data_emissao }}</DTFin>
<TipoTrib>{{ nfse.tipo_tributacao }}</TipoTrib>
<DtAdeSN>{{ nfse.data_adesao_simples }}</DtAdeSN>
<AlqIssSN_IP>{{ nfse.aliquota_simples_isencao|comma }}</AlqIssSN_IP>
<Versao>2.00</Versao>
{% for rps in nfse.lista_rps -%}
<Reg20>
<!-- Optional -->
<Reg20Item>
<TipoNFS>{{ rps.tipo_nfse }}</TipoNFS>
<NumRps>{{ rps.numero }}</NumRps>
<SerRps>{{ rps.serie }}</SerRps>
<DtEmi>{{ rps.data_emissao }}</DtEmi>
<RetFonte>{{ rps.iss_retido }}</RetFonte>
<CodSrv>{{ rps.codigo_servico }}</CodSrv>
<DiscrSrv>{{ rps.descricao}}</DiscrSrv>
<VlNFS>{{ rps.valor_liquido_nfse|comma }}</VlNFS>
<VlDed>{{ rps.valor_deducao|comma }}</VlDed>
<DiscrDed>{{ rps.discriminacao_deducao }}</DiscrDed>
<VlBasCalc>{{ rps.base_calculo|comma }}</VlBasCalc>
<AlqIss>{{ rps.aliquota_issqn|comma }}</AlqIss>
<VlIss>{{ rps.valor_iss|comma }}</VlIss>
<VlIssRet>{{ rps.valor_iss_retido|comma }}</VlIssRet>
<CpfCnpTom>{{ rps.tomador.cnpj_cpf }}</CpfCnpTom>
<RazSocTom>{{ rps.tomador.razao_social }}</RazSocTom>
<TipoLogtom>{{ rps.tomador.tipo_logradouro }}</TipoLogtom>
<LogTom>{{ rps.tomador.logradouro }}</LogTom>
<NumEndTom>{{ rps.tomador.numero }}</NumEndTom>
<ComplEndTom>{{ rps.tomador.complemento }}</ComplEndTom>
<BairroTom>{{ rps.tomador.bairro }}</BairroTom>
<MunTom>{{ rps.tomador.municipio }}</MunTom>
<SiglaUFTom>{{ rps.tomador.uf }}</SiglaUFTom>
<CepTom>{{ rps.tomador.cep }}</CepTom>
<Telefone>{{ rps.tomador.telefone }}</Telefone>
<InscricaoMunicipal>{{ rps.tomador.inscricao_municipal }}</InscricaoMunicipal>
{% if rps.local_prestacao == 'prestador' %}
<TipoLogLocPre>{{ rps.prestador.tipo_logradouro }}</TipoLogLocPre>
<LogLocPre>{{ rps.prestador.logradouro }}</LogLocPre>
<NumEndLocPre>{{ rps.prestador.numero }}</NumEndLocPre>
<ComplEndLocPre>{{ rps.prestador.complemento }}</ComplEndLocPre>
<BairroLocPre>{{ rps.prestador.bairro }}</BairroLocPre>
<MunLocPre>{{ rps.prestador.municipio }}</MunLocPre>
<SiglaUFLocpre>{{ rps.prestador.uf }}</SiglaUFLocpre>
<CepLocPre>{{ rps.prestador.cep }}</CepLocPre>
{% endif %}
<Email1>{{ rps.tomador.email }}</Email1>
{% for imposto in rps.impostos -%}
<Reg30>
<Reg30Item>
<TributoSigla>{{ imposto.sigla }}</TributoSigla>
<TributoAliquota>{{ imposto.aliquota|comma }}</TributoAliquota>
<TributoValor>{{ imposto.valor|comma }}</TributoValor>
</Reg30Item>
</Reg30>
{% endfor %}
</Reg20Item>
</Reg20>
{% endfor %}
<Reg90>
<QtdRegNormal>{{ nfse.lista_rps|length }}</QtdRegNormal>
<ValorNFS>{{ nfse.lista_rps|sum(attribute='valor_liquido_nfse')|comma }}</ValorNFS>
<ValorISS>{{ nfse.lista_rps|sum(attribute='valor_iss')|comma }}</ValorISS>
<ValorDed>{{ nfse.lista_rps|sum(attribute='valor_deducao')|comma }}</ValorDed>
<ValorIssRetTom>{{ nfse.lista_rps|sum(attribute='valor_iss_retido')|comma }}</ValorIssRetTom>
<QtdReg30>{{ nfse.quantidade_impostos }}</QtdReg30>
<ValorTributos>{{ nfse.valor_tributos|comma }}</ValorTributos>
</Reg90>
</SDTRPS>
</Sdt_processarpsin>
</ws_nfe.PROCESSARPS>

5
pytrustnfe/nfse/imperial/templates/SoapRequest.xml

@ -1,5 +0,0 @@
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
{{ soap_body }}
</Body>
</Envelope>

2
pytrustnfe/nfse/simpliss/__init__.py

@ -40,7 +40,7 @@ def _send(method, **kwargs):
base_url = 'http://wshomologacao.simplissweb.com.br/nfseservice.svc' # noqa base_url = 'http://wshomologacao.simplissweb.com.br/nfseservice.svc' # noqa
base_url = 'http://wshomologacao.simplissweb.com.br/nfseservice.svc' base_url = 'http://wshomologacao.simplissweb.com.br/nfseservice.svc'
xml_send = kwargs["xml"].replace('<?xml version="1.0"?>', '')
xml_send = kwargs["xml"]
path = os.path.join(os.path.dirname(__file__), 'templates') path = os.path.join(os.path.dirname(__file__), 'templates')
soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send) soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send)

6
pytrustnfe/urls.py

@ -39,6 +39,7 @@ URLS = {
DF: 'http://www.fazenda.df.gov.br/nfce/qrcode?', DF: 'http://www.fazenda.df.gov.br/nfce/qrcode?',
GO: 'http://nfe.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe?', GO: 'http://nfe.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe?',
MA: 'http://nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp?', MA: 'http://nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp?',
MG: 'https://nfce.fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml?',
MS: 'http://www.dfe.ms.gov.br/nfce/qrcode?', MS: 'http://www.dfe.ms.gov.br/nfce/qrcode?',
MT: 'http://www.sefaz.mt.gov.br/nfce/consultanfce?', MT: 'http://www.sefaz.mt.gov.br/nfce/consultanfce?',
PA: 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/nfceForm.seam?', # noqa PA: 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/nfceForm.seam?', # noqa
@ -65,6 +66,7 @@ URLS = {
GO: 'http://homolog.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe?', GO: 'http://homolog.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe?',
MA: 'http://homologacao.sefaz.ma.gov.br/portal/consultarNFCe.jsp?', MA: 'http://homologacao.sefaz.ma.gov.br/portal/consultarNFCe.jsp?',
MS: 'http://www.dfe.ms.gov.br/nfce/qrcode?', MS: 'http://www.dfe.ms.gov.br/nfce/qrcode?',
MG: 'https://nfce.fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml?',
MT: 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce?', MT: 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce?',
PA: 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/nfceForm.seam?', # noqa PA: 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/nfceForm.seam?', # noqa
PB: 'http://www.receita.pb.gov.br/nfcehom?', PB: 'http://www.receita.pb.gov.br/nfcehom?',
@ -96,7 +98,7 @@ URLS_EXIBICAO = {
MA: 'www.sefaz.ma.gov.br/nfce/consulta', MA: 'www.sefaz.ma.gov.br/nfce/consulta',
MS: 'www.dfe.ms.gov.br/nfce/consulta', MS: 'www.dfe.ms.gov.br/nfce/consulta',
MT: 'www.sefaz.mt.gov.br/nfce/consulta', MT: 'www.sefaz.mt.gov.br/nfce/consulta',
MG: 'www.fazenda.mg.gov.br/nfce/consulta',
MG: 'http://nfce.fazenda.mg.gov.br/portalnfce',
PA: 'www.sefa.pa.gov.br/nfce/consulta', PA: 'www.sefa.pa.gov.br/nfce/consulta',
PB: 'www.receita.pb.gov.br/nfce/consulta', PB: 'www.receita.pb.gov.br/nfce/consulta',
PE: 'nfce.sefaz.pe.gov.br/nfce/consulta', PE: 'nfce.sefaz.pe.gov.br/nfce/consulta',
@ -124,7 +126,7 @@ URLS_EXIBICAO = {
MA: 'www.sefaz.ma.gov.br/nfce/consulta', MA: 'www.sefaz.ma.gov.br/nfce/consulta',
MS: 'www.dfe.ms.gov.br/nfce/consulta', MS: 'www.dfe.ms.gov.br/nfce/consulta',
MT: 'www.sefaz.mt.gov.br/nfce/consulta', MT: 'www.sefaz.mt.gov.br/nfce/consulta',
MG: 'www.fazenda.mg.gov.br/nfce/consulta',
MG: 'http://hnfce.fazenda.mg.gov.br/portalnfce',
PA: 'www.sefa.pa.gov.br/nfce/consulta', PA: 'www.sefa.pa.gov.br/nfce/consulta',
PB: 'www.receita.pb.gov.br/nfcehom', PB: 'www.receita.pb.gov.br/nfcehom',
PE: 'nfce.sefaz.pe.gov.br/nfce/consulta', PE: 'nfce.sefaz.pe.gov.br/nfce/consulta',

297
pytrustnfe/xml/schemas/distDFeInt_v1.01.xsd

@ -0,0 +1,297 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="TNSU">
<xs:annotation>
<xs:documentation>Tipo número sequencial único</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="[0-9]{15}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TQNSU">
<xs:annotation>
<xs:documentation>Tipo quantidade de NSU</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:unsignedShort">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="50"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TVerDistDFe">
<xs:annotation>
<xs:documentation>Tipo Versão dos leiautes do Web Service NFeDistribuicaoDFe</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="1.01"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TAmb">
<xs:annotation>
<xs:documentation>Tipo Ambiente</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Tipo Código da UF da tabela do IBGE</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="11"/>
<xs:enumeration value="12"/>
<xs:enumeration value="13"/>
<xs:enumeration value="14"/>
<xs:enumeration value="15"/>
<xs:enumeration value="16"/>
<xs:enumeration value="17"/>
<xs:enumeration value="21"/>
<xs:enumeration value="22"/>
<xs:enumeration value="23"/>
<xs:enumeration value="24"/>
<xs:enumeration value="25"/>
<xs:enumeration value="26"/>
<xs:enumeration value="27"/>
<xs:enumeration value="28"/>
<xs:enumeration value="29"/>
<xs:enumeration value="31"/>
<xs:enumeration value="32"/>
<xs:enumeration value="33"/>
<xs:enumeration value="35"/>
<xs:enumeration value="41"/>
<xs:enumeration value="42"/>
<xs:enumeration value="43"/>
<xs:enumeration value="50"/>
<xs:enumeration value="51"/>
<xs:enumeration value="52"/>
<xs:enumeration value="53"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCOrgaoIBGE">
<xs:annotation>
<xs:documentation>Tipo Código de orgão (UF da tabela do IBGE + 90 RFB)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="11"/>
<xs:enumeration value="12"/>
<xs:enumeration value="13"/>
<xs:enumeration value="14"/>
<xs:enumeration value="15"/>
<xs:enumeration value="16"/>
<xs:enumeration value="17"/>
<xs:enumeration value="21"/>
<xs:enumeration value="22"/>
<xs:enumeration value="23"/>
<xs:enumeration value="24"/>
<xs:enumeration value="25"/>
<xs:enumeration value="26"/>
<xs:enumeration value="27"/>
<xs:enumeration value="28"/>
<xs:enumeration value="29"/>
<xs:enumeration value="31"/>
<xs:enumeration value="32"/>
<xs:enumeration value="33"/>
<xs:enumeration value="35"/>
<xs:enumeration value="41"/>
<xs:enumeration value="42"/>
<xs:enumeration value="43"/>
<xs:enumeration value="50"/>
<xs:enumeration value="51"/>
<xs:enumeration value="52"/>
<xs:enumeration value="53"/>
<xs:enumeration value="90"/>
<xs:enumeration value="91"/>
<xs:enumeration value="92"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCnpj">
<xs:annotation>
<xs:documentation>Tipo Número do CNPJ</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCpf">
<xs:annotation>
<xs:documentation>Tipo Número do CPF</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="11"/>
<xs:pattern value="[0-9]{11}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TVerAplic">
<xs:annotation>
<xs:documentation>Tipo Versão do Aplicativo</xs:documentation>
</xs:annotation>
<xs:restriction base="TString">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TStat">
<xs:annotation>
<xs:documentation>Tipo Código da Mensagem enviada</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="3"/>
<xs:pattern value="[0-9]{3}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TMotivo">
<xs:annotation>
<xs:documentation>Tipo Motivo</xs:documentation>
</xs:annotation>
<xs:restriction base="TString">
<xs:maxLength value="255"/>
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TString">
<xs:annotation>
<xs:documentation> Tipo string genérico</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[!-ÿ]{1}[ -ÿ]{0,}[!-ÿ]{1}|[!-ÿ]{1}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TChNFe">
<xs:annotation>
<xs:documentation>Tipo Chave da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="44"/>
<xs:pattern value="[0-9]{44}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TProt">
<xs:annotation>
<xs:documentation>Tipo Número do Protocolo de Status</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="15"/>
<xs:pattern value="[0-9]{15}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDateTimeUTC">
<xs:annotation>
<xs:documentation>Data e Hora, formato UTC (AAAA-MM-DDThh:mm:ssTZD, onde TZD = +hh:mm ou -hh:mm)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="(((20(([02468][048])|([13579][26]))-02-29))|(20[0-9][0-9])-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))T(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d([\-,\+](0[0-9]|10|11):00|([\+](12):00))"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIe">
<xs:annotation>
<xs:documentation>Tipo Inscrição Estadual do Emitente // alterado EM 24/10/08 para aceitar ISENTO</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{2,14}|ISENTO"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1302">
<xs:annotation>
<xs:documentation>Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{2}|[1-9]{1}[0-9]{0,12}(\.[0-9]{2})?"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="distDFeInt">
<xs:annotation>
<xs:documentation>Schema de pedido de distribuição de DF-e de interesse</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>
Identificação do Ambiente:
1 - Produção
2 - Homologação
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUFAutor" type="TCodUfIBGE" minOccurs="0">
<xs:annotation>
<xs:documentation>Código da UF do Autor</xs:documentation>
</xs:annotation>
</xs:element>
<xs:choice>
<xs:element name="CNPJ" type="TCnpj">
<xs:annotation>
<xs:documentation>CNPJ do interessado no DF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CPF" type="TCpf">
<xs:annotation>
<xs:documentation>CPF do interessado no DF-e</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:choice>
<xs:element name="distNSU">
<xs:annotation>
<xs:documentation>Grupo para distribuir DF-e de interesse</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="ultNSU" type="TNSU">
<xs:annotation>
<xs:documentation>Último NSU recebido pelo ator. Caso seja informado com zero, ou com um NSU muito antigo, a consulta retornará unicamente as informações resumidas e documentos fiscais eletrônicos que tenham sido recepcionados pelo Ambiente Nacional nos últimos 3 meses.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="consNSU">
<xs:annotation>
<xs:documentation>Grupo para consultar um DF-e a partir de um NSU específico</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="NSU" type="TNSU">
<xs:annotation>
<xs:documentation>Número Sequencial Único. Geralmente esta consulta será utilizada quando identificado pelo interessado um NSU faltante. O Web Service retornará o documento ou informará que o NSU não existe no Ambiente Nacional. Assim, esta consulta fechará a lacuna do NSU identificado como faltante.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="consChNFe">
<xs:annotation>
<xs:documentation>Grupo para consultar uma NF-e a partir da chave de acesso</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="chNFe" type="TChNFe">
<xs:annotation>
<xs:documentation>Chave de acesso da NF-e a ser consultada</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="versao" type="TVerDistDFe" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

289
pytrustnfe/xml/schemas/leiauteNFe_v4.00.xsd

@ -9,6 +9,8 @@
<!-- PL_009-v4a alterações de esquema decorrentes da - NT2016.002 v1.60 - 06/2018 --> <!-- PL_009-v4a alterações de esquema decorrentes da - NT2016.002 v1.60 - 06/2018 -->
<!-- PL_009-v4a.1 correções de esquema decorrentes da - NT2016.002 v1.60 - 06/2018 --> <!-- PL_009-v4a.1 correções de esquema decorrentes da - NT2016.002 v1.60 - 06/2018 -->
<!-- PL_009-v4a.2 adequação do campo placa para novo padrão do Mercosul - 06/2018 --> <!-- PL_009-v4a.2 adequação do campo placa para novo padrão do Mercosul - 06/2018 -->
<!-- PL_009-v4a.3 adequação da lista TCListServ - 10/2018 -->
<!-- PL_009-v4a.4 implementado alterações da NT 2018.005 -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.portalfiscal.inf.br/nfe" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:editix="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.portalfiscal.inf.br/nfe" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:editix="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/> <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
@ -875,7 +877,8 @@ Formato ”CFOP9999”.</xs:documentation>
<xs:simpleType> <xs:simpleType>
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/> <xs:whiteSpace value="preserve"/>
<xs:pattern value="([!-ÿ]{8}|[!-ÿ]{10})?"/> </xs:restriction>
<xs:pattern value="([!-ÿ]{8}|[!-ÿ]{10})?"/>
</xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:element> </xs:element>
<xs:element minOccurs="0" name="EXTIPI"> <xs:element minOccurs="0" name="EXTIPI">
@ -1268,10 +1271,10 @@ Formato ”CFOP9999”.</xs:documentation>
</xs:element> </xs:element>
<xs:element minOccurs="0" name="cAgreg"> <xs:element minOccurs="0" name="cAgreg">
<xs:simpleType> <xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{1,20}"/>
</xs:restriction>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{1,20}"/>
</xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -1586,12 +1589,22 @@ N-NormalVIN</xs:documentation>
<xs:sequence> <xs:sequence>
<xs:element minOccurs="1" name="cProdANVISA"> <xs:element minOccurs="1" name="cProdANVISA">
<xs:annotation> <xs:annotation>
<xs:documentation>Utilizar o número do registro ANVISA
Obs.: Para medicamento isento de registro na ANVISA, utilizar o número da decisão que o isenta, como por exemplo o número da Resolução da Diretoria Colegiada da ANVISA (RDC).</xs:documentation>
<xs:documentation>Utilizar o número do registro ANVISA ou preencher com o literal “ISENTO”, no caso de medicamento isento de registro na ANVISA.</xs:documentation>
</xs:annotation> </xs:annotation>
<xs:simpleType> <xs:simpleType>
<xs:restriction base="TString"> <xs:restriction base="TString">
<xs:length value="13"/>
<xs:pattern value="[0-9]{13}|ISENTO"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="xMotivoIsencao">
<xs:annotation>
<xs:documentation>Obs.: Para medicamento isento de registro na ANVISA, informar o número da decisão que o isenta, como por exemplo o número da Resolução da Diretoria Colegiada da ANVISA (RDC).</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:minLength value="1"/>
<xs:maxLength value="255"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:element> </xs:element>
@ -2355,9 +2368,8 @@ Informar o motivo da desoneração:
<xs:enumeration value="10"/> <xs:enumeration value="10"/>
<xs:enumeration value="11"/> <xs:enumeration value="11"/>
<xs:enumeration value="16"/> <xs:enumeration value="16"/>
<xs:enumeration value="90"/>
</xs:restriction>
<xs:enumeration value="90"/>
</xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
@ -2504,7 +2516,12 @@ A exigência do preenchimento das informações do ICMS diferido fica à critér
<xs:documentation>Aliquota suportada pelo consumidor final.</xs:documentation> <xs:documentation>Aliquota suportada pelo consumidor final.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element name="vICMSSTRet" type="TDec_1302">
<xs:element minOccurs="0" name="vICMSSubstituto" type="TDec_1302">
<xs:annotation>
<xs:documentation>Valor do ICMS Próprio do Substituto cobrado em operação anterior</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vICMSSTRet" type="TDec_1302">
<xs:annotation> <xs:annotation>
<xs:documentation>Valor do ICMS ST retido anteriormente</xs:documentation> <xs:documentation>Valor do ICMS ST retido anteriormente</xs:documentation>
</xs:annotation> </xs:annotation>
@ -2527,10 +2544,8 @@ A exigência do preenchimento das informações do ICMS diferido fica à critér
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:sequence minOccurs="0">
<xs:element name="pRedBCEfet" type="TDec_0302a04Opc">
<xs:sequence minOccurs="0">
<xs:element name="pRedBCEfet" type="TDec_0302a04Opc">
<xs:annotation> <xs:annotation>
<xs:documentation>Percentual de redução da base de cálculo efetiva.</xs:documentation> <xs:documentation>Percentual de redução da base de cálculo efetiva.</xs:documentation>
</xs:annotation> </xs:annotation>
@ -3058,11 +3073,38 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
<xs:documentation>Informar o valor da BC do ICMS ST retido na UF remetente</xs:documentation> <xs:documentation>Informar o valor da BC do ICMS ST retido na UF remetente</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element minOccurs="0" name="pST" type="TDec_0302a04Opc">
<xs:annotation>
<xs:documentation>Aliquota suportada pelo consumidor final.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="vICMSSubstituto" type="TDec_1302">
<xs:annotation>
<xs:documentation>Valor do ICMS Próprio do Substituto cobrado em operação anterior</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vICMSSTRet" type="TDec_1302"> <xs:element name="vICMSSTRet" type="TDec_1302">
<xs:annotation> <xs:annotation>
<xs:documentation> Informar o valor do ICMS ST retido na UF remetente (iv2.0))</xs:documentation> <xs:documentation> Informar o valor do ICMS ST retido na UF remetente (iv2.0))</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:sequence minOccurs="0">
<xs:element name="vBCFCPSTRet" type="TDec_1302">
<xs:annotation>
<xs:documentation>Informar o valor da Base de Cálculo do FCP retido anteriormente por ST.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="pFCPSTRet" type="TDec_0302a04Opc">
<xs:annotation>
<xs:documentation>Percentual relativo ao Fundo de Combate à Pobreza (FCP) retido por substituição tributária.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vFCPSTRet" type="TDec_1302">
<xs:annotation>
<xs:documentation>Valor do ICMS relativo ao Fundo de Combate à Pobreza (FCP) retido por substituição tributária.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:element name="vBCSTDest" type="TDec_1302"> <xs:element name="vBCSTDest" type="TDec_1302">
<xs:annotation> <xs:annotation>
<xs:documentation> Informar o valor da BC do ICMS ST da UF destino</xs:documentation> <xs:documentation> Informar o valor da BC do ICMS ST da UF destino</xs:documentation>
@ -3073,6 +3115,28 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
<xs:documentation>Informar o valor da BC do ICMS ST da UF destino (v2.0)</xs:documentation> <xs:documentation>Informar o valor da BC do ICMS ST da UF destino (v2.0)</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:sequence minOccurs="0">
<xs:element name="pRedBCEfet" type="TDec_0302a04Opc">
<xs:annotation>
<xs:documentation>Percentual de redução da base de cálculo efetiva.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vBCEfet" type="TDec_1302">
<xs:annotation>
<xs:documentation>Valor da base de cálculo efetiva.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="pICMSEfet" type="TDec_0302a04Opc">
<xs:annotation>
<xs:documentation>Alíquota do ICMS efetivo.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vICMSEfet" type="TDec_1302">
<xs:annotation>
<xs:documentation>Valor do ICMS efetivo.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
@ -3380,6 +3444,11 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
<xs:documentation>Aliquota suportada pelo consumidor final.</xs:documentation> <xs:documentation>Aliquota suportada pelo consumidor final.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element minOccurs="0" name="vICMSSubstituto" type="TDec_1302">
<xs:annotation>
<xs:documentation>Valor do ICMS próprio do substituto</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="vICMSSTRet" type="TDec_1302"> <xs:element name="vICMSSTRet" type="TDec_1302">
<xs:annotation> <xs:annotation>
<xs:documentation>Valor do ICMS ST retido anteriormente (v2.0)</xs:documentation> <xs:documentation>Valor do ICMS ST retido anteriormente (v2.0)</xs:documentation>
@ -3403,10 +3472,8 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:sequence minOccurs="0">
<xs:element name="pRedBCEfet" type="TDec_0302a04Opc">
<xs:sequence minOccurs="0">
<xs:element name="pRedBCEfet" type="TDec_0302a04Opc">
<xs:annotation> <xs:annotation>
<xs:documentation>Percentual de redução da base de cálculo efetiva.</xs:documentation> <xs:documentation>Percentual de redução da base de cálculo efetiva.</xs:documentation>
</xs:annotation> </xs:annotation>
@ -3427,8 +3494,7 @@ Operação interestadual para consumidor final com partilha do ICMS devido na o
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
</xs:sequence>
</xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="ICMSSN900"> <xs:element name="ICMSSN900">
@ -4985,8 +5051,8 @@ Substituição Tributaria;</xs:documentation>
<xs:simpleType> <xs:simpleType>
<xs:restriction base="xs:string"> <xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/> <xs:whiteSpace value="preserve"/>
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
</xs:element> </xs:element>
@ -5407,6 +5473,11 @@ concessório</xs:documentation>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element minOccurs="0" name="infRespTec" type="TInfRespTec">
<xs:annotation>
<xs:documentation>Informações do Responsável Técnico pela emissão do DF-e</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute name="versao" type="TVerNFe" use="required"> <xs:attribute name="versao" type="TVerNFe" use="required">
<xs:annotation> <xs:annotation>
@ -5518,6 +5589,30 @@ concessório</xs:documentation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation> <xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:sequence minOccurs="0">
<xs:element name="cMsg">
<xs:annotation>
<xs:documentation>Código da Mensagem.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{1,4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="xMsg">
<xs:annotation>
<xs:documentation>Mensagem da SEFAZ para o emissor.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:minLength value="1"/>
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:sequence> </xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/> <xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType> </xs:complexType>
@ -5967,6 +6062,17 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
</xs:choice> </xs:choice>
<xs:element minOccurs="0" name="xNome">
<xs:annotation>
<xs:documentation>Razão Social ou Nome do Expedidor/Recebedor</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:maxLength value="60"/>
<xs:minLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="xLgr"> <xs:element name="xLgr">
<xs:annotation> <xs:annotation>
<xs:documentation>Logradouro</xs:documentation> <xs:documentation>Logradouro</xs:documentation>
@ -6032,6 +6138,136 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
<xs:documentation>Sigla da UF</xs:documentation> <xs:documentation>Sigla da UF</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element minOccurs="0" name="CEP">
<xs:annotation>
<xs:documentation>CEP</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{8}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="cPais">
<xs:annotation>
<xs:documentation>Código de Pais</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{1,4}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="xPais">
<xs:annotation>
<xs:documentation>Nome do país</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:maxLength value="60"/>
<xs:minLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="fone">
<xs:annotation>
<xs:documentation>Telefone, preencher com Código DDD + número do telefone , nas operações com exterior é permtido informar o código do país + código da localidade + número do telefone</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{6,14}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="email">
<xs:annotation>
<xs:documentation>Informar o e-mail do expedidor/Recebedor. O campo pode ser utilizado para informar o e-mail de recepção da NF-e indicada pelo expedidor</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:whiteSpace value="preserve"/>
<xs:minLength value="1"/>
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" name="IE" type="TIe">
<xs:annotation>
<xs:documentation>Inscrição Estadual (v2.0)</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TInfRespTec">
<xs:annotation>
<xs:documentation>Grupo de informações do responsável técnico pelo sistema de emissão de DF-e</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="CNPJ" type="TCnpjOpc">
<xs:annotation>
<xs:documentation>CNPJ</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xContato">
<xs:annotation>
<xs:documentation>Informar o nome da pessoa a ser contatada na empresa desenvolvedora do sistema utilizado na emissão do documento fiscal eletrônico.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:maxLength value="60"/>
<xs:minLength value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="email">
<xs:annotation>
<xs:documentation>Informar o e-mail da pessoa a ser contatada na empresa desenvolvedora do sistema.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:whiteSpace value="preserve"/>
<xs:minLength value="6"/>
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="fone">
<xs:annotation>
<xs:documentation>Informar o telefone da pessoa a ser contatada na empresa desenvolvedora do sistema. Preencher com o Código DDD + número do telefone.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{6,14}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:sequence minOccurs="0">
<xs:element name="idCSRT">
<xs:annotation>
<xs:documentation>Identificador do CSRT utilizado para montar o hash do CSRT</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="hashCSRT">
<xs:annotation>
<xs:documentation>O hashCSRT é o resultado da função hash (SHA-1 – Base64) do CSRT fornecido pelo fisco mais a Chave de Acesso da NFe.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:base64Binary">
<xs:length value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:sequence> </xs:sequence>
</xs:complexType> </xs:complexType>
<xs:complexType name="TVeiculo"> <xs:complexType name="TVeiculo">
@ -6124,6 +6360,7 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
<xs:enumeration value="01.06"/> <xs:enumeration value="01.06"/>
<xs:enumeration value="01.07"/> <xs:enumeration value="01.07"/>
<xs:enumeration value="01.08"/> <xs:enumeration value="01.08"/>
<xs:enumeration value="01.09"/>
<xs:enumeration value="02.01"/> <xs:enumeration value="02.01"/>
<xs:enumeration value="03.02"/> <xs:enumeration value="03.02"/>
<xs:enumeration value="03.03"/> <xs:enumeration value="03.03"/>
@ -6166,6 +6403,7 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
<xs:enumeration value="06.03"/> <xs:enumeration value="06.03"/>
<xs:enumeration value="06.04"/> <xs:enumeration value="06.04"/>
<xs:enumeration value="06.05"/> <xs:enumeration value="06.05"/>
<xs:enumeration value="06.06"/>
<xs:enumeration value="07.01"/> <xs:enumeration value="07.01"/>
<xs:enumeration value="07.02"/> <xs:enumeration value="07.02"/>
<xs:enumeration value="07.03"/> <xs:enumeration value="07.03"/>
@ -6239,6 +6477,7 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
<xs:enumeration value="14.11"/> <xs:enumeration value="14.11"/>
<xs:enumeration value="14.12"/> <xs:enumeration value="14.12"/>
<xs:enumeration value="14.13"/> <xs:enumeration value="14.13"/>
<xs:enumeration value="14.14"/>
<xs:enumeration value="15.01"/> <xs:enumeration value="15.01"/>
<xs:enumeration value="15.02"/> <xs:enumeration value="15.02"/>
<xs:enumeration value="15.03"/> <xs:enumeration value="15.03"/>
@ -6258,6 +6497,7 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
<xs:enumeration value="15.17"/> <xs:enumeration value="15.17"/>
<xs:enumeration value="15.18"/> <xs:enumeration value="15.18"/>
<xs:enumeration value="16.01"/> <xs:enumeration value="16.01"/>
<xs:enumeration value="16.02"/>
<xs:enumeration value="17.01"/> <xs:enumeration value="17.01"/>
<xs:enumeration value="17.02"/> <xs:enumeration value="17.02"/>
<xs:enumeration value="17.03"/> <xs:enumeration value="17.03"/>
@ -6295,6 +6535,7 @@ alterado para tamanho variavel 1-4. (NT2011/004)</xs:documentation>
<xs:enumeration value="25.02"/> <xs:enumeration value="25.02"/>
<xs:enumeration value="25.03"/> <xs:enumeration value="25.03"/>
<xs:enumeration value="25.04"/> <xs:enumeration value="25.04"/>
<xs:enumeration value="25.05"/>
<xs:enumeration value="26.01"/> <xs:enumeration value="26.01"/>
<xs:enumeration value="27.01"/> <xs:enumeration value="27.01"/>
<xs:enumeration value="28.01"/> <xs:enumeration value="28.01"/>

5
pytrustnfe/xml/validate.py

@ -8,11 +8,12 @@ from lxml import etree
PATH = os.path.dirname(os.path.abspath(__file__)) PATH = os.path.dirname(os.path.abspath(__file__))
SCHEMA = os.path.join(PATH, 'schemas/enviNFe_v4.00.xsd') SCHEMA = os.path.join(PATH, 'schemas/enviNFe_v4.00.xsd')
SCHEMA_DFE = os.path.join(PATH, 'schemas/distDFeInt_v1.01.xsd')
def valida_nfe(xml_nfe):
def valida_nfe(xml_nfe, schema=SCHEMA):
nfe = etree.fromstring(xml_nfe) nfe = etree.fromstring(xml_nfe)
esquema = etree.XMLSchema(etree.parse(SCHEMA))
esquema = etree.XMLSchema(etree.parse(schema))
esquema.validate(nfe) esquema.validate(nfe)
erros = [x.message for x in esquema.error_log] erros = [x.message for x in esquema.error_log]
return "\n".join(erros) return "\n".join(erros)

4
setup.py

@ -2,7 +2,7 @@
from setuptools import setup, find_packages from setuptools import setup, find_packages
VERSION = "1.0.33.post3"
VERSION = "1.0.45"
setup( setup(
@ -39,12 +39,14 @@ later (LGPLv2+)',
'nfse/carioca/templates/*xml', 'nfse/carioca/templates/*xml',
'nfse/bh/templates/*xml', 'nfse/bh/templates/*xml',
'nfse/mga/templates/*xml', 'nfse/mga/templates/*xml',
'nfse/aparecida/templates/*xml',
'xml/schemas/*xsd', 'xml/schemas/*xsd',
]}, ]},
url='https://github.com/danimaribeiro/PyTrustNFe', url='https://github.com/danimaribeiro/PyTrustNFe',
license='LGPL-v2.1+', license='LGPL-v2.1+',
description='PyTrustNFe é uma biblioteca para envio de NF-e', description='PyTrustNFe é uma biblioteca para envio de NF-e',
long_description=open('README.md', 'r').read(), long_description=open('README.md', 'r').read(),
long_description_content_type='text/markdown',
install_requires=[ install_requires=[
'urllib3', 'urllib3',
'xmlsec==1.3.3', # apt update;apt install libxmlsec1-dev pkg-config -y 'xmlsec==1.3.3', # apt update;apt install libxmlsec1-dev pkg-config -y

2
tests/test_servidores.py

@ -21,7 +21,7 @@ url_rs = 'https://nfe.sefazrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx?w
url_cad_rs = 'https://cad.sefazrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx?wsdl' url_cad_rs = 'https://cad.sefazrs.rs.gov.br/ws/cadconsultacadastro/cadconsultacadastro4.asmx?wsdl'
url_cad_sc = 'https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsulta\ url_cad_sc = 'https://cad.svrs.rs.gov.br/ws/cadconsultacadastro/cadconsulta\
cadastro2.asmx?wsdl'
cadastro4.asmx?wsdl'
class test_servidores(unittest.TestCase): class test_servidores(unittest.TestCase):

Loading…
Cancel
Save