Skip to content

Commit d6366e5

Browse files
NFSe Betha: Correção de erros de comunicação com homologação (#411)
* Correção de erro de namespace * CNPJ válido para testes * Atualização de testes
1 parent e9e287e commit d6366e5

File tree

5 files changed

+64
-55
lines changed

5 files changed

+64
-55
lines changed

pynfe/processamento/autorizador_nfse.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ def gerar(self, nfse):
8484
gnfse = nfse_schema.GerarNfseEnvio()
8585
gnfse.Rps = declaracao_servico
8686

87-
return gnfse.toxml(element_name="GerarNfseEnvio")
87+
gnfse = (
88+
gnfse.toxml(element_name="GerarNfseEnvio")
89+
.replace("ns1:", "")
90+
.replace(":ns1", "")
91+
.replace('<?xml version="1.0" ?>', "")
92+
)
93+
94+
return gnfse
8895

8996
def consultar_rps(self, nfse):
9097
"""Retorna string de um XML gerado a partir do

pynfe/processamento/comunicacao.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ def _cabecalho(self, retorna_string=True):
752752
nsmap={"ns2": self._namespace, "xsi": NAMESPACE_XSI},
753753
versao=self._versao,
754754
)
755-
etree.SubElement(raiz, "versaoDados").text = self._versao
755+
etree.SubElement(
756+
raiz, "{%s}versaoDados" % self._namespace).text = self._versao
756757

757758
if retorna_string:
758759
cabecalho = etree.tostring(

tests/test_nfse_serializacao.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def get_notafiscal_servico() -> NotaFiscalServico:
3131
servico = Servico(
3232
valor_servico=Decimal('100.00'),
3333
iss_retido=1, # 1 - Sim; 2 - Não
34+
exigibilidade=1,
3435
item_lista='0101',
3536
discriminacao='Mensalidade',
3637
codigo_municipio=obter_codigo_por_municipio(
@@ -124,7 +125,7 @@ def _get_config() -> SerializacaoNFSeConfigTest:
124125
@staticmethod
125126
def _get_emitente() -> Emitente:
126127
return Emitente(
127-
cnpj='99999999999999',
128+
cnpj='45111111111100',
128129
inscricao_municipal='000000'
129130
)
130131

tests/test_nfse_serializacao_betha.py

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,52 +34,52 @@ def _get_notafiscal_servico(self) -> NotaFiscalServico:
3434

3535
def _get_nfse_esperada(self) -> str:
3636
return SerializacaoNFSeTest.strip_xml(f"""
37-
<GerarNfseEnvio xmlns:ns1="http://www.betha.com.br/e-nota-contribuinte-ws">
38-
<ns1:Rps>
39-
<ns1:InfDeclaracaoPrestacaoServico Id="50">
40-
<ns1:Rps>
41-
<ns1:IdentificacaoRps>
42-
<ns1:Numero>50</ns1:Numero>
43-
<ns1:Serie>A1</ns1:Serie>
44-
<ns1:Tipo>1</ns1:Tipo>
45-
</ns1:IdentificacaoRps>
46-
<ns1:DataEmissao>{SerializacaoNFSeTest.data_hora[:10]}</ns1:DataEmissao>
47-
<ns1:Status>1</ns1:Status>
48-
</ns1:Rps>
49-
<ns1:Competencia>{SerializacaoNFSeTest.data_hora[:10]}</ns1:Competencia>
50-
<ns1:Servico>
51-
<ns1:Valores>
52-
<ns1:ValorServicos>100.0</ns1:ValorServicos>
53-
</ns1:Valores>
54-
<ns1:IssRetido>1</ns1:IssRetido>
55-
<ns1:ItemListaServico>0101</ns1:ItemListaServico>
56-
<ns1:Discriminacao>Mensalidade</ns1:Discriminacao>
57-
<ns1:CodigoMunicipio>3149309</ns1:CodigoMunicipio>
58-
<ns1:ExigibilidadeISS>0</ns1:ExigibilidadeISS>
59-
<ns1:MunicipioIncidencia>3149309</ns1:MunicipioIncidencia>
60-
</ns1:Servico>
61-
<ns1:Prestador>
62-
<ns1:CpfCnpj>
63-
<ns1:Cnpj>99999999999999</ns1:Cnpj>
64-
</ns1:CpfCnpj>
65-
<ns1:InscricaoMunicipal>000000</ns1:InscricaoMunicipal>
66-
</ns1:Prestador>
67-
<ns1:Tomador>
68-
<ns1:RazaoSocial>NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</ns1:RazaoSocial>
69-
<ns1:Endereco>
70-
<ns1:Endereco>Rua tal</ns1:Endereco>
71-
<ns1:Numero>0</ns1:Numero>
72-
<ns1:Bairro>Centro</ns1:Bairro>
73-
<ns1:CodigoMunicipio>123</ns1:CodigoMunicipio>
74-
<ns1:Uf>MG</ns1:Uf>
75-
<ns1:CodigoPais>1058</ns1:CodigoPais>
76-
<ns1:Cep>33257010</ns1:Cep>
77-
</ns1:Endereco>
78-
</ns1:Tomador>
79-
<ns1:OptanteSimplesNacional>1</ns1:OptanteSimplesNacional>
80-
<ns1:IncentivoFiscal>2</ns1:IncentivoFiscal>
81-
</ns1:InfDeclaracaoPrestacaoServico>
82-
</ns1:Rps>
37+
<GerarNfseEnvio xmlns="http://www.betha.com.br/e-nota-contribuinte-ws">
38+
<Rps>
39+
<InfDeclaracaoPrestacaoServico Id="50">
40+
<Rps>
41+
<IdentificacaoRps>
42+
<Numero>50</Numero>
43+
<Serie>A1</Serie>
44+
<Tipo>1</Tipo>
45+
</IdentificacaoRps>
46+
<DataEmissao>{SerializacaoNFSeTest.data_hora[:10]}</DataEmissao>
47+
<Status>1</Status>
48+
</Rps>
49+
<Competencia>{SerializacaoNFSeTest.data_hora[:10]}</Competencia>
50+
<Servico>
51+
<Valores>
52+
<ValorServicos>100.0</ValorServicos>
53+
</Valores>
54+
<IssRetido>1</IssRetido>
55+
<ItemListaServico>0101</ItemListaServico>
56+
<Discriminacao>Mensalidade</Discriminacao>
57+
<CodigoMunicipio>3149309</CodigoMunicipio>
58+
<ExigibilidadeISS>1</ExigibilidadeISS>
59+
<MunicipioIncidencia>3149309</MunicipioIncidencia>
60+
</Servico>
61+
<Prestador>
62+
<CpfCnpj>
63+
<Cnpj>45111111111100</Cnpj>
64+
</CpfCnpj>
65+
<InscricaoMunicipal>000000</InscricaoMunicipal>
66+
</Prestador>
67+
<Tomador>
68+
<RazaoSocial>NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</RazaoSocial>
69+
<Endereco>
70+
<Endereco>Rua tal</Endereco>
71+
<Numero>0</Numero>
72+
<Bairro>Centro</Bairro>
73+
<CodigoMunicipio>123</CodigoMunicipio>
74+
<Uf>MG</Uf>
75+
<CodigoPais>1058</CodigoPais>
76+
<Cep>33257010</Cep>
77+
</Endereco>
78+
</Tomador>
79+
<OptanteSimplesNacional>1</OptanteSimplesNacional>
80+
<IncentivoFiscal>2</IncentivoFiscal>
81+
</InfDeclaracaoPrestacaoServico>
82+
</Rps>
8383
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
8484
<SignedInfo>
8585
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
@@ -90,10 +90,10 @@ def _get_nfse_esperada(self) -> str:
9090
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
9191
</Transforms>
9292
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
93-
<DigestValue>xzbAflAhVih7JNxmSa2ZJ1rMpzw=</DigestValue>
93+
<DigestValue>zKwAgg0wya+wUPDgBq7Uvtv4Q+k=</DigestValue>
9494
</Reference>
9595
</SignedInfo>
96-
<SignatureValue>W6Ys1KHIbz9BDtG+ej++ROAkqZTtSgYH2cplorcxxOZ2VJG3KKWnasyLghEIJfcXtss4kjblgdGOf3IJVgaDuub4GyYPkEzCxnGEr1nQXw74rDmGLwZg1vPBUdHsIbcw8wvAoUOW6zfMI5ljr61Rz5CCytBu4IqpUFCQzWguiG8=</SignatureValue>
96+
<SignatureValue>ak3Ze/cqE4FXmXt0BrUOz7FWOBDH6i2V6ADeF9p8qTBdYCZa5hKFJoQkYpmd8T4lgtn6W4SDDsh0aXvhPn4UXGt5qOulfzBWrlU5+ohldDo60SBZ4gP2DVVtjmGqP0GtdBGp2U+1y75+8brJIUzgGQQxw9fArdlPyB6D6x/GEYo=</SignatureValue>
9797
<KeyInfo>
9898
<X509Data>
9999
<X509Certificate>MIICMTCCAZqgAwIBAgIQfYOsIEVuAJ1FwwcTrY0t1DANBgkqhkiG9w0BAQUFADBX\nMVUwUwYDVQQDHkwAewA1ADkARgAxAEUANAA2ADEALQBEAEQARQA1AC0ANABEADIA\nRgAtAEEAMAAxAEEALQA4ADMAMwAyADIAQQA5AEUAQgA4ADMAOAB9MB4XDTE1MDYx\nNTA1NDc1N1oXDTE2MDYxNDExNDc1N1owVzFVMFMGA1UEAx5MAHsANQA5AEYAMQBF\nADQANgAxAC0ARABEAEUANQAtADQARAAyAEYALQBBADAAMQBBAC0AOAAzADMAMgAy\nAEEAOQBFAEIAOAAzADgAfTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAk41G\nnqXXLaiOC/y0/cA4tbS+NZCqI+x4EsztgDFvPPlHstiVYcLRkni4i93gK9zoC6g0\nmh66HMVzAfE8vRNwW5b7m6nWS1SiHBon7/Mqsw4MIq3SC+J/fTbKpqwyfAuH2YZl\nAiQuQc85fyllAMLh2WrA7JgOLR/5tF3kLtpbHdECAwEAATANBgkqhkiG9w0BAQUF\nAAOBgQArdh+RyT6VxKGsXk1zhHsgwXfToe6GpTF4W8PHI1+T0WIsNForDhvst6nm\nQtgAhuZM9rxpOJuNKc+pM29EixpAiZZiRMCSWEItNyEVdUIi+YnKBcAHd88TwO86\nd126MWQ2O8cu5W1VoDp7hYBYKOnLbYi11/StO+0rzK+oPYAvIw==\n</X509Certificate>

tests/test_nfse_serializacao_ginfes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _get_nfse_esperada(self) -> str:
4848
xmlns:ns2="http://www.ginfes.com.br/tipos_v03.xsd">
4949
<ns1:LoteRps Id="1">
5050
<ns2:NumeroLote>1</ns2:NumeroLote>
51-
<ns2:Cnpj>99999999999999</ns2:Cnpj>
51+
<ns2:Cnpj>45111111111100</ns2:Cnpj>
5252
<ns2:InscricaoMunicipal>000000</ns2:InscricaoMunicipal>
5353
<ns2:QuantidadeRps>1</ns2:QuantidadeRps>
5454
<ns2:ListaRps>
@@ -90,7 +90,7 @@ def _get_nfse_esperada(self) -> str:
9090
<ns2:CodigoMunicipio>3149309</ns2:CodigoMunicipio>
9191
</ns2:Servico>
9292
<ns2:Prestador>
93-
<ns2:Cnpj>99999999999999</ns2:Cnpj>
93+
<ns2:Cnpj>45111111111100</ns2:Cnpj>
9494
<ns2:InscricaoMunicipal>000000</ns2:InscricaoMunicipal>
9595
</ns2:Prestador>
9696
<ns2:Tomador>
@@ -129,10 +129,10 @@ def _get_nfse_esperada(self) -> str:
129129
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
130130
</Transforms>
131131
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
132-
<DigestValue>qFoEQUv7n6YrTR3yg3zBBtTR/VU=</DigestValue>
132+
<DigestValue>1KzhiSjBh9Ka3slT/bpIlKyPEcI=</DigestValue>
133133
</Reference>
134134
</SignedInfo>
135-
<SignatureValue>fM8cbCN5s31qeu2Oy89keXXh01l9x8gHpQYXrdjz6jtt0CDZ3fBMb7PwDZjUFVKM5U33IeBX8m0RRKJXZuQWWFCI1vux+uoVG7JWhYXfPysjGUNz7LNfr5FkjVWWobI5YzZitY15aDkzwYyeGt/h22dDZim5CooEs4AUI63fwKM=</SignatureValue>
135+
<SignatureValue>ZwLBWwIgp1UmNnNi1M1Eqeym1L3hc6Y4iaQlQE8qQnF+l5y0V0l78cbqnqnhhJ4Aus/g89UajSr/6pAKHJf242nWBjD7A4KYH9bbSkAh12W4n1wf5gpUrMPyQUlDhgCLOfCpOyzWnhofy+f7Tm1/Qws82JFUWs1jyJ9A5UyTbrU=</SignatureValue>
136136
<KeyInfo>
137137
<X509Data>
138138
<X509Certificate>MIICMTCCAZqgAwIBAgIQfYOsIEVuAJ1FwwcTrY0t1DANBgkqhkiG9w0BAQUFADBX\nMVUwUwYDVQQDHkwAewA1ADkARgAxAEUANAA2ADEALQBEAEQARQA1AC0ANABEADIA\nRgAtAEEAMAAxAEEALQA4ADMAMwAyADIAQQA5AEUAQgA4ADMAOAB9MB4XDTE1MDYx\nNTA1NDc1N1oXDTE2MDYxNDExNDc1N1owVzFVMFMGA1UEAx5MAHsANQA5AEYAMQBF\nADQANgAxAC0ARABEAEUANQAtADQARAAyAEYALQBBADAAMQBBAC0AOAAzADMAMgAy\nAEEAOQBFAEIAOAAzADgAfTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAk41G\nnqXXLaiOC/y0/cA4tbS+NZCqI+x4EsztgDFvPPlHstiVYcLRkni4i93gK9zoC6g0\nmh66HMVzAfE8vRNwW5b7m6nWS1SiHBon7/Mqsw4MIq3SC+J/fTbKpqwyfAuH2YZl\nAiQuQc85fyllAMLh2WrA7JgOLR/5tF3kLtpbHdECAwEAATANBgkqhkiG9w0BAQUF\nAAOBgQArdh+RyT6VxKGsXk1zhHsgwXfToe6GpTF4W8PHI1+T0WIsNForDhvst6nm\nQtgAhuZM9rxpOJuNKc+pM29EixpAiZZiRMCSWEItNyEVdUIi+YnKBcAHd88TwO86\nd126MWQ2O8cu5W1VoDp7hYBYKOnLbYi11/StO+0rzK+oPYAvIw==\n</X509Certificate>

0 commit comments

Comments
 (0)