Browse Source

[FIX]

pull/88/head
carcaroff 8 years ago
committed by Danimar Ribeiro
parent
commit
f42937ae5f
  1. 35
      pytrustnfe/nfe/danfe.py

35
pytrustnfe/nfe/danfe.py

@ -72,6 +72,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):
@ -189,7 +190,8 @@ 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)
@ -223,7 +225,8 @@ class danfe(object):
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 +
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)
@ -352,8 +355,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'))
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)
cDt, cHr = getdateUTC(tagtext(oNode=elem_ide, cTag='dhEmi'))
@ -643,7 +648,8 @@ obsCont[@xCampo='NomeVendedor']")
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.stringcenter(nCol_, self.nlin + 5.5,
'DESCRIÇÃO DO PRODUTO/SERVIÇO')
# Conteúdo campos
self.canvas.setFont('NimbusSanL-Regu', 5)
@ -661,7 +667,8 @@ obsCont[@xCampo='NomeVendedor']")
".//{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')
@ -683,8 +690,10 @@ obsCont[@xCampo='NomeVendedor']")
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 - 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,
@ -720,7 +729,8 @@ obsCont[@xCampo='NomeVendedor']")
self.canvas.setFont('NimbusSanL-Bold', 6)
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.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)
@ -763,12 +773,14 @@ obsCont[@xCampo='NomeVendedor']")
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, "%s" % (cNF))
self.string(self.width - self.nRight - nW +
2, self.nlin + 8, "%s" % (cNF))
self.string(self.width - self.nRight - nW + 2, self.nlin + 14,
"SÉRIE %s" % (tagtext(oNode=el_ide, cTag='serie')))
@ -839,3 +851,4 @@ obsCont[@xCampo='NomeVendedor']")
pdf_out = self.oPDF_IO.getvalue()
self.oPDF_IO.close()
fileObj.write(pdf_out)
Loading…
Cancel
Save