From a1d559c6508f4019e0c9f51173eee903b60b90e5 Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Thu, 14 Sep 2017 18:00:35 -0300 Subject: [PATCH 01/13] =?UTF-8?q?WIP=20-=20Implementa=C3=A7=C3=A3o=20nota?= =?UTF-8?q?=20imperial=20-=20Petropolis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pytrustnfe/nfse/imperial/__init__.py | 75 +++++++++++++++++++++ .../imperial/templates/CANCELANOTAELETRONICA.xml | 17 +++++ .../imperial/templates/CONSULTANOTASPROTOCOLO.xml | 9 +++ .../nfse/imperial/templates/CONSULTAPROTOCOLO.xml | 9 +++ pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml | 78 ++++++++++++++++++++++ pytrustnfe/nfse/imperial/templates/SoapRequest.xml | 5 ++ 6 files changed, 193 insertions(+) create mode 100644 pytrustnfe/nfse/imperial/__init__.py create mode 100644 pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml create mode 100644 pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml create mode 100644 pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml create mode 100644 pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml create mode 100644 pytrustnfe/nfse/imperial/templates/SoapRequest.xml diff --git a/pytrustnfe/nfse/imperial/__init__.py b/pytrustnfe/nfse/imperial/__init__.py new file mode 100644 index 0000000..1393758 --- /dev/null +++ b/pytrustnfe/nfse/imperial/__init__.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +# © 2016 Danimar Ribeiro, Trustcode +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import os +from pytrustnfe import HttpClient +from pytrustnfe.xml import render_xml, sanitize_response + + +def _render(certificado, method, **kwargs): + path = os.path.join(os.path.dirname(__file__), 'templates') + xml_send = render_xml(path, '%s.xml' % method, True, **kwargs) + return xml_send + + +def _send(certificado, method, **kwargs): + base_url = '' + if kwargs['ambiente'] == 'producao': + base_url = 'https://producao.ginfes.com.br/ServiceGinfesImpl?wsdl' + else: + base_url = 'https://nfehomologacao.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa + + xml_send = kwargs["xml"] + path = os.path.join(os.path.dirname(__file__), 'templates') + soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send) + + client = HttpClient(base_url) + response = client.post_soap(soap, 'NFeaction/AWS_NFE.%s' % method) + + response, obj = sanitize_response(response) + return { + 'sent_xml': xml_send, + 'received_xml': response, + 'object': obj + } + + +def xml_processa_rps(certificado, **kwargs): + return _render(certificado, 'PROCESSARPS', **kwargs) + + +def processa_rps(certificado, **kwargs): + if "xml" not in kwargs: + kwargs['xml'] = xml_processa_rps(certificado, **kwargs) + return _send(certificado, 'PROCESSARPS', **kwargs) + + +def xml_consulta_protocolo(certificado, **kwargs): + return _render(certificado, 'CONSULTAPROTOCOLO', **kwargs) + + +def consulta_protocolo(certificado, **kwargs): + if "xml" not in kwargs: + kwargs['xml'] = xml_consulta_protocolo(certificado, **kwargs) + return _send(certificado, 'CONSULTAPROTOCOLO', **kwargs) + + +def xml_consulta_notas_protocolo(certificado, **kwargs): + return _render(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs) + + +def consulta_notas_protocolo(certificado, **kwargs): + if "xml" not in kwargs: + kwargs['xml'] = xml_consulta_notas_protocolo(certificado, **kwargs) + return _send(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs) + + +def xml_cancelar_nfse(certificado, **kwargs): + return _render(certificado, 'CANCELANOTAELETRONICA', **kwargs) + + +def cancelar_nfse(certificado, **kwargs): + if "xml" not in kwargs: + kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs) + return _send(certificado, 'CANCELANOTAELETRONICA', **kwargs) diff --git a/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml b/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml new file mode 100644 index 0000000..7a383a3 --- /dev/null +++ b/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml @@ -0,0 +1,17 @@ + + + + [string] + [string] + + + [string] + [int] + [string] + [int] + [double] + [string] + [string] + + + diff --git a/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml b/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml new file mode 100644 index 0000000..5c0f433 --- /dev/null +++ b/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml @@ -0,0 +1,9 @@ + + + [string] + + [string] + [string] + + + diff --git a/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml b/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml new file mode 100644 index 0000000..d321c21 --- /dev/null +++ b/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml @@ -0,0 +1,9 @@ + + + [string] + + [string] + [string] + + + diff --git a/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml new file mode 100644 index 0000000..4d65450 --- /dev/null +++ b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml @@ -0,0 +1,78 @@ + + + + [string] + [string] + + + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + + + + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + [string] + + + + [string] + [string] + [string] + + + + + + [string] + [string] + [string] + [string] + [string] + [string] + [string] + + + + diff --git a/pytrustnfe/nfse/imperial/templates/SoapRequest.xml b/pytrustnfe/nfse/imperial/templates/SoapRequest.xml new file mode 100644 index 0000000..e8b56b4 --- /dev/null +++ b/pytrustnfe/nfse/imperial/templates/SoapRequest.xml @@ -0,0 +1,5 @@ + + + {{ soap_body }} + + From 97f2ada8abc5056f9bbfd07d7e3c8f41074eaa1a Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Thu, 14 Sep 2017 19:11:30 -0300 Subject: [PATCH 02/13] WIP - Ajustando templates da nota imperial --- pytrustnfe/nfse/imperial/__init__.py | 5 +++-- .../nfse/imperial/templates/CANCELANOTAELETRONICA.xml | 18 +++++++++--------- .../nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml | 6 +++--- .../nfse/imperial/templates/CONSULTAPROTOCOLO.xml | 6 +++--- pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml | 10 +++++----- setup.py | 3 ++- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/pytrustnfe/nfse/imperial/__init__.py b/pytrustnfe/nfse/imperial/__init__.py index 1393758..303b619 100644 --- a/pytrustnfe/nfse/imperial/__init__.py +++ b/pytrustnfe/nfse/imperial/__init__.py @@ -3,6 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import os +from lxml import etree from pytrustnfe import HttpClient from pytrustnfe.xml import render_xml, sanitize_response @@ -10,13 +11,13 @@ from pytrustnfe.xml import render_xml, sanitize_response def _render(certificado, method, **kwargs): path = os.path.join(os.path.dirname(__file__), 'templates') xml_send = render_xml(path, '%s.xml' % method, True, **kwargs) - return xml_send + return etree.tostring(xml_send) def _send(certificado, method, **kwargs): base_url = '' if kwargs['ambiente'] == 'producao': - base_url = 'https://producao.ginfes.com.br/ServiceGinfesImpl?wsdl' + base_url = 'https://nfe.etransparencia.com.br/rj.petropolis/nfe/principal.aspx' # noqa else: base_url = 'https://nfehomologacao.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa diff --git a/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml b/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml index 7a383a3..3afb262 100644 --- a/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml +++ b/pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml @@ -1,17 +1,17 @@ - [string] - [string] + {{ cancelamento.codigo_usuario }} + {{ cancelamento.codigo_contribuinte }} - [string] - [int] - [string] - [int] - [double] - [string] - [string] + {{ cancelamento.serie_nota }} + {{ cancelamento.numero_nota }} + {{ cancelamento.serie_rps }} + {{ cancelamento.numero_rps }} + {{ cancelamento.valor }} + {{ cancelamento.motivo }} + {{ cancelamento.cancelar_guia }} diff --git a/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml b/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml index 5c0f433..30ea3d6 100644 --- a/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml +++ b/pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml @@ -1,9 +1,9 @@ - [string] + {{ consulta.protocolo }} - [string] - [string] + {{ consulta.codigo_usuario }} + {{ consulta.codigo_contribuinte }} diff --git a/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml b/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml index d321c21..09765e5 100644 --- a/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml +++ b/pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml @@ -1,9 +1,9 @@ - [string] + {{ consulta.protocolo }} - [string] - [string] + {{ consulta.codigo_usuario }} + {{ consulta.codigo_contribuinte }} diff --git a/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml index 4d65450..20f3fce 100644 --- a/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml +++ b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml @@ -1,13 +1,13 @@ - [string] - [string] + {{ nfse.codigo_usuario }} + {{ nfse.codigo_contribuinte }} - [string] - [string] - [string] + {{ nfse.ano }} + {{ nfse.mes }} + {{ nfse.cnpj_prestador }} [string] [string] [string] diff --git a/setup.py b/setup.py index f74be77..312e883 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # coding=utf-8 from setuptools import setup, find_packages -VERSION = "0.1.39" +VERSION = "0.1.40" setup( name="PyTrustNFe", @@ -27,6 +27,7 @@ later (LGPLv2+)', 'nfse/simpliss/templates/*xml', 'nfse/betha/templates/*xml', 'nfse/susesu/templates/*xml', + 'nfse/imperial/templates/*xml', 'xml/schemas/*xsd', ]}, url='https://github.com/danimaribeiro/PyTrustNFe', From 5868c96fa4f5606ee21e3b13791ea567aefe82bb Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Tue, 19 Sep 2017 22:16:31 -0300 Subject: [PATCH 03/13] =?UTF-8?q?DONE=20-=20Finalizado=20implementa=C3=A7?= =?UTF-8?q?=C3=A3o=20da=20Nota=20Imperial=20-=20Petropolis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pytrustnfe/nfse/ginfes/__init__.py | 1 - pytrustnfe/nfse/ginfes/templates/Rps.xml | 2 +- pytrustnfe/nfse/imperial/__init__.py | 2 +- pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml | 111 +++++++++++---------- pytrustnfe/xml/__init__.py | 1 + pytrustnfe/xml/filters.py | 6 ++ setup.py | 2 +- 7 files changed, 67 insertions(+), 58 deletions(-) diff --git a/pytrustnfe/nfse/ginfes/__init__.py b/pytrustnfe/nfse/ginfes/__init__.py index f2655dc..f69ffe1 100644 --- a/pytrustnfe/nfse/ginfes/__init__.py +++ b/pytrustnfe/nfse/ginfes/__init__.py @@ -4,7 +4,6 @@ import os import suds -from lxml import etree from pytrustnfe.xml import render_xml, sanitize_response from pytrustnfe.client import get_authenticated_client from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key diff --git a/pytrustnfe/nfse/ginfes/templates/Rps.xml b/pytrustnfe/nfse/ginfes/templates/Rps.xml index b65ac46..d366389 100644 --- a/pytrustnfe/nfse/ginfes/templates/Rps.xml +++ b/pytrustnfe/nfse/ginfes/templates/Rps.xml @@ -27,11 +27,11 @@ {{ rps.valor_csll }} {{ rps.iss_retido }} {{ rps.valor_iss }} + {{ rps.valor_iss_retido }} {{ rps.outras_retencoes }} {{ rps.base_calculo }} {{ rps.aliquota_issqn }} {{ rps.valor_liquido_nfse }} - {{ rps.valor_iss_retido }} {{ rps.desconto_incondicionado }} {{ rps.desconto_condicionado }} diff --git a/pytrustnfe/nfse/imperial/__init__.py b/pytrustnfe/nfse/imperial/__init__.py index 303b619..64a8125 100644 --- a/pytrustnfe/nfse/imperial/__init__.py +++ b/pytrustnfe/nfse/imperial/__init__.py @@ -17,7 +17,7 @@ def _render(certificado, method, **kwargs): def _send(certificado, method, **kwargs): base_url = '' if kwargs['ambiente'] == 'producao': - base_url = 'https://nfe.etransparencia.com.br/rj.petropolis/nfe/principal.aspx' # noqa + base_url = 'https://nfe.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa else: base_url = 'https://nfehomologacao.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa diff --git a/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml index 20f3fce..3cfb27a 100644 --- a/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml +++ b/pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml @@ -8,70 +8,73 @@ {{ nfse.ano }} {{ nfse.mes }} {{ nfse.cnpj_prestador }} - [string] - [string] - [string] - [string] - [string] - [string] + {{ nfse.data_emissao }} + {{ nfse.data_emissao }} + {{ nfse.tipo_tributacao }} + {{ nfse.data_adesao_simples }} + {{ nfse.aliquota_simples_isencao|comma }} + 2.00 + {% for rps in nfse.lista_rps -%} - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] - [string] + {{ rps.tipo_nfse }} + {{ rps.numero }} + {{ rps.serie }} + {{ rps.data_emissao }} + {{ rps.iss_retido }} + {{ rps.codigo_servico }} + {{ rps.descricao}} + {{ rps.valor_liquido_nfse|comma }} + {{ rps.valor_deducao|comma }} + {{ rps.discriminacao_deducao }} + {{ rps.base_calculo|comma }} + {{ rps.aliquota_issqn|comma }} + {{ rps.valor_iss|comma }} + {{ rps.valor_iss_retido|comma }} + {{ rps.tomador.cnpj_cpf }} + {{ rps.tomador.razao_social }} + {{ rps.tomador.tipo_logradouro }} + {{ rps.tomador.logradouro }} + {{ rps.tomador.numero }} + {{ rps.tomador.complemento }} + {{ rps.tomador.bairro }} + {{ rps.tomador.municipio }} + {{ rps.tomador.uf }} + {{ rps.tomador.cep }} + {{ rps.tomador.telefone }} + {{ rps.tomador.inscricao_municipal }} + {% if rps.local_prestacao == 'prestador' %} + {{ rps.prestador.tipo_logradouro }} + {{ rps.prestador.logradouro }} + {{ rps.prestador.numero }} + {{ rps.prestador.complemento }} + {{ rps.prestador.bairro }} + {{ rps.prestador.municipio }} + {{ rps.prestador.uf }} + {{ rps.prestador.cep }} + {% endif %} + {{ rps.tomador.email }} + {% for imposto in rps.impostos -%} - - [string] - [string] - [string] + {{ imposto.sigla }} + {{ imposto.aliquota|comma }} + {{ imposto.valor|comma }} + {% endfor %} + {% endfor %} - [string] - [string] - [string] - [string] - [string] - [string] - [string] + {{ nfse.lista_rps|length }} + {{ nfse.lista_rps|sum(attribute='valor_liquido_nfse')|comma }} + {{ nfse.lista_rps|sum(attribute='valor_iss')|comma }} + {{ nfse.lista_rps|sum(attribute='valor_deducao')|comma }} + {{ nfse.lista_rps|sum(attribute='valor_iss_retido')|comma }} + {{ nfse.quantidade_impostos }} + {{ nfse.valor_tributos|comma }} diff --git a/pytrustnfe/xml/__init__.py b/pytrustnfe/xml/__init__.py index d3eeeea..360c919 100644 --- a/pytrustnfe/xml/__init__.py +++ b/pytrustnfe/xml/__init__.py @@ -25,6 +25,7 @@ def render_xml(path, template_name, remove_empty, **nfe): env.filters["format_percent"] = filters.format_percent env.filters["format_datetime"] = filters.format_datetime env.filters["format_date"] = filters.format_date + env.filters["comma"] = filters.format_with_comma template = env.get_template(template_name) diff --git a/pytrustnfe/xml/filters.py b/pytrustnfe/xml/filters.py index a9ed689..8a33af4 100644 --- a/pytrustnfe/xml/filters.py +++ b/pytrustnfe/xml/filters.py @@ -59,3 +59,9 @@ def format_date(value): if isinstance(value, date): return value.strftime(dt_format) return value + + +def format_with_comma(value): + if isinstance(value, float): + return ('%.2f' % value).replace('.', ',') + return value diff --git a/setup.py b/setup.py index 312e883..2a02d5c 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # coding=utf-8 from setuptools import setup, find_packages -VERSION = "0.1.40" +VERSION = "0.1.41" setup( name="PyTrustNFe", From ab4c243f52715d27770c2e21a007402a95921960 Mon Sep 17 00:00:00 2001 From: Yogesh Kushwaha Date: Wed, 20 Sep 2017 13:45:37 -0300 Subject: [PATCH 04/13] FIX new line in description --- pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml b/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml index 8e9f34d..2a53cdd 100644 --- a/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml +++ b/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml @@ -54,7 +54,7 @@ {{ rps.tomador.uf }} {{ rps.tomador.cep }} - {{ rps.descricao|normalize|escape }} + {{ rps.descricao }} {% endfor %} From 25dbb6e1a957ce13693a58bd7376581516e94b59 Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Wed, 20 Sep 2017 17:17:52 -0300 Subject: [PATCH 05/13] Revert "FIX new line in description" This reverts commit ab4c243f52715d27770c2e21a007402a95921960. --- pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml b/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml index 2a53cdd..8e9f34d 100644 --- a/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml +++ b/pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml @@ -54,7 +54,7 @@ {{ rps.tomador.uf }} {{ rps.tomador.cep }} - {{ rps.descricao }} + {{ rps.descricao|normalize|escape }} {% endfor %} From aa7128acd53198253a58866a5a9d6ffed955a34a Mon Sep 17 00:00:00 2001 From: Johny Chen Jy <31947361+carcaroff@users.noreply.github.com> Date: Mon, 18 Dec 2017 10:48:53 -0200 Subject: [PATCH 06/13] Update Servidores.py --- pytrustnfe/Servidores.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pytrustnfe/Servidores.py b/pytrustnfe/Servidores.py index e942df9..8ff98cd 100644 --- a/pytrustnfe/Servidores.py +++ b/pytrustnfe/Servidores.py @@ -332,8 +332,8 @@ UFBA = { WS_NFE_SITUACAO: 'webservices/NfeStatusServico/NfeStatusServico.asmx', WS_NFE_INUTILIZACAO: 'webservices/nfenw/nfeinutilizacao2.asmx', WS_NFE_CADASTRO: 'webservices/nfenw/CadConsultaCadastro2.asmx', - WS_NFE_RECEPCAO_EVENTO: 'webservices/sre/recepcaoevento', - WS_NFE_CANCELAMENTO: 'webservices/sre/recepcaoevento', + WS_NFE_RECEPCAO_EVENTO: 'webservices/sre/recepcaoevento.asmx', + WS_NFE_CANCELAMENTO: 'webservices/sre/recepcaoevento.asmx', }, NFE_AMBIENTE_HOMOLOGACAO: { 'servidor': 'hnfe.sefaz.ba.gov.br', @@ -344,8 +344,8 @@ UFBA = { WS_NFE_SITUACAO: 'webservices/NfeStatusServico/NfeStatusServico.asmx', WS_NFE_INUTILIZACAO: 'webservices/nfenw/nfeinutilizacao2.asmx', WS_NFE_CADASTRO: 'webservices/nfenw/CadConsultaCadastro2.asmx', - WS_NFE_RECEPCAO_EVENTO: 'webservices/sre/recepcaoevento', - WS_NFE_CANCELAMENTO: 'webservices/sre/recepcaoevento', + WS_NFE_RECEPCAO_EVENTO: 'webservices/sre/recepcaoevento.asmx', + WS_NFE_CANCELAMENTO: 'webservices/sre/recepcaoevento.asmx', } } From 26f4f4cb0e6b39b0698bb6da18fcaffbe9f877ba Mon Sep 17 00:00:00 2001 From: Johny Chen Jy <31947361+carcaroff@users.noreply.github.com> Date: Mon, 18 Dec 2017 12:03:39 -0200 Subject: [PATCH 07/13] Update Version 0.1.42 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2a02d5c..696a49f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # coding=utf-8 from setuptools import setup, find_packages -VERSION = "0.1.41" +VERSION = "0.1.42" setup( name="PyTrustNFe", From 4f8bf2b43e7d0cd9939fe9a45621744f23e8a722 Mon Sep 17 00:00:00 2001 From: pal0schi <31492998+pal0schi@users.noreply.github.com> Date: Mon, 18 Dec 2017 15:28:48 -0200 Subject: [PATCH 08/13] adicionado string.strip ao render_xml (#77) --- pytrustnfe/xml/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pytrustnfe/xml/__init__.py b/pytrustnfe/xml/__init__.py index 360c919..ff1a6f3 100644 --- a/pytrustnfe/xml/__init__.py +++ b/pytrustnfe/xml/__init__.py @@ -16,7 +16,20 @@ def recursively_empty(e): return all((recursively_empty(c) for c in e.iterchildren())) +def recursively_normalize(vals): + for item in vals: + if type(vals[item]) is str: + vals[item] = vals[item].strip() + elif type(vals[item]) is dict: + recursively_normalize(vals[item]) + elif type(vals[item]) is list: + for a in vals[item]: + recursively_normalize(a) + return vals + + def render_xml(path, template_name, remove_empty, **nfe): + nfe = recursively_normalize(nfe) env = Environment( loader=FileSystemLoader(path), extensions=['jinja2.ext.with_']) From 9f7a2ebd63f710f60317bc015c60b1de882a53e0 Mon Sep 17 00:00:00 2001 From: carcaroff Date: Fri, 22 Dec 2017 15:38:17 -0200 Subject: [PATCH 09/13] [FIX]Campo CPF --- pytrustnfe/nfe/danfe.py | 13 +++++++------ setup.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pytrustnfe/nfe/danfe.py b/pytrustnfe/nfe/danfe.py index 799150c..bfe9692 100644 --- a/pytrustnfe/nfe/danfe.py +++ b/pytrustnfe/nfe/danfe.py @@ -55,6 +55,7 @@ def tagtext(oNode=None, cTag=None): cText = '' return cText + REGIME_TRIBUTACAO = { '1': 'Simples Nacional', '2': 'Simples Nacional, excesso sublimite de receita bruta', @@ -81,7 +82,7 @@ class danfe(object): self.nlin = self.nTop self.logo = logo self.oFrete = {'0': '0 - Emitente', - '1': '1 - Dest/Remet', + '1': '1 - Destinatário', '2': '2 - Terceiros', '9': '9 - Sem Frete'} @@ -342,8 +343,10 @@ class danfe(object): self.canvas.setFont('NimbusSanL-Regu', 8) self.string(self.nLeft+1, self.nlin+7.5, tagtext(oNode=elem_dest, cTag='xNome')) - self.string(nMr-69, self.nlin+7.5, - format_cnpj_cpf(tagtext(oNode=elem_dest, cTag='CNPJ'))) + cnpj_cpf = format_cnpj_cpf(tagtext(oNode=elem_dest, cTag='CNPJ')) + if cnpj_cpf == '..-' or not cnpj_cpf: + cnpj_cpf = format_cnpj_cpf(tagtext(oNode=elem_dest, cTag='CPF')) + self.string(nMr-69, self.nlin+7.5, cnpj_cpf) cDt, cHr = getdateUTC(tagtext(oNode=elem_ide, cTag='dhEmi')) self.string(nMr-24, self.nlin+7.7, cDt + ' ' + cHr) cDt, cHr = getdateUTC(tagtext(oNode=elem_ide, cTag='dhSaiEnt')) @@ -647,9 +650,8 @@ obsCont[@xCampo='NomeVendedor']") ".//{http://www.portalfiscal.inf.br/nfe}ICMS") el_imp_IPI = el_imp.find( ".//{http://www.portalfiscal.inf.br/nfe}IPI") - cCST = tagtext(oNode=el_imp_ICMS, cTag='orig') + \ - tagtext(oNode=el_imp_ICMS, cTag='CST') + tagtext(oNode=el_imp_ICMS, cTag='CSOSN') vBC = tagtext(oNode=el_imp_ICMS, cTag='vBC') vICMS = tagtext(oNode=el_imp_ICMS, cTag='vICMS') pICMS = tagtext(oNode=el_imp_ICMS, cTag='pICMS') @@ -719,7 +721,6 @@ obsCont[@xCampo='NomeVendedor']") styleN.fontSize = 6 styleN.fontName = 'NimbusSanL-Regu' styleN.leading = 7 - fisco = tagtext(oNode=el_infAdic, cTag='infAdFisco') observacoes = tagtext(oNode=el_infAdic, cTag='infCpl') if fisco: diff --git a/setup.py b/setup.py index 696a49f..2964952 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # coding=utf-8 from setuptools import setup, find_packages -VERSION = "0.1.42" +VERSION = "0.1.43" setup( name="PyTrustNFe", From bebc9f94d2429e87f2618a57d5d64abd1913bf09 Mon Sep 17 00:00:00 2001 From: carcaroff Date: Tue, 26 Dec 2017 11:39:42 -0200 Subject: [PATCH 10/13] [FIX] --- pytrustnfe/nfe/danfe.py | 562 +++++++++++++++++++++++++----------------------- 1 file changed, 287 insertions(+), 275 deletions(-) diff --git a/pytrustnfe/nfe/danfe.py b/pytrustnfe/nfe/danfe.py index bfe9692..61e391f 100644 --- a/pytrustnfe/nfe/danfe.py +++ b/pytrustnfe/nfe/danfe.py @@ -20,7 +20,7 @@ from reportlab.platypus import Paragraph, Image def chunks(cString, nLen): for start in range(0, len(cString), nLen): - yield cString[start:start+nLen] + yield cString[start:start + nLen] def format_cnpj_cpf(value): @@ -63,7 +63,7 @@ REGIME_TRIBUTACAO = { } -def get_image(path, width=1*cm): +def get_image(path, width=1 * cm): img = utils.ImageReader(path) iw, ih = img.getSize() aspect = ih / float(iw) @@ -71,6 +71,7 @@ def get_image(path, width=1*cm): class danfe(object): + def __init__(self, sizepage=A4, list_xml=None, recibo=True, orientation='portrait', logo=None): self.width = 210 # 21 x 29,7cm @@ -180,82 +181,84 @@ class danfe(object): elem_ide = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}ide") cChave = elem_infNFe.attrib.get('Id')[3:] - barcode128 = code128.Code128(cChave, barHeight=10*mm, barWidth=0.25*mm) + barcode128 = code128.Code128( + cChave, barHeight=10 * mm, barWidth=0.25 * mm) self.canvas.setLineWidth(.5) - self.rect(self.nLeft, self.nlin+1, self.nLeft+75, 32) - self.rect(self.nLeft+115, self.nlin+1, - self.width-self.nLeft-self.nRight-115, 39) + self.rect(self.nLeft, self.nlin + 1, self.nLeft + 75, 32) + self.rect(self.nLeft + 115, self.nlin + 1, + self.width - self.nLeft - self.nRight - 115, 39) - self.hline(self.nLeft+85, self.nlin+1, 125) + self.hline(self.nLeft + 85, self.nlin + 1, 125) - self.rect(self.nLeft+116, self.nlin+15, - self.width-self.nLeft-self.nRight-117, 6) + self.rect(self.nLeft + 116, self.nlin + 15, + self.width - self.nLeft - self.nRight - 117, 6) - self.rect(self.nLeft, self.nlin+33, - self.width-self.nLeft-self.nRight, 14) - self.hline(self.nLeft, self.nlin+40, self.width-self.nRight) - self.vline(self.nLeft+60, self.nlin+40, 7) - self.vline(self.nLeft+100, self.nlin+40, 7) + self.rect(self.nLeft, self.nlin + 33, + self.width - self.nLeft - self.nRight, 14) + self.hline(self.nLeft, self.nlin + 40, self.width - self.nRight) + self.vline(self.nLeft + 60, self.nlin + 40, 7) + self.vline(self.nLeft + 100, self.nlin + 40, 7) # Labels self.canvas.setFont('NimbusSanL-Bold', 12) - self.stringcenter(self.nLeft+98, self.nlin+5, 'DANFE') - self.stringcenter(self.nLeft+109, self.nlin+19.5, + self.stringcenter(self.nLeft + 98, self.nlin + 5, 'DANFE') + self.stringcenter(self.nLeft + 109, self.nlin + 19.5, tagtext(oNode=elem_ide, cTag='tpNF')) self.canvas.setFont('NimbusSanL-Bold', 8) cNF = tagtext(oNode=elem_ide, cTag='nNF') cNF = '{0:011,}'.format(int(cNF)).replace(",", ".") - self.stringcenter(self.nLeft+100, self.nlin+25, "Nº %s" % (cNF)) + self.stringcenter(self.nLeft + 100, self.nlin + 25, "Nº %s" % (cNF)) - self.stringcenter(self.nLeft+100, self.nlin+29, u"SÉRIE %s" % ( + self.stringcenter(self.nLeft + 100, self.nlin + 29, u"SÉRIE %s" % ( tagtext(oNode=elem_ide, cTag='serie'))) cPag = "Página %s de %s" % (str(self.Page), str(self.NrPages)) - self.stringcenter(self.nLeft+100, self.nlin+32, cPag) + self.stringcenter(self.nLeft + 100, self.nlin + 32, cPag) self.canvas.setFont('NimbusSanL-Regu', 6) - self.string(self.nLeft+86, self.nlin+8, 'Documento Auxiliar da') - self.string(self.nLeft+86, self.nlin+10.5, 'Nota Fiscal Eletrônica') - self.string(self.nLeft+86, self.nlin+16, '0 - Entrada') - self.string(self.nLeft+86, self.nlin+19, '1 - Saída') - self.rect(self.nLeft+105, self.nlin+15, 8, 6) + self.string(self.nLeft + 86, self.nlin + 8, 'Documento Auxiliar da') + self.string(self.nLeft + 86, self.nlin + + 10.5, 'Nota Fiscal Eletrônica') + self.string(self.nLeft + 86, self.nlin + 16, '0 - Entrada') + self.string(self.nLeft + 86, self.nlin + 19, '1 - Saída') + self.rect(self.nLeft + 105, self.nlin + 15, 8, 6) self.stringcenter( - self.nLeft+152, self.nlin+25, + self.nLeft + 152, self.nlin + 25, 'Consulta de autenticidade no portal nacional da NF-e') self.stringcenter( - self.nLeft+152, self.nlin+28, + self.nLeft + 152, self.nlin + 28, 'www.nfe.fazenda.gov.br/portal ou no site da SEFAZ Autorizadora') self.canvas.setFont('NimbusSanL-Regu', 5) - self.string(self.nLeft+117, self.nlin+16.7, 'CHAVE DE ACESSO') - self.string(self.nLeft+116, self.nlin+2.7, 'CONTROLE DO FISCO') + self.string(self.nLeft + 117, self.nlin + 16.7, 'CHAVE DE ACESSO') + self.string(self.nLeft + 116, self.nlin + 2.7, 'CONTROLE DO FISCO') - self.string(self.nLeft+1, self.nlin+34.7, 'NATUREZA DA OPERAÇÃO') - self.string(self.nLeft+116, self.nlin+34.7, + self.string(self.nLeft + 1, self.nlin + 34.7, 'NATUREZA DA OPERAÇÃO') + self.string(self.nLeft + 116, self.nlin + 34.7, 'PROTOCOLO DE AUTORIZAÇÃO DE USO') - self.string(self.nLeft+1, self.nlin+41.7, 'INSCRIÇÃO ESTADUAL') - self.string(self.nLeft+61, self.nlin+41.7, + self.string(self.nLeft + 1, self.nlin + 41.7, 'INSCRIÇÃO ESTADUAL') + self.string(self.nLeft + 61, self.nlin + 41.7, 'INSCRIÇÃO ESTADUAL DO SUBST. TRIB.') - self.string(self.nLeft+101, self.nlin+41.7, 'CNPJ') + self.string(self.nLeft + 101, self.nlin + 41.7, 'CNPJ') # Conteúdo campos - barcode128.drawOn(self.canvas, (self.nLeft+111.5)*mm, - (self.height-self.nlin-14)*mm) + barcode128.drawOn(self.canvas, (self.nLeft + 111.5) * mm, + (self.height - self.nlin - 14) * mm) self.canvas.setFont('NimbusSanL-Bold', 6) - nW_Rect = (self.width-self.nLeft-self.nRight-117) / 2 - self.stringcenter(self.nLeft+116.5+nW_Rect, self.nlin+19.5, + nW_Rect = (self.width - self.nLeft - self.nRight - 117) / 2 + self.stringcenter(self.nLeft + 116.5 + nW_Rect, self.nlin + 19.5, ' '.join(chunks(cChave, 4))) # Chave self.canvas.setFont('NimbusSanL-Regu', 8) cDt, cHr = getdateUTC(tagtext(oNode=elem_protNFe, cTag='dhRecbto')) cProtocolo = tagtext(oNode=elem_protNFe, cTag='nProt') cDt = cProtocolo + ' - ' + cDt + ' ' + cHr - nW_Rect = (self.width-self.nLeft-self.nRight-110) / 2 - self.stringcenter(self.nLeft+115+nW_Rect, self.nlin+38.7, cDt) + nW_Rect = (self.width - self.nLeft - self.nRight - 110) / 2 + self.stringcenter(self.nLeft + 115 + nW_Rect, self.nlin + 38.7, cDt) self.canvas.setFont('NimbusSanL-Regu', 8) - self.string(self.nLeft+1, self.nlin+38.7, + self.string(self.nLeft + 1, self.nlin + 38.7, tagtext(oNode=elem_ide, cTag='natOp')) - self.string(self.nLeft+1, self.nlin+46, + self.string(self.nLeft + 1, self.nlin + 46, tagtext(oNode=elem_emit, cTag='IE')) - self.string(self.nLeft+101, self.nlin+46, + self.string(self.nLeft + 101, self.nlin + 46, format_cnpj_cpf(tagtext(oNode=elem_emit, cTag='CNPJ'))) styles = getSampleStyleSheet() @@ -266,14 +269,14 @@ class danfe(object): # Razão Social emitente P = Paragraph(tagtext(oNode=elem_emit, cTag='xNome'), styleN) - w, h = P.wrap(55*mm, 50*mm) - P.drawOn(self.canvas, (self.nLeft+30)*mm, - (self.height-self.nlin-12)*mm) + w, h = P.wrap(55 * mm, 50 * mm) + P.drawOn(self.canvas, (self.nLeft + 30) * mm, + (self.height - self.nlin - 12) * mm) if self.logo: - img = get_image(self.logo, width=2*cm) - img.drawOn(self.canvas, (self.nLeft+5)*mm, - (self.height-self.nlin-22)*mm) + img = get_image(self.logo, width=2 * cm) + img.drawOn(self.canvas, (self.nLeft + 5) * mm, + (self.height - self.nlin - 22) * mm) cEnd = tagtext(oNode=elem_emit, cTag='xLgr') + ', ' + tagtext( oNode=elem_emit, cTag='nro') + ' - ' @@ -290,9 +293,9 @@ class danfe(object): styleN.fontSize = 7 styleN.leading = 10 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) + w, h = P.wrap(55 * mm, 30 * mm) + P.drawOn(self.canvas, (self.nLeft + 30) * mm, + (self.height - self.nlin - 31) * mm) # Homologação if tagtext(oNode=elem_ide, cTag='tpAmb') == '2': @@ -300,7 +303,7 @@ class danfe(object): self.canvas.rotate(90) self.canvas.setFont('Times-Bold', 40) self.canvas.setFillColorRGB(0.57, 0.57, 0.57) - self.string(self.nLeft+65, 449, 'SEM VALOR FISCAL') + self.string(self.nLeft + 65, 449, 'SEM VALOR FISCAL') self.canvas.restoreState() self.nlin += 48 @@ -308,88 +311,90 @@ class danfe(object): def destinatario(self, oXML=None): elem_ide = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}ide") elem_dest = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}dest") - nMr = self.width-self.nRight + nMr = self.width - self.nRight self.nlin += 1 self.canvas.setFont('NimbusSanL-Bold', 7) - self.string(self.nLeft+1, self.nlin+1, 'DESTINATÁRIO/REMETENTE') - self.rect(self.nLeft, self.nlin+2, - self.width-self.nLeft-self.nRight, 20) - self.vline(nMr-25, self.nlin+2, 20) - self.hline(self.nLeft, self.nlin+8.66, self.width-self.nLeft) - self.hline(self.nLeft, self.nlin+15.32, self.width-self.nLeft) - self.vline(nMr-70, self.nlin+2, 6.66) - self.vline(nMr-53, self.nlin+8.66, 6.66) - self.vline(nMr-99, self.nlin+8.66, 6.66) - self.vline(nMr-90, self.nlin+15.32, 6.66) - self.vline(nMr-102, self.nlin+15.32, 6.66) - self.vline(nMr-136, self.nlin+15.32, 6.66) + self.string(self.nLeft + 1, self.nlin + 1, 'DESTINATÁRIO/REMETENTE') + self.rect(self.nLeft, self.nlin + 2, + self.width - self.nLeft - self.nRight, 20) + self.vline(nMr - 25, self.nlin + 2, 20) + self.hline(self.nLeft, self.nlin + 8.66, self.width - self.nLeft) + self.hline(self.nLeft, self.nlin + 15.32, self.width - self.nLeft) + self.vline(nMr - 70, self.nlin + 2, 6.66) + self.vline(nMr - 53, self.nlin + 8.66, 6.66) + self.vline(nMr - 99, self.nlin + 8.66, 6.66) + self.vline(nMr - 90, self.nlin + 15.32, 6.66) + self.vline(nMr - 102, self.nlin + 15.32, 6.66) + self.vline(nMr - 136, self.nlin + 15.32, 6.66) # Labels/Fields self.canvas.setFont('NimbusSanL-Bold', 5) - self.string(self.nLeft+1, self.nlin+3.7, 'NOME/RAZÃO SOCIAL') - self.string(nMr-69, self.nlin+3.7, 'CNPJ/CPF') - self.string(nMr-24, self.nlin+3.7, 'DATA DA EMISSÃO') - self.string(self.nLeft+1, self.nlin+10.3, 'ENDEREÇO') - self.string(nMr-98, self.nlin+10.3, 'BAIRRO/DISTRITO') - self.string(nMr-52, self.nlin+10.3, 'CEP') - self.string(nMr-24, self.nlin+10.3, 'DATA DE ENTRADA/SAÍDA') - self.string(self.nLeft+1, self.nlin+17.1, 'MUNICÍPIO') - self.string(nMr-135, self.nlin+17.1, 'FONE/FAX') - self.string(nMr-101, self.nlin+17.1, 'UF') - self.string(nMr-89, self.nlin+17.1, 'INSCRIÇÃO ESTADUAL') - self.string(nMr-24, self.nlin+17.1, 'HORA DE ENTRADA/SAÍDA') + self.string(self.nLeft + 1, self.nlin + 3.7, 'NOME/RAZÃO SOCIAL') + self.string(nMr - 69, self.nlin + 3.7, 'CNPJ/CPF') + self.string(nMr - 24, self.nlin + 3.7, 'DATA DA EMISSÃO') + self.string(self.nLeft + 1, self.nlin + 10.3, 'ENDEREÇO') + self.string(nMr - 98, self.nlin + 10.3, 'BAIRRO/DISTRITO') + self.string(nMr - 52, self.nlin + 10.3, 'CEP') + self.string(nMr - 24, self.nlin + 10.3, 'DATA DE ENTRADA/SAÍDA') + self.string(self.nLeft + 1, self.nlin + 17.1, 'MUNICÍPIO') + self.string(nMr - 135, self.nlin + 17.1, 'FONE/FAX') + self.string(nMr - 101, self.nlin + 17.1, 'UF') + self.string(nMr - 89, self.nlin + 17.1, 'INSCRIÇÃO ESTADUAL') + self.string(nMr - 24, self.nlin + 17.1, 'HORA DE ENTRADA/SAÍDA') # Conteúdo campos self.canvas.setFont('NimbusSanL-Regu', 8) - self.string(self.nLeft+1, self.nlin+7.5, + self.string(self.nLeft + 1, self.nlin + 7.5, tagtext(oNode=elem_dest, cTag='xNome')) - cnpj_cpf = format_cnpj_cpf(tagtext(oNode=elem_dest, cTag='CNPJ')) - if cnpj_cpf == '..-' or not cnpj_cpf: + cnpj_cpf = tagtext(oNode=elem_dest, cTag='CNPJ') + if cnpj_cpf: + cnpj_cpf = format_cnpj_cpf(cnpj_cpf) + else: cnpj_cpf = format_cnpj_cpf(tagtext(oNode=elem_dest, cTag='CPF')) - self.string(nMr-69, self.nlin+7.5, cnpj_cpf) + self.string(nMr - 69, self.nlin + 7.5, cnpj_cpf) cDt, cHr = getdateUTC(tagtext(oNode=elem_ide, cTag='dhEmi')) - self.string(nMr-24, self.nlin+7.7, cDt + ' ' + cHr) + self.string(nMr - 24, self.nlin + 7.7, cDt + ' ' + cHr) cDt, cHr = getdateUTC(tagtext(oNode=elem_ide, cTag='dhSaiEnt')) - self.string(nMr-24, self.nlin+14.3, cDt + ' ' + cHr) # Dt saída + self.string(nMr - 24, self.nlin + 14.3, cDt + ' ' + cHr) # Dt saída cEnd = tagtext(oNode=elem_dest, cTag='xLgr') + ', ' + tagtext( oNode=elem_dest, cTag='nro') - self.string(self.nLeft+1, self.nlin+14.3, cEnd) - self.string(nMr-98, self.nlin+14.3, + self.string(self.nLeft + 1, self.nlin + 14.3, cEnd) + self.string(nMr - 98, self.nlin + 14.3, tagtext(oNode=elem_dest, cTag='xBairro')) - self.string(nMr-52, self.nlin+14.3, + self.string(nMr - 52, self.nlin + 14.3, tagtext(oNode=elem_dest, cTag='CEP')) - self.string(self.nLeft+1, self.nlin+21.1, + self.string(self.nLeft + 1, self.nlin + 21.1, tagtext(oNode=elem_dest, cTag='xMun')) - self.string(nMr-135, self.nlin+21.1, + self.string(nMr - 135, self.nlin + 21.1, tagtext(oNode=elem_dest, cTag='fone')) - self.string(nMr-101, self.nlin+21.1, + self.string(nMr - 101, self.nlin + 21.1, tagtext(oNode=elem_dest, cTag='UF')) - self.string(nMr-89, self.nlin+21.1, + self.string(nMr - 89, self.nlin + 21.1, tagtext(oNode=elem_dest, cTag='IE')) self.nlin += 24 # Nr linhas ocupadas pelo bloco def faturas(self, oXML=None): - nMr = self.width-self.nRight + nMr = self.width - self.nRight self.canvas.setFont('NimbusSanL-Bold', 7) - self.string(self.nLeft+1, self.nlin+1, 'FATURA') - self.rect(self.nLeft, self.nlin+2, - self.width-self.nLeft-self.nRight, 13) - self.vline(nMr-47.5, self.nlin+2, 13) - self.vline(nMr-95, self.nlin+2, 13) - self.vline(nMr-142.5, self.nlin+2, 13) - self.hline(nMr-47.5, self.nlin+8.5, self.width-self.nLeft) + self.string(self.nLeft + 1, self.nlin + 1, 'FATURA') + self.rect(self.nLeft, self.nlin + 2, + self.width - self.nLeft - self.nRight, 13) + self.vline(nMr - 47.5, self.nlin + 2, 13) + self.vline(nMr - 95, self.nlin + 2, 13) + self.vline(nMr - 142.5, self.nlin + 2, 13) + self.hline(nMr - 47.5, self.nlin + 8.5, self.width - self.nLeft) # Labels self.canvas.setFont('NimbusSanL-Regu', 5) - self.string(nMr-46.5, self.nlin+3.8, 'CÓDIGO VENDEDOR') - self.string(nMr-46.5, self.nlin+10.2, 'NOME VENDEDOR') - self.string(nMr-93.5, self.nlin+3.8, + self.string(nMr - 46.5, self.nlin + 3.8, 'CÓDIGO VENDEDOR') + self.string(nMr - 46.5, self.nlin + 10.2, 'NOME VENDEDOR') + self.string(nMr - 93.5, self.nlin + 3.8, 'FATURA VENCIMENTO VALOR') - self.string(nMr-140.5, self.nlin+3.8, + self.string(nMr - 140.5, self.nlin + 3.8, 'FATURA VENCIMENTO VALOR') - self.string(self.nLeft+2, self.nlin+3.8, + self.string(self.nLeft + 2, self.nlin + 3.8, 'FATURA VENCIMENTO VALOR') # Conteúdo campos @@ -403,11 +408,11 @@ class danfe(object): for oXML_dup in line_iter: cDt, cHr = getdateUTC(tagtext(oNode=oXML_dup, cTag='dVenc')) - self.string(self.nLeft+nCol+1, self.nlin+nLin, + self.string(self.nLeft + nCol + 1, self.nlin + nLin, tagtext(oNode=oXML_dup, cTag='nDup')) - self.string(self.nLeft+nCol+17, self.nlin+nLin, cDt) + self.string(self.nLeft + nCol + 17, self.nlin + nLin, cDt) self.stringRight( - self.nLeft+nCol+47, self.nlin+nLin, + self.nLeft + nCol + 47, self.nlin + nLin, format_number(tagtext(oNode=oXML_dup, cTag='vDup'), precision=2)) @@ -428,11 +433,11 @@ class danfe(object): codvend = elem_infAdic.find( ".//{http://www.portalfiscal.inf.br/nfe}obsCont\ [@xCampo='CodVendedor']") - self.string(nMr-46.5, self.nlin+7.7, + self.string(nMr - 46.5, self.nlin + 7.7, tagtext(oNode=codvend, cTag='xTexto')) vend = elem_infAdic.find(".//{http://www.portalfiscal.inf.br/nfe}\ obsCont[@xCampo='NomeVendedor']") - self.string(nMr-46.5, self.nlin+14.3, + self.string(nMr - 46.5, self.nlin + 14.3, tagtext(oNode=vend, cTag='xTexto')[:36]) self.nlin += 16 # Nr linhas ocupadas pelo bloco @@ -440,149 +445,149 @@ obsCont[@xCampo='NomeVendedor']") def impostos(self, oXML=None): # Impostos el_total = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}total") - nMr = self.width-self.nRight + nMr = self.width - self.nRight self.nlin += 1 self.canvas.setFont('NimbusSanL-Bold', 7) - self.string(self.nLeft+1, self.nlin+1, 'CÁLCULO DO IMPOSTO') - self.rect(self.nLeft, self.nlin+2, - self.width-self.nLeft-self.nRight, 13) - self.hline(self.nLeft, self.nlin+8.5, self.width-self.nLeft) - self.vline(nMr-35, self.nlin+2, 6.5) - self.vline(nMr-65, self.nlin+2, 6.5) - self.vline(nMr-95, self.nlin+2, 6.5) - self.vline(nMr-125, self.nlin+2, 6.5) - self.vline(nMr-155, self.nlin+2, 6.5) - self.vline(nMr-35, self.nlin+8.5, 6.5) - self.vline(nMr-65, self.nlin+8.5, 6.5) - self.vline(nMr-95, self.nlin+8.5, 6.5) - self.vline(nMr-125, self.nlin+8.5, 6.5) - self.vline(nMr-155, self.nlin+8.5, 6.5) + self.string(self.nLeft + 1, self.nlin + 1, 'CÁLCULO DO IMPOSTO') + self.rect(self.nLeft, self.nlin + 2, + self.width - self.nLeft - self.nRight, 13) + self.hline(self.nLeft, self.nlin + 8.5, self.width - self.nLeft) + self.vline(nMr - 35, self.nlin + 2, 6.5) + self.vline(nMr - 65, self.nlin + 2, 6.5) + self.vline(nMr - 95, self.nlin + 2, 6.5) + self.vline(nMr - 125, self.nlin + 2, 6.5) + self.vline(nMr - 155, self.nlin + 2, 6.5) + self.vline(nMr - 35, self.nlin + 8.5, 6.5) + self.vline(nMr - 65, self.nlin + 8.5, 6.5) + self.vline(nMr - 95, self.nlin + 8.5, 6.5) + self.vline(nMr - 125, self.nlin + 8.5, 6.5) + self.vline(nMr - 155, self.nlin + 8.5, 6.5) # Labels self.canvas.setFont('NimbusSanL-Regu', 5) - self.string(self.nLeft+1, self.nlin+3.8, 'BASE DE CÁLCULO DO ICMS') - self.string(nMr-154, self.nlin+3.8, 'VALOR DO ICMS') - self.string(nMr-124, self.nlin+3.8, 'BASE DE CÁLCULO DO ICMS ST') - self.string(nMr-94, self.nlin+3.8, 'VALOR DO ICMS ST') - self.string(nMr-64, self.nlin+3.8, 'VALOR APROX TRIBUTOS') - self.string(nMr-34, self.nlin+3.8, 'VALOR TOTAL DOS PRODUTOS') - - self.string(self.nLeft+1, self.nlin+10.2, 'VALOR DO FRETE') - self.string(nMr-154, self.nlin+10.2, 'VALOR DO SEGURO') - self.string(nMr-124, self.nlin+10.2, 'DESCONTO') - self.string(nMr-94, self.nlin+10.2, 'OUTRAS DESP. ACESSÓRIAS') - self.string(nMr-64, self.nlin+10.2, 'VALOR DO IPI') - self.string(nMr-34, self.nlin+10.2, 'VALOR TOTAL DA NOTA') + self.string(self.nLeft + 1, self.nlin + 3.8, 'BASE DE CÁLCULO DO ICMS') + self.string(nMr - 154, self.nlin + 3.8, 'VALOR DO ICMS') + self.string(nMr - 124, self.nlin + 3.8, 'BASE DE CÁLCULO DO ICMS ST') + self.string(nMr - 94, self.nlin + 3.8, 'VALOR DO ICMS ST') + self.string(nMr - 64, self.nlin + 3.8, 'VALOR APROX TRIBUTOS') + self.string(nMr - 34, self.nlin + 3.8, 'VALOR TOTAL DOS PRODUTOS') + + self.string(self.nLeft + 1, self.nlin + 10.2, 'VALOR DO FRETE') + self.string(nMr - 154, self.nlin + 10.2, 'VALOR DO SEGURO') + self.string(nMr - 124, self.nlin + 10.2, 'DESCONTO') + self.string(nMr - 94, self.nlin + 10.2, 'OUTRAS DESP. ACESSÓRIAS') + self.string(nMr - 64, self.nlin + 10.2, 'VALOR DO IPI') + self.string(nMr - 34, self.nlin + 10.2, 'VALOR TOTAL DA NOTA') # Conteúdo campos self.canvas.setFont('NimbusSanL-Regu', 8) self.stringRight( - self.nLeft+34, self.nlin+7.7, + self.nLeft + 34, self.nlin + 7.7, format_number(tagtext(oNode=el_total, cTag='vBC'), precision=2)) self.stringRight( - self.nLeft+64, self.nlin+7.7, + self.nLeft + 64, self.nlin + 7.7, format_number(tagtext(oNode=el_total, cTag='vICMS'), precision=2)) self.stringRight( - self.nLeft+94, self.nlin+7.7, + self.nLeft + 94, self.nlin + 7.7, format_number(tagtext(oNode=el_total, cTag='vBCST'), precision=2)) self.stringRight( - nMr-66, self.nlin+7.7, + nMr - 66, self.nlin + 7.7, format_number(tagtext(oNode=el_total, cTag='vST'), precision=2)) self.stringRight( - nMr-36, self.nlin+7.7, + nMr - 36, self.nlin + 7.7, format_number(tagtext(oNode=el_total, cTag='vTotTrib'), precision=2)) self.stringRight( - nMr-1, self.nlin+7.7, + nMr - 1, self.nlin + 7.7, format_number(tagtext(oNode=el_total, cTag='vProd'), precision=2)) self.stringRight( - self.nLeft+34, self.nlin+14.1, + self.nLeft + 34, self.nlin + 14.1, format_number(tagtext(oNode=el_total, cTag='vFrete'), precision=2)) self.stringRight( - self.nLeft+64, self.nlin+14.1, + self.nLeft + 64, self.nlin + 14.1, format_number(tagtext(oNode=el_total, cTag='vSeg'), precision=2)) self.stringRight( - self.nLeft+94, self.nlin+14.1, + self.nLeft + 94, self.nlin + 14.1, format_number(tagtext(oNode=el_total, cTag='vDesc'), precision=2)) self.stringRight( - self.nLeft+124, self.nlin+14.1, + self.nLeft + 124, self.nlin + 14.1, format_number(tagtext(oNode=el_total, cTag='vOutro'), precision=2)) self.stringRight( - self.nLeft+154, self.nlin+14.1, + self.nLeft + 154, self.nlin + 14.1, format_number(tagtext(oNode=el_total, cTag='vIPI'), precision=2)) self.stringRight( - nMr-1, self.nlin+14.1, + nMr - 1, self.nlin + 14.1, format_number(tagtext(oNode=el_total, cTag='vNF'), precision=2)) self.nlin += 17 # Nr linhas ocupadas pelo bloco def transportes(self, oXML=None): el_transp = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}transp") - nMr = self.width-self.nRight + nMr = self.width - self.nRight self.canvas.setFont('NimbusSanL-Bold', 7) - self.string(self.nLeft+1, self.nlin+1, + self.string(self.nLeft + 1, self.nlin + 1, 'TRANSPORTADOR/VOLUMES TRANSPORTADOS') self.canvas.setFont('NimbusSanL-Regu', 5) - self.rect(self.nLeft, self.nlin+2, - self.width-self.nLeft-self.nRight, 20) - self.hline(self.nLeft, self.nlin+8.6, self.width-self.nLeft) - self.hline(self.nLeft, self.nlin+15.2, self.width-self.nLeft) - self.vline(nMr-40, self.nlin+2, 13.2) - self.vline(nMr-49, self.nlin+2, 20) - self.vline(nMr-92, self.nlin+2, 6.6) - self.vline(nMr-120, self.nlin+2, 6.6) - self.vline(nMr-75, self.nlin+2, 6.6) - self.vline(nMr-26, self.nlin+15.2, 6.6) - self.vline(nMr-102, self.nlin+8.6, 6.6) - self.vline(nMr-85, self.nlin+15.2, 6.6) - self.vline(nMr-121, self.nlin+15.2, 6.6) - self.vline(nMr-160, self.nlin+15.2, 6.6) + self.rect(self.nLeft, self.nlin + 2, + self.width - self.nLeft - self.nRight, 20) + self.hline(self.nLeft, self.nlin + 8.6, self.width - self.nLeft) + self.hline(self.nLeft, self.nlin + 15.2, self.width - self.nLeft) + self.vline(nMr - 40, self.nlin + 2, 13.2) + self.vline(nMr - 49, self.nlin + 2, 20) + self.vline(nMr - 92, self.nlin + 2, 6.6) + self.vline(nMr - 120, self.nlin + 2, 6.6) + self.vline(nMr - 75, self.nlin + 2, 6.6) + self.vline(nMr - 26, self.nlin + 15.2, 6.6) + self.vline(nMr - 102, self.nlin + 8.6, 6.6) + self.vline(nMr - 85, self.nlin + 15.2, 6.6) + self.vline(nMr - 121, self.nlin + 15.2, 6.6) + self.vline(nMr - 160, self.nlin + 15.2, 6.6) # Labels/Fields - self.string(nMr-39, self.nlin+3.8, 'CNPJ/CPF') - self.string(nMr-74, self.nlin+3.8, 'PLACA DO VEÍCULO') - self.string(nMr-91, self.nlin+3.8, 'CÓDIGO ANTT') - self.string(nMr-119, self.nlin+3.8, 'FRETE POR CONTA') - self.string(self.nLeft+1, self.nlin+3.8, 'RAZÃO SOCIAL') - self.string(nMr-48, self.nlin+3.8, 'UF') - self.string(nMr-39, self.nlin+10.3, 'INSCRIÇÃO ESTADUAL') - self.string(nMr-48, self.nlin+10.3, 'UF') - self.string(nMr-101, self.nlin+10.3, 'MUNICÍPIO') - self.string(self.nLeft+1, self.nlin+10.3, 'ENDEREÇO') - self.string(nMr-48, self.nlin+17, 'PESO BRUTO') - self.string(nMr-25, self.nlin+17, 'PESO LÍQUIDO') - self.string(nMr-84, self.nlin+17, 'NUMERAÇÃO') - self.string(nMr-120, self.nlin+17, 'MARCA') - self.string(nMr-159, self.nlin+17, 'ESPÉCIE') - self.string(self.nLeft+1, self.nlin+17, 'QUANTIDADE') + self.string(nMr - 39, self.nlin + 3.8, 'CNPJ/CPF') + self.string(nMr - 74, self.nlin + 3.8, 'PLACA DO VEÍCULO') + self.string(nMr - 91, self.nlin + 3.8, 'CÓDIGO ANTT') + self.string(nMr - 119, self.nlin + 3.8, 'FRETE POR CONTA') + self.string(self.nLeft + 1, self.nlin + 3.8, 'RAZÃO SOCIAL') + self.string(nMr - 48, self.nlin + 3.8, 'UF') + self.string(nMr - 39, self.nlin + 10.3, 'INSCRIÇÃO ESTADUAL') + self.string(nMr - 48, self.nlin + 10.3, 'UF') + self.string(nMr - 101, self.nlin + 10.3, 'MUNICÍPIO') + self.string(self.nLeft + 1, self.nlin + 10.3, 'ENDEREÇO') + self.string(nMr - 48, self.nlin + 17, 'PESO BRUTO') + self.string(nMr - 25, self.nlin + 17, 'PESO LÍQUIDO') + self.string(nMr - 84, self.nlin + 17, 'NUMERAÇÃO') + self.string(nMr - 120, self.nlin + 17, 'MARCA') + self.string(nMr - 159, self.nlin + 17, 'ESPÉCIE') + self.string(self.nLeft + 1, self.nlin + 17, 'QUANTIDADE') # Conteúdo campos self.canvas.setFont('NimbusSanL-Regu', 8) - self.string(self.nLeft+1, self.nlin+7.7, + self.string(self.nLeft + 1, self.nlin + 7.7, tagtext(oNode=el_transp, cTag='xNome')[:40]) - self.string(self.nLeft+71, self.nlin+7.7, + self.string(self.nLeft + 71, self.nlin + 7.7, self.oFrete[tagtext(oNode=el_transp, cTag='modFrete')]) - self.string(nMr-39, self.nlin+7.7, + self.string(nMr - 39, self.nlin + 7.7, format_cnpj_cpf(tagtext(oNode=el_transp, cTag='CNPJ'))) - self.string(self.nLeft+1, self.nlin+14.2, + self.string(self.nLeft + 1, self.nlin + 14.2, tagtext(oNode=el_transp, cTag='xEnder')[:45]) - self.string(self.nLeft+89, self.nlin+14.2, + self.string(self.nLeft + 89, self.nlin + 14.2, tagtext(oNode=el_transp, cTag='xMun')) - self.string(nMr-48, self.nlin+14.2, + self.string(nMr - 48, self.nlin + 14.2, tagtext(oNode=el_transp, cTag='UF')) - self.string(nMr-39, self.nlin+14.2, + self.string(nMr - 39, self.nlin + 14.2, tagtext(oNode=el_transp, cTag='IE')) - self.string(self.nLeft+1, self.nlin+21.2, + self.string(self.nLeft + 1, self.nlin + 21.2, tagtext(oNode=el_transp, cTag='qVol')) - self.string(self.nLeft+31, self.nlin+21.2, + self.string(self.nLeft + 31, self.nlin + 21.2, tagtext(oNode=el_transp, cTag='esp')) - self.string(self.nLeft+70, self.nlin+21.2, + self.string(self.nLeft + 70, self.nlin + 21.2, tagtext(oNode=el_transp, cTag='marca')) - self.string(self.nLeft+106, self.nlin+21.2, + self.string(self.nLeft + 106, self.nlin + 21.2, tagtext(oNode=el_transp, cTag='nVol')) self.stringRight( - nMr-27, self.nlin+21.2, + nMr - 27, self.nlin + 21.2, format_number(tagtext(oNode=el_transp, cTag='pesoB'), precision=3)) self.stringRight( - nMr-1, self.nlin+21.2, + nMr - 1, self.nlin + 21.2, format_number(tagtext(oNode=el_transp, cTag='pesoL'), precision=3)) self.nlin += 23 @@ -590,55 +595,56 @@ obsCont[@xCampo='NomeVendedor']") def produtos(self, oXML=None, el_det=None, oPaginator=None, list_desc=None, list_cod_prod=None, nHeight=29): - nMr = self.width-self.nRight + nMr = self.width - self.nRight nStep = 2.5 # Passo entre linhas nH = 7.5 + (nHeight * nStep) # cabeçalho 7.5 self.nlin += 1 self.canvas.setFont('NimbusSanL-Bold', 7) - self.string(self.nLeft+1, self.nlin+1, 'DADOS DO PRODUTO/SERVIÇO') - self.rect(self.nLeft, self.nlin+2, - self.width-self.nLeft-self.nRight, nH) - self.hline(self.nLeft, self.nlin+8, self.width-self.nLeft) + self.string(self.nLeft + 1, self.nlin + 1, 'DADOS DO PRODUTO/SERVIÇO') + self.rect(self.nLeft, self.nlin + 2, + self.width - self.nLeft - self.nRight, nH) + self.hline(self.nLeft, self.nlin + 8, self.width - self.nLeft) self.canvas.setFont('NimbusSanL-Regu', 5.5) # Colunas - self.vline(self.nLeft+15, self.nlin+2, nH) - self.stringcenter(self.nLeft+7.5, self.nlin+5.5, 'CÓDIGO') - self.vline(nMr-7, self.nlin+2, nH) - self.stringcenter(nMr-3.5, self.nlin+4.5, 'ALÍQ') - self.stringcenter(nMr-3.5, self.nlin+6.5, 'IPI') - self.vline(nMr-14, self.nlin+2, nH) - self.stringcenter(nMr-10.5, self.nlin+4.5, 'ALÍQ') - self.stringcenter(nMr-10.5, self.nlin+6.5, 'ICMS') - self.vline(nMr-26, self.nlin+2, nH) - self.stringcenter(nMr-20, self.nlin+5.5, 'VLR. IPI') - self.vline(nMr-38, self.nlin+2, nH) - self.stringcenter(nMr-32, self.nlin+5.5, 'VLR. ICMS') - self.vline(nMr-50, self.nlin+2, nH) - self.stringcenter(nMr-44, self.nlin+5.5, 'BC ICMS') - self.vline(nMr-64, self.nlin+2, nH) - self.stringcenter(nMr-57, self.nlin+5.5, 'VLR TOTAL') - self.vline(nMr-77, self.nlin+2, nH) - self.stringcenter(nMr-70.5, self.nlin+5.5, 'VLR UNIT') - self.vline(nMr-90, self.nlin+2, nH) - self.stringcenter(nMr-83.5, self.nlin+5.5, 'QTD') - self.vline(nMr-96, self.nlin+2, nH) - self.stringcenter(nMr-93, self.nlin+5.5, 'UNID') - self.vline(nMr-102, self.nlin+2, nH) - self.stringcenter(nMr-99, self.nlin+5.5, 'CFOP') - self.vline(nMr-108, self.nlin+2, nH) - self.stringcenter(nMr-105, self.nlin+5.5, 'CST') - self.vline(nMr-117, self.nlin+2, nH) - self.stringcenter(nMr-112.5, self.nlin+5.5, 'NCM/SH') - - nWidth_Prod = nMr-135-self.nLeft-11 - nCol_ = self.nLeft+20 + (nWidth_Prod / 2) - self.stringcenter(nCol_, self.nlin+5.5, 'DESCRIÇÃO DO PRODUTO/SERVIÇO') + self.vline(self.nLeft + 15, self.nlin + 2, nH) + self.stringcenter(self.nLeft + 7.5, self.nlin + 5.5, 'CÓDIGO') + self.vline(nMr - 7, self.nlin + 2, nH) + self.stringcenter(nMr - 3.5, self.nlin + 4.5, 'ALÍQ') + self.stringcenter(nMr - 3.5, self.nlin + 6.5, 'IPI') + self.vline(nMr - 14, self.nlin + 2, nH) + self.stringcenter(nMr - 10.5, self.nlin + 4.5, 'ALÍQ') + self.stringcenter(nMr - 10.5, self.nlin + 6.5, 'ICMS') + self.vline(nMr - 26, self.nlin + 2, nH) + self.stringcenter(nMr - 20, self.nlin + 5.5, 'VLR. IPI') + self.vline(nMr - 38, self.nlin + 2, nH) + self.stringcenter(nMr - 32, self.nlin + 5.5, 'VLR. ICMS') + self.vline(nMr - 50, self.nlin + 2, nH) + self.stringcenter(nMr - 44, self.nlin + 5.5, 'BC ICMS') + self.vline(nMr - 64, self.nlin + 2, nH) + self.stringcenter(nMr - 57, self.nlin + 5.5, 'VLR TOTAL') + self.vline(nMr - 77, self.nlin + 2, nH) + self.stringcenter(nMr - 70.5, self.nlin + 5.5, 'VLR UNIT') + self.vline(nMr - 90, self.nlin + 2, nH) + self.stringcenter(nMr - 83.5, self.nlin + 5.5, 'QTD') + self.vline(nMr - 96, self.nlin + 2, nH) + self.stringcenter(nMr - 93, self.nlin + 5.5, 'UNID') + self.vline(nMr - 102, self.nlin + 2, nH) + self.stringcenter(nMr - 99, self.nlin + 5.5, 'CFOP') + self.vline(nMr - 108, self.nlin + 2, nH) + self.stringcenter(nMr - 105, self.nlin + 5.5, 'CST') + self.vline(nMr - 117, self.nlin + 2, nH) + self.stringcenter(nMr - 112.5, self.nlin + 5.5, 'NCM/SH') + + nWidth_Prod = nMr - 135 - self.nLeft - 11 + nCol_ = self.nLeft + 20 + (nWidth_Prod / 2) + self.stringcenter(nCol_, self.nlin + 5.5, + 'DESCRIÇÃO DO PRODUTO/SERVIÇO') # Conteúdo campos self.canvas.setFont('NimbusSanL-Regu', 5) - nLin = self.nlin+10.5 + nLin = self.nlin + 10.5 for id in xrange(oPaginator[0], oPaginator[1]): item = el_det[id] @@ -651,7 +657,8 @@ obsCont[@xCampo='NomeVendedor']") el_imp_IPI = el_imp.find( ".//{http://www.portalfiscal.inf.br/nfe}IPI") cCST = tagtext(oNode=el_imp_ICMS, cTag='orig') + \ - tagtext(oNode=el_imp_ICMS, cTag='CSOSN') + (tagtext(oNode=el_imp_ICMS, cTag='CST') or + tagtext(oNode=el_imp_ICMS, cTag='CSOSN')) vBC = tagtext(oNode=el_imp_ICMS, cTag='vBC') vICMS = tagtext(oNode=el_imp_ICMS, cTag='vICMS') pICMS = tagtext(oNode=el_imp_ICMS, cTag='pICMS') @@ -659,45 +666,47 @@ obsCont[@xCampo='NomeVendedor']") vIPI = tagtext(oNode=el_imp_IPI, cTag='vIPI') pIPI = tagtext(oNode=el_imp_IPI, cTag='pIPI') - self.stringcenter(nMr-112.5, nLin, + self.stringcenter(nMr - 112.5, nLin, tagtext(oNode=el_prod, cTag='NCM')) - self.stringcenter(nMr-105, nLin, cCST) - self.stringcenter(nMr-99, nLin, + self.stringcenter(nMr - 105, nLin, cCST) + self.stringcenter(nMr - 99, nLin, tagtext(oNode=el_prod, cTag='CFOP')) - self.stringcenter(nMr-93, nLin, + self.stringcenter(nMr - 93, nLin, tagtext(oNode=el_prod, cTag='uCom')) - self.stringRight(nMr-77.5, nLin, format_number( + self.stringRight(nMr - 77.5, nLin, format_number( tagtext(oNode=el_prod, cTag='qCom'), precision=4)) - self.stringRight(nMr-64.5, nLin, format_number( + self.stringRight(nMr - 64.5, nLin, format_number( tagtext(oNode=el_prod, cTag='vUnCom'), precision=2)) - self.stringRight(nMr-50.5, nLin, format_number( + self.stringRight(nMr - 50.5, nLin, format_number( tagtext(oNode=el_prod, cTag='vProd'), precision=2)) - self.stringRight(nMr-38.5, nLin, format_number(vBC, precision=2)) - self.stringRight(nMr-26.5, nLin, format_number(vICMS, precision=2)) - self.stringRight(nMr-7.5, nLin, format_number(pICMS, precision=2)) + self.stringRight(nMr - 38.5, nLin, format_number(vBC, precision=2)) + self.stringRight(nMr - 26.5, nLin, + format_number(vICMS, precision=2)) + self.stringRight( + nMr - 7.5, nLin, format_number(pICMS, precision=2)) if vIPI: - self.stringRight(nMr-14.5, nLin, + self.stringRight(nMr - 14.5, nLin, format_number(vIPI, precision=2)) if pIPI: - self.stringRight(nMr-0.5, nLin, + self.stringRight(nMr - 0.5, nLin, format_number(pIPI, precision=2)) # Código Item line_cod = nLin for des in list_cod_prod[id]: - self.string(self.nLeft+0.2, line_cod, des) + self.string(self.nLeft + 0.2, line_cod, des) line_cod += nStep # Descrição Item line_desc = nLin for des in list_desc[id]: - self.string(self.nLeft+15.5, line_desc, des) + self.string(self.nLeft + 15.5, line_desc, des) line_desc += nStep nLin = max(line_cod, line_desc) self.canvas.setStrokeColor(gray) - self.hline(self.nLeft, nLin-2, self.width-self.nLeft) + self.hline(self.nLeft, nLin - 2, self.width - self.nLeft) self.canvas.setStrokeColor(black) self.nlin += nH + 3 @@ -708,13 +717,14 @@ obsCont[@xCampo='NomeVendedor']") self.nlin += 2 self.canvas.setFont('NimbusSanL-Bold', 6) - self.string(self.nLeft+1, self.nlin+1, 'DADOS ADICIONAIS') + self.string(self.nLeft + 1, self.nlin + 1, 'DADOS ADICIONAIS') self.canvas.setFont('NimbusSanL-Regu', 5) - self.string(self.nLeft+1, self.nlin+4, 'INFORMAÇÕES COMPLEMENTARES') - self.string((self.width/2)+1, self.nlin+4, 'RESERVADO AO FISCO') - self.rect(self.nLeft, self.nlin+2, - self.width-self.nLeft-self.nRight, 42) - self.vline(self.width/2, self.nlin+2, 42) + self.string(self.nLeft + 1, self.nlin + 4, + 'INFORMAÇÕES COMPLEMENTARES') + self.string((self.width / 2) + 1, self.nlin + 4, 'RESERVADO AO FISCO') + self.rect(self.nLeft, self.nlin + 2, + self.width - self.nLeft - self.nRight, 42) + self.vline(self.width / 2, self.nlin + 2, 42) # Conteúdo campos styles = getSampleStyleSheet() styleN = styles['Normal'] @@ -726,9 +736,9 @@ obsCont[@xCampo='NomeVendedor']") if fisco: observacoes = fisco + ' ' + observacoes P = Paragraph(observacoes, styles['Normal']) - w, h = P.wrap(92*mm, 32*mm) - altura = (self.height-self.nlin-5)*mm - P.drawOn(self.canvas, (self.nLeft+1)*mm, altura - h) + w, h = P.wrap(92 * mm, 32 * mm) + altura = (self.height - self.nlin - 5) * mm + P.drawOn(self.canvas, (self.nLeft + 1) * mm, altura - h) self.nlin += 36 def recibo_entrega(self, oXML=None): @@ -742,23 +752,25 @@ obsCont[@xCampo='NomeVendedor']") nH = 17 self.canvas.setLineWidth(.5) self.rect(self.nLeft, self.nlin, - self.width-(self.nLeft+self.nRight), nH) - self.hline(self.nLeft, self.nlin+8.5, self.width-self.nRight-nW) - self.vline(self.width-self.nRight-nW, self.nlin, nH) - self.vline(self.nLeft+nW, self.nlin+8.5, 8.5) + self.width - (self.nLeft + self.nRight), nH) + self.hline(self.nLeft, self.nlin + 8.5, self.width - self.nRight - nW) + self.vline(self.width - self.nRight - nW, self.nlin, nH) + self.vline(self.nLeft + nW, self.nlin + 8.5, 8.5) # Labels self.canvas.setFont('NimbusSanL-Regu', 5) - self.string(self.nLeft+1, self.nlin+10.2, 'DATA DE RECEBIMENTO') - self.string(self.nLeft+41, self.nlin+10.2, + self.string(self.nLeft + 1, self.nlin + 10.2, 'DATA DE RECEBIMENTO') + self.string(self.nLeft + 41, self.nlin + 10.2, 'IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR') - self.stringcenter(self.width-self.nRight-(nW/2), self.nlin+2, 'NF-e') + self.stringcenter(self.width - self.nRight - + (nW / 2), self.nlin + 2, 'NF-e') # Conteúdo campos self.canvas.setFont('NimbusSanL-Bold', 8) cNF = tagtext(oNode=el_ide, cTag='nNF') cNF = '{0:011,}'.format(int(cNF)).replace(",", ".") - self.string(self.width-self.nRight-nW+2, self.nlin+8, "Nº %s" % (cNF)) - self.string(self.width-self.nRight-nW+2, self.nlin+14, + self.string(self.width - self.nRight - nW + + 2, self.nlin + 8, "Nº %s" % (cNF)) + self.string(self.width - self.nRight - nW + 2, self.nlin + 14, u"SÉRIE %s" % (tagtext(oNode=el_ide, cTag='serie'))) cDt, cHr = getdateUTC(tagtext(oNode=el_ide, cTag='dhEmi')) @@ -785,12 +797,12 @@ obsCont[@xCampo='NomeVendedor']") styleN.leading = 7 P = Paragraph(cString, styleN) - w, h = P.wrap(149*mm, 7*mm) - P.drawOn(self.canvas, (self.nLeft+1)*mm, - ((self.height-self.nlin)*mm) - h) + w, h = P.wrap(149 * mm, 7 * mm) + P.drawOn(self.canvas, (self.nLeft + 1) * mm, + ((self.height - self.nlin) * mm) - h) self.nlin += 20 - self.hline(self.nLeft, self.nlin, self.width-self.nRight) + self.hline(self.nLeft, self.nlin, self.width - self.nRight) self.nlin += 2 def newpage(self): @@ -800,29 +812,29 @@ obsCont[@xCampo='NomeVendedor']") def hline(self, x, y, width): y = self.height - y - self.canvas.line(x*mm, y*mm, width*mm, y*mm) + self.canvas.line(x * mm, y * mm, width * mm, y * mm) def vline(self, x, y, width): width = self.height - y - width y = self.height - y - self.canvas.line(x*mm, y*mm, x*mm, width*mm) + self.canvas.line(x * mm, y * mm, x * mm, width * mm) def rect(self, col, lin, nWidth, nHeight, fill=False): lin = self.height - nHeight - lin - self.canvas.rect(col*mm, lin*mm, nWidth*mm, nHeight*mm, + self.canvas.rect(col * mm, lin * mm, nWidth * mm, nHeight * mm, stroke=True, fill=fill) def string(self, x, y, value): y = self.height - y - self.canvas.drawString(x*mm, y*mm, value) + self.canvas.drawString(x * mm, y * mm, value) def stringRight(self, x, y, value): y = self.height - y - self.canvas.drawRightString(x*mm, y*mm, value) + self.canvas.drawRightString(x * mm, y * mm, value) def stringcenter(self, x, y, value): y = self.height - y - self.canvas.drawCentredString(x*mm, y*mm, value) + self.canvas.drawCentredString(x * mm, y * mm, value) def writeto_pdf(self, fileObj): pdf_out = self.oPDF_IO.getvalue() From c1bde795a345fa9c4c5e4094bbb38f0b44f838f5 Mon Sep 17 00:00:00 2001 From: Johny Chen Jy <31947361+carcaroff@users.noreply.github.com> Date: Wed, 17 Jan 2018 12:51:38 -0200 Subject: [PATCH 11/13] Adicionado layout do CC-e (#89) * Adicionado layout do CCE --- pytrustnfe/nfe/danfe.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/pytrustnfe/nfe/danfe.py b/pytrustnfe/nfe/danfe.py index 61e391f..745694e 100644 --- a/pytrustnfe/nfe/danfe.py +++ b/pytrustnfe/nfe/danfe.py @@ -16,6 +16,7 @@ from reportlab.graphics.barcode import code128 from reportlab.lib.styles import getSampleStyleSheet from reportlab.lib.enums import TA_CENTER from reportlab.platypus import Paragraph, Image +from reportlab.lib.styles import ParagraphStyle def chunks(cString, nLen): @@ -73,7 +74,7 @@ def get_image(path, width=1 * cm): class danfe(object): def __init__(self, sizepage=A4, list_xml=None, recibo=True, - orientation='portrait', logo=None): + orientation='portrait', logo=None, cce_xml=None): self.width = 210 # 21 x 29,7cm self.height = 297 self.nLeft = 10 @@ -169,7 +170,10 @@ class danfe(object): list_cod_prod=list_cod_prod) self.newpage() - + if cce_xml: + for xml in cce_xml: + self._generate_cce(cce_xml=xml, oXML=oXML) + self.newpage() self.canvas.save() def ide_emit(self, oXML=None): @@ -840,3 +844,82 @@ obsCont[@xCampo='NomeVendedor']") pdf_out = self.oPDF_IO.getvalue() self.oPDF_IO.close() fileObj.write(pdf_out) + + def _generate_cce(self, cce_xml=None, oXML=None): + self.canvas.setLineWidth(.2) + + # labels + self.canvas.setFont('NimbusSanL-Bold', 12) + self.stringcenter(105, 10, u"Carta de Correção") + self.canvas.setFont('NimbusSanL-Regu', 6) + self.string(10, 18, u"RAZÃO SOCIAL DO EMITENTE") + self.string(10, 24, u"CNPJ DO EMITENTE") + self.string(10, 30, u"CHAVE DE ACESSO DA NF-E") + self.string(10, 36, u"DATA DA CORREÇÃO") + self.string(10, 42, u"ID") + self.stringcenter(105, 48, u"CORREÇÃO") + + # lines + self.hline(9, 14, 200) + self.hline(9, 20, 200) + self.hline(9, 26, 200) + self.hline(9, 32, 200) + self.hline(9, 38, 200) + self.hline(9, 44, 200) + self.hline(9, 50, 200) + + # values + infNFe = oXML.find( + ".//{http://www.portalfiscal.inf.br/nfe}infNFe") + res_partner = infNFe.find( + ".//{http://www.portalfiscal.inf.br/nfe}xNome") + + elem_infNFe = cce_xml.find( + ".//{http://www.portalfiscal.inf.br/nfe}infEvento") + + res_partner = tagtext(oNode=infNFe, cTag='xNome') + self.string(82, 18, res_partner) + cnpj = format_cnpj_cpf(tagtext + (oNode=elem_infNFe, cTag='CNPJ')) + self.string(82, 24, cnpj) + chave_acesso = tagtext(oNode=elem_infNFe, cTag='chNFe') + self.string(82, 30, chave_acesso) + data_correcao = getdateUTC(tagtext( + oNode=elem_infNFe, cTag='dhEvento')) + data_correcao = data_correcao[0] + " " + data_correcao[1] + self.string(82, 36, data_correcao) + cce_id = elem_infNFe.values()[0] + self.string(82, 42, cce_id) + + correcao = tagtext(oNode=elem_infNFe, cTag='xCorrecao') + + w, h, paragraph = self._paragraph( + correcao, 'NimbusSanL-Regu', 10, 190*mm, 20*mm) + paragraph.drawOn(self.canvas, 10*mm, (297-52)*mm - h) + + self.hline(9, 54+(h/mm), 200) + self.stringcenter(105, 58+(h/mm), u"CONDIÇÃO DE USO") + self.hline(9, 60+(h/mm), 200) + + condicoes = tagtext(oNode=elem_infNFe, cTag='xCondUso') + + w2, h2, paragraph = self._paragraph( + condicoes, 'NimbusSanL-Regu', 10, 190*mm, 20*mm) + paragraph.drawOn(self.canvas, 10*mm, (297-62)*mm-h-h2) + + self.hline(9, 68+((h+h2)/mm), 200) + + self.vline(80, 14, 30) + self.vline(9, 14, 54+((h+h2)/mm)) + self.vline(200, 14, 54+((h+h2)/mm)) + + def _paragraph(self, text, font, font_size, x, y): + ptext = '%s' % (font_size, text) + style = ParagraphStyle(name='Normal', + fontName=font, + fontSize=font_size, + ) + paragraph = Paragraph(ptext, style=style) + w, h = paragraph.wrapOn(self.canvas, x, y) + return w, h, paragraph + From 33d23217240f39c3f5f97d3aeae044a0955ab97a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Luna?= Date: Thu, 18 Jan 2018 15:32:09 -0200 Subject: [PATCH 12/13] =?UTF-8?q?Altera=20m=C3=A9todo=20de=20formata=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20n=C3=BAmeros=20na=20dande=20para=20somente=20tro?= =?UTF-8?q?car=20pontos=20por=20virgulas,=20imprimindo=20assim=20o=20conte?= =?UTF-8?q?=C3=BAdo=20identico=20ao=20que=20foi=20recebido=20no=20xml.=20A?= =?UTF-8?q?ltera=20posi=C3=A7=C3=A3o=20das=20colunas=20de=20quantidade=20e?= =?UTF-8?q?=20valor=20unit=C3=A1rio=20na=20danfe,=20para=20adequar=20al=20?= =?UTF-8?q?n=C3=BAmero=20de=20casas=20decimais=20do=20mesmos.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + pytrustnfe/nfe/danfe.py | 90 ++++++++++++++++++++++--------------------------- 2 files changed, 41 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 7f2aa80..f171cd6 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ dist/ *egg*/ docs/_build .vscode/tags +.cache/ diff --git a/pytrustnfe/nfe/danfe.py b/pytrustnfe/nfe/danfe.py index 745694e..c1fb83c 100644 --- a/pytrustnfe/nfe/danfe.py +++ b/pytrustnfe/nfe/danfe.py @@ -40,11 +40,9 @@ def getdateUTC(cDateUTC): return '/'.join(cDt), cDateUTC[11:16] -def format_number(cNumber, precision=0, group_sep='.', decimal_sep=','): +def format_number(cNumber): if cNumber: - number = float(cNumber) - return ("{:,." + str(precision) + "f}").format(number).\ - replace(",", "X").replace(".", ",").replace("X", ".") + return cNumber.replace(",", "X").replace(".", ",").replace("X", ".") return "" @@ -417,8 +415,7 @@ class danfe(object): self.string(self.nLeft + nCol + 17, self.nlin + nLin, cDt) self.stringRight( self.nLeft + nCol + 47, self.nlin + nLin, - format_number(tagtext(oNode=oXML_dup, cTag='vDup'), - precision=2)) + format_number(tagtext(oNode=oXML_dup, cTag='vDup'))) if nPar == 3: nLin = 7 @@ -486,41 +483,40 @@ obsCont[@xCampo='NomeVendedor']") self.canvas.setFont('NimbusSanL-Regu', 8) self.stringRight( self.nLeft + 34, self.nlin + 7.7, - format_number(tagtext(oNode=el_total, cTag='vBC'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vBC'))) self.stringRight( self.nLeft + 64, self.nlin + 7.7, - format_number(tagtext(oNode=el_total, cTag='vICMS'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vICMS'))) self.stringRight( self.nLeft + 94, self.nlin + 7.7, - format_number(tagtext(oNode=el_total, cTag='vBCST'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vBCST'))) self.stringRight( nMr - 66, self.nlin + 7.7, - format_number(tagtext(oNode=el_total, cTag='vST'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vST'))) self.stringRight( nMr - 36, self.nlin + 7.7, - format_number(tagtext(oNode=el_total, cTag='vTotTrib'), - precision=2)) + format_number(tagtext(oNode=el_total, cTag='vTotTrib'))) self.stringRight( nMr - 1, self.nlin + 7.7, - format_number(tagtext(oNode=el_total, cTag='vProd'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vProd'))) self.stringRight( self.nLeft + 34, self.nlin + 14.1, - format_number(tagtext(oNode=el_total, cTag='vFrete'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vFrete'))) self.stringRight( self.nLeft + 64, self.nlin + 14.1, - format_number(tagtext(oNode=el_total, cTag='vSeg'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vSeg'))) self.stringRight( self.nLeft + 94, self.nlin + 14.1, - format_number(tagtext(oNode=el_total, cTag='vDesc'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vDesc'))) self.stringRight( self.nLeft + 124, self.nlin + 14.1, - format_number(tagtext(oNode=el_total, cTag='vOutro'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vOutro'))) self.stringRight( self.nLeft + 154, self.nlin + 14.1, - format_number(tagtext(oNode=el_total, cTag='vIPI'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vIPI'))) self.stringRight( nMr - 1, self.nlin + 14.1, - format_number(tagtext(oNode=el_total, cTag='vNF'), precision=2)) + format_number(tagtext(oNode=el_total, cTag='vNF'))) self.nlin += 17 # Nr linhas ocupadas pelo bloco @@ -589,10 +585,10 @@ obsCont[@xCampo='NomeVendedor']") tagtext(oNode=el_transp, cTag='nVol')) self.stringRight( nMr - 27, self.nlin + 21.2, - format_number(tagtext(oNode=el_transp, cTag='pesoB'), precision=3)) + format_number(tagtext(oNode=el_transp, cTag='pesoB'))) self.stringRight( nMr - 1, self.nlin + 21.2, - format_number(tagtext(oNode=el_transp, cTag='pesoL'), precision=3)) + format_number(tagtext(oNode=el_transp, cTag='pesoL'))) self.nlin += 23 @@ -628,10 +624,10 @@ obsCont[@xCampo='NomeVendedor']") self.stringcenter(nMr - 44, self.nlin + 5.5, 'BC ICMS') self.vline(nMr - 64, self.nlin + 2, nH) self.stringcenter(nMr - 57, self.nlin + 5.5, 'VLR TOTAL') - self.vline(nMr - 77, self.nlin + 2, nH) + self.vline(nMr - 78, self.nlin + 2, nH) self.stringcenter(nMr - 70.5, self.nlin + 5.5, 'VLR UNIT') self.vline(nMr - 90, self.nlin + 2, nH) - self.stringcenter(nMr - 83.5, self.nlin + 5.5, 'QTD') + self.stringcenter(nMr - 83.8, self.nlin + 5.5, 'QTD') self.vline(nMr - 96, self.nlin + 2, nH) self.stringcenter(nMr - 93, self.nlin + 5.5, 'UNID') self.vline(nMr - 102, self.nlin + 2, nH) @@ -677,24 +673,20 @@ obsCont[@xCampo='NomeVendedor']") tagtext(oNode=el_prod, cTag='CFOP')) self.stringcenter(nMr - 93, nLin, tagtext(oNode=el_prod, cTag='uCom')) - self.stringRight(nMr - 77.5, nLin, format_number( - tagtext(oNode=el_prod, cTag='qCom'), precision=4)) + self.stringRight(nMr - 78.5, nLin, format_number( + tagtext(oNode=el_prod, cTag='qCom'))) self.stringRight(nMr - 64.5, nLin, format_number( - tagtext(oNode=el_prod, cTag='vUnCom'), precision=2)) - self.stringRight(nMr - 50.5, nLin, format_number( - tagtext(oNode=el_prod, cTag='vProd'), precision=2)) - self.stringRight(nMr - 38.5, nLin, format_number(vBC, precision=2)) - self.stringRight(nMr - 26.5, nLin, - format_number(vICMS, precision=2)) - self.stringRight( - nMr - 7.5, nLin, format_number(pICMS, precision=2)) + tagtext(oNode=el_prod, cTag='vUnCom'))) + self.stringRight(nMr - 50.5, nLin, + tagtext(oNode=el_prod, cTag='vProd')) + self.stringRight(nMr - 38.5, nLin, format_number(vBC)) + self.stringRight(nMr - 26.5, nLin, format_number(vICMS)) + self.stringRight(nMr - 7.5, nLin, format_number(pICMS)) if vIPI: - self.stringRight(nMr - 14.5, nLin, - format_number(vIPI, precision=2)) + self.stringRight(nMr - 14.5, nLin, format_number(vIPI)) if pIPI: - self.stringRight(nMr - 0.5, nLin, - format_number(pIPI, precision=2)) + self.stringRight(nMr - 0.5, nLin, format_number(pIPI)) # Código Item line_cod = nLin @@ -778,8 +770,7 @@ obsCont[@xCampo='NomeVendedor']") u"SÉRIE %s" % (tagtext(oNode=el_ide, cTag='serie'))) cDt, cHr = getdateUTC(tagtext(oNode=el_ide, cTag='dhEmi')) - cTotal = format_number(tagtext(oNode=el_total, cTag='vNF'), - precision=2) + cTotal = format_number(tagtext(oNode=el_total, cTag='vNF')) cEnd = tagtext(oNode=el_dest, cTag='xNome') + ' - ' cEnd += tagtext(oNode=el_dest, cTag='xLgr') + ', ' + tagtext( @@ -894,24 +885,24 @@ obsCont[@xCampo='NomeVendedor']") correcao = tagtext(oNode=elem_infNFe, cTag='xCorrecao') w, h, paragraph = self._paragraph( - correcao, 'NimbusSanL-Regu', 10, 190*mm, 20*mm) - paragraph.drawOn(self.canvas, 10*mm, (297-52)*mm - h) + correcao, 'NimbusSanL-Regu', 10, 190 * mm, 20 * mm) + paragraph.drawOn(self.canvas, 10 * mm, (297 - 52) * mm - h) - self.hline(9, 54+(h/mm), 200) - self.stringcenter(105, 58+(h/mm), u"CONDIÇÃO DE USO") - self.hline(9, 60+(h/mm), 200) + self.hline(9, 54 + (h / mm), 200) + self.stringcenter(105, 58 + (h / mm), u"CONDIÇÃO DE USO") + self.hline(9, 60 + (h / mm), 200) condicoes = tagtext(oNode=elem_infNFe, cTag='xCondUso') w2, h2, paragraph = self._paragraph( - condicoes, 'NimbusSanL-Regu', 10, 190*mm, 20*mm) - paragraph.drawOn(self.canvas, 10*mm, (297-62)*mm-h-h2) + condicoes, 'NimbusSanL-Regu', 10, 190 * mm, 20 * mm) + paragraph.drawOn(self.canvas, 10 * mm, (297 - 62) * mm - h - h2) - self.hline(9, 68+((h+h2)/mm), 200) + self.hline(9, 68 + ((h + h2) / mm), 200) self.vline(80, 14, 30) - self.vline(9, 14, 54+((h+h2)/mm)) - self.vline(200, 14, 54+((h+h2)/mm)) + self.vline(9, 14, 54 + ((h + h2) / mm)) + self.vline(200, 14, 54 + ((h + h2) / mm)) def _paragraph(self, text, font, font_size, x, y): ptext = '%s' % (font_size, text) @@ -922,4 +913,3 @@ obsCont[@xCampo='NomeVendedor']") paragraph = Paragraph(ptext, style=style) w, h = paragraph.wrapOn(self.canvas, x, y) return w, h, paragraph - From 48991849b658460a126a9144faf0742899c838b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Luna?= Date: Thu, 18 Jan 2018 16:00:39 -0200 Subject: [PATCH 13/13] =?UTF-8?q?Incrementa=20vers=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2964952..2b186be 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # coding=utf-8 from setuptools import setup, find_packages -VERSION = "0.1.43" +VERSION = "0.1.44" setup( name="PyTrustNFe",