diff --git a/README.md b/README.md index 0de4cde..d16772c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,12 @@ Dependências: * reportlab * Jinja2 +NFSe - Cidades atendidas +-------------- +* [Ariss](cidades/ariss.md) - 4 cidades atendidas +* [Simpliss](cidades/simpliss.md) - 18 cidade atendidas + + Roadmap -------------- Teste unitários diff --git a/cidades/ariss.md b/cidades/ariss.md new file mode 100644 index 0000000..0187533 --- /dev/null +++ b/cidades/ariss.md @@ -0,0 +1,4 @@ +* Prefeitura de Rio das Pedras/SP +* Prefeitura de Piracaia/SP +* Prefeitura de Ipeúna/SP +* Prefeitura de Santa Maria da Serra/SP diff --git a/cidades/simpliss.md b/cidades/simpliss.md new file mode 100644 index 0000000..a1200c2 --- /dev/null +++ b/cidades/simpliss.md @@ -0,0 +1,18 @@ +* Araras / SP +* Balneario Camboriu / SC +* Bambuí / MG +* Bandeirantes / PR +* Carapicuíba / SP +* Casa Branca / SP +* Cerquilho / SP +* Dois Corregos / SP +* Jales / SP +* Lagoa Da Prata / MG +* Osvaldo Cruz / SP +* Patrocinio / MG +* Piracicaba / SP +* Presidente Prudente / SP +* São João da Boa Vista / SP +* São José do Rio Pardo / SP +* Tupa / SP +* Vargem Grande do Sul / SP diff --git a/pytrustnfe/nfse/ariss/__init__.py b/pytrustnfe/nfse/ariss/__init__.py new file mode 100644 index 0000000..5339304 --- /dev/null +++ b/pytrustnfe/nfse/ariss/__init__.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# 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): + path = os.path.join(os.path.dirname(__file__), 'templates') + xml_send = render_xml(path, '%s.xml' % method, False, **kwargs) + + if kwargs['ambiente'] == 'producao': + base_url = 'http://www.susesu.com.br/wsnfd/serviconfd.asmx?WSDL' + else: + base_url = 'http://pira.comunix.net:5002/gestaopublica/wsnfd/ServicoNfd.asmx?WSDL' # noqa + + client = get_client(base_url) + try: + result = getattr(client.service, method)(__inject={'msg': xml_send}) + except Exception as e: + return { + 'sent_xml': xml_send, + 'received_xml': e.fault.faultstring, + } + result = unicode(result) + result = unicodedata.normalize('NFKD', result).encode('ascii', 'ignore') + return { + 'sent_xml': xml_send, + 'received_xml': result, + } + + +def enviar_nota(**kwargs): + return _send('EnviarNota', **kwargs) + + +def enviar_nota_retorna_url(**kwargs): + return _send('EnviarNotaRetornaurlNota', **kwargs) diff --git a/pytrustnfe/nfse/ariss/templates/EnviarNota.xml b/pytrustnfe/nfse/ariss/templates/EnviarNota.xml new file mode 100644 index 0000000..fb2b929 --- /dev/null +++ b/pytrustnfe/nfse/ariss/templates/EnviarNota.xml @@ -0,0 +1,32 @@ + + 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/EnviarNotaRetornaurlNota.xml b/pytrustnfe/nfse/ariss/templates/EnviarNotaRetornaurlNota.xml new file mode 100644 index 0000000..9df6443 --- /dev/null +++ b/pytrustnfe/nfse/ariss/templates/EnviarNotaRetornaurlNota.xml @@ -0,0 +1,14 @@ + + + + {{ codigo_prefeitura }} + + + + {{ cnpj_prestador }} + {{ senha_nfd }} + + + diff --git a/pytrustnfe/nfse/ariss/templates/Nota.xml b/pytrustnfe/nfse/ariss/templates/Nota.xml new file mode 100644 index 0000000..8efafac --- /dev/null +++ b/pytrustnfe/nfse/ariss/templates/Nota.xml @@ -0,0 +1,32 @@ + + 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/test/test_ariss.py b/pytrustnfe/test/test_ariss.py new file mode 100644 index 0000000..e679911 --- /dev/null +++ b/pytrustnfe/test/test_ariss.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# 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 + + +class test_nfse_arisss(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 + } + response = enviar_nota_retorna_url(ambiente='homologacao', **dados) + self.assertEqual(response['received_xml'], + '0-Numero da nota fiscal invalido.')