Skip to content

Commit

Permalink
[DONE] Finalização do layout Nota Carioca - Geração e Cancelamento
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Mar 28, 2018
1 parent 35f3f0c commit 3fc3d61
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
9 changes: 6 additions & 3 deletions pytrustnfe/nfse/carioca/__init__.py
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import os
import suds
from pytrustnfe.client import get_authenticated_client
from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key
from pytrustnfe.xml import render_xml, sanitize_response
Expand All @@ -15,6 +16,8 @@ def _render(certificado, method, **kwargs):
reference = ''
if method == 'GerarNfse':
reference = 'r%s' % kwargs['rps']['numero']
elif method == 'CancelarNfse':
reference = 'Cancelamento_NF%s' % kwargs['cancelamento']['numero_nfse']

signer = Assinatura(certificado.pfx, certificado.password)
xml_send = signer.assina_xml(xml_send, reference)
Expand All @@ -35,7 +38,7 @@ def _send(certificado, method, **kwargs):
client = get_authenticated_client(base_url, cert, key)

try:
response = client.service.GerarNfse(xml_send)
response = getattr(client.service, method)(xml_send)
except suds.WebFault as e:
return {
'sent_xml': str(xml_send),
Expand All @@ -62,10 +65,10 @@ def gerar_nfse(certificado, **kwargs):


def xml_cancelar_nfse(certificado, **kwargs):
return _render(certificado, 'CancelarNfseEnvio', **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, 'CancelarNfseEnvio', **kwargs)
return _send(certificado, 'CancelarNfse', **kwargs)
13 changes: 13 additions & 0 deletions pytrustnfe/nfse/carioca/templates/CancelarNfse.xml
@@ -0,0 +1,13 @@
<CancelarNfseEnvio xmlns="http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd">
<Pedido>
<InfPedidoCancelamento Id="Cancelamento_NF{{ cancelamento.numero_nfse }}">
<IdentificacaoNfse>
<Numero>{{ cancelamento.numero_nfse }}</Numero>
<Cnpj>{{ cancelamento.cnpj_prestador }}</Cnpj>
<InscricaoMunicipal>{{ cancelamento.inscricao_municipal }}</InscricaoMunicipal>
<CodigoMunicipio>{{ cancelamento.cidade }}</CodigoMunicipio>
</IdentificacaoNfse>
<CodigoCancelamento>1</CodigoCancelamento>
</InfPedidoCancelamento>
</Pedido>
</CancelarNfseEnvio>
13 changes: 0 additions & 13 deletions pytrustnfe/nfse/carioca/templates/CancelarNfseEnvio.xml

This file was deleted.

8 changes: 0 additions & 8 deletions pytrustnfe/nfse/carioca/templates/ConsultarNfseEnvio.xml

This file was deleted.

2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages


VERSION = "0.9.11"
VERSION = "0.9.12"


setup(
Expand Down

0 comments on commit 3fc3d61

Please sign in to comment.