Browse Source
Merge branch 'master3' of github.com:danimaribeiro/PyTrustNFe into master3
pull/263/head
Merge branch 'master3' of github.com:danimaribeiro/PyTrustNFe into master3
pull/263/head
60 changed files with 9191 additions and 8111 deletions
-
2.gitignore
-
2.travis.yml
-
855pytrustnfe/Servidores.py
-
30pytrustnfe/client.py
-
252pytrustnfe/nfe/__init__.py
-
34pytrustnfe/nfe/comunicacao.py
-
461pytrustnfe/nfe/danfce.py
-
283pytrustnfe/nfe/danfe.py
-
39pytrustnfe/nfe/patch.py
-
8pytrustnfe/nfe/templates/NFeDistribuicaoDFe.xml
-
145pytrustnfe/nfe/templates/NfeAutorizacao.xml
-
3pytrustnfe/nfe/templates/NfeConsultaProtocolo.xml
-
2pytrustnfe/nfe/templates/NfeInutilizacao.xml
-
2pytrustnfe/nfe/templates/NfeRetAutorizacao.xml
-
2pytrustnfe/nfe/templates/NfeStatusServico.xml
-
6pytrustnfe/nfe/templates/RecepcaoEvento.xml
-
21pytrustnfe/nfe/templates/RecepcaoEventoCarta.xml
-
31pytrustnfe/nfe/templates/RecepcaoEventoEPEC.xml
-
2pytrustnfe/nfe/templates/RecepcaoEventoManifesto.xml
-
84pytrustnfe/nfse/bh/__init__.py
-
44pytrustnfe/nfse/bh/assinatura.py
-
13pytrustnfe/nfse/bh/templates/CancelarNfse.xml
-
11pytrustnfe/nfse/bh/templates/GerarNfse.xml
-
91pytrustnfe/nfse/bh/templates/Rps.xml
-
14pytrustnfe/nfse/dsf/__init__.py
-
24pytrustnfe/nfse/dsf/templates/enviar.xml
-
5pytrustnfe/nfse/floripa/__init__.py
-
29pytrustnfe/nfse/ginfes/__init__.py
-
5pytrustnfe/nfse/imperial/__init__.py
-
75pytrustnfe/nfse/mga/__init__.py
-
45pytrustnfe/nfse/mga/assinatura.py
-
15pytrustnfe/nfse/mga/templates/CancelarNfse.xml
-
3pytrustnfe/nfse/mga/templates/GerarNfse.xml
-
81pytrustnfe/nfse/mga/templates/Rps.xml
-
4pytrustnfe/nfse/paulistana/__init__.py
-
2pytrustnfe/nfse/paulistana/templates/EnvioLoteRPS.xml
-
2pytrustnfe/nfse/paulistana/templates/EnvioRPS.xml
-
150pytrustnfe/urls.py
-
14pytrustnfe/utils.py
-
24pytrustnfe/xml/__init__.py
-
2pytrustnfe/xml/schemas/enviNFe_v4.00.xsd
-
1040pytrustnfe/xml/schemas/leiauteNFe_v4.00.xsd
-
2pytrustnfe/xml/schemas/nfe_v4.00.xsd
-
22pytrustnfe/xml/schemas/tiposBasico_v4.00.xsd
-
2pytrustnfe/xml/validate.py
-
4requirements.txt
-
10setup.py
-
10tests/XMLs/paulistana_signature.xml
-
34tests/test_add_qr_code.py
-
20tests/test_comunicacao.py
-
19tests/test_consulta_cadastro.py
-
17tests/test_servidores.py
-
8tests/test_utils.py
-
189tests/xml_com_qrcode.xml
-
190tests/xml_sem_qrcode.xml
855
pytrustnfe/Servidores.py
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,34 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# © 2016 Danimar Ribeiro, Trustcode |
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
||||
|
|
||||
|
|
||||
from pytrustnfe.client import HttpClient |
|
||||
from pytrustnfe.certificado import save_cert_key, extract_cert_and_key_from_pfx |
|
||||
|
|
||||
from ..xml import sanitize_response |
|
||||
|
|
||||
|
|
||||
def _soap_xml(body, cabecalho): |
|
||||
xml = '<?xml version="1.0" encoding="utf-8"?>' |
|
||||
xml += '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header>' |
|
||||
xml += '<nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/' + cabecalho.soap_action + '">' |
|
||||
xml += '<cUF>' + cabecalho.estado + '</cUF><versaoDados>' + cabecalho.versao + '</versaoDados></nfeCabecMsg></soap:Header><soap:Body>' |
|
||||
xml += '<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/' + cabecalho.soap_action + '">' |
|
||||
xml += body |
|
||||
xml += '</nfeDadosMsg></soap:Body></soap:Envelope>' |
|
||||
return xml.rstrip('\n') |
|
||||
|
|
||||
|
|
||||
def executar_consulta(certificado, url, cabecalho, xmlEnviar, send_raw=False): |
|
||||
cert, key = extract_cert_and_key_from_pfx( |
|
||||
certificado.pfx, certificado.password) |
|
||||
cert_path, key_path = save_cert_key(cert, key) |
|
||||
client = HttpClient(url, cert_path, key_path) |
|
||||
|
|
||||
xml_enviar = _soap_xml(xmlEnviar, cabecalho) |
|
||||
if send_raw: |
|
||||
xml = '<?xml version="1.0" encoding="utf-8"?>' + xmlEnviar.rstrip('\n') |
|
||||
xml_enviar = xml |
|
||||
xml_retorno = client.post_soap(xml_enviar, cabecalho, send_raw) |
|
||||
return sanitize_response(xml_retorno.encode()) |
|
||||
@ -0,0 +1,461 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2017 Johny Chen Jy, Trustcode |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import re |
||||
|
from textwrap import wrap |
||||
|
from io import BytesIO |
||||
|
|
||||
|
from reportlab.lib import utils |
||||
|
from reportlab.pdfgen import canvas |
||||
|
from reportlab.lib.units import cm, mm |
||||
|
from reportlab.graphics.barcode import qr |
||||
|
from reportlab.graphics import renderPDF |
||||
|
from reportlab.graphics.shapes import Drawing |
||||
|
from reportlab.platypus import Table, TableStyle, Paragraph, Image |
||||
|
from reportlab.lib.enums import TA_CENTER |
||||
|
from reportlab.lib.styles import ParagraphStyle |
||||
|
|
||||
|
|
||||
|
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 getdateUTC(cDateUTC): |
||||
|
cDt = cDateUTC[0:10].split('-') |
||||
|
cDt.reverse() |
||||
|
return '/'.join(cDt), cDateUTC[11:16] |
||||
|
|
||||
|
|
||||
|
def format_number(cNumber, precision=0, group_sep='.', decimal_sep=','): |
||||
|
if cNumber: |
||||
|
number = float(cNumber) |
||||
|
return ("{:,." + str(precision) + "f}").format(number).\ |
||||
|
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 |
||||
|
|
||||
|
|
||||
|
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)) |
||||
|
|
||||
|
|
||||
|
def format_telefone(telefone): |
||||
|
telefone = re.sub('[^0-9]', '', telefone) |
||||
|
if len(telefone) == 10: |
||||
|
telefone = '(%s) %s-%s' % (telefone[0:2], |
||||
|
telefone[2:6], |
||||
|
telefone[6:]) |
||||
|
elif len(telefone) == 11: |
||||
|
telefone = '(%s) %s-%s' % (telefone[0:2], |
||||
|
telefone[2:7], |
||||
|
telefone[7:]) |
||||
|
return telefone |
||||
|
|
||||
|
|
||||
|
class danfce(object): |
||||
|
|
||||
|
def __init__(self, list_xml, logo=None, timezone=None): |
||||
|
|
||||
|
self.current_font_size = 7 |
||||
|
self.current_font_name = 'NimbusSanL-Regu' |
||||
|
|
||||
|
self.max_height = 840 |
||||
|
self.min_height = 1 |
||||
|
self.min_width = 5 |
||||
|
self.max_width = 200 |
||||
|
self.current_height = 840 |
||||
|
|
||||
|
self.oPDF_IO = BytesIO() |
||||
|
self.canvas = canvas.Canvas(self.oPDF_IO, pagesize=(7.2 * cm, 30 * cm)) |
||||
|
self.canvas.setTitle('DANFCE') |
||||
|
self.canvas.setLineWidth(.5) |
||||
|
self.canvas.setFont(self.current_font_name, self.current_font_size) |
||||
|
|
||||
|
self.list_xml = list_xml |
||||
|
self.logo = logo |
||||
|
|
||||
|
self.nfce_generate() |
||||
|
|
||||
|
def ide_emit(self, oXML=None): |
||||
|
|
||||
|
elem_emit = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}emit") |
||||
|
|
||||
|
# Razão Social emitente |
||||
|
nomeEmpresa = tagtext(oNode=elem_emit, cTag='xFant') |
||||
|
self.drawTitle(nomeEmpresa, 10) |
||||
|
|
||||
|
if self.logo: |
||||
|
img = get_image(self.logo, width=10 * mm) |
||||
|
img.drawOn(self.canvas, 5, 830) |
||||
|
|
||||
|
cEnd = tagtext(oNode=elem_emit, cTag="xNome") + '<br />' |
||||
|
cEnd += "CNPJ: %s " % (format_cnpj_cpf( |
||||
|
tagtext(oNode=elem_emit, cTag='CNPJ'))) |
||||
|
cEnd += "IE: %s" % (tagtext(oNode=elem_emit, cTag="IE")) + '<br />' |
||||
|
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 += tagtext(oNode=elem_emit, cTag='UF') + ' - ' + tagtext( |
||||
|
oNode=elem_emit, cTag='CEP') + '<br />' |
||||
|
cEnd += 'Fone: ' + format_telefone(tagtext( |
||||
|
oNode=elem_emit, cTag='fone')) |
||||
|
|
||||
|
self._drawCenteredParagraph(cEnd) |
||||
|
self.drawLine() |
||||
|
|
||||
|
def danfce_information(self): |
||||
|
self.drawTitle( |
||||
|
"DANFE NFC-e - Documento Auxiliar da Nota Fiscal de", |
||||
|
7, 'NimbusSanL-Bold') |
||||
|
|
||||
|
self.drawTitle("Consumidor Eletrônica", 7, 'NimbusSanL-Bold') |
||||
|
|
||||
|
self.drawString( |
||||
|
"NFC-e não permite aproveitamento de crédito de ICMS", True) |
||||
|
self.drawLine() |
||||
|
|
||||
|
def produtos(self, oXML=None, el_det=None, oPaginator=None, |
||||
|
list_desc=None, list_cod_prod=None): |
||||
|
|
||||
|
rows = [['Cód', 'Descrição', 'Qtde', 'Un', 'Unit.', 'Total']] |
||||
|
colWidths = (25, 90, 15, 15, 25, 25) |
||||
|
rowHeights = [7] |
||||
|
|
||||
|
for id in range(oPaginator[0], oPaginator[1]): |
||||
|
|
||||
|
item = el_det[id] |
||||
|
el_prod = item.find(".//{http://www.portalfiscal.inf.br/nfe}prod") |
||||
|
|
||||
|
cod = tagtext(oNode=el_prod, cTag='cProd') |
||||
|
descricao = tagtext(oNode=el_prod, cTag='xProd') |
||||
|
descricao = (descricao[:20] + '..') if len(descricao) > 20 else descricao |
||||
|
Un = tagtext(oNode=el_prod, cTag='uCom') |
||||
|
Un = (Un[:2]) if len(Un) > 2 else Un |
||||
|
qtde = format_number(tagtext(oNode=el_prod, cTag='qCom'), |
||||
|
precision=2) |
||||
|
vl_unit = format_number(tagtext(oNode=el_prod, cTag='vUnCom'), |
||||
|
precision=2) |
||||
|
vl_total = format_number( |
||||
|
tagtext(oNode=el_prod, cTag='vProd'), precision=2) |
||||
|
|
||||
|
new_row = [cod, descricao, qtde, Un, vl_unit, vl_total] |
||||
|
|
||||
|
rows.append(new_row) |
||||
|
rowHeights.append(self.current_font_size + 2) |
||||
|
|
||||
|
self._draw_product_table(rows, colWidths, rowHeights) |
||||
|
|
||||
|
def _draw_product_table(self, rows, colWidths, rowHeights): |
||||
|
table = Table(rows, colWidths, tuple(rowHeights)) |
||||
|
table.setStyle(TableStyle([ |
||||
|
('FONTSIZE', (0, 0), (-1, -1), 7), |
||||
|
('FONT', (0, 1), (-1, -1), 'NimbusSanL-Regu'), |
||||
|
('FONT', (0, 0), (-1, 0), 'NimbusSanL-Bold'), |
||||
|
('ALIGN', (0, 0), (-1, 0), "LEFT"), |
||||
|
('ALIGN', (1, 0), (-1, 0), "LEFT"), |
||||
|
('ALIGN', (2, 0), (-1, 0), "CENTER"), |
||||
|
('ALIGN', (3, 0), (-1, 0), "CENTER"), |
||||
|
('ALIGN', (0, 1), (-1, -1), "LEFT"), |
||||
|
('ALIGN', (1, 1), (-1, -1), "LEFT"), |
||||
|
('ALIGN', (2, 1), (-1, -1), "CENTER"), |
||||
|
('ALIGN', (3, 1), (-1, -1), "CENTER"), |
||||
|
])) |
||||
|
|
||||
|
w, h = table.wrapOn(self.canvas, 200, 450) |
||||
|
table.drawOn(self.canvas, 0, self.current_height - (h * 1.2)) |
||||
|
self.current_height -= (h * 1.1) |
||||
|
|
||||
|
def totais(self, oXML=None): |
||||
|
# Impostos |
||||
|
el_total = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}total") |
||||
|
|
||||
|
total_tributo = format_number( |
||||
|
tagtext(oNode=el_total, cTag='vTotTrib'), precision=2) |
||||
|
valor_total = format_number( |
||||
|
tagtext(oNode=el_total, cTag='vProd'), precision=2) |
||||
|
desconto = format_number( |
||||
|
tagtext(oNode=el_total, cTag='vDesc'), precision=2) |
||||
|
valor_a_pagar = format_number( |
||||
|
tagtext(oNode=el_total, cTag='vNF'), precision=2) |
||||
|
el_pag = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}pag") |
||||
|
troco = tagtext(oNode=el_pag, cTag="vTroco") |
||||
|
|
||||
|
payment_method_list = {'01': 'Dinheiro', |
||||
|
'02': 'Cheque', |
||||
|
'03': 'Cartão de Crédito', |
||||
|
'04': 'Cartão de Débito', |
||||
|
"05": "Crédito Loja", |
||||
|
'10': 'Vale Alimentação', |
||||
|
'11': 'Vale Refeição', |
||||
|
'12': 'Vale Presente', |
||||
|
'13': 'Vale Combustível', |
||||
|
'14': 'Duplicata Mercantil', |
||||
|
'15': 'Boleto Bancario', |
||||
|
'90': 'Sem Pagamento', |
||||
|
'99': 'Outros'} |
||||
|
quant_produtos = len(oXML.findall( |
||||
|
".//{http://www.portalfiscal.inf.br/nfe}det")) |
||||
|
|
||||
|
payment_methods = [] |
||||
|
for pagId, item in enumerate(el_pag): |
||||
|
payment = [] |
||||
|
tipo_pagamento = tagtext(oNode=item, cTag="tPag") |
||||
|
val = format_number(tagtext(oNode=item, cTag="vPag"), precision=2) |
||||
|
|
||||
|
method = payment_method_list.get(tipo_pagamento) |
||||
|
|
||||
|
payment.append(method) |
||||
|
payment.append(val) |
||||
|
payment_methods.append(payment) |
||||
|
|
||||
|
values = { |
||||
|
'quantidade_itens': quant_produtos, |
||||
|
'total_tributo': total_tributo, |
||||
|
'valor_total': valor_total, |
||||
|
'desconto': desconto, |
||||
|
'valor_a_pagar': valor_a_pagar, |
||||
|
'formas_de_pagamento': payment_methods, |
||||
|
'troco': troco, |
||||
|
} |
||||
|
|
||||
|
self.draw_totals_table(values) |
||||
|
|
||||
|
self.drawLine() |
||||
|
|
||||
|
def draw_totals_table(self, values): |
||||
|
rowHeights = [7, 7, 7, 7, 7] |
||||
|
data = [ |
||||
|
['QTD.TOTAL DE ITENS', values['quantidade_itens']], |
||||
|
['VALOR TOTAL R$', values['valor_total']], |
||||
|
['DESCONTO R$', values['desconto']], |
||||
|
['VALOR A PAGAR R$', values['valor_a_pagar']], |
||||
|
['FORMA DE PAGAMENTO', 'VALOR PAGO R$'], |
||||
|
] |
||||
|
|
||||
|
for item in values['formas_de_pagamento']: |
||||
|
data.append([item[0], item[1]]) |
||||
|
rowHeights.append(7) |
||||
|
data.append(['TROCO', format_number(values['troco'], precision=2)]) |
||||
|
rowHeights.append(7) |
||||
|
|
||||
|
table2 = Table(data, colWidths=(150, 50), rowHeights=tuple(rowHeights)) |
||||
|
table2.setStyle(TableStyle([ |
||||
|
('FONTSIZE', (0, 0), (-1, -1), 7), |
||||
|
('FONT', (0, 0), (1, -1), 'NimbusSanL-Regu'), |
||||
|
('FONT', (0, 4), (1, 4), 'NimbusSanL-Bold'), |
||||
|
('ALIGN', (1, 0), (1, -1), "RIGHT") |
||||
|
])) |
||||
|
w, h = table2.wrapOn(self.canvas, 200, 450) |
||||
|
table2.drawOn(self.canvas, 0, self.current_height - (h * 1.1)) |
||||
|
self.current_height -= h |
||||
|
|
||||
|
def inf_authentication(self, oXML=None): |
||||
|
el_infNFe = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}infNFe") |
||||
|
# n nfce, serie e data de solicitacao |
||||
|
el_ide = oXML.find(".//{http://www.portalfiscal.inf.br/nfe}ide") |
||||
|
|
||||
|
el_NFeSupl = oXML.find( |
||||
|
".//{http://www.portalfiscal.inf.br/nfe}infNFeSupl") |
||||
|
|
||||
|
el_dest = el_infNFe.find(".//{http://www.portalfiscal.inf.br/nfe}dest") |
||||
|
# chave, n protocolo, data autorizacao |
||||
|
el_prot_nfe = oXML.find( |
||||
|
".//{http://www.portalfiscal.inf.br/nfe}protNFe") |
||||
|
|
||||
|
el_infAdic = oXML.find( |
||||
|
".//{http://www.portalfiscal.inf.br/nfe}infAdic") |
||||
|
|
||||
|
url_chave = tagtext(oNode=el_NFeSupl, cTag='urlChave') |
||||
|
access_key = tagtext(oNode=el_prot_nfe, cTag="chNFe") |
||||
|
|
||||
|
frase_chave_acesso = 'Consulte pela Chave de Acesso em:<br />\ |
||||
|
%s<br />%s' % (url_chave, access_key) |
||||
|
|
||||
|
qrcode = tagtext(oNode=el_NFeSupl, cTag='qrCode') |
||||
|
|
||||
|
cnpj = tagtext(oNode=el_dest, cTag='CNPJ') |
||||
|
cpf = tagtext(oNode=el_dest, cTag='CPF') |
||||
|
if cnpj: |
||||
|
cnpj_cpf = format_cnpj_cpf(cnpj) |
||||
|
cnpj_cpf = "CONSUMIDOR CNPJ: %s" % (cnpj) |
||||
|
elif cpf: |
||||
|
cnpj_cpf = format_cnpj_cpf(cpf) |
||||
|
cnpj_cpf = "CONSUMIDOR CPF: %s" % (cpf) |
||||
|
else: |
||||
|
cnpj_cpf = u"CONSUMIDOR NÃO IDENTIFICADO" |
||||
|
|
||||
|
nNFC = tagtext(oNode=el_ide, cTag="nNF") |
||||
|
serie = tagtext(oNode=el_ide, cTag='serie') |
||||
|
|
||||
|
dataSolicitacao = getdateUTC(tagtext(oNode=el_ide, cTag="dhEmi")) |
||||
|
dataSolicitacao = dataSolicitacao[0] + " " + dataSolicitacao[1] |
||||
|
|
||||
|
numProtocolo = tagtext(oNode=el_prot_nfe, cTag="nProt") |
||||
|
|
||||
|
dataAutorizacao = getdateUTC(tagtext(oNode=el_prot_nfe, |
||||
|
cTag='dhRecbto')) |
||||
|
dataAutorizacao = dataAutorizacao[0] + " " + dataAutorizacao[1] |
||||
|
|
||||
|
text = u"%s <br />%s <br />NFC-e nº%s Série %s %s<br />\ |
||||
|
Protocolo de autorização: %s<br />Data de autorização %s<br />\ |
||||
|
" % (frase_chave_acesso, cnpj_cpf, nNFC, serie, dataSolicitacao, |
||||
|
numProtocolo, dataAutorizacao) |
||||
|
|
||||
|
self._drawCenteredParagraph(text) |
||||
|
|
||||
|
self.draw_qr_code(qrcode) |
||||
|
|
||||
|
infAdFisco = tagtext(oNode=el_infAdic, cTag='infAdFisco') |
||||
|
self._drawCenteredParagraph(infAdFisco) |
||||
|
|
||||
|
infCpl = tagtext(oNode=el_infAdic, cTag='infCpl') |
||||
|
self._drawCenteredParagraph(infCpl) |
||||
|
|
||||
|
def _drawCenteredParagraph(self, text): |
||||
|
|
||||
|
style = ParagraphStyle( |
||||
|
name='Normal', |
||||
|
fontName='NimbusSanL-Regu', |
||||
|
fontSize=7, |
||||
|
alignment=TA_CENTER, |
||||
|
leading=7, |
||||
|
) |
||||
|
|
||||
|
paragraph = Paragraph(text, style=style) |
||||
|
w, h = paragraph.wrapOn(self.canvas, 180, 300) |
||||
|
paragraph.drawOn(self.canvas, 10, self.current_height - h) |
||||
|
self.current_height -= (h*1.1) |
||||
|
|
||||
|
def drawString(self, string, centered=False): |
||||
|
if centered: |
||||
|
self.canvas.drawCentredString( |
||||
|
self.max_width / 2, self.current_height, string) |
||||
|
self.current_height -= self.current_font_size |
||||
|
else: |
||||
|
self.canvas.drawString(self.min_width, self.current_height, string) |
||||
|
self.current_height -= self.current_font_size |
||||
|
|
||||
|
def drawTitle(self, string, size, font='NimbusSanL-Regu'): |
||||
|
self.canvas.setFont(font, size) |
||||
|
self.canvas.drawCentredString( |
||||
|
self.max_width / 2, self.current_height, string) |
||||
|
self.current_height -= self.current_font_size |
||||
|
self.canvas.setFont(self.current_font_name, self.current_font_size) |
||||
|
|
||||
|
def drawLine(self): |
||||
|
self.canvas.line(self.min_width, self.current_height, |
||||
|
self.max_width, self.current_height) |
||||
|
self.current_height -= self.current_font_size |
||||
|
|
||||
|
def draw_qr_code(self, string): |
||||
|
qr_code = qr.QrCodeWidget(string) |
||||
|
drawing = Drawing(23 * mm, 23 * mm) |
||||
|
drawing.add(qr_code) |
||||
|
renderPDF.draw(drawing, self.canvas, 20 * mm, self.current_height - 85) |
||||
|
self.current_height -= 85 |
||||
|
|
||||
|
def newpage(self): |
||||
|
self.current_height = self.max_height |
||||
|
self.Page += 1 |
||||
|
self.canvas.showPage() |
||||
|
|
||||
|
def nfce_generate(self): |
||||
|
for oXML in self.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 29 linhas para itens na primeira folha |
||||
|
nNr_Lin_Pg_1 = 34 if oXML_cobr is None else 30 |
||||
|
# [ 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 |
||||
|
|
||||
|
self.ide_emit(oXML=oXML) |
||||
|
# self.destinatario(oXML=oXML) |
||||
|
self.danfce_information() |
||||
|
|
||||
|
self.produtos(oXML=oXML, el_det=el_det, oPaginator=oPaginator[0], |
||||
|
list_desc=list_desc, list_cod_prod=list_cod_prod) |
||||
|
|
||||
|
self.drawLine() |
||||
|
|
||||
|
self.totais(oXML=oXML) |
||||
|
|
||||
|
self.inf_authentication(oXML=oXML) |
||||
|
|
||||
|
# Gera o restante das páginas do XML |
||||
|
for oPag in oPaginator[1:]: |
||||
|
if oPag: |
||||
|
self.newpage() |
||||
|
self.ide_emit(oXML=oXML) |
||||
|
# self.destinatario(oXML=oXML) |
||||
|
self.produtos(oXML=oXML, el_det=el_det, oPaginator=oPag, |
||||
|
list_desc=list_desc, |
||||
|
list_cod_prod=list_cod_prod) |
||||
|
self.totais(oXML=oXML) |
||||
|
self.inf_authentication(oXML=oXML) |
||||
|
|
||||
|
self.newpage() |
||||
|
|
||||
|
self.canvas.save() |
||||
|
|
||||
|
def writeto_pdf(self, fileObj): |
||||
|
pdf_out = self.oPDF_IO.getvalue() |
||||
|
self.oPDF_IO.close() |
||||
|
fileObj.write(pdf_out) |
||||
@ -0,0 +1,39 @@ |
|||||
|
from ..Servidores import SIGLA_ESTADO |
||||
|
from pytrustnfe.xml import sanitize_response |
||||
|
|
||||
|
|
||||
|
def nfeInutilizacaoCE(session, xml_send, ambiente): |
||||
|
soap = '<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope"><Body>\ |
||||
|
<nfeDadosMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeInutilizacao4"\ |
||||
|
>' + xml_send + '</nfeDadosMsg></Body></Envelope>' |
||||
|
headers = { |
||||
|
'SOAPAction': "", |
||||
|
'Content-Type': 'application/soap+xml; charset="utf-8"' |
||||
|
} |
||||
|
if ambiente == 1: |
||||
|
response = session.post( |
||||
|
'https://nfe.sefaz.ce.gov.br/nfe4/services/NFeInutilizacao4', |
||||
|
data=soap, headers=headers) |
||||
|
else: |
||||
|
response = session.post( |
||||
|
'https://nfeh.sefaz.ce.gov.br/nfe4/services/NFeInutilizacao4', |
||||
|
data=soap, headers=headers) |
||||
|
response, obj = sanitize_response(response.text) |
||||
|
return { |
||||
|
'sent_xml': xml_send, |
||||
|
'received_xml': response, |
||||
|
'object': obj.Body.getchildren()[0] |
||||
|
} |
||||
|
|
||||
|
|
||||
|
methods = { |
||||
|
'NfeInutilizacaoCE': nfeInutilizacaoCE |
||||
|
} |
||||
|
|
||||
|
|
||||
|
def has_patch(cod_estado, metodo): |
||||
|
uf = SIGLA_ESTADO[cod_estado] |
||||
|
method = metodo+uf |
||||
|
if method in methods: |
||||
|
return methods[method] |
||||
|
return None |
||||
@ -1,5 +1,4 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
|
||||
<consSitNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.01"> |
|
||||
|
<consSitNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"> |
||||
<tpAmb>{{ obj.ambiente }}</tpAmb> |
<tpAmb>{{ obj.ambiente }}</tpAmb> |
||||
<xServ>CONSULTAR</xServ> |
<xServ>CONSULTAR</xServ> |
||||
<chNFe>{{ obj.chave_nfe }}</chNFe> |
<chNFe>{{ obj.chave_nfe }}</chNFe> |
||||
@ -1,4 +1,4 @@ |
|||||
<consReciNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10"> |
|
||||
|
<consReciNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"> |
||||
<tpAmb>{{ obj.ambiente }}</tpAmb> |
<tpAmb>{{ obj.ambiente }}</tpAmb> |
||||
<nRec>{{ obj.numero_recibo }}</nRec> |
<nRec>{{ obj.numero_recibo }}</nRec> |
||||
</consReciNFe> |
</consReciNFe> |
||||
@ -1,5 +1,5 @@ |
|||||
<?xml version="1.0" encoding="UTF-8" ?> |
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10"> |
|
||||
|
<consStatServ xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00"> |
||||
<tpAmb>{{ obj.ambiente }}</tpAmb> |
<tpAmb>{{ obj.ambiente }}</tpAmb> |
||||
<cUF>{{ obj.estado }}</cUF> |
<cUF>{{ obj.estado }}</cUF> |
||||
<xServ>STATUS</xServ> |
<xServ>STATUS</xServ> |
||||
@ -1,21 +0,0 @@ |
|||||
<envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|
||||
<idLote>{{ idLote }}</idLote> |
|
||||
<evento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|
||||
<infEvento Id="{{ Id }}"> |
|
||||
<cOrgao>{{ cOrgao }}</cOrgao> |
|
||||
<tpAmb>{{ tpAmb }}</tpAmb> |
|
||||
<CNPJ>{{ CNPJ }}</CNPJ> |
|
||||
<CPF>{{ CPF }}</CPF> |
|
||||
<chNFe>{{ chNFe }}</chNFe> |
|
||||
<dhEvento>{{ dhEvento }}</dhEvento> |
|
||||
<tpEvento>{{ tpEvento }}</tpEvento> |
|
||||
<nSeqEvento>{{ nSeqEvento }}</nSeqEvento> |
|
||||
<verEvento>1.00</verEvento> |
|
||||
<detEvento versao="1.00"> |
|
||||
<descEvento>Carta de Correção</descEvento> |
|
||||
<xCorrecao>{{ xCorrecao|normalize|escape }}</xCorrecao> |
|
||||
<xCondUso>A Carta de Correção é disciplinada pelo § 1º-A do art. 7º do Convênio S/N, de 15 de dezembro de 1970 e pode ser utilizada para regularização de erro ocorrido na emissão de documento fiscal, desde que o erro não esteja relacionado com: I - as variáveis que determinam o valor do imposto tais como: base de cálculo, alíquota, diferença de preço, quantidade, valor da operação ou da prestação; II - a correção de dados cadastrais que implique mudança do remetente ou do destinatário; III - a data de emissão ou de saída.</xCondUso> |
|
||||
</detEvento> |
|
||||
</infEvento> |
|
||||
</evento> |
|
||||
</envEvento> |
|
||||
@ -1,31 +0,0 @@ |
|||||
<envEvento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|
||||
<idLote>00106151340701</idLote> |
|
||||
<evento xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.00"> |
|
||||
<infEvento Id="ID1101403514081014278500019055001001061513407959995201"> |
|
||||
<cOrgao>91</cOrgao> |
|
||||
<tpAmb>2</tpAmb> |
|
||||
<CNPJ>10142785000190</CNPJ> |
|
||||
<chNFe>35140810142785000190550010010615134079599952</chNFe> |
|
||||
<dhEvento>2014-08-07T04:52:51-03:00</dhEvento> |
|
||||
<tpEvento>110140</tpEvento> |
|
||||
<nSeqEvento>1</nSeqEvento> |
|
||||
<verEvento>1.00</verEvento> |
|
||||
<detEvento versao="1.00"> |
|
||||
<descEvento>EPEC</descEvento> |
|
||||
<cOrgaoAutor>35</cOrgaoAutor> |
|
||||
<tpAutor>1</tpAutor> |
|
||||
<verAplic>1.26</verAplic> |
|
||||
<dhEmi>2014-08-07T00:00:00-03:00</dhEmi> |
|
||||
<tpNF>1</tpNF> |
|
||||
<IE>495171423115</IE> |
|
||||
<dest> |
|
||||
<UF>SP</UF> |
|
||||
<CPF>00000000191</CPF> |
|
||||
<vNF>86.00</vNF> |
|
||||
<vICMS>6.02</vICMS> |
|
||||
<vST>0</vST> |
|
||||
</dest> |
|
||||
</detEvento> |
|
||||
</infEvento> |
|
||||
</evento> |
|
||||
</envEvento> |
|
||||
@ -0,0 +1,84 @@ |
|||||
|
# © 2018 Danimar Ribeiro, Trustcode |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import os |
||||
|
from lxml import etree |
||||
|
from requests import Session |
||||
|
from zeep import Client |
||||
|
from zeep.transports import Transport |
||||
|
|
||||
|
from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key |
||||
|
from pytrustnfe.xml import render_xml, sanitize_response |
||||
|
from pytrustnfe.nfse.bh.assinatura import Assinatura |
||||
|
|
||||
|
|
||||
|
def _render(certificado, method, **kwargs): |
||||
|
path = os.path.join(os.path.dirname(__file__), 'templates') |
||||
|
xml_send = render_xml(path, '%s.xml' % method, True, **kwargs) |
||||
|
|
||||
|
reference = '' |
||||
|
ref_lote = '' |
||||
|
if method == 'GerarNfse': |
||||
|
reference = 'rps:%s' % kwargs['rps']['numero'] |
||||
|
ref_lote = 'lote%s' % kwargs['rps']['numero_lote'] |
||||
|
elif method == 'CancelarNfse': |
||||
|
reference = 'pedidoCancelamento_%s' % kwargs['cancelamento']['numero_nfse'] |
||||
|
|
||||
|
signer = Assinatura(certificado.pfx, certificado.password) |
||||
|
xml_send = signer.assina_xml(xml_send, reference) |
||||
|
if ref_lote: |
||||
|
xml_send = signer.assina_xml(etree.fromstring(xml_send), ref_lote) |
||||
|
return xml_send.encode('utf-8') |
||||
|
|
||||
|
|
||||
|
def _send(certificado, method, **kwargs): |
||||
|
base_url = '' |
||||
|
if kwargs['ambiente'] == 'producao': |
||||
|
base_url = 'https://bhissdigital.pbh.gov.br/bhiss-ws/nfse?wsdl' |
||||
|
else: |
||||
|
base_url = 'https://bhisshomologa.pbh.gov.br/bhiss-ws/nfse?wsdl' |
||||
|
|
||||
|
xml_send = kwargs["xml"].decode('utf-8') |
||||
|
xml_cabecalho = '<?xml version="1.0" encoding="UTF-8"?>\ |
||||
|
<cabecalho xmlns="http://www.abrasf.org.br/nfse.xsd" versao="1.00">\ |
||||
|
<versaoDados>1.00</versaoDados></cabecalho>' |
||||
|
|
||||
|
cert, key = extract_cert_and_key_from_pfx( |
||||
|
certificado.pfx, certificado.password) |
||||
|
cert, key = save_cert_key(cert, key) |
||||
|
|
||||
|
session = Session() |
||||
|
session.cert = (cert, key) |
||||
|
session.verify = False |
||||
|
transport = Transport(session=session) |
||||
|
|
||||
|
client = Client(base_url, transport=transport) |
||||
|
|
||||
|
response = client.service[method](xml_cabecalho, xml_send) |
||||
|
|
||||
|
response, obj = sanitize_response(response) |
||||
|
return { |
||||
|
'sent_xml': xml_send, |
||||
|
'received_xml': response, |
||||
|
'object': obj |
||||
|
} |
||||
|
|
||||
|
|
||||
|
def xml_gerar_nfse(certificado, **kwargs): |
||||
|
return _render(certificado, 'GerarNfse', **kwargs) |
||||
|
|
||||
|
|
||||
|
def gerar_nfse(certificado, **kwargs): |
||||
|
if "xml" not in kwargs: |
||||
|
kwargs['xml'] = xml_gerar_nfse(certificado, **kwargs) |
||||
|
return _send(certificado, 'GerarNfse', **kwargs) |
||||
|
|
||||
|
|
||||
|
def xml_cancelar_nfse(certificado, **kwargs): |
||||
|
return _render(certificado, 'CancelarNfse', **kwargs) |
||||
|
|
||||
|
|
||||
|
def cancelar_nfse(certificado, **kwargs): |
||||
|
if "xml" not in kwargs: |
||||
|
kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs) |
||||
|
return _send(certificado, 'CancelarNfse', **kwargs) |
||||
@ -0,0 +1,44 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Danimar Ribeiro, Trustcode |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import signxml |
||||
|
from lxml import etree |
||||
|
from pytrustnfe.certificado import extract_cert_and_key_from_pfx |
||||
|
from signxml import XMLSigner |
||||
|
|
||||
|
|
||||
|
class Assinatura(object): |
||||
|
|
||||
|
def __init__(self, arquivo, senha): |
||||
|
self.arquivo = arquivo |
||||
|
self.senha = senha |
||||
|
|
||||
|
def assina_xml(self, xml_element, reference): |
||||
|
cert, key = extract_cert_and_key_from_pfx(self.arquivo, self.senha) |
||||
|
|
||||
|
for element in xml_element.iter("*"): |
||||
|
if element.text is not None and not element.text.strip(): |
||||
|
element.text = None |
||||
|
|
||||
|
signer = XMLSigner( |
||||
|
method=signxml.methods.enveloped, signature_algorithm="rsa-sha1", |
||||
|
digest_algorithm='sha1', |
||||
|
c14n_algorithm='http://www.w3.org/TR/2001/REC-xml-c14n-20010315') |
||||
|
|
||||
|
ns = {} |
||||
|
ns[None] = signer.namespaces['ds'] |
||||
|
signer.namespaces = ns |
||||
|
|
||||
|
ref_uri = ('#%s' % reference) if reference else None |
||||
|
signed_root = signer.sign( |
||||
|
xml_element, key=key.encode(), cert=cert.encode(), |
||||
|
reference_uri=ref_uri) |
||||
|
if reference: |
||||
|
element_signed = signed_root.find(".//*[@Id='%s']" % reference) |
||||
|
signature = signed_root.find(".//*[@URI='#%s']" % reference).getparent().getparent() |
||||
|
|
||||
|
if element_signed is not None and signature is not None: |
||||
|
parent = element_signed.getparent() |
||||
|
parent.append(signature) |
||||
|
return etree.tostring(signed_root, encoding=str) |
||||
@ -0,0 +1,13 @@ |
|||||
|
<CancelarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd"> |
||||
|
<Pedido xmlns="http://www.abrasf.org.br/nfse.xsd"> |
||||
|
<InfPedidoCancelamento Id="pedidoCancelamento_{{ cancelamento.numero_nfse }}"> |
||||
|
<IdentificacaoNfse> |
||||
|
<Numero>{{ cancelamento.numero_nfse }}</Numero> |
||||
|
<Cnpj>{{ cancelamento.cnpj_prestador }}</Cnpj> |
||||
|
<InscricaoMunicipal>{{ cancelamento.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
<CodigoMunicipio>{{ cancelamento.cidade }}</CodigoMunicipio> |
||||
|
</IdentificacaoNfse> |
||||
|
<CodigoCancelamento>2</CodigoCancelamento> |
||||
|
</InfPedidoCancelamento> |
||||
|
</Pedido> |
||||
|
</CancelarNfseEnvio> |
||||
@ -0,0 +1,11 @@ |
|||||
|
<GerarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd"> |
||||
|
<LoteRps Id="lote{{ rps.numero_lote }}" versao="1.00"> |
||||
|
<NumeroLote>{{ rps.numero_lote }}</NumeroLote> |
||||
|
<Cnpj>{{ rps.prestador.cnpj }}</Cnpj> |
||||
|
<InscricaoMunicipal>{{ rps.prestador.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
<QuantidadeRps>1</QuantidadeRps> |
||||
|
<ListaRps xmlns="http://www.abrasf.org.br/nfse.xsd"> |
||||
|
{% include 'Rps.xml' %} |
||||
|
</ListaRps> |
||||
|
</LoteRps> |
||||
|
</GerarNfseEnvio> |
||||
@ -0,0 +1,91 @@ |
|||||
|
<Rps> |
||||
|
<InfRps xmlns="http://www.abrasf.org.br/nfse.xsd" Id="rps:{{ rps.numero }}"> |
||||
|
<IdentificacaoRps> |
||||
|
<Numero>{{ rps.numero }}</Numero> |
||||
|
<Serie>{{ rps.serie }}</Serie> |
||||
|
<Tipo>{{ rps.tipo_rps }}</Tipo> |
||||
|
</IdentificacaoRps> |
||||
|
<DataEmissao>{{ rps.data_emissao }}</DataEmissao> |
||||
|
<NaturezaOperacao>{{ rps.natureza_operacao }}</NaturezaOperacao> |
||||
|
<RegimeEspecialTributacao>{{ rps.regime_tributacao }}</RegimeEspecialTributacao> |
||||
|
<OptanteSimplesNacional>{{ rps.optante_simples }}</OptanteSimplesNacional> |
||||
|
<IncentivadorCultural>{{ rps.incentivador_cultural }}</IncentivadorCultural> |
||||
|
<Status>{{ rps.status }}</Status> |
||||
|
<RpsSubstituido> |
||||
|
<Numero>{{ rps.numero_substituido }}</Numero> |
||||
|
<Serie>{{ rps.serie_substituido }}</Serie> |
||||
|
<Tipo>{{ rps.tipo_substituido }}</Tipo> |
||||
|
</RpsSubstituido> |
||||
|
<Servico> |
||||
|
<Valores> |
||||
|
<ValorServicos>{{ rps.valor_servico }}</ValorServicos> |
||||
|
<ValorDeducoes>{{ rps.valor_deducao }}</ValorDeducoes> |
||||
|
<ValorPis>{{ rps.valor_pis }}</ValorPis> |
||||
|
<ValorCofins>{{ rps.valor_cofins }}</ValorCofins> |
||||
|
<ValorInss>{{ rps.valor_inss }}</ValorInss> |
||||
|
<ValorIr>{{ rps.valor_ir }}</ValorIr> |
||||
|
<ValorCsll>{{ rps.valor_csll }}</ValorCsll> |
||||
|
<IssRetido>{{ rps.iss_retido }}</IssRetido> |
||||
|
<ValorIss>{{ rps.valor_iss }}</ValorIss> |
||||
|
<ValorIssRetido>{{ rps.valor_iss_retido }}</ValorIssRetido> |
||||
|
<OutrasRetencoes>{{ rps.outras_retencoes }}</OutrasRetencoes> |
||||
|
<BaseCalculo>{{ rps.base_calculo }}</BaseCalculo> |
||||
|
<Aliquota>{{ rps.aliquota_issqn }}</Aliquota> |
||||
|
<ValorLiquidoNfse>{{ rps.valor_liquido_nfse }}</ValorLiquidoNfse> |
||||
|
<DescontoIncondicionado>{{ rps.desconto_incondicionado }}</DescontoIncondicionado> |
||||
|
<DescontoCondicionado>{{ rps.desconto_condicionado }}</DescontoCondicionado> |
||||
|
</Valores> |
||||
|
<ItemListaServico>{{ rps.codigo_servico }}</ItemListaServico> |
||||
|
<CodigoCnae>{{ rps.cnae_servico }}</CodigoCnae> |
||||
|
<CodigoTributacaoMunicipio>{{ rps.codigo_tributacao_municipio }}</CodigoTributacaoMunicipio> |
||||
|
<Discriminacao>{{ rps.descricao }}</Discriminacao> |
||||
|
<CodigoMunicipio>{{ rps.codigo_municipio }}</CodigoMunicipio> |
||||
|
</Servico> |
||||
|
<Prestador> |
||||
|
<Cnpj>{{ rps.prestador.cnpj }}</Cnpj> |
||||
|
<InscricaoMunicipal>{{ rps.prestador.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
</Prestador> |
||||
|
<Tomador> |
||||
|
<IdentificacaoTomador> |
||||
|
<CpfCnpj> |
||||
|
{% if rps.tomador.cnpj_cpf|length == 14 %} |
||||
|
<Cnpj>{{ rps.tomador.cnpj_cpf }}</Cnpj> |
||||
|
{% endif %} |
||||
|
{% if rps.tomador.cnpj_cpf|length == 11 %} |
||||
|
<Cpf>{{ rps.tomador.cnpj_cpf }}</Cpf> |
||||
|
{% endif %} |
||||
|
</CpfCnpj> |
||||
|
<InscricaoMunicipal>{{ rps.tomador.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
</IdentificacaoTomador> |
||||
|
<RazaoSocial>{{ rps.tomador.razao_social }}</RazaoSocial> |
||||
|
<Endereco> |
||||
|
<Endereco>{{ rps.tomador.logradouro }}</Endereco> |
||||
|
<Numero>{{ rps.tomador.numero }}</Numero> |
||||
|
<Complemento>{{ rps.tomador.complemento }}</Complemento> |
||||
|
<Bairro>{{ rps.tomador.bairro }}</Bairro> |
||||
|
<CodigoMunicipio>{{ rps.tomador.cidade }}</CodigoMunicipio> |
||||
|
<Uf>{{ rps.tomador.uf }}</Uf> |
||||
|
<Cep>{{ rps.tomador.cep }}</Cep> |
||||
|
</Endereco> |
||||
|
<Contato> |
||||
|
<Telefone>{{ rps.tomador.telefone }}</Telefone> |
||||
|
<Email>{{ rps.tomador.email }}</Email> |
||||
|
</Contato> |
||||
|
</Tomador> |
||||
|
{% if rps.intermediario is defined -%} |
||||
|
<IntermediarioServico> |
||||
|
<RazaoSocial>{{ rps.intermediario.razao_social }}</RazaoSocial> |
||||
|
<CpfCnpj> |
||||
|
<Cnpj>{{ rps.intermediario.cnpj }}</Cnpj> |
||||
|
</CpfCnpj> |
||||
|
<InscricaoMunicipal>{{ rps.intermediario.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
</IntermediarioServico> |
||||
|
{% endif %} |
||||
|
{% if rps.construcao_civil is defined -%} |
||||
|
<ContrucaoCivil> |
||||
|
<CodigoObra>{{ rps.construcao_civil.codigo_obra }}</CodigoObra> |
||||
|
<Art>{{ rps.construcao_civil.art }}</Art> |
||||
|
</ContrucaoCivil> |
||||
|
{% endif %} |
||||
|
</InfRps> |
||||
|
</Rps> |
||||
@ -0,0 +1,75 @@ |
|||||
|
# © 2018 Danimar Ribeiro, Trustcode |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import os |
||||
|
from requests import Session |
||||
|
from zeep import Client |
||||
|
from zeep.transports import Transport |
||||
|
|
||||
|
from pytrustnfe.certificado import extract_cert_and_key_from_pfx, save_cert_key |
||||
|
from pytrustnfe.xml import render_xml, sanitize_response |
||||
|
from pytrustnfe.nfse.mga.assinatura import Assinatura |
||||
|
|
||||
|
|
||||
|
def _render(certificado, method, **kwargs): |
||||
|
path = os.path.join(os.path.dirname(__file__), 'templates') |
||||
|
xml_send = render_xml(path, '%s.xml' % method, True, **kwargs) |
||||
|
|
||||
|
reference = '' |
||||
|
if method == 'GerarNfse': |
||||
|
reference = 'rps:%s' % kwargs['rps']['numero'] |
||||
|
elif method == 'CancelarNfse': |
||||
|
reference = 'Cancelamento_NF%s' % kwargs['cancelamento']['numero_nfse'] |
||||
|
|
||||
|
signer = Assinatura(certificado.pfx, certificado.password) |
||||
|
xml_send = signer.assina_xml(xml_send, reference) |
||||
|
return xml_send.encode('utf-8') |
||||
|
|
||||
|
|
||||
|
def _send(certificado, method, **kwargs): |
||||
|
base_url = '' |
||||
|
if kwargs['ambiente'] == 'producao': |
||||
|
base_url = 'https://isse.maringa.pr.gov.br/ws/?wsdl' |
||||
|
else: |
||||
|
base_url = 'https://isseteste.maringa.pr.gov.br/ws/?wsdl' |
||||
|
|
||||
|
xml_send = kwargs["xml"].decode('utf-8') |
||||
|
|
||||
|
cert, key = extract_cert_and_key_from_pfx( |
||||
|
certificado.pfx, certificado.password) |
||||
|
cert, key = save_cert_key(cert, key) |
||||
|
|
||||
|
session = Session() |
||||
|
session.cert = (cert, key) |
||||
|
session.verify = False |
||||
|
transport = Transport(session=session) |
||||
|
|
||||
|
client = Client(base_url, transport=transport) |
||||
|
response = client.service[method](xml_send) |
||||
|
|
||||
|
response, obj = sanitize_response(response) |
||||
|
return { |
||||
|
'sent_xml': str(xml_send), |
||||
|
'received_xml': str(response), |
||||
|
'object': obj |
||||
|
} |
||||
|
|
||||
|
|
||||
|
def xml_gerar_nfse(certificado, **kwargs): |
||||
|
return _render(certificado, 'GerarNfse', **kwargs) |
||||
|
|
||||
|
|
||||
|
def gerar_nfse(certificado, **kwargs): |
||||
|
if "xml" not in kwargs: |
||||
|
kwargs['xml'] = xml_gerar_nfse(certificado, **kwargs) |
||||
|
return _send(certificado, 'GerarNfse', **kwargs) |
||||
|
|
||||
|
|
||||
|
def xml_cancelar_nfse(certificado, **kwargs): |
||||
|
return _render(certificado, 'CancelarNfse', **kwargs) |
||||
|
|
||||
|
|
||||
|
def cancelar_nfse(certificado, **kwargs): |
||||
|
if "xml" not in kwargs: |
||||
|
kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs) |
||||
|
return _send(certificado, 'CancelarNfse', **kwargs) |
||||
@ -0,0 +1,45 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# © 2016 Danimar Ribeiro, Trustcode |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import signxml |
||||
|
from lxml import etree |
||||
|
from pytrustnfe.certificado import extract_cert_and_key_from_pfx |
||||
|
from signxml import XMLSigner |
||||
|
|
||||
|
|
||||
|
class Assinatura(object): |
||||
|
|
||||
|
def __init__(self, arquivo, senha): |
||||
|
self.arquivo = arquivo |
||||
|
self.senha = senha |
||||
|
|
||||
|
def assina_xml(self, xml_element, reference): |
||||
|
cert, key = extract_cert_and_key_from_pfx(self.arquivo, self.senha) |
||||
|
|
||||
|
for element in xml_element.iter("*"): |
||||
|
if element.text is not None and not element.text.strip(): |
||||
|
element.text = None |
||||
|
|
||||
|
signer = XMLSigner( |
||||
|
method=signxml.methods.enveloped, signature_algorithm=u"rsa-sha1", |
||||
|
digest_algorithm=u'sha1', |
||||
|
c14n_algorithm=u'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') |
||||
|
|
||||
|
ns = {} |
||||
|
ns[None] = signer.namespaces['ds'] |
||||
|
signer.namespaces = ns |
||||
|
element_to_be_signed = xml_element.getchildren()[0].getchildren()[0] |
||||
|
|
||||
|
signed_root = signer.sign( |
||||
|
element_to_be_signed, key=key.encode(), cert=cert.encode()) |
||||
|
if reference: |
||||
|
element_signed = xml_element.find(".//*[@Id='%s']" % reference) |
||||
|
|
||||
|
signature = signed_root.find( |
||||
|
".//{http://www.w3.org/2000/09/xmldsig#}Signature") |
||||
|
|
||||
|
if element_signed is not None and signature is not None: |
||||
|
parent = xml_element.getchildren()[0] |
||||
|
parent.append(signature) |
||||
|
return etree.tostring(xml_element, encoding=str) |
||||
@ -0,0 +1,15 @@ |
|||||
|
<CancelarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd"> |
||||
|
<Pedido> |
||||
|
<InfPedidoCancelamento Id="Cancelamento_NF{{ cancelamento.numero_nfse }}"> |
||||
|
<IdentificacaoNfse> |
||||
|
<Numero>{{ cancelamento.numero_nfse }}</Numero> |
||||
|
<CpfCnpj> |
||||
|
<Cnpj>{{ cancelamento.cnpj_prestador }}</Cnpj> |
||||
|
</CpfCnpj> |
||||
|
<InscricaoMunicipal>{{ cancelamento.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
<CodigoMunicipio>{{ cancelamento.cidade }}</CodigoMunicipio> |
||||
|
</IdentificacaoNfse> |
||||
|
<CodigoCancelamento>1</CodigoCancelamento> |
||||
|
</InfPedidoCancelamento> |
||||
|
</Pedido> |
||||
|
</CancelarNfseEnvio> |
||||
@ -0,0 +1,3 @@ |
|||||
|
<GerarNfseEnvio xmlns="http://www.abrasf.org.br/nfse.xsd"> |
||||
|
{% include 'Rps.xml' %} |
||||
|
</GerarNfseEnvio> |
||||
@ -0,0 +1,81 @@ |
|||||
|
<Rps> |
||||
|
<InfDeclaracaoPrestacaoServico> |
||||
|
<Rps Id="rps:{{ rps.numero }}"> |
||||
|
<IdentificacaoRps> |
||||
|
<Numero>{{ rps.numero }}</Numero> |
||||
|
<Serie>{{ rps.serie }}</Serie> |
||||
|
<Tipo>{{ rps.tipo_rps }}</Tipo> |
||||
|
</IdentificacaoRps> |
||||
|
<DataEmissao>{{ rps.data_emissao }}</DataEmissao> |
||||
|
<Status>{{ rps.status }}</Status> |
||||
|
</Rps> |
||||
|
<Competencia>{{ rps.data_emissao }}</Competencia> |
||||
|
<Servico> |
||||
|
<Valores> |
||||
|
<ValorServicos>{{ rps.valor_servico }}</ValorServicos> |
||||
|
<ValorDeducoes>{{ rps.valor_deducao }}</ValorDeducoes> |
||||
|
<ValorPis>{{ rps.valor_pis }}</ValorPis> |
||||
|
<ValorCofins>{{ rps.valor_cofins }}</ValorCofins> |
||||
|
<ValorInss>{{ rps.valor_inss }}</ValorInss> |
||||
|
<ValorIr>{{ rps.valor_ir }}</ValorIr> |
||||
|
<ValorCsll>{{ rps.valor_csll }}</ValorCsll> |
||||
|
<OutrasRetencoes>{{ rps.outras_retencoes }}</OutrasRetencoes> |
||||
|
<ValorIss>{{ rps.valor_iss }}</ValorIss> |
||||
|
<Aliquota>{{ rps.aliquota_issqn }}</Aliquota> |
||||
|
<DescontoIncondicionado>{{ rps.desconto_incondicionado }}</DescontoIncondicionado> |
||||
|
<DescontoCondicionado>{{ rps.desconto_condicionado }}</DescontoCondicionado> |
||||
|
</Valores> |
||||
|
<IssRetido>{{ rps.iss_retido }}</IssRetido> |
||||
|
<ItemListaServico>{{ rps.codigo_servico }}</ItemListaServico> |
||||
|
<CodigoCnae>{{ rps.cnae_servico }}</CodigoCnae> |
||||
|
<CodigoTributacaoMunicipio>{{ rps.codigo_tributacao_municipio }}</CodigoTributacaoMunicipio> |
||||
|
<Discriminacao>{{ rps.descricao }}</Discriminacao> |
||||
|
<CodigoMunicipio>{{ rps.codigo_municipio }}</CodigoMunicipio> |
||||
|
<CodigoPais>{{ rps.codigo_pais }}</CodigoPais> |
||||
|
<ExigibilidadeISS>{{ rps.exigibilidade_iss}}</ExigibilidadeISS> |
||||
|
</Servico> |
||||
|
<Prestador> |
||||
|
<CpfCnpj> |
||||
|
<Cnpj>{{ rps.prestador.cnpj }}</Cnpj> |
||||
|
</CpfCnpj> |
||||
|
<InscricaoMunicipal>{{ rps.prestador.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
</Prestador> |
||||
|
<Tomador> |
||||
|
<IdentificacaoTomador> |
||||
|
<CpfCnpj> |
||||
|
{% if rps.tomador.cnpj_cpf|length == 14 %} |
||||
|
<Cnpj>{{ rps.tomador.cnpj_cpf }}</Cnpj> |
||||
|
{% endif %} |
||||
|
{% if rps.tomador.cnpj_cpf|length == 11 %} |
||||
|
<Cpf>{{ rps.tomador.cnpj_cpf }}</Cpf> |
||||
|
{% endif %} |
||||
|
</CpfCnpj> |
||||
|
<InscricaoMunicipal>{{ rps.tomador.inscricao_municipal }}</InscricaoMunicipal> |
||||
|
</IdentificacaoTomador> |
||||
|
<RazaoSocial>{{ rps.tomador.razao_social }}</RazaoSocial> |
||||
|
<Endereco> |
||||
|
<Endereco>{{ rps.tomador.logradouro }}</Endereco> |
||||
|
<Numero>{{ rps.tomador.numero }}</Numero> |
||||
|
<Complemento>{{ rps.tomador.complemento }}</Complemento> |
||||
|
<Bairro>{{ rps.tomador.bairro }}</Bairro> |
||||
|
<CodigoMunicipio>{{ rps.tomador.cidade }}</CodigoMunicipio> |
||||
|
<Uf>{{ rps.tomador.uf }}</Uf> |
||||
|
<CodigoPais>{{ rps.tomador.codigo_pais }}</CodigoPais> |
||||
|
<Cep>{{ rps.tomador.cep }}</Cep> |
||||
|
</Endereco> |
||||
|
<Contato> |
||||
|
<Telefone>{{ rps.tomador.telefone }}</Telefone> |
||||
|
<Email>{{ rps.tomador.email }}</Email> |
||||
|
</Contato> |
||||
|
</Tomador> |
||||
|
{% if rps.construcao_civil is defined -%} |
||||
|
<ContrucaoCivil> |
||||
|
<CodigoObra>{{ rps.construcao_civil.codigo_obra }}</CodigoObra> |
||||
|
<Art>{{ rps.construcao_civil.art }}</Art> |
||||
|
</ContrucaoCivil> |
||||
|
{% endif %} |
||||
|
<RegimeEspecialTributacao>{{ rps.regime_tributacao }}</RegimeEspecialTributacao> |
||||
|
<OptanteSimplesNacional>{{ rps.optante_simples }}</OptanteSimplesNacional> |
||||
|
<IncentivoFiscal>{{ rps.incentivador_cultural }}</IncentivoFiscal> |
||||
|
</InfDeclaracaoPrestacaoServico> |
||||
|
</Rps> |
||||
@ -0,0 +1,150 @@ |
|||||
|
AC = '12' |
||||
|
AL = '27' |
||||
|
AM = '13' |
||||
|
AP = '16' |
||||
|
BA = '29' |
||||
|
CE = '23' |
||||
|
DF = '53' |
||||
|
ES = '32' |
||||
|
GO = '52' |
||||
|
MA = '21' |
||||
|
MG = '31' |
||||
|
MS = '50' |
||||
|
MT = '51' |
||||
|
PA = '15' |
||||
|
PB = '25' |
||||
|
PE = '26' |
||||
|
PI = '22' |
||||
|
PR = '41' |
||||
|
RJ = '33' |
||||
|
RN = '24' |
||||
|
RO = '11' |
||||
|
RR = '14' |
||||
|
RS = '43' |
||||
|
SC = '42' |
||||
|
SE = '28' |
||||
|
SP = '35' |
||||
|
TO = '17' |
||||
|
|
||||
|
PRODUCAO = '1' |
||||
|
HOMOLOGACAO = '2' |
||||
|
|
||||
|
URLS = { |
||||
|
PRODUCAO: { |
||||
|
AC: 'http://www.sefaznet.ac.gov.br/nfce/qrcode?', |
||||
|
AL: 'http://nfce.sefaz.al.gov.br/QRCode/consultarNFCe.jsp?', |
||||
|
AM: 'http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?', |
||||
|
AP: 'https://www.sefaz.ap.gov.br/nfce/nfcep.php?', |
||||
|
BA: 'http://nfe.sefaz.ba.gov.br/servicos/nfce/qrcode.aspx?', |
||||
|
DF: 'http://www.fazenda.df.gov.br/nfce/qrcode?', |
||||
|
GO: 'http://nfe.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe?', |
||||
|
MA: 'http://nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp?', |
||||
|
MS: 'http://www.dfe.ms.gov.br/nfce/qrcode?', |
||||
|
MT: 'http://www.sefaz.mt.gov.br/nfce/consultanfce?', |
||||
|
PA: 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/nfceForm.seam?', # noqa |
||||
|
PB: 'http://www.receita.pb.gov.br/nfce?', |
||||
|
PE: 'http://nfce.sefaz.pe.gov.br/nfce/consulta?', |
||||
|
PI: 'http://www.sefaz.pi.gov.br/nfce/qrcode?', |
||||
|
PR: 'http://www.fazenda.pr.gov.br/nfce/consulta?', |
||||
|
RJ: 'http://www4.fazenda.rj.gov.br/consultaNFCe/QRCode?', |
||||
|
RN: 'http://nfce.set.rn.gov.br/consultarNFCe.aspx?', |
||||
|
RO: 'http://www.nfce.sefin.ro.gov.br/consultanfce/consulta.jsp?', |
||||
|
RR: 'https://www.sefaz.rr.gov.br/nfce/servlet/qrcode?', |
||||
|
RS: 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx?', |
||||
|
SE: 'http://www.nfce.se.gov.br/nfce/qrcode?', |
||||
|
SP: 'https://www.nfce.fazenda.sp.gov.br/qrcode?', |
||||
|
TO: 'http://www.sefaz.to.gov.br/nfce/qrcode?', |
||||
|
}, |
||||
|
HOMOLOGACAO: { |
||||
|
AC: 'http://www.hml.sefaznet.ac.gov.br/nfce/qrcode?', |
||||
|
AL: 'http://nfce.sefaz.al.gov.br/QRCode/consultarNFCe.jsp?', |
||||
|
AM: 'http://homnfce.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?', |
||||
|
AP: 'https://www.sefaz.ap.gov.br/nfcehml/nfce.php?', |
||||
|
BA: 'http://hnfe.sefaz.ba.gov.br/servicos/nfce/qrcode.aspx?', |
||||
|
DF: 'http://www.fazenda.df.gov.br/nfce/qrcode?', |
||||
|
GO: 'http://homolog.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe?', |
||||
|
MA: 'http://homologacao.sefaz.ma.gov.br/portal/consultarNFCe.jsp?', |
||||
|
MS: 'http://www.dfe.ms.gov.br/nfce/qrcode?', |
||||
|
MT: 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce?', |
||||
|
PA: 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/nfceForm.seam?', # noqa |
||||
|
PB: 'http://www.receita.pb.gov.br/nfcehom?', |
||||
|
PE: 'http://nfcehomolog.sefaz.pe.gov.br/nfce/consulta?', |
||||
|
PI: 'http://www.sefaz.pi.gov.br/nfce/qrcode?', |
||||
|
PR: 'http://www.fazenda.pr.gov.br/nfce/consulta?', |
||||
|
RJ: 'http://www4.fazenda.rj.gov.br/consultaNFCe/QRCode?', |
||||
|
RN: 'http://hom.nfce.set.rn.gov.br/consultarNFCe.aspx?', |
||||
|
RO: 'http://200.174.88.103:8080/nfce/servlet/qrcode?', |
||||
|
RR: 'https://www.sefaz.rr.gov.br/nfce/servlet/qrcode?', |
||||
|
RS: 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx?', |
||||
|
SE: 'http://www.hom.nfe.se.gov.br/nfce/qrcode?', |
||||
|
SP: 'https://www.homologacao.nfce.fazenda.sp.gov.br/qrcode?', |
||||
|
TO: 'http://homologacao.sefaz.to.gov.br/nfce/qrcode?', |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
URLS_EXIBICAO = { |
||||
|
PRODUCAO: { |
||||
|
AC: 'www.sefaznet.ac.gov.br/nfce/consulta', |
||||
|
AL: 'www.sefaz.al.gov.br/nfce/consulta', |
||||
|
AM: 'www.sefaz.am.gov.br/nfce/consulta', |
||||
|
AP: 'www.sefaz.ap.gov.br/nfce/consulta', |
||||
|
BA: 'http://www.sefaz.ba.gov.br/nfce/consulta', |
||||
|
CE: 'www.sefaz.ce.gov.br/nfce/consulta', |
||||
|
DF: 'www.fazenda.df.gov.br/nfce/consulta', |
||||
|
ES: 'www.sefaz.es.gov.br/nfce/consulta', |
||||
|
GO: 'www.sefaz.go.gov.br/nfce/consulta', |
||||
|
MA: 'www.sefaz.ma.gov.br/nfce/consulta', |
||||
|
MS: 'www.dfe.ms.gov.br/nfce/consulta', |
||||
|
MT: 'www.sefaz.mt.gov.br/nfce/consulta', |
||||
|
MG: 'www.fazenda.mg.gov.br/nfce/consulta', |
||||
|
PA: 'www.sefa.pa.gov.br/nfce/consulta', |
||||
|
PB: 'www.receita.pb.gov.br/nfce/consulta', |
||||
|
PE: 'nfce.sefaz.pe.gov.br/nfce/consulta', |
||||
|
PI: 'www.sefaz.pi.gov.br/nfce/consulta', |
||||
|
PR: 'http://www.fazenda.pr.gov.br/nfce/consulta', |
||||
|
RJ: 'www.fazenda.rj.gov.br/nfce/consulta', |
||||
|
RN: 'www.set.rn.gov.br/nfce/consulta', |
||||
|
RO: 'www.sefin.ro.gov.br/nfce/consulta', |
||||
|
RR: 'www.sefaz.rr.gov.br/nfce/consulta', |
||||
|
RS: 'www.sefaz.rs.gov.br/nfce/consulta', |
||||
|
SE: 'http://www.nfce.se.gov.br/nfce/consulta', |
||||
|
SP: 'https://www.nfce.fazenda.sp.gov.br/consulta', |
||||
|
TO: 'www.sefaz.to.gov.br/nfce/consulta', |
||||
|
}, |
||||
|
HOMOLOGACAO: { |
||||
|
AC: 'www.sefaznet.ac.gov.br/nfce/consulta', |
||||
|
AL: 'www.sefaz.al.gov.br/nfce/consulta', |
||||
|
AM: 'www.sefaz.am.gov.br/nfce/consulta', |
||||
|
AP: 'www.sefaz.ap.gov.br/nfce/consulta', |
||||
|
BA: 'http://hinternet.sefaz.ba.gov.br/nfce/consulta', |
||||
|
CE: 'www.sefaz.ce.gov.br/nfce/consulta', |
||||
|
DF: 'www.fazenda.df.gov.br/nfce/consulta', |
||||
|
ES: 'www.sefaz.es.gov.br/nfce/consulta', |
||||
|
GO: 'www.sefaz.go.gov.br/nfce/consulta', |
||||
|
MA: 'www.sefaz.ma.gov.br/nfce/consulta', |
||||
|
MS: 'www.dfe.ms.gov.br/nfce/consulta', |
||||
|
MT: 'www.sefaz.mt.gov.br/nfce/consulta', |
||||
|
MG: 'www.fazenda.mg.gov.br/nfce/consulta', |
||||
|
PA: 'www.sefa.pa.gov.br/nfce/consulta', |
||||
|
PB: 'www.receita.pb.gov.br/nfcehom', |
||||
|
PE: 'nfce.sefaz.pe.gov.br/nfce/consulta', |
||||
|
PI: 'www.sefaz.pi.gov.br/nfce/consulta', |
||||
|
PR: 'http://www.fazenda.pr.gov.br/nfce/consulta', |
||||
|
RJ: 'www.fazenda.rj.gov.br/nfce/consulta', |
||||
|
RN: 'www.set.rn.gov.br/nfce/consulta', |
||||
|
RO: 'www.sefin.ro.gov.br/nfce/consulta', |
||||
|
RR: 'www.sefaz.rr.gov.br/nfce/consulta', |
||||
|
RS: 'www.sefaz.rs.gov.br/nfce/consulta', |
||||
|
SE: 'http://www.hom.nfe.se.gov.br/nfce/consulta', |
||||
|
SP: 'https://www.homologacao.nfce.fazenda.sp.gov.br/consulta', |
||||
|
TO: 'www.sefaz.to.gov.br/nfce/consulta', |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
def url_qrcode(estado, ambiente): |
||||
|
return URLS[ambiente][estado] |
||||
|
|
||||
|
|
||||
|
def url_qrcode_exibicao(estado, ambiente): |
||||
|
return URLS_EXIBICAO[ambiente][estado] |
||||
@ -1,6 +1,6 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
<?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: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_v3.10.xsd"/> |
|
||||
|
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/> |
||||
<xs:element name="enviNFe" type="TEnviNFe"> |
<xs:element name="enviNFe" type="TEnviNFe"> |
||||
<xs:annotation> |
<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:documentation>Schema XML de validação do Pedido de Concessão de Autorização da Nota Fiscal Eletrônica</xs:documentation> |
||||
1040
pytrustnfe/xml/schemas/leiauteNFe_v4.00.xsd
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,6 +1,6 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
<?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: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_v3.10.xsd"/> |
|
||||
|
<xs:include schemaLocation="leiauteNFe_v4.00.xsd"/> |
||||
<xs:element name="NFe" type="TNFe"> |
<xs:element name="NFe" type="TNFe"> |
||||
<xs:annotation> |
<xs:annotation> |
||||
<xs:documentation>Nota Fiscal Eletrônica</xs:documentation> |
<xs:documentation>Nota Fiscal Eletrônica</xs:documentation> |
||||
@ -1,34 +0,0 @@ |
|||||
# -*- coding: utf-8-*- |
|
||||
# © 2016 Alessandro Fernandes Martini |
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
||||
|
|
||||
import unittest |
|
||||
# from lxml import etree |
|
||||
from pytrustnfe.nfe import _add_qrCode |
|
||||
|
|
||||
|
|
||||
class TestAddQRCode(unittest.TestCase): |
|
||||
def setUp(self): |
|
||||
self.xml_sem_qrcode = open('tests/xml_sem_qrcode.xml', 'r') |
|
||||
self.xml_com_qrcode = open('tests/xml_com_qrcode.xml', 'r') |
|
||||
dhEmi = '2016-11-09T16:03:25-00:00' |
|
||||
chave_nfe = 'NFe35161121332917000163650010000000011448875034' |
|
||||
ambiente = 2 |
|
||||
valor_total = '324.00' |
|
||||
icms_total = '61.56' |
|
||||
cid_token = '000001' |
|
||||
csc = '123456789' |
|
||||
estado = '35' |
|
||||
total = {'vNF': valor_total, 'vICMS': icms_total} |
|
||||
infnfe = {'ide': {'dhEmi': dhEmi}, 'Id': chave_nfe, 'total': total, |
|
||||
'codigo_seguranca': {'cid_token': cid_token, 'csc': csc}} |
|
||||
infnfe = {'infNFe': infnfe} |
|
||||
self.kwargs = {} |
|
||||
self.kwargs['ambiente'] = ambiente |
|
||||
self.kwargs['estado'] = estado |
|
||||
self.kwargs['NFes'] = [infnfe] |
|
||||
|
|
||||
def test_add_qrCode(self): |
|
||||
xml_init = self.xml_sem_qrcode.read() |
|
||||
xml_end = _add_qrCode(xml_init, **self.kwargs) |
|
||||
self.assertEqual(xml_end, self.xml_com_qrcode.read()) |
|
||||
@ -1,20 +0,0 @@ |
|||||
# coding=utf-8 |
|
||||
''' |
|
||||
Created on Jun 16, 2015 |
|
||||
|
|
||||
@author: danimar |
|
||||
''' |
|
||||
import unittest |
|
||||
import os.path |
|
||||
|
|
||||
|
|
||||
XML_RETORNO = '<retEnviNFe><cStat>103</cStat>' \ |
|
||||
'<cUF>42</cUF></retEnviNFe>' |
|
||||
|
|
||||
|
|
||||
class test_comunicacao(unittest.TestCase): |
|
||||
|
|
||||
caminho = os.path.dirname(__file__) |
|
||||
|
|
||||
def test_envio_nfe(self): |
|
||||
pass |
|
||||
@ -1,19 +0,0 @@ |
|||||
# coding=utf-8 |
|
||||
|
|
||||
import mock |
|
||||
import os.path |
|
||||
import unittest |
|
||||
from pytrustnfe.certificado import Certificado |
|
||||
from pytrustnfe.nfe import consulta_cadastro |
|
||||
|
|
||||
|
|
||||
class test_consulta_cadastro(unittest.TestCase): |
|
||||
|
|
||||
caminho = os.path.dirname(__file__) |
|
||||
|
|
||||
def test_conta_de_cadastro(self): |
|
||||
pfx_source = open(os.path.join(self.caminho, 'teste.pfx'), 'rb').read() |
|
||||
pfx = Certificado(pfx_source, '123456') |
|
||||
|
|
||||
obj = {'cnpj': '12345678901234', 'estado': '42'} |
|
||||
consulta_cadastro(pfx, obj=obj, ambiente=1, estado='42') |
|
||||
@ -1,189 +0,0 @@ |
|||||
<enviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10"> |
|
||||
<idLote>103</idLote> |
|
||||
<indSinc>1</indSinc> |
|
||||
<NFe xmlns="http://www.portalfiscal.inf.br/nfe"> |
|
||||
<infNFe versao="3.10" Id="NFe35161121332917000163650010000000011448875034"> |
|
||||
<ide> |
|
||||
<cUF>35</cUF> |
|
||||
<cNF>44887503</cNF> |
|
||||
<natOp>Venda POS</natOp> |
|
||||
<indPag>0</indPag> |
|
||||
<mod>65</mod> |
|
||||
<serie>1</serie> |
|
||||
<nNF>1</nNF> |
|
||||
<dhEmi>2016-11-09T16:03:58-00:00</dhEmi> |
|
||||
<tpNF>1</tpNF> |
|
||||
<idDest>1</idDest> |
|
||||
<cMunFG>3550308</cMunFG> |
|
||||
<tpImp>4</tpImp> |
|
||||
<tpEmis>1</tpEmis> |
|
||||
<cDV>4</cDV> |
|
||||
<tpAmb>2</tpAmb> |
|
||||
<finNFe>1</finNFe> |
|
||||
<indFinal>1</indFinal> |
|
||||
<indPres>1</indPres> |
|
||||
<procEmi>0</procEmi> |
|
||||
<verProc>Odoo Brasil 10</verProc> |
|
||||
</ide> |
|
||||
<emit> |
|
||||
<CNPJ>21332917000163</CNPJ> |
|
||||
<xNome>LEL AMBIENTAL LTDA - EPP</xNome> |
|
||||
<xFant>Zell Ambiental</xFant> |
|
||||
<enderEmit> |
|
||||
<xLgr>Rua Padre João</xLgr> |
|
||||
<nro>444</nro> |
|
||||
<xBairro>Penha de França</xBairro> |
|
||||
<cMun>3550308</cMun> |
|
||||
<xMun>São Paulo</xMun> |
|
||||
<UF>SP</UF> |
|
||||
<CEP>03637000</CEP> |
|
||||
<cPais>1058</cPais> |
|
||||
<xPais>Brasil</xPais> |
|
||||
<fone>3425323750</fone> |
|
||||
</enderEmit> |
|
||||
<IE>244694180116</IE> |
|
||||
<CRT>3</CRT> |
|
||||
</emit> |
|
||||
<det nItem="1"> |
|
||||
<prod> |
|
||||
<cProd>MISC</cProd> |
|
||||
<cEAN/> |
|
||||
<xProd>NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xProd> |
|
||||
<NCM>28431000</NCM> |
|
||||
<CEST>2806300</CEST> |
|
||||
<CFOP>5101</CFOP> |
|
||||
<uCom>Unit(s</uCom> |
|
||||
<qCom>18.0</qCom> |
|
||||
<vUnCom>18.00</vUnCom> |
|
||||
<vProd>324.00</vProd> |
|
||||
<cEANTrib/> |
|
||||
<uTrib>Unit(s</uTrib> |
|
||||
<qTrib>18.0</qTrib> |
|
||||
<vUnTrib>18.00</vUnTrib> |
|
||||
<indTot>1</indTot> |
|
||||
</prod> |
|
||||
<imposto> |
|
||||
<vTotTrib>0.00</vTotTrib> |
|
||||
<ICMS> |
|
||||
<ICMS00> |
|
||||
<orig>0</orig> |
|
||||
<CST>00</CST> |
|
||||
<modBC>3</modBC> |
|
||||
<vBC>324.00</vBC> |
|
||||
<pICMS>19.00</pICMS> |
|
||||
<vICMS>61.56</vICMS> |
|
||||
</ICMS00> |
|
||||
</ICMS> |
|
||||
<PIS> |
|
||||
<PISAliq> |
|
||||
<CST>01</CST> |
|
||||
<vBC>324.00</vBC> |
|
||||
<pPIS>0.00</pPIS> |
|
||||
<vPIS>2.11</vPIS> |
|
||||
</PISAliq> |
|
||||
</PIS> |
|
||||
<COFINS> |
|
||||
<COFINSAliq> |
|
||||
<CST>01</CST> |
|
||||
<vBC>324.00</vBC> |
|
||||
<pCOFINS>0.00</pCOFINS> |
|
||||
<vCOFINS>9.72</vCOFINS> |
|
||||
</COFINSAliq> |
|
||||
</COFINS> |
|
||||
</imposto> |
|
||||
</det> |
|
||||
<total> |
|
||||
<ICMSTot> |
|
||||
<vBC>324.00</vBC> |
|
||||
<vICMS>61.56</vICMS> |
|
||||
<vICMSDeson>0.00</vICMSDeson> |
|
||||
<vBCST>0.00</vBCST> |
|
||||
<vST>0.00</vST> |
|
||||
<vProd>324.00</vProd> |
|
||||
<vFrete>0.00</vFrete> |
|
||||
<vSeg>0.00</vSeg> |
|
||||
<vDesc>0.00</vDesc> |
|
||||
<vII>0.00</vII> |
|
||||
<vIPI>0.00</vIPI> |
|
||||
<vPIS>2.11</vPIS> |
|
||||
<vCOFINS>9.72</vCOFINS> |
|
||||
<vOutro>0.00</vOutro> |
|
||||
<vNF>324.00</vNF> |
|
||||
<vTotTrib>0.00</vTotTrib> |
|
||||
</ICMSTot> |
|
||||
</total> |
|
||||
<transp> |
|
||||
<modFrete>9</modFrete> |
|
||||
</transp> |
|
||||
<pag> |
|
||||
<tPag>01</tPag> |
|
||||
<vPag>324.00</vPag> |
|
||||
</pag> |
|
||||
</infNFe> |
|
||||
<infNFeSupl><qrCode><![CDATA[https://homologacao.nfce.fazenda.sp.gov.br/NFCEConsultaPublica/Paginas/ConstultaQRCode.aspx?chNFe=35161121332917000163650010000000011448875034&nVersao=100&tpAmb=2&dhEmi=323031362d31312d30395431363a30333a32352d30303a3030&vNF=324.00&vICMS=61.56&digVal=66664a5a2b30346a6d484e33754c7830386875796b7942733272343d&cIdToken=000001&cHashQRCode=6d674f77ece8067d1255c5ca33fc2acaab3a0e8e]]></qrCode></infNFeSupl><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> |
|
||||
<SignedInfo> |
|
||||
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> |
|
||||
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> |
|
||||
<Reference URI="#NFe35161121332917000163650010000000011448875034"> |
|
||||
<Transforms> |
|
||||
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> |
|
||||
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> |
|
||||
</Transforms> |
|
||||
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> |
|
||||
<DigestValue>ffJZ+04jmHN3uLx08huykyBs2r4=</DigestValue> |
|
||||
</Reference> |
|
||||
</SignedInfo> |
|
||||
<SignatureValue>u42y8bBqNM336yc7r0+5YWiePmCerKu3cFcp2J+lmQzIK6snba7txyeBtwVos8jQxrYLsnfWtKb5P6FxmhDeqAB41o2aoSIcnxc0yxdFn2ZDTquwU+AurH6E4hGclz8D/5qapv2+g3y+VpXMZFNNCqZSm2vJpvXBmPEY/7oO2cPB13N7WDhDRmI9H4kRDsPuxeeJetr2Bf1ThGJ0EUA4DXC7My0kl/Bw0rYwoPDhoqhxinr9Wocw1UyQ1vprLF0JVHXOtSq39Uqfqmj5QUDwUvvh4Y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Zjx1/A4XjqLQ9yPoPWgIWe14Vh/76dVcgz3ElWMbmPCDoc/wX+FoHX1 |
|
||||
Fbux |
|
||||
</X509Certificate> |
|
||||
</X509Data> |
|
||||
</KeyInfo> |
|
||||
</Signature> |
|
||||
</NFe> |
|
||||
</enviNFe> |
|
||||
@ -1,190 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<enviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10"> |
|
||||
<idLote>103</idLote> |
|
||||
<indSinc>1</indSinc> |
|
||||
<NFe xmlns="http://www.portalfiscal.inf.br/nfe"> |
|
||||
<infNFe versao="3.10" Id="NFe35161121332917000163650010000000011448875034"> |
|
||||
<ide> |
|
||||
<cUF>35</cUF> |
|
||||
<cNF>44887503</cNF> |
|
||||
<natOp>Venda POS</natOp> |
|
||||
<indPag>0</indPag> |
|
||||
<mod>65</mod> |
|
||||
<serie>1</serie> |
|
||||
<nNF>1</nNF> |
|
||||
<dhEmi>2016-11-09T16:03:58-00:00</dhEmi> |
|
||||
<tpNF>1</tpNF> |
|
||||
<idDest>1</idDest> |
|
||||
<cMunFG>3550308</cMunFG> |
|
||||
<tpImp>4</tpImp> |
|
||||
<tpEmis>1</tpEmis> |
|
||||
<cDV>4</cDV> |
|
||||
<tpAmb>2</tpAmb> |
|
||||
<finNFe>1</finNFe> |
|
||||
<indFinal>1</indFinal> |
|
||||
<indPres>1</indPres> |
|
||||
<procEmi>0</procEmi> |
|
||||
<verProc>Odoo Brasil 10</verProc> |
|
||||
</ide> |
|
||||
<emit> |
|
||||
<CNPJ>21332917000163</CNPJ> |
|
||||
<xNome>LEL AMBIENTAL LTDA - EPP</xNome> |
|
||||
<xFant>Zell Ambiental</xFant> |
|
||||
<enderEmit> |
|
||||
<xLgr>Rua Padre João</xLgr> |
|
||||
<nro>444</nro> |
|
||||
<xBairro>Penha de França</xBairro> |
|
||||
<cMun>3550308</cMun> |
|
||||
<xMun>São Paulo</xMun> |
|
||||
<UF>SP</UF> |
|
||||
<CEP>03637000</CEP> |
|
||||
<cPais>1058</cPais> |
|
||||
<xPais>Brasil</xPais> |
|
||||
<fone>3425323750</fone> |
|
||||
</enderEmit> |
|
||||
<IE>244694180116</IE> |
|
||||
<CRT>3</CRT> |
|
||||
</emit> |
|
||||
<det nItem="1"> |
|
||||
<prod> |
|
||||
<cProd>MISC</cProd> |
|
||||
<cEAN/> |
|
||||
<xProd>NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xProd> |
|
||||
<NCM>28431000</NCM> |
|
||||
<CEST>2806300</CEST> |
|
||||
<CFOP>5101</CFOP> |
|
||||
<uCom>Unit(s</uCom> |
|
||||
<qCom>18.0</qCom> |
|
||||
<vUnCom>18.00</vUnCom> |
|
||||
<vProd>324.00</vProd> |
|
||||
<cEANTrib/> |
|
||||
<uTrib>Unit(s</uTrib> |
|
||||
<qTrib>18.0</qTrib> |
|
||||
<vUnTrib>18.00</vUnTrib> |
|
||||
<indTot>1</indTot> |
|
||||
</prod> |
|
||||
<imposto> |
|
||||
<vTotTrib>0.00</vTotTrib> |
|
||||
<ICMS> |
|
||||
<ICMS00> |
|
||||
<orig>0</orig> |
|
||||
<CST>00</CST> |
|
||||
<modBC>3</modBC> |
|
||||
<vBC>324.00</vBC> |
|
||||
<pICMS>19.00</pICMS> |
|
||||
<vICMS>61.56</vICMS> |
|
||||
</ICMS00> |
|
||||
</ICMS> |
|
||||
<PIS> |
|
||||
<PISAliq> |
|
||||
<CST>01</CST> |
|
||||
<vBC>324.00</vBC> |
|
||||
<pPIS>0.00</pPIS> |
|
||||
<vPIS>2.11</vPIS> |
|
||||
</PISAliq> |
|
||||
</PIS> |
|
||||
<COFINS> |
|
||||
<COFINSAliq> |
|
||||
<CST>01</CST> |
|
||||
<vBC>324.00</vBC> |
|
||||
<pCOFINS>0.00</pCOFINS> |
|
||||
<vCOFINS>9.72</vCOFINS> |
|
||||
</COFINSAliq> |
|
||||
</COFINS> |
|
||||
</imposto> |
|
||||
</det> |
|
||||
<total> |
|
||||
<ICMSTot> |
|
||||
<vBC>324.00</vBC> |
|
||||
<vICMS>61.56</vICMS> |
|
||||
<vICMSDeson>0.00</vICMSDeson> |
|
||||
<vBCST>0.00</vBCST> |
|
||||
<vST>0.00</vST> |
|
||||
<vProd>324.00</vProd> |
|
||||
<vFrete>0.00</vFrete> |
|
||||
<vSeg>0.00</vSeg> |
|
||||
<vDesc>0.00</vDesc> |
|
||||
<vII>0.00</vII> |
|
||||
<vIPI>0.00</vIPI> |
|
||||
<vPIS>2.11</vPIS> |
|
||||
<vCOFINS>9.72</vCOFINS> |
|
||||
<vOutro>0.00</vOutro> |
|
||||
<vNF>324.00</vNF> |
|
||||
<vTotTrib>0.00</vTotTrib> |
|
||||
</ICMSTot> |
|
||||
</total> |
|
||||
<transp> |
|
||||
<modFrete>9</modFrete> |
|
||||
</transp> |
|
||||
<pag> |
|
||||
<tPag>01</tPag> |
|
||||
<vPag>324.00</vPag> |
|
||||
</pag> |
|
||||
</infNFe> |
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> |
|
||||
<SignedInfo> |
|
||||
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> |
|
||||
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> |
|
||||
<Reference URI="#NFe35161121332917000163650010000000011448875034"> |
|
||||
<Transforms> |
|
||||
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> |
|
||||
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/> |
|
||||
</Transforms> |
|
||||
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> |
|
||||
<DigestValue>ffJZ+04jmHN3uLx08huykyBs2r4=</DigestValue> |
|
||||
</Reference> |
|
||||
</SignedInfo> |
|
||||
<SignatureValue>u42y8bBqNM336yc7r0+5YWiePmCerKu3cFcp2J+lmQzIK6snba7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gJ |
|
||||
QosPJuzW3t0fU/FWbc00sZWV6lgBPyWhdF8EodaRIWC+EOC2wJbODyw+vdX8pUxT |
|
||||
TUJKV2iAP8206gR2h07o2CZgXckJGJQ5MnBUbS78AaITXZ5JlPaS7ZdU9zWY3kD+ |
|
||||
j5YERs0+UweijKi5eHZioGRZRDZ2uksh1wrgeLFLWuiSNaPFYVVrQ/ZGo+E5uVNl |
|
||||
8FuoR6P9TZjx1/A4XjqLQ9yPoPWgIWe14Vh/76dVcgz3ElWMbmPCDoc/wX+FoHX1 |
|
||||
Fbux |
|
||||
</X509Certificate> |
|
||||
</X509Data> |
|
||||
</KeyInfo> |
|
||||
</Signature> |
|
||||
</NFe> |
|
||||
</enviNFe> |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue