Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - Adicionando tag EAN apenas quando a mesma não existir #20

Merged
merged 1 commit into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pytrustnfe/nfe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ def _add_required_node(elemTree):

prods = elemTree.findall('ns:NFe/ns:infNFe/ns:det/ns:prod', namespaces=ns)
for prod in prods:
cEan = etree.Element('cEAN')
cEANTrib = etree.Element('cEANTrib')
prod.insert(1, cEan)
vProd = prod.find('ns:vProd', namespaces=ns)
prod.insert(prod.index(vProd) + 1, cEANTrib)
element = prod.find('ns:cEAN', namespaces=ns)
if element is None:
cEan = etree.Element('cEAN')
prod.insert(1, cEan)
element = prod.find('ns:cEANTrib', namespaces=ns)
if element is None:
cEANTrib = etree.Element('cEANTrib')
vProd = prod.find('ns:vProd', namespaces=ns)
prod.insert(prod.index(vProd) + 1, cEANTrib)
return elemTree


Expand Down
3 changes: 2 additions & 1 deletion pytrustnfe/nfe/assinatura.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def assina_xml(self, xml_element, reference):
element_signed = signed_root.find(".//*[@Id='%s']" % reference)
signature = signed_root.find(
".//{http://www.w3.org/2000/09/xmldsig#}Signature")
if element_signed and signature:

if element_signed is not None and signature is not None:
parent = element_signed.getparent()
parent.append(signature)
return etree.tostring(signed_root)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
from setuptools import setup, find_packages

VERSION = "0.1.18"
VERSION = "0.1.19"

setup(
name="PyTrustNFe",
Expand Down