diff --git a/pytrustnfe/__init__.py b/pytrustnfe/__init__.py index 449d2f8..252e121 100644 --- a/pytrustnfe/__init__.py +++ b/pytrustnfe/__init__.py @@ -1,3 +1,24 @@ # -*- coding: utf-8 -*- # © 2016 Danimar Ribeiro, Trustcode # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import requests + + +class HttpClient(object): + + def __init__(self, url): + self.url = url + + def _headers(self, action): + return { + u'Content-type': + u'text/xml; charset=utf-8;', + u'Accept': u'application/soap+xml; charset=utf-8', + u'SOAPAction': action + } + + def post_soap(self, xml_soap, action): + header = self._headers(action) + res = requests.post(self.url, data=xml_soap, headers=header) + return res.text diff --git a/pytrustnfe/nfse/ariss/templates/EnviarNota.xml b/pytrustnfe/nfse/ariss/templates/EnviarNota.xml deleted file mode 100644 index fb2b929..0000000 --- a/pytrustnfe/nfse/ariss/templates/EnviarNota.xml +++ /dev/null @@ -1,32 +0,0 @@ - - 6053 - 21/05/2016 - 09.00 - - NOTA FISCAL DE PRESTAÇÃO DE SERVIÇOS - DESCRIÇÃO DO SERVIÇO - 440,00 - 1 - 0,00 - 0,00 - 0,00 - 0,00 - 0,00 - 440,00 - 0,00 - 3550407 - LOCAL EXECUÇÃO - N - 00000000000 - TOMADOR RAZAO/NOME - LOGRADOURO - BAIRRO - 13400000 - ISENTO - ISENTO - email@email.com - 1912345678 - 3506003 - 3,00 - 0 - diff --git a/pytrustnfe/nfse/ariss/templates/Nota.xml b/pytrustnfe/nfse/ariss/templates/Nota.xml deleted file mode 100644 index 8efafac..0000000 --- a/pytrustnfe/nfse/ariss/templates/Nota.xml +++ /dev/null @@ -1,32 +0,0 @@ - - 200 - 21/05/2016 - 09.00 - - NOTA FISCAL DE PRESTAÇÃO DE SERVIÇOS - DESCRIÇÃO DO SERVIÇO - 440,00 - 1 - 0,00 - 0,00 - 0,00 - 0,00 - 0,00 - 440,00 - 0,00 - 3550407 - LOCAL EXECUÇÃO - N - 00000000000 - TOMADOR RAZAO/NOME - LOGRADOURO - BAIRRO - 13400000 - ISENTO - ISENTO - email@email.com - 1912345678 - 3506003 - 3,00 - 0 - diff --git a/pytrustnfe/nfse/simpliss/__init__.py b/pytrustnfe/nfse/simpliss/__init__.py index dcd1bef..372770a 100644 --- a/pytrustnfe/nfse/simpliss/__init__.py +++ b/pytrustnfe/nfse/simpliss/__init__.py @@ -1,49 +1,62 @@ # -*- coding: utf-8 -*- # © 2016 Danimar Ribeiro, Trustcode # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# Endereços Simpliss Piracicaba +# Homologação: http://wshomologacao.simplissweb.com.br/nfseservice.svc +# Homologação site: http://homologacaonovo.simplissweb.com.br/Account/Login + +# Prod:http://sistemas.pmp.sp.gov.br/semfi/simpliss/contrib/Account/Login +# Prod:http://sistemas.pmp.sp.gov.br/semfi/simpliss/ws_nfse/nfseservice.svc import os -import suds +from lxml import etree +from pytrustnfe import HttpClient from pytrustnfe.xml import render_xml, sanitize_response -from pytrustnfe.client import get_authenticated_client from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key from pytrustnfe.nfse.assinatura import Assinatura -def _send(certificado, method, **kwargs): - # A little hack to test +def _render_xml(certificado, method, **kwargs): path = os.path.join(os.path.dirname(__file__), 'templates') - xml_send = render_xml(path, '%s.xml' % method, False, **kwargs) + + cert, key = extract_cert_and_key_from_pfx( + certificado.pfx, certificado.password) + cert, key = save_cert_key(cert, key) + + pfx_path = certificado.save_pfx() + signer = Assinatura(pfx_path, certificado.password) + xml_send = signer.assina_xml(xml_send, '') + + return xml_send + + +def _validate(method, xml): + path = os.path.join(os.path.dirname(__file__), 'templates') schema = os.path.join(path, '%s.xsd' % method) - from lxml import etree - nfe = etree.fromstring(xml_send) + nfe = etree.fromstring(xml) esquema = etree.XMLSchema(etree.parse(schema)) esquema.validate(nfe) erros = [x.message for x in esquema.error_log] + return erros -# if erros: -# raise Exception('\n'.join(erros)) - base_url = 'http://sistemas.pmp.sp.gov.br/semfi/simpliss/ws_nfse/nfseservice.svc?wsdl' - cert, key = extract_cert_and_key_from_pfx( - certificado.pfx, certificado.password) - cert, key = save_cert_key(cert, key) - client = get_authenticated_client(base_url, cert, key) - - #pfx_path = certificado.save_pfx() - #signer = Assinatura(pfx_path, certificado.password) - #xml_send = signer.assina_xml(xml_send, '') - - try: - response = getattr(client.service, method)(xml_send) - except suds.WebFault, e: - return { - 'sent_xml': xml_send, - 'received_xml': e.fault.faultstring, - 'object': None - } +def _send(method, **kwargs): + if kwargs['ambiente'] == 'producao': + base_url = 'http://sistemas.pmp.sp.gov.br/semfi/simpliss/ws_nfse/nfseservice.svc?WSDL' # noqa + else: + base_url = 'http://wshomologacao.simplissweb.com.br/nfseservice.svc?WSDL' # noqa + + xml_send = kwargs["xml"].replace('', '') + path = os.path.join(os.path.dirname(__file__), 'templates') + soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send) + + act = 'http://www.sistema.com.br/Sistema.Ws.Nfse/INfseService/%s' % method + + client = HttpClient(base_url) + response = client.post_soap(soap, act) + print response response, obj = sanitize_response(response) return { @@ -53,25 +66,37 @@ def _send(certificado, method, **kwargs): } +def xml_recepcionar_lote_rps(certificado, **kwargs): + return _render_xml(certificado, 'RecepcionarLoteRps', **kwargs) + + def recepcionar_lote_rps(certificado, **kwargs): - return _send(certificado, 'RecepcionarLoteRps', **kwargs) + if "xml" not in kwargs: + kwargs['xml'] = xml_recepcionar_lote_rps(certificado, **kwargs) + return _send('RecepcionarLoteRps', **kwargs) + + +def xml_consultar_situacao_lote(certificado, **kwargs): + return _render_xml(certificado, 'ConsultarSituacaoLoteRps', **kwargs) def consultar_situacao_lote(certificado, **kwargs): - return _send(certificado, 'ConsultarSituacaoLoteRps', **kwargs) + if "xml" not in kwargs: + kwargs['xml'] = xml_consultar_situacao_lote(certificado, **kwargs) + return _send('ConsultarSituacaoLoteRps', **kwargs) def consultar_nfse_por_rps(certificado, **kwargs): - return _send(certificado, 'ConsultarNfsePorRps', **kwargs) + return _send('ConsultarNfsePorRps', **kwargs) def consultar_lote_rps(certificado, **kwargs): - return _send(certificado, 'ConsultarLoteRps', **kwargs) + return _send('ConsultarLoteRps', **kwargs) def consultar_nfse(certificado, **kwargs): - return _send(certificado, 'ConsultarNfse', **kwargs) + return _send('ConsultarNfse', **kwargs) def cancelar_nfse(certificado, **kwargs): - return _send(certificado, 'CancelarNfse', **kwargs) + return _send('CancelarNfse', **kwargs) diff --git a/pytrustnfe/nfse/simpliss/templates/CancelarNfse.xml b/pytrustnfe/nfse/simpliss/templates/CancelarNfse.xml index 03f1403..8b1d937 100644 --- a/pytrustnfe/nfse/simpliss/templates/CancelarNfse.xml +++ b/pytrustnfe/nfse/simpliss/templates/CancelarNfse.xml @@ -1,13 +1,19 @@ - - - - - {{ cancelar.numero_nfse }} - {{ cancelar.cnpj_prestador }} - {{ cancelar.inscricao_prestador }} - {{ cancelar.codigo_municipio }} - - {{ cancelar.codigo_cancelamento }} - - - + + + + + + [nonNegativeInteger?] + [string?] + [string?] + [int] + + [string?] + + + + + [string?] + [string?] + + diff --git a/pytrustnfe/nfse/simpliss/templates/ConsultarLoteRps.xml b/pytrustnfe/nfse/simpliss/templates/ConsultarLoteRps.xml index 11a3d06..f11b044 100644 --- a/pytrustnfe/nfse/simpliss/templates/ConsultarLoteRps.xml +++ b/pytrustnfe/nfse/simpliss/templates/ConsultarLoteRps.xml @@ -1,6 +1,13 @@ - - - {{ consulta.cnpj_prestador }} - - {{ consulta.protocolo }} - + + + + [string?] + [string?] + + [string?] + + + [string?] + [string?] + + diff --git a/pytrustnfe/nfse/simpliss/templates/ConsultarNfse.xml b/pytrustnfe/nfse/simpliss/templates/ConsultarNfse.xml index 88e0a2a..2b8ffc8 100644 --- a/pytrustnfe/nfse/simpliss/templates/ConsultarNfse.xml +++ b/pytrustnfe/nfse/simpliss/templates/ConsultarNfse.xml @@ -1,6 +1,30 @@ - - - {{ consulta.cnpj_prestador }} - - {{ consulta.numero_nfse }} - + + + + [string?] + [string?] + + [nonNegativeInteger?] + + [date] + [date] + + + + [string?] + + [string?] + + + [string?] + + [string?] + + [string?] + + + + [string?] + [string?] + + diff --git a/pytrustnfe/nfse/simpliss/templates/ConsultarNfsePorRps.xml b/pytrustnfe/nfse/simpliss/templates/ConsultarNfsePorRps.xml index ab6ccd4..7420ffe 100644 --- a/pytrustnfe/nfse/simpliss/templates/ConsultarNfsePorRps.xml +++ b/pytrustnfe/nfse/simpliss/templates/ConsultarNfsePorRps.xml @@ -1,11 +1,17 @@ - - - {{ consulta.numero_rps }} - {{ consulta.serie_rps }} - {{ consulta.tipo_rps }} - - - {{ consulta.cnpj_prestador }} - {{ consulta.inscricao_prestador }} - - + + + + [nonNegativeInteger?] + [string?] + [byte] + + + [string?] + [string?] + + + + [string?] + [string?] + + diff --git a/pytrustnfe/nfse/simpliss/templates/ConsultarSituacaoLoteRps.xml b/pytrustnfe/nfse/simpliss/templates/ConsultarSituacaoLoteRps.xml index 1feb5a5..e24cc0a 100644 --- a/pytrustnfe/nfse/simpliss/templates/ConsultarSituacaoLoteRps.xml +++ b/pytrustnfe/nfse/simpliss/templates/ConsultarSituacaoLoteRps.xml @@ -1,7 +1,13 @@ - - - {{ consulta.cnpj_prestador }} - {{ consulta.inscricao_prestador }} - - {{ consulta.protocolo }} - + + + + [string?] + [string?] + + [string?] + + + [string?] + [string?] + + diff --git a/pytrustnfe/nfse/simpliss/templates/RecepcionarLoteRps.xml b/pytrustnfe/nfse/simpliss/templates/RecepcionarLoteRps.xml index d82352e..641a711 100644 --- a/pytrustnfe/nfse/simpliss/templates/RecepcionarLoteRps.xml +++ b/pytrustnfe/nfse/simpliss/templates/RecepcionarLoteRps.xml @@ -1,11 +1,19 @@ - - - 2012024 - 45111111111100 - 123498 - 1 - - {% include 'rps.xml' %} - - - + + + + {{ nfse.numero_lote }} + {{ nfse.cnpj_prestador }} + {{ nfse.inscricao_municipal }} + 1 + + {% for rps in nfse.lista_rps -%} + {% include 'Rps.xml' %} + {% endfor %} + + + + + {{ nfse.cnpj_prestador }} + {{ nfse.senha }} + + diff --git a/pytrustnfe/nfse/simpliss/templates/Rps.xml b/pytrustnfe/nfse/simpliss/templates/Rps.xml index 3c55b6b..0a172e5 100644 --- a/pytrustnfe/nfse/simpliss/templates/Rps.xml +++ b/pytrustnfe/nfse/simpliss/templates/Rps.xml @@ -1,82 +1,94 @@ - + - 25 - A1 - 1 + {{ rps.numero }} + {{ rps.serie }} + {{ rps.tipo }} - 2014-12-06 - 1 - 1 - 1 - 1 - 1 + {{ rps.data_emissao }} + {{ rps.natureza_operacao }} + {{ rps.regime_tributacao }} + {{ rps.optante_simples }} + {{ rps.incentivador_cultural }} + {{ rps.status }} - 1 - 1 - 1 + {{ rps.numero_substituido }} + {{ rps.serie_substituido }} + {{ rps.tipo_substituido }} - 1 - 100 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + {{ rps.valor_servico }} + {{ rps.valor_deducao }} + {{ rps.valor_pis }} + {{ rps.valor_cofins }} + {{ rps.valor_inss }} + {{ rps.valor_ir }} + {{ rps.valor_csll }} + {{ rps.iss_retido }} + {{ rps.valor_iss }} + {{ rps.valor_iss_retido }} + {{ rps.outras_retencoes }} + {{ rps.base_calculo }} + {{ rps.aliquota }} + {{ rps.valor_liquido_nfse }} + {{ rps.desconto_incondicionado }} + {{ rps.desconto_condicionado }} - 2 - 0702 - 2525 - Prog. - 4204608 - 1 - 4204608 + {{ rps.codigo_servico }} + {{ rps.cnae }} + {{ rps.codigo_tributacao }} + {{ rps.descricao }} + {{ rps.codigo_municipio }} + {% for item in rps.itens_servico -%} + + {{ item.descricao }} + {{ item.quantidade }} + {{ item.valor_unitario }} + + {% endfor %} - - 45111111111100 - - 123498 + {{ rps.prestador.cnpj }} + {{ rps.prestador.inscricao_municipal }} - 83787494000123 + {{ rps.tomador.cnpj_cpf }} + {{ rps.tomador.cnpj_cpf }} + {{ rps.tomador.inscricao_municipal }} - INSTITUICAO FINANCEIRA + {{ rps.tomador.razao_social }} - AV. 7 DE SETEMBRO - 1505 - AO LADO DO JOAO AUTOMOVEIS - CENTRO - 4201406 - SC - 88900000 + {{ rps.tomador.logradouro }} + {{ rps.tomador.numero }} + {{ rps.tomador.complemento }} + {{ rps.tomador.bairro }} + {{ rps.tomador.codigo_municipio }} + {{ rps.tomador.uf }} + {{ rps.tomador.cep }} - 4835220026 - luiz.alves@cxpostal.com + {{ rps.tomador.telefone }} + {{ rps.tomador.email }} + {% if rps.intermediario is defined -%} - - - 06410987065144 - - 22252 - - CONSTRUTORA TERRA FIRME + {{ rps.intermediario.razao_social }} + + {{ rps.intermediario.cnpj }} + + {{ rps.intermediario.inscricao_municipal }} - - 142 - 1/2014 - - + {% endif %} + {% if rps.construcao_civil is defined -%} + + {{ rps.construcao_civil.codigo_obra }} + {{ rps.construcao_civil.art }} + + {% endif %} + diff --git a/pytrustnfe/nfse/simpliss/templates/SoapRequest.xml b/pytrustnfe/nfse/simpliss/templates/SoapRequest.xml new file mode 100644 index 0000000..e8b56b4 --- /dev/null +++ b/pytrustnfe/nfse/simpliss/templates/SoapRequest.xml @@ -0,0 +1,5 @@ + + + {{ soap_body }} + + diff --git a/pytrustnfe/nfse/ariss/__init__.py b/pytrustnfe/nfse/susesu/__init__.py similarity index 73% rename from pytrustnfe/nfse/ariss/__init__.py rename to pytrustnfe/nfse/susesu/__init__.py index 5339304..2295bb2 100644 --- a/pytrustnfe/nfse/ariss/__init__.py +++ b/pytrustnfe/nfse/susesu/__init__.py @@ -3,16 +3,18 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import os -import suds import unicodedata from pytrustnfe.xml import render_xml from pytrustnfe.client import get_client -def _send(method, **kwargs): +def _render_xml(method, **kwargs): path = os.path.join(os.path.dirname(__file__), 'templates') xml_send = render_xml(path, '%s.xml' % method, False, **kwargs) + return xml_send + +def _send(method, **kwargs): if kwargs['ambiente'] == 'producao': base_url = 'http://www.susesu.com.br/wsnfd/serviconfd.asmx?WSDL' else: @@ -20,6 +22,7 @@ def _send(method, **kwargs): client = get_client(base_url) try: + xml_send = kwargs["xml"] result = getattr(client.service, method)(__inject={'msg': xml_send}) except Exception as e: return { @@ -34,9 +37,21 @@ def _send(method, **kwargs): } +def xml_enviar_nota(**kwargs): + return _render_xml('EnviarNota', **kwargs) + + def enviar_nota(**kwargs): + if "xml" not in kwargs: + kwargs['xml'] = xml_enviar_nota(**kwargs) return _send('EnviarNota', **kwargs) +def xml_enviar_nota_retorna_url(**kwargs): + return _render_xml('EnviarNotaRetornaurlNota', **kwargs) + + def enviar_nota_retorna_url(**kwargs): + if "xml" not in kwargs: + kwargs['xml'] = xml_enviar_nota_retorna_url(**kwargs) return _send('EnviarNotaRetornaurlNota', **kwargs) diff --git a/pytrustnfe/nfse/ariss/templates/EnviarNotaRetornaurlNota.xml b/pytrustnfe/nfse/susesu/templates/EnviarNota.xml similarity index 83% rename from pytrustnfe/nfse/ariss/templates/EnviarNotaRetornaurlNota.xml rename to pytrustnfe/nfse/susesu/templates/EnviarNota.xml index 9df6443..bf75e03 100644 --- a/pytrustnfe/nfse/ariss/templates/EnviarNotaRetornaurlNota.xml +++ b/pytrustnfe/nfse/susesu/templates/EnviarNota.xml @@ -1,6 +1,6 @@ - + {{ codigo_prefeitura }} {{ cnpj_prestador }} {{ senha_nfd }} - + diff --git a/pytrustnfe/nfse/susesu/templates/EnviarNotaRetornaurlNota.xml b/pytrustnfe/nfse/susesu/templates/EnviarNotaRetornaurlNota.xml new file mode 100644 index 0000000..b8a27ca --- /dev/null +++ b/pytrustnfe/nfse/susesu/templates/EnviarNotaRetornaurlNota.xml @@ -0,0 +1,14 @@ + + + + {{ nfse.codigo_prefeitura }} + + + + {{ nfse.cnpj_prestador }} + {{ nfse.senha_nfd }} + + + diff --git a/pytrustnfe/nfse/susesu/templates/Nota.xml b/pytrustnfe/nfse/susesu/templates/Nota.xml new file mode 100644 index 0000000..4095e52 --- /dev/null +++ b/pytrustnfe/nfse/susesu/templates/Nota.xml @@ -0,0 +1,32 @@ + + {{ nfse.numero }} + {{ nfse.data_emissao }} + {{ nfse.codigo_atividade }} + + {{ nfse.observacoes}} + {{ nfse.descricao }} + {{ nfse.total_servicos }} + 1 + {{ nfse.valor_ir }} + {{ nfse.valor_inss }} + {{ nfse.valor_pis }} + {{ nfse.valor_pis }} + 0,00 + {{ nfse.total_servicos }} + {{ nfse.valor_deducao }} + {{ nfse.prestador.cidade }} + {{ nfse.prestador.cidade_descricao }} + N + {{ nfse.tomador.cpf_cnpj }} + {{ nfse.tomador.razao_social }} + {{ nfse.tomador.logradouro }} + {{ nfse.tomador.bairro }} + {{ nfse.tomador.cep }} + {{ nfse.tomador.inscricao_estadual }} + {{ nfse.tomador.inscricao_municipal }} + {{ nfse.tomador.email }} + {{ nfse.tomador.telefone }} + {{ nfse.tomador.cidade }} + {{ nfse.tomador.aliquota_atividade }} + 0 + diff --git a/pytrustnfe/test/test_ginfes.py b/pytrustnfe/test/test_ginfes.py index bb350f8..ffb9f20 100644 --- a/pytrustnfe/test/test_ginfes.py +++ b/pytrustnfe/test/test_ginfes.py @@ -5,7 +5,6 @@ import os.path import unittest from pytrustnfe.certificado import Certificado from pytrustnfe.nfse.ginfes import consultar_situacao_lote -from pytrustnfe.nfse.ginfes import consultar_nfse class test_nfse_ginfes(unittest.TestCase): @@ -13,13 +12,12 @@ class test_nfse_ginfes(unittest.TestCase): caminho = os.path.dirname(__file__) def test_consulta_situacao_lote(self): - pfx_source = open('/home/danimar/Downloads/2016.pfx', 'r').read() - pfx = Certificado(pfx_source, '1234') + pfx_source = open('/home/danimar/Downloads/machado.pfx', 'r').read() + pfx = Certificado(pfx_source, '123456789') dados = {'ambiente': 'homologacao'} retorno = consultar_situacao_lote( pfx, consulta=dados, ambiente='homologacao') - print retorno self.assertNotEqual(retorno['received_xml'], '') self.assertEqual(retorno['object'].Cabecalho.Sucesso, True) diff --git a/pytrustnfe/test/test_simpliss.py b/pytrustnfe/test/test_simpliss.py index 0849882..a063007 100644 --- a/pytrustnfe/test/test_simpliss.py +++ b/pytrustnfe/test/test_simpliss.py @@ -3,63 +3,21 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import os.path import unittest -from unittest import skip from pytrustnfe.certificado import Certificado -from pytrustnfe.nfse.simpliss import consultar_situacao_lote -from pytrustnfe.nfse.simpliss import consultar_nfse_por_rps -from pytrustnfe.nfse.simpliss import consultar_lote_rps -from pytrustnfe.nfse.simpliss import consultar_nfse -from pytrustnfe.nfse.simpliss import cancelar_nfse +from pytrustnfe.nfse.simpliss import recepcionar_lote_rps class test_nfse_simpliss(unittest.TestCase): caminho = os.path.dirname(__file__) - def test_consulta_situacao_lote(self): - pfx_source = open('/home/danimar/Downloads/2016.pfx', 'r').read() - pfx = Certificado(pfx_source, '1234') + def test_recepcionar_lote(self): + pfx_source = open('/home/danimar/Downloads/machado.pfx', 'r').read() + pfx = Certificado(pfx_source, '123456789') - dados = {'cnpj_prestador': '12345678910234', 'inscricao_prestador': '123', 'protocolo': '123'} - response = consultar_situacao_lote( + dados = {'cnpj_prestador': '12345678910234', + 'inscricao_prestador': '123', + 'protocolo': '123'} + response = recepcionar_lote_rps( pfx, consulta=dados, ambiente='homologacao') print response - - @skip - def test_consultar_nfse_rps(self): - pfx_source = open('/home/danimar/Downloads/2016.pfx', 'r').read() - pfx = Certificado(pfx_source, '1234') - - dados = {'cnpj_prestador': '01234567896589', 'inscricao_prestador': '123', - 'tipo_rps': '1', 'serie_rps': 'AZ', 'numero_rps': 123} - consultar_nfse_por_rps( - pfx, consulta=dados, ambiente='homologacao') - - @skip - def test_consultar_lote(self): - pfx_source = open('/home/danimar/Downloads/2016.pfx', 'r').read() - pfx = Certificado(pfx_source, '1234') - - dados = {'cnpj_prestador': '01234567896589', 'protocolo': '545455451'} - consultar_lote_rps( - pfx, consulta=dados, ambiente='homologacao') - - @skip - def test_consultar_nfse(self): - pfx_source = open('/home/danimar/Downloads/2016.pfx', 'r').read() - pfx = Certificado(pfx_source, '1234') - - dados = {'cnpj_prestador': '01234567896589', 'numero_nfse': '545455451'} - consultar_nfse( - pfx, consulta=dados, ambiente='homologacao') - - @skip - def test_cancelar_nfse(self): - pfx_source = open('/home/danimar/Downloads/2016.pfx', 'r').read() - pfx = Certificado(pfx_source, '1234') - - dados = {'cnpj_prestador': '01234567896589', 'numero_nfse': '545455451', - 'inscricao_prestador': 454564, 'codigo_municipio': 1234567, - 'codigo_cancelamento': '1'} - cancelar_nfse( - pfx, cancelar=dados, ambiente='homologacao') diff --git a/pytrustnfe/test/test_ariss.py b/pytrustnfe/test/test_susesu.py similarity index 72% rename from pytrustnfe/test/test_ariss.py rename to pytrustnfe/test/test_susesu.py index e679911..3390af7 100644 --- a/pytrustnfe/test/test_ariss.py +++ b/pytrustnfe/test/test_susesu.py @@ -3,24 +3,21 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import os.path import unittest -from pytrustnfe.nfse.ariss import enviar_nota -from pytrustnfe.nfse.ariss import enviar_nota_retorna_url +from pytrustnfe.nfse.susesu import enviar_nota_retorna_url -class test_nfse_arisss(unittest.TestCase): +class test_nfse_susesu(unittest.TestCase): caminho = os.path.dirname(__file__) def test_enviar_nota_url_nota(self): - nota = { - - } dados = { 'cnpj_prestador': '21118045000135', 'codigo_prefeitura': 3150, 'senha_nfd': 'fiscalb', - 'nota': nota + 'prestador': {}, + 'tomador': {} } - response = enviar_nota_retorna_url(ambiente='homologacao', **dados) + response = enviar_nota_retorna_url(ambiente='homologacao', nfse=dados) self.assertEqual(response['received_xml'], '0-Numero da nota fiscal invalido.') diff --git a/setup.py b/setup.py index b623ba1..aa52877 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,7 @@ later (LGPLv2+)', 'nfse/ginfes/templates/*xml', 'nfse/simpliss/templates/*xml', 'nfse/betha/templates/*xml', + 'nfse/susesu/templates/*xml', 'xml/schemas/*xsd', ]}, url='https://github.com/danimaribeiro/PyTrustNFe',