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

Ajuste tag cInt como opcional e formatação vCarga #243

Merged
merged 3 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 5 additions & 3 deletions pynfe/processamento/serializacao.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,8 @@ def _serializar_modal_rodoviario(self, modal_rodoviario, tag_raiz='infModal', re

for num, item in enumerate(modal_rodoviario.veiculo_tracao):
veicTracao = etree.SubElement(rodo, 'veicTracao')
etree.SubElement(veicTracao, 'cInt').text = item.cInt
if item.cInt:
etree.SubElement(veicTracao, 'cInt').text = item.cInt
etree.SubElement(veicTracao, 'placa').text = item.placa
if item.RENAVAM:
etree.SubElement(veicTracao, 'RENAVAM').text = item.RENAVAM
Expand Down Expand Up @@ -1546,7 +1547,8 @@ def _serializar_modal_rodoviario(self, modal_rodoviario, tag_raiz='infModal', re
if modal_rodoviario.veiculo_reboque != None:
for num, item_reboque in enumerate(modal_rodoviario.veiculo_reboque):
veicReboque = etree.SubElement(rodo, 'veicReboque')
etree.SubElement(veicReboque, 'cInt').text = item_reboque.cInt
if item_reboque.cInt:
etree.SubElement(veicReboque, 'cInt').text = item_reboque.cInt
etree.SubElement(veicReboque, 'placa').text = item_reboque.placa
if item_reboque.RENAVAM:
etree.SubElement(veicReboque, 'RENAVAM').text = item_reboque.RENAVAM
Expand Down Expand Up @@ -1649,7 +1651,7 @@ def _serializar_totais(self, totais, tag_raiz='tot', retorna_string=True):
elif totais.qNFe > 0:
etree.SubElement(raiz, 'qNFe').text = str(totais.qNFe)

etree.SubElement(raiz, 'vCarga').text = str(totais.vCarga)
etree.SubElement(raiz, 'vCarga').text = str('{:.2f}').format(totais.vCarga or 0)
if totais.cUnid == 'KG':
etree.SubElement(raiz, 'cUnid').text = '01'
elif totais.cUnid == 'TON':
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mdfe_serializacao.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def grupo_totais(self):
qCarga = self.xml_assinado.xpath('//ns:infMDFe/ns:tot/ns:qCarga', namespaces=self.ns)[0].text

self.assertEqual(qNFe, '2')
self.assertEqual(vCarga, '1000')
self.assertEqual(vCarga, str('{:.2f}').format('1000'))
self.assertEqual(cUnid, '01')
self.assertEqual(qCarga, '5000.0000')

Expand Down