diff --git a/pytrustnfe/nfe/danfe.py b/pytrustnfe/nfe/danfe.py index 5b578bc..63decf9 100644 --- a/pytrustnfe/nfe/danfe.py +++ b/pytrustnfe/nfe/danfe.py @@ -323,7 +323,7 @@ class danfe(object): P = Paragraph(tagtext(oNode=elem_emit, cTag='xNome'), styleN) w, h = P.wrap(55 * mm, 40 * mm) P.drawOn(self.canvas, (self.nLeft + 30) * mm, - (self.height - self.nlin - ((5*h + 12)/12)) * mm) + (self.height - self.nlin - ((4.3*h + 12)/12)) * mm) if self.logo: img = get_image(self.logo, width=2 * cm) @@ -347,7 +347,7 @@ class danfe(object): P = Paragraph(cEnd, styleN) w, h = P.wrap(55 * mm, 30 * mm) P.drawOn(self.canvas, (self.nLeft + 30) * mm, - (self.height - self.nlin - 31) * mm) + (self.height - self.nlin - 33) * mm) # Homologação if tagtext(oNode=elem_ide, cTag='tpAmb') == '2': diff --git a/pytrustnfe/nfse/mga/__init__.py b/pytrustnfe/nfse/mga/__init__.py index a3d207f..ee0cbbc 100644 --- a/pytrustnfe/nfse/mga/__init__.py +++ b/pytrustnfe/nfse/mga/__init__.py @@ -2,7 +2,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import os -from lxml import etree from requests import Session from zeep import Client from zeep.transports import Transport @@ -19,27 +18,22 @@ def _render(certificado, method, **kwargs): reference = '' if method == 'GerarNfse': reference = 'rps:%s' % kwargs['rps']['numero'] - ref_lote = 'lote%s' % kwargs['rps']['numero_lote'] 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) - xml_send = signer.assina_xml(etree.fromstring(xml_send), ref_lote) return xml_send.encode('utf-8') def _send(certificado, method, **kwargs): base_url = '' if kwargs['ambiente'] == 'producao': - base_url = 'https://isse.maringa.gov.br/ws/?wsdl' + base_url = 'https://isse.maringa.pr.gov.br/ws/?wsdl' else: - base_url = 'https://isseteste.maringa.gov.br/ws/?wsdl' + base_url = 'https://isseteste.maringa.pr.gov.br/ws/?wsdl' xml_send = kwargs["xml"].decode('utf-8') - xml_cabecalho = '\ - \ - 1.00' cert, key = extract_cert_and_key_from_pfx( certificado.pfx, certificado.password) @@ -51,8 +45,7 @@ def _send(certificado, method, **kwargs): transport = Transport(session=session) client = Client(base_url, transport=transport) - - response = client.service[method](xml_cabecalho, xml_send) + response = client.service[method](xml_send) response, obj = sanitize_response(response.encode('utf-8')) return { diff --git a/pytrustnfe/nfse/mga/assinatura.py b/pytrustnfe/nfse/mga/assinatura.py index 1831379..3b302fe 100644 --- a/pytrustnfe/nfse/mga/assinatura.py +++ b/pytrustnfe/nfse/mga/assinatura.py @@ -22,23 +22,24 @@ class Assinatura(object): element.text = None signer = XMLSigner( - method=signxml.methods.enveloped, signature_algorithm="rsa-sha1", - digest_algorithm='sha1', - c14n_algorithm='http://www.w3.org/TR/2001/REC-xml-c14n-20010315') + method=signxml.methods.enveloped, signature_algorithm=u"rsa-sha1", + digest_algorithm=u'sha1', + c14n_algorithm=u'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') ns = {} ns[None] = signer.namespaces['ds'] signer.namespaces = ns + element_to_be_signed = xml_element.getchildren()[0].getchildren()[0] - ref_uri = ('#%s' % reference) if reference else None signed_root = signer.sign( - xml_element, key=key.encode(), cert=cert.encode(), - reference_uri=ref_uri) + element_to_be_signed, key=key.encode(), cert=cert.encode()) if reference: element_signed = signed_root.find(".//*[@Id='%s']" % reference) - signature = signed_root.find(".//*[@URI='#%s']" % reference).getparent().getparent() + + signature = signed_root.find( + ".//{http://www.w3.org/2000/09/xmldsig#}Signature") if element_signed is not None and signature is not None: - parent = element_signed.getparent() + parent = xml_element.getchildren()[0] parent.append(signature) - return etree.tostring(signed_root, encoding=str) + return etree.tostring(xml_element, encoding=str) diff --git a/pytrustnfe/nfse/mga/templates/CancelarNfse.xml b/pytrustnfe/nfse/mga/templates/CancelarNfse.xml index 137897e..6c95398 100644 --- a/pytrustnfe/nfse/mga/templates/CancelarNfse.xml +++ b/pytrustnfe/nfse/mga/templates/CancelarNfse.xml @@ -1,9 +1,11 @@ - + {{ cancelamento.numero_nfse }} - {{ cancelamento.cnpj_prestador }} + + {{ cancelamento.cnpj_prestador }} + {{ cancelamento.inscricao_municipal }} {{ cancelamento.cidade }} diff --git a/pytrustnfe/nfse/mga/templates/GerarNfse.xml b/pytrustnfe/nfse/mga/templates/GerarNfse.xml index 6b35d4d..ae702fd 100644 --- a/pytrustnfe/nfse/mga/templates/GerarNfse.xml +++ b/pytrustnfe/nfse/mga/templates/GerarNfse.xml @@ -1,11 +1,3 @@ - - {{ rps.numero_lote }} - {{ rps.prestador.cnpj }} - {{ rps.prestador.inscricao_municipal }} - 1 - - {% include 'Rps.xml' %} - - + {% include 'Rps.xml' %} diff --git a/pytrustnfe/nfse/mga/templates/Rps.xml b/pytrustnfe/nfse/mga/templates/Rps.xml index 0dfd0cf..489db01 100644 --- a/pytrustnfe/nfse/mga/templates/Rps.xml +++ b/pytrustnfe/nfse/mga/templates/Rps.xml @@ -1,21 +1,15 @@ - - - {{ rps.numero }} - {{ rps.serie }} - {{ rps.tipo_rps }} - - {{ rps.data_emissao }} - {{ rps.natureza_operacao }} - {{ rps.regime_tributacao }} - {{ rps.optante_simples }} - {{ rps.incentivador_cultural }} - {{ rps.status }} - - {{ rps.numero_substituido }} - {{ rps.serie_substituido }} - {{ rps.tipo_substituido }} - + + + + {{ rps.numero }} + {{ rps.serie }} + {{ rps.tipo_rps }} + + {{ rps.data_emissao }} + {{ rps.status }} + + {{ rps.data_emissao }} {{ rps.valor_servico }} @@ -25,24 +19,25 @@ {{ 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.valor_iss }} {{ rps.aliquota_issqn }} - {{ rps.valor_liquido_nfse }} {{ rps.desconto_incondicionado }} {{ rps.desconto_condicionado }} + {{ rps.iss_retido }} {{ rps.codigo_servico }} {{ rps.cnae_servico }} {{ rps.codigo_tributacao_municipio }} {{ rps.descricao }} {{ rps.codigo_municipio }} + {{ rps.codigo_pais }} + {{ rps.exigibilidade_iss}} - {{ rps.prestador.cnpj }} + + {{ rps.prestador.cnpj }} + {{ rps.prestador.inscricao_municipal }} @@ -65,6 +60,7 @@ {{ rps.tomador.bairro }} {{ rps.tomador.cidade }} {{ rps.tomador.uf }} + {{ rps.tomador.codigo_pais }} {{ rps.tomador.cep }} @@ -72,20 +68,14 @@ {{ rps.tomador.email }} - {% if rps.intermediario is defined -%} - - {{ rps.intermediario.razao_social }} - - {{ rps.intermediario.cnpj }} - - {{ rps.intermediario.inscricao_municipal }} - - {% endif %} {% if rps.construcao_civil is defined -%} {{ rps.construcao_civil.codigo_obra }} {{ rps.construcao_civil.art }} {% endif %} - + {{ rps.regime_tributacao }} + {{ rps.optante_simples }} + {{ rps.incentivador_cultural }} + diff --git a/setup.py b/setup.py index 9337653..f548242 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages -VERSION = "0.9.24" +VERSION = "0.9.26" setup(