Browse Source

Merge b02e2dba4b into b7ccf244d7

pull/44/merge
Marcelo Salhab Brogliato 5 years ago
committed by GitHub
parent
commit
313b8ac139
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 986
      pynfe/danfe/__init__.py
  2. 97
      pynfe/danfe/fonts/LICENSE-Gentium
  3. BIN
      pynfe/danfe/fonts/NimbusSanL Bold.ttf
  4. BIN
      pynfe/danfe/fonts/NimbusSanL Regular.ttf
  5. BIN
      pynfe/danfe/fonts/genbkbasb.ttf
  6. BIN
      pynfe/danfe/fonts/genbkbasbi.ttf
  7. BIN
      pynfe/danfe/fonts/genbkbasi.ttf
  8. BIN
      pynfe/danfe/fonts/genbkbasr.ttf
  9. 9
      pynfe/data/XSDs/consReciNFe_v4.00.xsd
  10. 9
      pynfe/data/XSDs/consSitNFe_v4.00.xsd
  11. 9
      pynfe/data/XSDs/consStatServ_v4.00.xsd
  12. 9
      pynfe/data/XSDs/enviNFe_v4.00.xsd
  13. 9
      pynfe/data/XSDs/inutNFe_v4.00.xsd
  14. 502
      pynfe/data/XSDs/leiauteConsSitNFe_v4.00.xsd
  15. 98
      pynfe/data/XSDs/leiauteConsStatServ_v4.00.xsd
  16. 193
      pynfe/data/XSDs/leiauteInutNFe_v4.00.xsd
  17. 6480
      pynfe/data/XSDs/leiauteNFe_v4.00.xsd
  18. 9
      pynfe/data/XSDs/nfe_v4.00.xsd
  19. 9
      pynfe/data/XSDs/procInutNFe_v4.00.xsd
  20. 9
      pynfe/data/XSDs/procNFe_v4.00.xsd
  21. 9
      pynfe/data/XSDs/retConsReciNFe_v4.00.xsd
  22. 9
      pynfe/data/XSDs/retConsSitNFe_v4.00.xsd
  23. 9
      pynfe/data/XSDs/retConsStatServ_v4.00.xsd
  24. 9
      pynfe/data/XSDs/retEnviNFe_v4.00.xsd
  25. 9
      pynfe/data/XSDs/retInutNFe_v4.00.xsd
  26. 589
      pynfe/data/XSDs/tiposBasico_v4.00.xsd
  27. 3
      pynfe/entidades/fonte_dados.py
  28. 2
      pynfe/entidades/servico.py
  29. 1
      pynfe/processamento/comunicacao.py
  30. 14
      pynfe/processamento/serializacao.py
  31. 5
      pynfe/processamento/validacao.py
  32. 3
      pynfe/utils/__init__.py
  33. 1
      pynfe/utils/webservices.py
  34. 2
      setup.py

986
pynfe/danfe/__init__.py

