Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
"3.9",
"3.10",
"3.11",
"3.12"
"3.12",
"3.13"
]
steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
## PyNFe

[![Active Development](https://img.shields.io/badge/Maintenance%20Level-Actively%20Developed-brightgreen.svg)](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d)
![status](https://img.shields.io/badge/status-stable-green.svg) ![https://github.com/TadaSoftware/PyNFe/actions](https://github.com/TadaSoftware/PyNFe/workflows/PyNFe%20CI/badge.svg?branch=main) ![pyversions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue)
![status](https://img.shields.io/badge/status-stable-green.svg) ![https://github.com/TadaSoftware/PyNFe/actions](https://github.com/TadaSoftware/PyNFe/actions/workflows/ci.yml/badge.svg) ![pyversions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
[![PyPI version](https://badge.fury.io/py/pynfe.svg)](https://badge.fury.io/py/pynfe)




Biblioteca de interface com os webservices de Nota Fiscal Eletrônica (NF-e) e Nota Fiscal de Consumidor Eletrônica (NFC-e) da SEFAZ e Receita Federal do Brasil, Nota Fiscal de Serviço Eletrônica (NFS-e) para Prefeituras e Manifesto de Documentos Fiscais Eletrônicos (MDF-e).

- **NF-e** visa substituir as notas fiscais séries 1 e 1A.
Expand Down
22 changes: 15 additions & 7 deletions pynfe/processamento/comunicacao.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,34 +238,42 @@ def consulta_distribuicao(

return self._post(url, xml)

def consulta_cadastro(self, modelo, documento, tipo='CNPJ'):
def consulta_cadastro(self, modelo, documento, tipo='CNPJ', uf=None):
"""
Consulta de cadastro
:param modelo: Modelo da nota
:param documento: Documento (CNPJ, CPF ou IE)
:tipo do documento: CNPJ, CPF, IE
:param uf: UF
:return:
"""
# UF que utilizam a SVRS - Sefaz Virtual do RS:
# Para serviço de Consulta Cadastro: AC, RN, PB, SC
lista_svrs = ["AC", "RN", "PB", "SC", "PA", "CE"]
lista_svrs = ["AC", "AL", "AP", "CE",
"DF", "ES", "PA", "PB",
"PI", "RJ", "RN", "RO",
"RR", "SC", "SE", "TO"]

# Se não informada UF nos parâmetros da função,
# utiliza a UF do construtor
if not uf:
uf = self.uf

# RS implementa um método diferente na consulta de cadastro
# usa o mesmo url para produção e homologação
# não tem url para NFCE
if self.uf.upper() == "RS":
if uf.upper() == "RS":
url = NFE["RS"]["CADASTRO"]
elif self.uf.upper() in lista_svrs:
elif uf.upper() in lista_svrs:
url = NFE["SVRS"]["CADASTRO"]
elif self.uf.upper() == "SVC-RS":
elif uf.upper() == "SVC-RS":
url = NFE["SVC-RS"]["CADASTRO"]
else:
url = self._get_url(modelo=modelo, consulta="CADASTRO")

raiz = etree.Element("ConsCad", versao="2.00", xmlns=NAMESPACE_NFE)
info = etree.SubElement(raiz, "infCons")
etree.SubElement(info, "xServ").text = "CONS-CAD"
etree.SubElement(info, "UF").text = self.uf.upper()
etree.SubElement(info, "UF").text = uf.upper()

# Monta tipo de documento CNPJ, CPF ou IE
etree.SubElement(info, tipo.upper()).text = documento
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="PyNFe",
version="0.5.0",
version="0.5.1",
author="TadaSoftware",
author_email="tadasoftware@gmail.com",
description="Interface library with the Brazilian Electronic Invoice web services",
Expand Down