Skip to content

Commit

Permalink
Merge a0f8cdf into f221e8e
Browse files Browse the repository at this point in the history
  • Loading branch information
danimaribeiro committed Jan 7, 2017
2 parents f221e8e + a0f8cdf commit 8d488c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
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

0 comments on commit 8d488c3

Please sign in to comment.