@ -0,0 +1,986 @@
# -*- coding: utf-8 -*-
# © 2017 Edson Bernardino, ITK Soft
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# Classe para geração de PDF da DANFE a partir de xml etree.fromstring
import os
from io import BytesIO
from textwrap import wrap
from reportlab.lib import utils
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm, cm
from reportlab.lib.pagesizes import A4
from reportlab.lib.colors import black, gray
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
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import pytz
from datetime import datetime, timedelta
def chunks(cString, nLen):
for start in range(0, len(cString), nLen):
yield cString[start:start + nLen]
def format_cnpj_cpf(value):
if len(value) < 12: # CPF
cValue = '%s.%s.%s-%s' % (value[:-8], value[-8:-5],
value[-5:-2], value[-2:])
else:
cValue = '%s.%s.%s/%s-%s' % (value[:-12], value[-12:-9],
value[-9:-6], value[-6:-2], value[-2:])
return cValue
def getdateByTimezone(cDateUTC, timezone=None):
'''
Esse método trata a data recebida de acordo com o timezone do
usuário. O seu retorno é dividido em duas partes:
1) A data em si;
2) As horas;
:param cDateUTC: string contendo as informações da data
:param timezone: timezone do usuário do sistema
:return: data e hora convertidos para a timezone do usuário
'''
# Aqui cortamos a informação do timezone da string (+03:00)
dt = cDateUTC[0:19]
# Verificamos se a string está completa (data + hora + timezone)
if timezone and len(cDateUTC) == 25:
# tz irá conter informações da timezone contida em cDateUTC
tz = cDateUTC[19:25]
tz = int(tz.split(':')[0])
dt = datetime.strptime(dt, '%Y-%m-%dT%H:%M:%S')
# dt agora será convertido para o horario em UTC
dt = dt - timedelta(hours=tz)
# tzinfo passará a apontar para <UTC>
dt = pytz.utc.localize(dt)
# valor de dt é convertido para a timezone do usuário
dt = timezone.normalize(dt)
dt = dt.strftime('%Y-%m-%dT%H:%M:%S')
cDt = dt[0:10].split('-')
cDt.reverse()
return '/'.join(cDt), dt[11:16]
def format_number(cNumber):
if cNumber:
return cNumber.replace(",", "X").replace(".", ",").replace("X", ".")
return ""
def tagtext(oNode=None, cTag=None):
try:
xpath = ".//{http://www.portalfiscal.inf.br/nfe}%s" % (cTag)
cText = oNode.find(xpath).text
except:
cText = ''
return cText
REGIME_TRIBUTACAO = {
'1': 'Simples Nacional',
'2': 'Simples Nacional, excesso sublimite de receita bruta',
'3': 'Regime Normal'
}
def get_image(path, width=1 * cm):
img = utils.ImageReader(path)
iw, ih = img.getSize()
aspect = ih / float(iw)
return Image(path, width=width, height=(width * aspect))
class DANFE(object):
def __init__(self, sizepage=A4, list_xml=None, recibo=True,
orientation='portrait', logo=None, cce_xml=None,
timezone=None):
path = os.path.join(os.path.dirname(__file__), 'fonts')
pdfmetrics.registerFont(
TTFont('NimbusSanL-Regu',
os.path.join(path, 'NimbusSanL Regular.ttf')))
pdfmetrics.registerFont(
TTFont('NimbusSanL-Bold',
os.path.join(path, 'NimbusSanL Bold.ttf')))
self.width = 210 # 21 x 29,7cm
self.height = 297
self.nLeft = 10
self.nRight = 10
self.nTop = 7
self.nBottom = 8
self.nlin = self.nTop
self.logo = logo
self.oFrete = {'0': '0 - Emitente',
'1': '1 - Destinatário',
'2': '2 - Terceiros',
'9': '9 - Sem Frete'}
self.oPDF_IO = BytesIO()
if orientation == 'landscape':
raise NameError('Rotina não implementada')
else:
size = sizepage
self.canvas = canvas.Canvas(self.oPDF_IO, pagesize=size)
self.canvas.setTitle('DANFE')
self.canvas.setStrokeColor(black)
for oXML in list_xml:
oXML_cobr = oXML.find(
".//{http://www.portalfiscal.inf.br/nfe}cobr")
self.NrPages = 1
self.Page = 1
# Calculando total linhas usadas para descrições dos itens
# Com bloco fatura, apenas 25 linhas para itens na primeira folha
nNr_Lin_Pg_1 = 30 if oXML_cobr is None else 26
# [ rec_ini , rec_fim , lines , limit_lines ]
oPaginator = [[0, 0, 0, nNr_Lin_Pg_1]]
el_det = oXML.findall(".//{http://www.portalfiscal.inf.br/nfe}det")
if el_det is not None:
list_desc = []
list_cod_prod = []
nPg = 0
for nId, item in enumerate(el_det):
el_prod = item.find(
".//{http://www.portalfiscal.inf.br/nfe}prod")
infAdProd = item.find(
".//{http://www.portalfiscal.inf.br/nfe}infAdProd")
list_ = wrap(tagtext(oNode=el_prod, cTag='xProd'), 56)
if infAdProd is not None:
list_.extend(wrap(infAdProd.text, 56))
list_desc.append(list_)
list_cProd = wrap(tagtext(oNode=el_prod, cTag='cProd'), 14)
list_cod_prod.append(list_cProd)
# Nr linhas necessárias p/ descrição item
nLin_Itens = len(list_)
if (oPaginator[nPg][2] + nLin_Itens) >= oPaginator[nPg][3]:
oPaginator.append([0, 0, 0, 77])
nPg += 1
oPaginator[nPg][0] = nId
oPaginator[nPg][1] = nId + 1
oPaginator[nPg][2] = nLin_Itens
else:
# adiciona-se 1 pelo funcionamento de xrange
oPaginator[nPg][1] = nId + 1
oPaginator[nPg][2] += nLin_Itens
self.NrPages = len(oPaginator) # Calculando nr. páginas
if recibo:
self.recibo_entrega(oXML=oXML, timezone=timezone)
self.ide_emit(oXML=oXML, timezone=timezone)
self.destinatario(oXML=oXML, timezone=timezone)
if oXML_cobr is not None:
self.faturas(oXML=oXML_cobr, timezone=timezone)
self.impostos(oXML=oXML)
self.transportes(oXML=oXML)
self.produtos(oXML=oXML, el_det=el_det, oPaginator=oPaginator[0],
list_desc=list_desc, list_cod_prod=list_cod_prod)
self.adicionais(oXML=oXML)
# Gera o restante das páginas do XML
for oPag in oPaginator[1:]:
self.newpage()
self.ide_emit(oXML=oXML, timezone=timezone)
self.produtos(oXML=oXML, el_det=el_det, oPaginator=oPag,
list_desc=list_desc, nHeight=77,
list_cod_prod=list_cod_prod)
self.newpage()
if cce_xml:
for xml in cce_xml:
self._generate_cce(cce_xml=xml, oXML=oXML, timezone=timezone)
self.newpage()
self.canvas.save()
def ide_emit(self, oXML=None, timezone=None):
elem_infNFe = oXML.find(
".//{http://www.portalfiscal.inf.br/nfe}infNFe")
elem_protNFe = oXML.find(
".//{http://www.portalfiscal.inf.br/nfe}protNFe")
elem_emit = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}emit")
elem_ide = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}ide")
elem_evento = oXML.find(
".//{http://www.portalfiscal.inf.br/nfe}infEvento")
cChave = elem_infNFe.attrib.get('Id')[3:]
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.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, 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,
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, "%s" % (cNF))
self.stringcenter(self.nLeft + 100, self.nlin + 29, "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.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.stringcenter(
self.nLeft + 152, self.nlin + 25,
'Consulta de autenticidade no portal nacional da NF-e')
self.stringcenter(
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 + 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,
'INSCRIÇÃO ESTADUAL DO SUBST. TRIB.')
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)
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,
' '.join(chunks(cChave, 4))) # Chave
self.canvas.setFont('NimbusSanL-Regu', 8)
cDt, cHr = getdateByTimezone(
tagtext(oNode=elem_protNFe, cTag='dhRecbto'), timezone)
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)
self.canvas.setFont('NimbusSanL-Regu', 8)
self.string(self.nLeft + 1, self.nlin + 38.7,
tagtext(oNode=elem_ide, cTag='natOp'))
self.string(self.nLeft + 1, self.nlin + 46,
tagtext(oNode=elem_emit, cTag='IE'))
self.string(self.nLeft + 101, self.nlin + 46,
format_cnpj_cpf(tagtext(oNode=elem_emit, cTag='CNPJ')))
styles = getSampleStyleSheet()
styleN = styles['Normal']
styleN.fontSize = 10
styleN.fontName = 'NimbusSanL-Bold'
styleN.alignment = TA_CENTER
# Razão Social emitente
P = Paragraph(tagtext(oNode=elem_emit, cTag='xNome'), styleN)
w, h = P.wrap(55 * mm, 40 * mm)
P.drawOn(self.canvas, (self.nLeft + 30) * mm,
(self.height - self.nlin - ((4.3*h + 12)/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)
cEnd = tagtext(oNode=elem_emit, cTag='xLgr') + ', ' + tagtext(
oNode=elem_emit, cTag='nro') + ' - '
cEnd += tagtext(oNode=elem_emit, cTag='xBairro') + '<br />' + tagtext(
oNode=elem_emit, cTag='xMun') + ' - '
cEnd += 'Fone: ' + tagtext(oNode=elem_emit, cTag='fone') + '<br />'
cEnd += tagtext(oNode=elem_emit, cTag='UF') + ' - ' + tagtext(
oNode=elem_emit, cTag='CEP')
regime = tagtext(oNode=elem_emit, cTag='CRT')
cEnd += '<br />Regime Tributário: %s' % (REGIME_TRIBUTACAO[regime])
styleN.fontName = 'NimbusSanL-Regu'
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 - 33) * mm)
# Homologação
if tagtext(oNode=elem_ide, cTag='tpAmb') == '2':
self.canvas.saveState()
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.canvas.restoreState()
# Cancelado
if tagtext(oNode=elem_evento, cTag='cStat') == '135':
self.canvas.saveState()
self.canvas.rotate(45)
self.canvas.setFont('NimbusSanL-Bold', 60)
self.canvas.setFillColorRGB(1, 0.2, 0.2)
self.string(self.nLeft + 80, 275, 'CANCELADO')
self.canvas.restoreState()
self.nlin += 48
def destinatario(self, oXML=None, timezone=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
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)
# 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')
# Conteúdo campos
self.canvas.setFont('NimbusSanL-Regu', 8)
self.string(self.nLeft + 1, self.nlin + 7.5,
tagtext(oNode=elem_dest, cTag='xNome'))
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 = getdateByTimezone(tagtext(oNode=elem_ide, cTag='dhEmi'),
timezone)
self.string(nMr - 24, self.nlin + 7.7, cDt + ' ' + cHr)
cDt, cHr = getdateByTimezone(
tagtext(oNode=elem_ide, cTag='dhSaiEnt'), timezone)
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,
tagtext(oNode=elem_dest, cTag='xBairro'))
self.string(nMr - 52, self.nlin + 14.3,
tagtext(oNode=elem_dest, cTag='CEP'))
self.string(self.nLeft + 1, self.nlin + 21.1,
tagtext(oNode=elem_dest, cTag='xMun'))
self.string(nMr - 135, self.nlin + 21.1,
tagtext(oNode=elem_dest, cTag='fone'))
self.string(nMr - 101, self.nlin + 21.1,
tagtext(oNode=elem_dest, cTag='UF'))
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, timezone=None):
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)
# 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,
'FATURA VENCIMENTO VALOR')
self.string(nMr - 140.5, self.nlin + 3.8,
'FATURA VENCIMENTO VALOR')
self.string(self.nLeft + 2, self.nlin + 3.8,
'FATURA VENCIMENTO VALOR')
# Conteúdo campos
self.canvas.setFont('NimbusSanL-Bold', 6)
nLin = 7
nPar = 1
nCol = 0
nAju = 0
line_iter = iter(oXML[1:10]) # Salta elemt 1 e considera os próximos 9
for oXML_dup in line_iter:
cDt, cHr = getdateByTimezone(tagtext(oNode=oXML_dup, cTag='dVenc'),
timezone)
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.stringRight(
self.nLeft + nCol + 47, self.nlin + nLin,
format_number(tagtext(oNode=oXML_dup, cTag='vDup')))
if nPar == 3:
nLin = 7
nPar = 1
nCol += 47
nAju += 1
nCol += nAju * (0.3)
else:
nLin += 3.3
nPar += 1
# Campos adicionais XML - Condicionados a existencia de financeiro
elem_infAdic = oXML.getparent().find(
".//{http://www.portalfiscal.inf.br/nfe}infAdic")
if elem_infAdic is not None:
codvend = elem_infAdic.find(
".//{http://www.portalfiscal.inf.br/nfe}obsCont\
[@xCampo='CodVendedor']")
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,
tagtext(oNode=vend, cTag='xTexto')[:36])
self.nlin += 16 # Nr linhas ocupadas pelo bloco
def impostos(self, oXML=None):
# Impostos
el_total = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}total")
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)
# 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')
# Conteúdo campos
self.canvas.setFont('NimbusSanL-Regu', 8)
self.stringRight(
self.nLeft + 34, self.nlin + 7.7,
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')))
self.stringRight(
self.nLeft + 94, self.nlin + 7.7,
format_number(tagtext(oNode=el_total, cTag='vBCST')))
self.stringRight(
nMr - 66, self.nlin + 7.7,
format_number(tagtext(oNode=el_total, cTag='vST')))
self.stringRight(
nMr - 36, self.nlin + 7.7,
format_number(tagtext(oNode=el_total, cTag='vTotTrib')))
self.stringRight(
nMr - 1, self.nlin + 7.7,
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')))
self.stringRight(
self.nLeft + 64, self.nlin + 14.1,
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')))
self.stringRight(
self.nLeft + 124, self.nlin + 14.1,
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')))
self.stringRight(
nMr - 1, self.nlin + 14.1,
format_number(tagtext(oNode=el_total, cTag='vNF')))
self.nlin += 17 # Nr linhas ocupadas pelo bloco
def transportes(self, oXML=None):
el_transp = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}transp")
veic_transp = oXML.find(
".//{http://www.portalfiscal.inf.br/nfe}veicTransp")
nMr = self.width - self.nRight
self.canvas.setFont('NimbusSanL-Bold', 7)
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)
# 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')
# Conteúdo campos
self.canvas.setFont('NimbusSanL-Regu', 8)
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.oFrete[tagtext(oNode=el_transp, cTag='modFrete')])
self.string(self.nLeft + 99, self.nlin + 7.7,
tagtext(oNode=el_transp, cTag='RNTC'))
self.string(self.nLeft + 116, self.nlin + 7.7,
tagtext(oNode=el_transp, cTag='placa'))
self.string(self.nLeft + 142, self.nlin + 7.7,
tagtext(oNode=veic_transp, cTag='UF'))
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,
tagtext(oNode=el_transp, cTag='xEnder')[:45])
self.string(self.nLeft + 89, self.nlin + 14.2,
tagtext(oNode=el_transp, cTag='xMun'))
self.string(nMr - 48, self.nlin + 14.2,
tagtext(oNode=el_transp, cTag='UF'))
self.string(nMr - 39, self.nlin + 14.2,
tagtext(oNode=el_transp, cTag='IE'))
self.string(self.nLeft + 1, self.nlin + 21.2,
tagtext(oNode=el_transp, cTag='qVol'))
self.string(self.nLeft + 31, self.nlin + 21.2,
tagtext(oNode=el_transp, cTag='esp'))
self.string(self.nLeft + 70, self.nlin + 21.2,
tagtext(oNode=el_transp, cTag='marca'))
self.string(self.nLeft + 106, self.nlin + 21.2,
tagtext(oNode=el_transp, cTag='nVol'))
self.stringRight(
nMr - 27, self.nlin + 21.2,
format_number(tagtext(oNode=el_transp, cTag='pesoB')))
self.stringRight(
nMr - 1, self.nlin + 21.2,
format_number(tagtext(oNode=el_transp, cTag='pesoL')))
self.nlin += 23
def produtos(self, oXML=None, el_det=None, oPaginator=None,
list_desc=None, list_cod_prod=None, nHeight=29):
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.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 - 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.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)
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
for id in range(oPaginator[0], oPaginator[1]):
item = el_det[id]
el_prod = item.find(".//{http://www.portalfiscal.inf.br/nfe}prod")
el_imp = item.find(
".//{http://www.portalfiscal.inf.br/nfe}imposto")
el_imp_ICMS = el_imp.find(
".//{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') 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')
vIPI = tagtext(oNode=el_imp_IPI, cTag='vIPI')
pIPI = tagtext(oNode=el_imp_IPI, cTag='pIPI')
self.stringcenter(nMr - 112.5, nLin,
tagtext(oNode=el_prod, cTag='NCM'))
self.stringcenter(nMr - 105, nLin, cCST)
self.stringcenter(nMr - 99, nLin,
tagtext(oNode=el_prod, cTag='CFOP'))
self.stringcenter(nMr - 93, nLin,
tagtext(oNode=el_prod, cTag='uCom'))
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')))
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))
if pIPI:
self.stringRight(nMr - 0.5, nLin, format_number(pIPI))
# Código Item
line_cod = nLin
for des in list_cod_prod[id]:
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)
line_desc += nStep
nLin = max(line_cod, line_desc)
self.canvas.setStrokeColor(gray)
self.hline(self.nLeft, nLin - 2, self.width - self.nLeft)
self.canvas.setStrokeColor(black)
self.nlin += nH + 3
def adicionais(self, oXML=None):
el_infAdic = oXML.find(
".//{http://www.portalfiscal.inf.br/nfe}infAdic")
self.nlin += 2
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.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']
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:
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)
self.nlin += 36
def recibo_entrega(self, oXML=None, timezone=None):
el_ide = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}ide")
el_dest = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}dest")
el_total = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}total")
el_emit = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}emit")
# self.nlin = self.height-self.nBottom-18 # 17 altura recibo
nW = 40
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)
# 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,
'IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR')
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 + 14,
"SÉRIE %s" % (tagtext(oNode=el_ide, cTag='serie')))
cDt, cHr = getdateByTimezone(
tagtext(oNode=el_ide, cTag='dhEmi'), timezone)
cTotal = format_number(tagtext(oNode=el_total, cTag='vNF'))
cEnd = tagtext(oNode=el_dest, cTag='xNome') + ' - '
cEnd += tagtext(oNode=el_dest, cTag='xLgr') + ', ' + tagtext(
oNode=el_dest, cTag='nro') + ', '
cEnd += tagtext(oNode=el_dest, cTag='xBairro') + ', ' + tagtext(
oNode=el_dest, cTag='xMun') + ' - '
cEnd += tagtext(oNode=el_dest, cTag='UF')
cString = """
RECEBEMOS DE %s OS PRODUTOS/SERVIÇOS CONSTANTES DA NOTA FISCAL INDICADA
ABAIXO. EMISSÃO: %s VALOR TOTAL: %s
DESTINATARIO: %s""" % (tagtext(oNode=el_emit, cTag='xNome'),
cDt, cTotal, cEnd)
styles = getSampleStyleSheet()
styleN = styles['Normal']
styleN.fontName = 'NimbusSanL-Regu'
styleN.fontSize = 6
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)
self.nlin += 20
self.hline(self.nLeft, self.nlin, self.width - self.nRight)
self.nlin += 2
def newpage(self):
self.nlin = self.nTop
self.Page += 1
self.canvas.showPage()
def hline(self, x, y, width):
y = self.height - y
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)
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,
stroke=True, fill=fill)
def string(self, x, y, value):
y = self.height - y
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)
def stringcenter(self, x, y, value):
y = self.height - y
self.canvas.drawCentredString(x * mm, y * mm, value)
def writeto_pdf(self, fileObj):
pdf_out = self.oPDF_IO.getvalue()
self.oPDF_IO.close()
fileObj.write(pdf_out)
def _generate_cce(self, cce_xml=None, oXML=None, timezone=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 = getdateByTimezone(tagtext(
oNode=elem_infNFe, cTag='dhEvento'), timezone)
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 = '<font size=%s>%s</font>' % (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

97
pynfe/danfe/fonts/LICENSE-Gentium

@ -0,0 +1,97 @@
Copyright (c) <dates>, <Copyright Holder> (<URL|email>),
with Reserved Font Name <Reserved Font Name>.
Copyright (c) <dates>, <additional Copyright Holder> (<URL|email>),
with Reserved Font Name <additional Reserved Font Name>.
Copyright (c) <dates>, <additional Copyright Holder> (<URL|email>).
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
pynfe/danfe/fonts/NimbusSanL Bold.ttf

BIN
pynfe/danfe/fonts/NimbusSanL Regular.ttf

BIN
pynfe/danfe/fonts/genbkbasb.ttf

BIN
pynfe/danfe/fonts/genbkbasbi.ttf

BIN
pynfe/danfe/fonts/genbkbasi.ttf

BIN
pynfe/danfe/fonts/genbkbasr.ttf

9
pynfe/data/XSDs/consReciNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="consReciNFe" type="TConsReciNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do Pedido de Consulta do Recido do Lote de Notas Fiscais Eletrônicas</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/consSitNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteConsSitNFe_v4.00.xsd"/>
<xs:element name="consSitNFe" type="TConsSitNFe">
<xs:annotation>
<xs:documentation>Schema de validação XML dp Pedido de Consulta da Situação Atual da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/consStatServ_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteConsStatServ_v4.00.xsd"/>
<xs:element name="consStatServ" type="TConsStatServ">
<xs:annotation>
<xs:documentation>Schema XML de validação do Pedido de Consulta do Status do Serviço</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/enviNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="enviNFe" type="TEnviNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do Pedido de Concessão de Autorização da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/inutNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteInutNFe_v4.00.xsd"/>
<xs:element name="inutNFe" type="TInutNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do Pedido de Inutilização de Numeração da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

502
pynfe/data/XSDs/leiauteConsSitNFe_v4.00.xsd

@ -0,0 +1,502 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- 13-05-2011 - correcao do pattern da data para aceitar -4:00 -->
<!-- 03-03-2011 - alteracoes na enumeracao das versoes e no detalhamento do evento -->
<!-- PL_006eventos versao alterada para consultar eventos 30/08/2010 -->
<!-- PL_006f versao com correcoes no xServ para tornar a literal CONSULTAR obrigatoria 21/05/2010 -->
<!-- PL_006c versao com correcoes 24/12/2009 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="tiposBasico_v4.00.xsd"/>
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
<xs:complexType name="TConsSitNFe">
<xs:annotation>
<xs:documentation>Tipo Pedido de Consulta da Situação Atual da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xServ">
<xs:annotation>
<xs:documentation>Serviço Solicitado</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TServ">
<xs:enumeration value="CONSULTAR"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="chNFe" type="TChNFe">
<xs:annotation>
<xs:documentation>Chaves de acesso da NF-e, compostas por: UF do emitente, AAMM da emissão da NFe, CNPJ do emitente, modelo, série e número da NF-e e código numérico + DV.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="versao" type="TVerConsSitNFe" use="required"/>
</xs:complexType>
<xs:complexType name="TRetConsSitNFe">
<xs:annotation>
<xs:documentation>Tipo Retorno de Pedido de Consulta da Situação Atual da Nota Fiscal Eletrônica </xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que processou a NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>código da UF de atendimento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhRecbto" type="TDateTimeUTC">
<xs:annotation>
<xs:documentation>AAAA-MM-DDTHH:MM:SSTZD</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="chNFe" type="TChNFe">
<xs:annotation>
<xs:documentation>Chaves de acesso da NF-e consultada</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="protNFe" type="TProtNFe" minOccurs="0">
<xs:annotation>
<xs:documentation>Protocolo de autorização de uso da NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="retCancNFe" type="TRetCancNFe" minOccurs="0">
<xs:annotation>
<xs:documentation>Protocolo de homologação de cancelamento de uso da NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="procEventoNFe" type="TProcEvento" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Protocolo de registro de evento da NF-e</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="versao" type="TVerConsSitNFe" use="required"/>
</xs:complexType>
<xs:complexType name="TProtNFe">
<xs:annotation>
<xs:documentation>Tipo Protocolo de status resultado do processamento da NF-e</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="infProt">
<xs:annotation>
<xs:documentation>Dados do protocolo de status</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que processou a NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="chNFe" type="TChNFe">
<xs:annotation>
<xs:documentation>Chaves de acesso da NF-e, compostas por: UF do emitente, AAMM da emissão da NFe, CNPJ do emitente, modelo, série e número da NF-e e código numérico+DV.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhRecbto" type="xs:dateTime">
<xs:annotation>
<xs:documentation>Data e hora de processamento, no formato AAAA-MM-DDTHH:MM:SS (ou AAAA-MM-DDTHH:MM:SSTZD, de acordo com versão). Deve ser preenchida com data e hora da gravação no Banco em caso de Confirmação. Em caso de Rejeição, com data e hora do recebimento do Lote de NF-e enviado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nProt" type="TProt" minOccurs="0">
<xs:annotation>
<xs:documentation>Número do Protocolo de Status da NF-e. 1 posição (1 – Secretaria de Fazenda Estadual 2 – Receita Federal); 2 - códiga da UF - 2 posições ano; 10 seqüencial no ano.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="digVal" type="ds:DigestValueType" minOccurs="0">
<xs:annotation>
<xs:documentation>Digest Value da NF-e processada. Utilizado para conferir a integridade da NF-e original.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element ref="ds:Signature" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerNFe" use="required"/>
</xs:complexType>
<xs:complexType name="TRetCancNFe">
<xs:annotation>
<xs:documentation>Tipo retorno Pedido de Cancelamento da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="infCanc">
<xs:annotation>
<xs:documentation>Dados do Resultado do Pedido de Cancelamento da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que processou o pedido de cancelamento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>código da UF de atendimento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="chNFe" type="TChNFe" minOccurs="0">
<xs:annotation>
<xs:documentation>Chaves de acesso da NF-e, compostas por: UF do emitente, AAMM da emissão da NFe, CNPJ do emitente, modelo, série e número da NF-e e código numérico + DV.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhRecbto" type="xs:dateTime" minOccurs="0">
<xs:annotation>
<xs:documentation>Data e hora de recebimento, no formato AAAA-MM-DDTHH:MM:SS. Deve ser preenchida com data e hora da gravação no Banco em caso de Confirmação.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nProt" type="TProt" minOccurs="0">
<xs:annotation>
<xs:documentation>Número do Protocolo de Status da NF-e. 1 posição (1 – Secretaria de Fazenda Estadual 2 – Receita Federal); 2 - código da UF - 2 posições ano; 10 seqüencial no ano.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element ref="ds:Signature" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerCancNFe" use="required"/>
</xs:complexType>
<xs:complexType name="TEvento">
<xs:annotation>
<xs:documentation>Tipo Evento</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="infEvento">
<xs:complexType>
<xs:sequence>
<xs:element name="cOrgao" type="TCOrgaoIBGE">
<xs:annotation>
<xs:documentation>Código do órgão de recepção do Evento. Utilizar a Tabela do IBGE extendida, utilizar 90 para identificar o Ambiente Nacional</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:choice>
<xs:annotation>
<xs:documentation>Identificação do autor do evento</xs:documentation>
</xs:annotation>
<xs:element name="CNPJ" type="TCnpjOpc">
<xs:annotation>
<xs:documentation>CNPJ</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CPF" type="TCpf">
<xs:annotation>
<xs:documentation>CPF</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:element name="chNFe" type="TChNFe">
<xs:annotation>
<xs:documentation>Chave de Acesso da NF-e vinculada ao evento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhEvento" type="TDateTimeUTC">
<xs:annotation>
<xs:documentation>Data e Hora do Evento, formato UTC (AAAA-MM-DDThh:mm:ssTZD, onde TZD = +hh:mm ou -hh:mm)</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tpEvento">
<xs:annotation>
<xs:documentation>Tipo do Evento</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{6}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nSeqEvento">
<xs:annotation>
<xs:documentation>Seqüencial do evento para o mesmo tipo de evento. Para maioria dos eventos será 1, nos casos em que possa existir mais de um evento, como é o caso da carta de correção, o autor do evento deve numerar de forma seqüencial.</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[1-9][0-9]{0,1}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="verEvento">
<xs:annotation>
<xs:documentation>Versão do Tipo do Evento</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="detEvento">
<xs:annotation>
<xs:documentation>Detalhe Específico do Evento</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:any processContents="skip" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute processContents="skip"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" use="required">
<xs:annotation>
<xs:documentation>Identificador da TAG a ser assinada, a regra de formação do Id é:
“ID” + tpEvento + chave da NF-e + nSeqEvento</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:ID">
<xs:pattern value="ID[0-9]{52}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element ref="ds:Signature"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerEvento" use="required"/>
</xs:complexType>
<xs:complexType name="TRetEvento">
<xs:annotation>
<xs:documentation>Tipo retorno do Evento</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="infEvento">
<xs:complexType>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que recebeu o Evento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cOrgao" type="TCOrgaoIBGE">
<xs:annotation>
<xs:documentation>Código do órgão de recepção do Evento. Utilizar a Tabela do IBGE extendida, utilizar 90 para identificar o Ambiente Nacional</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da registro do Evento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do registro do Evento</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="chNFe" type="TChNFe" minOccurs="0">
<xs:annotation>
<xs:documentation>Chave de Acesso NF-e vinculada</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tpEvento" minOccurs="0">
<xs:annotation>
<xs:documentation>Tipo do Evento vinculado</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{6}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="xEvento" minOccurs="0">
<xs:annotation>
<xs:documentation>Descrição do Evento</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:minLength value="5"/>
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nSeqEvento" minOccurs="0">
<xs:annotation>
<xs:documentation>Seqüencial do evento</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[1-9][0-9]{0,1}"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:choice minOccurs="0">
<xs:annotation>
<xs:documentation>Identificação do destinatpario da NF-e</xs:documentation>
</xs:annotation>
<xs:element name="CNPJDest" type="TCnpjOpc">
<xs:annotation>
<xs:documentation>CNPJ Destinatário</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CPFDest" type="TCpf">
<xs:annotation>
<xs:documentation>CPF Destiantário</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:element name="emailDest" minOccurs="0">
<xs:annotation>
<xs:documentation>email do destinatário</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TString">
<xs:minLength value="1"/>
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="dhRegEvento" type="TDateTimeUTC">
<xs:annotation>
<xs:documentation>Data e Hora de registro do evento formato UTC AAAA-MM-DDTHH:MM:SSTZD</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nProt" type="TProt" minOccurs="0">
<xs:annotation>
<xs:documentation>Número do protocolo de registro do evento</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" use="optional">
<xs:simpleType>
<xs:restriction base="xs:ID">
<xs:pattern value="ID[0-9]{15}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element ref="ds:Signature" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="versao" type="TRetVerEvento" use="required"/>
</xs:complexType>
<xs:complexType name="TProcEvento">
<xs:annotation>
<xs:documentation>Tipo procEvento</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="evento" type="TEvento"/>
<xs:element name="retEvento" type="TRetEvento"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerEvento" use="required"/>
</xs:complexType>
<xs:simpleType name="TVerNFe">
<xs:annotation>
<xs:documentation> Tipo Versão da NF-e</xs:documentation>
</xs:annotation>
<xs:restriction base="TString">
<xs:pattern value="[1-9]{1}\.[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TVerCancNFe">
<xs:annotation>
<xs:documentation>Tipo Versão do leiaute de Cancelamento de NF-e - 2.00/1.07</xs:documentation>
</xs:annotation>
<xs:restriction base="TString">
<xs:pattern value="[1-9]{1}\.[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TVerEvento">
<xs:annotation>
<xs:documentation>Tipo Versão do Evento 1.00</xs:documentation>
</xs:annotation>
<xs:restriction base="TString">
<xs:pattern value="[1-9]{1}\.[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TRetVerEvento">
<xs:annotation>
<xs:documentation>Tipo Versão do Evento</xs:documentation>
</xs:annotation>
<xs:restriction base="TString">
<xs:pattern value="[1-9]{1}\.[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TVerConsSitNFe">
<xs:annotation>
<xs:documentation>Tipo Versão do Leiaute da Cosulta situação NF-e - 4.00</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="4.00"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

98
pynfe/data/XSDs/leiauteConsStatServ_v4.00.xsd

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- PL_006f versao com correcoes no xServ para tornar a literal STATUS obrigatoria 21/05/2010 -->
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="tiposBasico_v4.00.xsd"/>
<xs:complexType name="TConsStatServ">
<xs:annotation>
<xs:documentation>Tipo Pedido de Consulta do Status do Serviço</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Sigla da UF consultada</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xServ">
<xs:annotation>
<xs:documentation>Serviço Solicitado</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TServ">
<xs:enumeration value="STATUS"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="versao" type="TVerConsStatServ" use="required"/>
</xs:complexType>
<xs:complexType name="TRetConsStatServ">
<xs:annotation>
<xs:documentation>Tipo Resultado da Consulta do Status do Serviço</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que processou a NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Código da UF responsável pelo serviço</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhRecbto" type="TDateTimeUTC">
<xs:annotation>
<xs:documentation>Data e hora do recebimento da consulta no formato AAAA-MM-DDTHH:MM:SSTZD</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tMed" type="TMed" minOccurs="0">
<xs:annotation>
<xs:documentation>Tempo médio de resposta do serviço (em segundos) dos últimos 5 minutos</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhRetorno" type="TDateTimeUTC" minOccurs="0">
<xs:annotation>
<xs:documentation>AAAA-MM-DDTHH:MM:SSDeve ser preenchida com data e hora previstas para o retorno dos serviços prestados.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xObs" type="TMotivo" minOccurs="0">
<xs:annotation>
<xs:documentation>Campo observação utilizado para incluir informações ao contribuinte</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="versao" type="TVerConsStatServ" use="required"/>
</xs:complexType>
<xs:simpleType name="TVerConsStatServ">
<xs:annotation>
<xs:documentation>Tipo versão do leiuate da Consulta Status do Serviço 4.00</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="4\.00"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

193
pynfe/data/XSDs/leiauteInutNFe_v4.00.xsd

@ -0,0 +1,193 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- PL_006f versao com correcoes no xServ para tornar a literal INUTILIZAR obrigatoria 21/05/2010 -->
<!-- PL_006c versao com correcoes 24/12/2009 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
<xs:include schemaLocation="tiposBasico_v4.00.xsd"/>
<xs:complexType name="TInutNFe">
<xs:annotation>
<xs:documentation>Tipo Pedido de Inutilização de Numeração da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="infInut">
<xs:annotation>
<xs:documentation>Dados do Pedido de Inutilização de Numeração da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xServ">
<xs:annotation>
<xs:documentation>Serviço Solicitado</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="TServ">
<xs:enumeration value="INUTILIZAR"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Código da UF do emitente</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ano" type="Tano">
<xs:annotation>
<xs:documentation>Ano de inutilização da numeração</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CNPJ" type="TCnpj">
<xs:annotation>
<xs:documentation>CNPJ do emitente</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="mod" type="TMod">
<xs:annotation>
<xs:documentation>Modelo da NF-e (55, 65 etc.)</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="serie" type="TSerie">
<xs:annotation>
<xs:documentation>Série da NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nNFIni" type="TNF">
<xs:annotation>
<xs:documentation>Número da NF-e inicial</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nNFFin" type="TNF">
<xs:annotation>
<xs:documentation>Número da NF-e final</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xJust" type="TJust">
<xs:annotation>
<xs:documentation>Justificativa do pedido de inutilização</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" use="required">
<xs:simpleType>
<xs:restriction base="xs:ID">
<xs:pattern value="ID[0-9]{41}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element ref="ds:Signature"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerInutNFe" use="required"/>
</xs:complexType>
<xs:complexType name="TRetInutNFe">
<xs:annotation>
<xs:documentation>Tipo retorno do Pedido de Inutilização de Numeração da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="infInut">
<xs:annotation>
<xs:documentation>Dados do Retorno do Pedido de Inutilização de Numeração da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="tpAmb" type="TAmb">
<xs:annotation>
<xs:documentation>Identificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="verAplic" type="TVerAplic">
<xs:annotation>
<xs:documentation>Versão do Aplicativo que processou a NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cStat" type="TStat">
<xs:annotation>
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="xMotivo" type="TMotivo">
<xs:annotation>
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="cUF" type="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Código da UF que atendeu a solicitação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="ano" type="Tano" minOccurs="0">
<xs:annotation>
<xs:documentation>Ano de inutilização da numeração</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="CNPJ" type="TCnpj" minOccurs="0">
<xs:annotation>
<xs:documentation>CNPJ do emitente</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="mod" type="TMod" minOccurs="0">
<xs:annotation>
<xs:documentation>Modelo da NF-e (55, etc.)</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="serie" type="TSerie" minOccurs="0">
<xs:annotation>
<xs:documentation>Série da NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nNFIni" type="TNF" minOccurs="0">
<xs:annotation>
<xs:documentation>Número da NF-e inicial</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nNFFin" type="TNF" minOccurs="0">
<xs:annotation>
<xs:documentation>Número da NF-e final</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="dhRecbto" type="TDateTimeUTC">
<xs:annotation>
<xs:documentation>Data e hora de recebimento, no formato AAAA-MM-DDTHH:MM:SS. Deve ser preenchida com data e hora da gravação no Banco em caso de Confirmação. Em caso de Rejeição, com data e hora do recebimento do Pedido de Inutilização.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="nProt" type="TProt" minOccurs="0">
<xs:annotation>
<xs:documentation>Número do Protocolo de Status da NF-e. 1 posição (1 – Secretaria de Fazenda Estadual 2 – Receita Federal); 2 - código da UF - 2 posições ano; 10 seqüencial no ano.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="Id" type="xs:ID" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element ref="ds:Signature" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerInutNFe" use="required"/>
</xs:complexType>
<xs:complexType name="TProcInutNFe">
<xs:annotation>
<xs:documentation>Tipo Pedido de inutilzação de númeração de NF-e processado</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="inutNFe" type="TInutNFe"/>
<xs:element name="retInutNFe" type="TRetInutNFe"/>
</xs:sequence>
<xs:attribute name="versao" type="TVerInutNFe" use="required"/>
</xs:complexType>
<xs:simpleType name="TVerInutNFe">
<xs:annotation>
<xs:documentation>Tipo Versão do leiaute de Inutilização 4.00</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:pattern value="4\.00"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

6480
pynfe/data/XSDs/leiauteNFe_v4.00.xsd
File diff suppressed because it is too large
View File

9
pynfe/data/XSDs/nfe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="NFe" type="TNFe">
<xs:annotation>
<xs:documentation>Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/procInutNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteInutNFe_v4.00.xsd"/>
<xs:element name="ProcInutNFe" type="TProcInutNFe">
<xs:annotation>
<xs:documentation>Pedido de inutilização de númeração de NF-e processado</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/procNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="nfeProc" type="TNfeProc">
<xs:annotation>
<xs:documentation>NF-e processada</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/retConsReciNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="retConsReciNFe" type="TRetConsReciNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do retorno do Pedido de Consulta do Recido do Lote de Notas Fiscais Eletrônicas</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/retConsSitNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteConsSitNFe_v4.00.xsd"/>
<xs:element name="retConsSitNFe" type="TRetConsSitNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do retorno da consulta da situação atual da NF-e</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/retConsStatServ_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteConsStatServ_v4.00.xsd"/>
<xs:element name="retConsStatServ" type="TRetConsStatServ">
<xs:annotation>
<xs:documentation>Schema XML de validação do Resultado da Consulta do Status do Serviço</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/retEnviNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/>
<xs:element name="retEnviNFe" type="TRetEnviNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do retorno do Pedido de Concessão de Autorização da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

9
pynfe/data/XSDs/retInutNFe_v4.00.xsd

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:include schemaLocation="leiauteInutNFe_v4.00.xsd"/>
<xs:element name="retInutNFe" type="TRetInutNFe">
<xs:annotation>
<xs:documentation>Schema XML de validação do retorno do Pedido de Inutilização de Numeração da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

589
pynfe/data/XSDs/tiposBasico_v4.00.xsd

@ -0,0 +1,589 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- PL_008 - 30/07/2013- NT 2013/005 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:nfe="http://www.portalfiscal.inf.br/nfe" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="TCodUfIBGE">
<xs:annotation>
<xs:documentation>Tipo Código da UF da tabela do IBGE</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="11"/>
<xs:enumeration value="12"/>
<xs:enumeration value="13"/>
<xs:enumeration value="14"/>
<xs:enumeration value="15"/>
<xs:enumeration value="16"/>
<xs:enumeration value="17"/>
<xs:enumeration value="21"/>
<xs:enumeration value="22"/>
<xs:enumeration value="23"/>
<xs:enumeration value="24"/>
<xs:enumeration value="25"/>
<xs:enumeration value="26"/>
<xs:enumeration value="27"/>
<xs:enumeration value="28"/>
<xs:enumeration value="29"/>
<xs:enumeration value="31"/>
<xs:enumeration value="32"/>
<xs:enumeration value="33"/>
<xs:enumeration value="35"/>
<xs:enumeration value="41"/>
<xs:enumeration value="42"/>
<xs:enumeration value="43"/>
<xs:enumeration value="50"/>
<xs:enumeration value="51"/>
<xs:enumeration value="52"/>
<xs:enumeration value="53"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCodMunIBGE">
<xs:annotation>
<xs:documentation>Tipo Código do Município da tabela do IBGE</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{7}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TChNFe">
<xs:annotation>
<xs:documentation>Tipo Chave da Nota Fiscal Eletrônica</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="44"/>
<xs:pattern value="[0-9]{44}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TProt">
<xs:annotation>
<xs:documentation>Tipo Número do Protocolo de Status</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="15"/>
<xs:pattern value="[0-9]{15}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TRec">
<xs:annotation>
<xs:documentation>Tipo Número do Recibo do envio de lote de NF-e</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="15"/>
<xs:pattern value="[0-9]{15}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TStat">
<xs:annotation>
<xs:documentation>Tipo Código da Mensagem enviada</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="3"/>
<xs:pattern value="[0-9]{3}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCnpj">
<xs:annotation>
<xs:documentation>Tipo Número do CNPJ</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCnpjVar">
<xs:annotation>
<xs:documentation>Tipo Número do CNPJ tmanho varíavel (3-14)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{3,14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCnpjOpc">
<xs:annotation>
<xs:documentation>Tipo Número do CNPJ Opcional</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{0}|[0-9]{14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCpf">
<xs:annotation>
<xs:documentation>Tipo Número do CPF</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="11"/>
<xs:pattern value="[0-9]{11}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCpfVar">
<xs:annotation>
<xs:documentation>Tipo Número do CPF de tamanho variável (3-11)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="11"/>
<xs:pattern value="[0-9]{3,11}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0104v">
<xs:annotation>
<xs:documentation>Tipo Decimal com até 1 dígitos inteiros, podendo ter de 1 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,4}|[1-9]{1}(\.[0-9]{1,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0204v">
<xs:annotation>
<xs:documentation>Tipo Decimal com até 2 dígitos inteiros, podendo ter de 1 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,4}|[1-9]{1}[0-9]{0,1}(\.[0-9]{1,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0302a04">
<xs:annotation>
<xs:documentation>Tipo Decimal com até 3 dígitos inteiros, podendo ter de 2 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{2,4}|[1-9]{1}[0-9]{0,2}(\.[0-9]{2,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0302a04Opc">
<xs:annotation>
<xs:documentation>Tipo Decimal com até 3 dígitos inteiros e 2 até 4 decimais. Utilizados em TAGs opcionais, não aceita valor zero.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0\.[0-9]{2,4}|[1-9]{1}[0-9]{0,2}(\.[0-9]{2,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0302Max100">
<xs:annotation>
<xs:documentation>Tipo Decimal com 3 inteiros (no máximo 100), com 2 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0(\.[0-9]{2})?|100(\.00)?|[1-9]{1}[0-9]{0,1}(\.[0-9]{2})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0304Max100">
<xs:annotation>
<xs:documentation>Tipo Decimal com 3 inteiros (no máximo 100), com 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0(\.[0-9]{4})?|100(\.00)?|[1-9]{1}[0-9]{0,1}(\.[0-9]{4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0302a04Max100">
<xs:annotation>
<xs:documentation>Tipo Decimal com 3 inteiros (no máximo 100), com até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0(\.[0-9]{2,4})?|[1-9]{1}[0-9]{0,1}(\.[0-9]{2,4})?|100(\.0{2,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_0803v">
<xs:annotation>
<xs:documentation>Tipo Decimal com 8 inteiros, podendo ter de 1 até 3 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{3}|[1-9]{1}[0-9]{0,7}(\.[0-9]{1,3})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1104">
<xs:annotation>
<xs:documentation>Tipo Decimal com 11 inteiros, podendo ter 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{4}|[1-9]{1}[0-9]{0,10}(\.[0-9]{4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1104v">
<xs:annotation>
<xs:documentation>Tipo Decimal com 11 inteiros, podendo ter de 1 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,4}|[1-9]{1}[0-9]{0,10}|[1-9]{1}[0-9]{0,10}(\.[0-9]{1,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1104Opc">
<xs:annotation>
<xs:documentation>Tipo Decimal com 11 inteiros, podendo ter 4 decimais (utilizado em tags opcionais)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0\.[1-9]{1}[0-9]{3}|0\.[0-9]{3}[1-9]{1}|0\.[0-9]{2}[1-9]{1}[0-9]{1}|0\.[0-9]{1}[1-9]{1}[0-9]{2}|[1-9]{1}[0-9]{0,10}(\.[0-9]{4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1110v">
<xs:annotation>
<xs:documentation>Tipo Decimal com 11 inteiros, podendo ter de 1 até 10 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,10}|[1-9]{1}[0-9]{0,10}|[1-9]{1}[0-9]{0,10}(\.[0-9]{1,10})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1203">
<xs:annotation>
<xs:documentation>Tipo Decimal com 12 inteiros, podendo ter 3 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{3}|[1-9]{1}[0-9]{0,11}(\.[0-9]{3})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1204">
<xs:annotation>
<xs:documentation>Tipo Decimal com 12 inteiros e 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,4}|[1-9]{1}[0-9]{0,11}|[1-9]{1}[0-9]{0,11}(\.[0-9]{4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1204v">
<xs:annotation>
<xs:documentation>Tipo Decimal com 12 inteiros de 1 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{1,4}|[1-9]{1}[0-9]{0,11}|[1-9]{1}[0-9]{0,11}(\.[0-9]{1,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1204Opc">
<xs:annotation>
<xs:documentation>Tipo Decimal com 12 inteiros com 1 até 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0\.[0-9]{1,4}|[1-9]{1}[0-9]{0,11}|[1-9]{1}[0-9]{0,11}(\.[0-9]{1,4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1204temperatura">
<xs:annotation>
<xs:documentation>Tipo Decimal com 12 inteiros, 1 a 4 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0\.[1-9]{1}[0-9]{3}|0\.[0-9]{3}[1-9]{1}|0\.[0-9]{2}[1-9]{1}[0-9]{1}|0\.[0-9]{1}[1-9]{1}[0-9]{2}|[1-9]{1}[0-9]{0,11}(\.[0-9]{4})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1302">
<xs:annotation>
<xs:documentation>Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|0\.[0-9]{2}|[1-9]{1}[0-9]{0,12}(\.[0-9]{2})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDec_1302Opc">
<xs:annotation>
<xs:documentation>Tipo Decimal com 15 dígitos, sendo 13 de corpo e 2 decimais, utilizado em tags opcionais</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0\.[0-9]{1}[1-9]{1}|0\.[1-9]{1}[0-9]{1}|[1-9]{1}[0-9]{0,12}(\.[0-9]{2})?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIeDest">
<xs:annotation>
<xs:documentation>Tipo Inscrição Estadual do Destinatário // alterado para aceitar vazio ou ISENTO - maio/2010 v2.0</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="ISENTO|[0-9]{2,14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIeDestNaoIsento">
<xs:annotation>
<xs:documentation>Tipo Inscrição Estadual do Destinatário // alterado para aceitar vazio ou ISENTO - maio/2010 v2.0</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{2,14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIeST">
<xs:annotation>
<xs:documentation>Tipo Inscrição Estadual do ST // acrescentado EM 24/10/08</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{2,14}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TIe">
<xs:annotation>
<xs:documentation>Tipo Inscrição Estadual do Emitente // alterado EM 24/10/08 para aceitar ISENTO</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:maxLength value="14"/>
<xs:pattern value="[0-9]{2,14}|ISENTO"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TMod">
<xs:annotation>
<xs:documentation>Tipo Modelo Documento Fiscal</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="55"/>
<xs:enumeration value="65"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TNF">
<xs:annotation>
<xs:documentation>Tipo Número do Documento Fiscal</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[1-9]{1}[0-9]{0,8}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TSerie">
<xs:annotation>
<xs:documentation>Tipo Série do Documento Fiscal </xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="0|[1-9]{1}[0-9]{0,2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TUf">
<xs:annotation>
<xs:documentation>Tipo Sigla da UF</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="AC"/>
<xs:enumeration value="AL"/>
<xs:enumeration value="AM"/>
<xs:enumeration value="AP"/>
<xs:enumeration value="BA"/>
<xs:enumeration value="CE"/>
<xs:enumeration value="DF"/>
<xs:enumeration value="ES"/>
<xs:enumeration value="GO"/>
<xs:enumeration value="MA"/>
<xs:enumeration value="MG"/>
<xs:enumeration value="MS"/>
<xs:enumeration value="MT"/>
<xs:enumeration value="PA"/>
<xs:enumeration value="PB"/>
<xs:enumeration value="PE"/>
<xs:enumeration value="PI"/>
<xs:enumeration value="PR"/>
<xs:enumeration value="RJ"/>
<xs:enumeration value="RN"/>
<xs:enumeration value="RO"/>
<xs:enumeration value="RR"/>
<xs:enumeration value="RS"/>
<xs:enumeration value="SC"/>
<xs:enumeration value="SE"/>
<xs:enumeration value="SP"/>
<xs:enumeration value="TO"/>
<xs:enumeration value="EX"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TUfEmi">
<xs:annotation>
<xs:documentation>Tipo Sigla da UF de emissor // acrescentado em 24/10/08 </xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="AC"/>
<xs:enumeration value="AL"/>
<xs:enumeration value="AM"/>
<xs:enumeration value="AP"/>
<xs:enumeration value="BA"/>
<xs:enumeration value="CE"/>
<xs:enumeration value="DF"/>
<xs:enumeration value="ES"/>
<xs:enumeration value="GO"/>
<xs:enumeration value="MA"/>
<xs:enumeration value="MG"/>
<xs:enumeration value="MS"/>
<xs:enumeration value="MT"/>
<xs:enumeration value="PA"/>
<xs:enumeration value="PB"/>
<xs:enumeration value="PE"/>
<xs:enumeration value="PI"/>
<xs:enumeration value="PR"/>
<xs:enumeration value="RJ"/>
<xs:enumeration value="RN"/>
<xs:enumeration value="RO"/>
<xs:enumeration value="RR"/>
<xs:enumeration value="RS"/>
<xs:enumeration value="SC"/>
<xs:enumeration value="SE"/>
<xs:enumeration value="SP"/>
<xs:enumeration value="TO"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TAmb">
<xs:annotation>
<xs:documentation>Tipo Ambiente</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="1"/>
<xs:enumeration value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TVerAplic">
<xs:annotation>
<xs:documentation>Tipo Versão do Aplicativo</xs:documentation>
</xs:annotation>
<xs:restriction base="nfe:TString">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TMotivo">
<xs:annotation>
<xs:documentation>Tipo Motivo</xs:documentation>
</xs:annotation>
<xs:restriction base="nfe:TString">
<xs:maxLength value="255"/>
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TJust">
<xs:annotation>
<xs:documentation>Tipo Justificativa</xs:documentation>
</xs:annotation>
<xs:restriction base="nfe:TString">
<xs:minLength value="15"/>
<xs:maxLength value="255"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TServ">
<xs:annotation>
<xs:documentation>Tipo Serviço solicitado</xs:documentation>
</xs:annotation>
<xs:restriction base="nfe:TString"/>
</xs:simpleType>
<xs:simpleType name="Tano">
<xs:annotation>
<xs:documentation> Tipo ano</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{2}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TMed">
<xs:annotation>
<xs:documentation> Tipo temp médio em segundos</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[0-9]{1,4}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TString">
<xs:annotation>
<xs:documentation> Tipo string genérico</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[!-ÿ]{1}[ -ÿ]{0,}[!-ÿ]{1}|[!-ÿ]{1}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TData">
<xs:annotation>
<xs:documentation> Tipo data AAAA-MM-DD</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="(((20(([02468][048])|([13579][26]))-02-29))|(20[0-9][0-9])-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TTime">
<xs:annotation>
<xs:documentation> Tipo hora HH:MM:SS // tipo acrescentado na v2.0</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="(([0-1][0-9])|([2][0-3])):([0-5][0-9]):([0-5][0-9])"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TDateTimeUTC">
<xs:annotation>
<xs:documentation>Data e Hora, formato UTC (AAAA-MM-DDThh:mm:ssTZD, onde TZD = +hh:mm ou -hh:mm)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="(((20(([02468][048])|([13579][26]))-02-29))|(20[0-9][0-9])-((((0[1-9])|(1[0-2]))-((0[1-9])|(1\d)|(2[0-8])))|((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30)))))T(20|21|22|23|[0-1]\d):[0-5]\d:[0-5]\d([\-,\+](0[0-9]|10|11):00|([\+](12):00))"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TPlaca">
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:pattern value="[A-Z]{2,3}[0-9]{4}|[A-Z]{3,4}[0-9]{3}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="TCOrgaoIBGE">
<xs:annotation>
<xs:documentation>Tipo Código de orgão (UF da tabela do IBGE + 90 RFB)</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
<xs:enumeration value="11"/>
<xs:enumeration value="12"/>
<xs:enumeration value="13"/>
<xs:enumeration value="14"/>
<xs:enumeration value="15"/>
<xs:enumeration value="16"/>
<xs:enumeration value="17"/>
<xs:enumeration value="21"/>
<xs:enumeration value="22"/>
<xs:enumeration value="23"/>
<xs:enumeration value="24"/>
<xs:enumeration value="25"/>
<xs:enumeration value="26"/>
<xs:enumeration value="27"/>
<xs:enumeration value="28"/>
<xs:enumeration value="29"/>
<xs:enumeration value="31"/>
<xs:enumeration value="32"/>
<xs:enumeration value="33"/>
<xs:enumeration value="35"/>
<xs:enumeration value="41"/>
<xs:enumeration value="42"/>
<xs:enumeration value="43"/>
<xs:enumeration value="50"/>
<xs:enumeration value="51"/>
<xs:enumeration value="52"/>
<xs:enumeration value="53"/>
<xs:enumeration value="90"/>
<xs:enumeration value="91"/>
<xs:enumeration value="92"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

3
pynfe/entidades/fonte_dados.py

@ -124,7 +124,8 @@ class FonteDados(object):
return len(self._objetos)
def limpar_dados(self):
self._objetos.clear()
del self._objetos[:]
#self._objetos.clear()
# Instancia da fonte de dados default
_fonte_dados = FonteDados()

2
pynfe/entidades/servico.py

@ -1,3 +1,5 @@
# encoding: utf-8
"""
@author: Junior Tada, Leonardo Tada
"""

1
pynfe/processamento/comunicacao.py

@ -65,6 +65,7 @@ class ComunicacaoSefaz(Comunicacao):
# Monta XML para envio da requisição
xml = self._construir_xml_soap('NFeAutorizacao4', raiz)
#print '---->', etree.tostring(xml, pretty_print=True)
# Faz request no Servidor da Sefaz
retorno = self._post(url, xml)

14
pynfe/processamento/serializacao.py

@ -10,6 +10,8 @@ import hashlib
from datetime import datetime
import re
import pytz
class Serializacao(object):
"""Classe abstrata responsavel por fornecer as funcionalidades basicas para
@ -75,7 +77,7 @@ class SerializacaoXML(Serializacao):
else:
return raiz
except Exception as e:
raise e
raise
finally:
if limpar:
self._fonte_dados.limpar_dados()
@ -532,7 +534,8 @@ class SerializacaoXML(Serializacao):
# Ex.: NFe35080599999090910270550010000000011518005123
raiz.attrib['Id'] = nota_fiscal.identificador_unico
tz = datetime.now().astimezone().strftime('%z')
#tz = datetime.now().astimezone().strftime('%z')
tz = datetime.now(pytz.timezone('America/Sao_Paulo')).strftime('%z')
tz = "{}:{}".format(tz[:-2], tz[-2:])
# Dados da Nota Fiscal
@ -655,7 +658,7 @@ class SerializacaoXML(Serializacao):
etree.SubElement(icms_total, 'vST').text = '{:.2f}'.format(nota_fiscal.totais_icms_st_total)
etree.SubElement(icms_total, 'vFCPST').text = '{:.2f}'.format(nota_fiscal.totais_fcp_st)
etree.SubElement(icms_total, 'vFCPSTRet').text = '{:.2f}'.format(nota_fiscal.totais_fcp_st_ret)
etree.SubElement(icms_total, 'vProd').text = str(nota_fiscal.totais_icms_total_produtos_e_servicos)
etree.SubElement(icms_total, 'vProd').text = str('{:.2f}').format(nota_fiscal.totais_icms_total_produtos_e_servicos)
etree.SubElement(icms_total, 'vFrete').text = '{:.2f}'.format(nota_fiscal.totais_icms_total_frete)
etree.SubElement(icms_total, 'vSeg').text = '{:.2f}'.format(nota_fiscal.totais_icms_total_seguro)
etree.SubElement(icms_total, 'vDesc').text = '{:.2f}'.format(nota_fiscal.totais_icms_total_desconto)
@ -668,7 +671,7 @@ class SerializacaoXML(Serializacao):
etree.SubElement(icms_total, 'vCOFINS').text = '{:.2f}'.format(nota_fiscal.totais_icms_cofins)
etree.SubElement(icms_total, 'vOutro').text = '{:.2f}'.format(nota_fiscal.totais_icms_outras_despesas_acessorias)
etree.SubElement(icms_total, 'vNF').text = str(nota_fiscal.totais_icms_total_nota)
etree.SubElement(icms_total, 'vNF').text = str('{:.2f}').format(nota_fiscal.totais_icms_total_nota)
if nota_fiscal.totais_tributos_aproximado:
etree.SubElement(icms_total, 'vTotTrib').text = '{:.2f}'.format(nota_fiscal.totais_tributos_aproximado)
@ -767,7 +770,8 @@ class SerializacaoXML(Serializacao):
return raiz
def serializar_evento(self, evento, tag_raiz='evento', retorna_string=False):
tz = datetime.now().astimezone().strftime('%z')
#tz = datetime.now().astimezone().strftime('%z')
tz = datetime.now(pytz.timezone('America/Sao_Paulo')).strftime('%z')
tz = "{}:{}".format(tz[:-2], tz[-2:])
raiz = etree.Element(tag_raiz, versao='1.00', xmlns=NAMESPACE_NFE)
e = etree.SubElement(raiz, 'infEvento', Id=evento.identificador)

5
pynfe/processamento/validacao.py

@ -58,5 +58,8 @@ class Validacao(object):
xsd_doc = etree.parse(xsd_file)
xsd_schema = etree.XMLSchema(xsd_doc)
self.MEM_CACHE[xsd_file] = xsd_schema
return use_assert and xsd_schema.assertValid(xml_doc) \
ret = use_assert and xsd_schema.assertValid(xml_doc) \
or xsd_schema.validate(xml_doc)
if ret is True:
return True
raise Exception(xsd_schema.error_log)

3
pynfe/utils/__init__.py

@ -1,5 +1,8 @@
# *-* encoding: utf-8 *-*
from __future__ import unicode_literals
from builtins import str
import os
import codecs
from unicodedata import normalize

1
pynfe/utils/webservices.py

@ -1,3 +1,4 @@
# encoding: utf-8
"""
@author: Junior Tada, Leonardo Tada

2
setup.py

@ -9,7 +9,7 @@ setuptools.setup(
url='https://github.com/TadaSoftware',
packages=setuptools.find_packages(exclude=['tests', 'tests.*']),
package_data={
'pynfe': ['data/**/*.txt'],
'pynfe': ['data/**/*.txt', 'data/**/*.xsd', 'danfe/**/*.ttf'],
},
install_requires=[
'pyopenssl',

Loading…
Cancel
Save