Compare commits
merge into: felipe:master
felipe:feature/betha
felipe:feature/cte
felipe:feature/nfe-4.0
felipe:feature/nfe-mde
felipe:feature/nota-dsf
felipe:fix-endereco
felipe:fix-invalid-token-bug
felipe:fix-url-df
felipe:fix/warning
felipe:iss-net
felipe:master
felipe:master3
felipe:merge-master3
pull from: felipe:feature/betha
felipe:feature/betha
felipe:feature/cte
felipe:feature/nfe-4.0
felipe:feature/nfe-mde
felipe:feature/nota-dsf
felipe:fix-endereco
felipe:fix-invalid-token-bug
felipe:fix-url-df
felipe:fix/warning
felipe:iss-net
felipe:master
felipe:master3
felipe:merge-master3
1 Commits
master
...
feature/be
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
f8ae6bfa9e |
WIP - Implementação NFSe Betha
|
9 years ago |
6 changed files with 125 additions and 7 deletions
-
6pytrustnfe/nfse/betha/__init__.py
-
2pytrustnfe/nfse/betha/templates/GerarNfse.xml
-
2pytrustnfe/nfse/betha/templates/RecepcionarLoteRps.xml
-
2pytrustnfe/nfse/betha/templates/RecepcionarLoteRpsSincrono.xml
-
2pytrustnfe/nfse/betha/templates/SubstituirNfse.xml
-
118pytrustnfe/test/test_nfse_betha.py
@ -1,3 +1,3 @@ |
|||
<GerarNfseEnvio xmlns = "http://www.betha.com.br/e-nota-contribuinte-ws"> |
|||
{% include 'rps.xml' %} |
|||
{% include 'Rps.xml' %} |
|||
</GerarNfseEnvio> |
|||
@ -0,0 +1,118 @@ |
|||
# coding=utf-8 |
|||
|
|||
import mock |
|||
import os.path |
|||
import unittest |
|||
from pytrustnfe.certificado import Certificado |
|||
from pytrustnfe.nfse.betha import envio_lote_rps |
|||
from pytrustnfe.nfse.betha import cancelar_nfse |
|||
|
|||
|
|||
class test_nfse_betha(unittest.TestCase): |
|||
|
|||
caminho = os.path.dirname(__file__) |
|||
|
|||
def _get_nfse(self): |
|||
rps = [ |
|||
{ |
|||
'assinatura': '123', |
|||
'serie': '1', |
|||
'numero': '1', |
|||
'data_emissao': '2016-08-29', |
|||
'codigo_atividade': '07498', |
|||
'total_servicos': '2.00', |
|||
'total_deducoes': '3.00', |
|||
'prestador': { |
|||
'inscricao_municipal': '123456' |
|||
}, |
|||
'tomador': { |
|||
'tipo_cpfcnpj': '1', |
|||
'cpf_cnpj': '12345678923256', |
|||
'inscricao_municipal': '123456', |
|||
'razao_social': 'Trustcode', |
|||
'tipo_logradouro': '1', |
|||
'logradouro': 'Vinicius de Moraes, 42', |
|||
'numero': '42', |
|||
'bairro': 'Corrego', |
|||
'cidade': 'Floripa', |
|||
'uf': 'SC', |
|||
'cep': '88037240', |
|||
}, |
|||
'codigo_atividade': '07498', |
|||
'aliquota_atividade': '5.00', |
|||
'descricao': 'Venda de servico' |
|||
} |
|||
] |
|||
nfse = { |
|||
'cpf_cnpj': '12345678901234', |
|||
'data_inicio': '2016-08-29', |
|||
'data_fim': '2016-08-29', |
|||
'lista_rps': rps, |
|||
'ambiente': 'homologacao', |
|||
} |
|||
return nfse |
|||
|
|||
def test_envio_nfse_lote(self): |
|||
pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'r').read() |
|||
pfx = Certificado(pfx_source, '123456') |
|||
nfse = self._get_nfse() |
|||
|
|||
retorno = envio_lote_rps(pfx, nfse=nfse, ambiente='homologacao') |
|||
|
|||
self.assertEqual(retorno['object'].Cabecalho.Sucesso, True) |
|||
self.assertEqual( |
|||
retorno['object'].ChaveNFeRPS.ChaveNFe.NumeroNFe, 446) |
|||
self.assertEqual( |
|||
retorno['object'].ChaveNFeRPS.ChaveRPS.NumeroRPS, 6) |
|||
|
|||
def _get_cancelamento(self): |
|||
return { |
|||
'cnpj_remetente': '123', |
|||
'assinatura': 'assinatura', |
|||
'numero_nfse': '456', |
|||
'inscricao_municipal': '654', |
|||
'codigo_verificacao': '789', |
|||
'ambiente': 'homologacao', |
|||
} |
|||
|
|||
def test_cancelamento_nfse_ok(self): |
|||
pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'r').read() |
|||
pfx = Certificado(pfx_source, '123456') |
|||
cancelamento = self._get_cancelamento() |
|||
|
|||
path = os.path.join(os.path.dirname(__file__), 'XMLs') |
|||
xml_return = open(os.path.join( |
|||
path, 'paulistana_canc_ok.xml'), 'r').read() |
|||
|
|||
with mock.patch('pytrustnfe.nfse.betha.get_authenticated_client') as client: |
|||
retorno = mock.MagicMock() |
|||
client.return_value = retorno |
|||
retorno.service.CancelarNfse.return_value = xml_return |
|||
|
|||
retorno = cancelar_nfse(pfx, cancelamento=cancelamento, |
|||
ambiente='homologacao') |
|||
|
|||
self.assertEqual(retorno['received_xml'], xml_return) |
|||
self.assertEqual(retorno['object'].Cabecalho.Sucesso, True) |
|||
|
|||
def test_cancelamento_nfse_com_erro(self): |
|||
pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'r').read() |
|||
pfx = Certificado(pfx_source, '123456') |
|||
cancelamento = self._get_cancelamento() |
|||
|
|||
path = os.path.join(os.path.dirname(__file__), 'XMLs') |
|||
xml_return = open(os.path.join( |
|||
path, 'paulistana_canc_errado.xml'), 'r').read() |
|||
|
|||
with mock.patch('pytrustnfe.nfse.betha.get_authenticated_client') as client: |
|||
retorno = mock.MagicMock() |
|||
client.return_value = retorno |
|||
retorno.service.CancelarNfse.return_value = xml_return |
|||
|
|||
retorno = cancelar_nfse(pfx, cancelamento=cancelamento, |
|||
ambiente='homologacao') |
|||
|
|||
self.assertEqual(retorno['received_xml'], xml_return) |
|||
self.assertEqual(retorno['object'].Cabecalho.Sucesso, False) |
|||
self.assertEqual( |
|||
retorno['object'].Erro.ChaveNFe.NumeroNFe, 446) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue