Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brunovcosta committed Nov 14, 2024
1 parent 702f002 commit d748e55
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion abstra_notas/assinatura.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from cryptography.hazmat.backends import default_backend
from pathlib import Path
from tempfile import NamedTemporaryFile
from lxml.etree import Element, tostring, fromstring, ElementBase
from lxml.etree import tostring, fromstring, ElementBase
import xmlsec


Expand Down
8 changes: 5 additions & 3 deletions abstra_notas/nfse/sp/sao_paulo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ A integração é feita atraves da [Nota do Milhão](https://notadomilhao.prefei

- [Gerar nota](/abstra_notas/nfse/sp/sao_paulo/exemplos/gerar_nota.py)
- [Gerar notas em lote](/abstra_notas/nfse/sp/sao_paulo/exemplos/gerar_notas_em_lote.py)
- [Consultar CNPJ](/abstra_notas/nfse/sp/sao_paulo/exemplos/consulta_cnpj.py)
- [Cancelar nota](/abstra_notas/nfse/sp/sao_paulo/exemplos/cancelamento_nfe.py)
- Consultar nota (Em breve)
- Envio de lote (Em breve)
- [Consultar CNPJ](/abstra_notas/nfse/sp/sao_paulo/exemplos/consulta_cnpj.py)
- [Consultar nota emitida (por RPS)](/abstra_notas/nfse/sp/sao_paulo/exemplos/consultar_nota.py)
- Consultar notas emitidas (por lote) (Em breve)
- Consultar notas emitidas (por período) (Em breve)
- Consultar notas recebidas (Em breve)
4 changes: 0 additions & 4 deletions abstra_notas/nfse/sp/sao_paulo/cancelamento_nfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,3 @@ def assinatura(self, assinador: Assinador) -> str:

signed_template = assinador.assinar_bytes_rsa_sh1(template_bytes)
return base64.b64encode(signed_template).decode("ascii")

@property
def remetente_tipo(self) -> Literal["CPF", "CNPJ"]:
return cpf_ou_cnpj(self.remetente)
6 changes: 6 additions & 0 deletions abstra_notas/nfse/sp/sao_paulo/consulta_cnpj_retorno.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from .retorno import Retorno
from lxml.etree import Element, SubElement, ElementBase
from .erro import Erro


@dataclass
Expand Down Expand Up @@ -43,5 +44,10 @@ def gerar_xml(self):
@staticmethod
def parse_xml(element: ElementBase) -> "RetornoConsultaCNPJ":
sucesso = element.find("Sucesso").text == "true"
if not sucesso:
raise Erro(
codigo=int(element.find("Codigo").text),
descricao=element.find("Descricao").text,
)
detalhe = Detalhe.parse_xml(element.find("Detalhe"))
return RetornoConsultaCNPJ(detalhe=detalhe)
4 changes: 1 addition & 3 deletions abstra_notas/nfse/sp/sao_paulo/consulta_cnpj_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from unittest import TestCase
from .consulta_cnpj import ConsultaCNPJ, RetornoConsultaCNPJ
from pathlib import Path
from lxml.etree import XMLSchema, fromstring
from datetime import date
from lxml.etree import fromstring
from .cliente import ClienteMock
import re
from abstra_notas.assinatura import AssinadorMock
from abstra_notas.validacoes.xml_iguais import assert_xml_iguais

Expand Down
11 changes: 0 additions & 11 deletions abstra_notas/nfse/sp/sao_paulo/consulta_nfe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,3 @@ def test_exemplo(self):
]
),
)

def test_consulta_nfe_invalida(self):
assinador = AssinadorMock()
pedido = ConsultaNFe(
remetente="99999997000100",
chave_nfe_inscricao_prestador="00000000",
chave_nfe_numero_nfe=0,
chave_rps_inscricao_prestador="00000000",
chave_rps_serie_rps="AA",
chave_rps_numero_rps=0,
)
1 change: 0 additions & 1 deletion abstra_notas/nfse/sp/sao_paulo/envio_rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from abstra_notas.validacoes.cpfcnpj import normalizar_cpf_ou_cnpj, cpf_ou_cnpj
from abstra_notas.validacoes.cep import normalizar_cep
from abstra_notas.validacoes.tipo_logradouro import TipoLogradouro
from .codigos_de_servico import codigos_de_servico_validos
from datetime import date
from .remessa import Remessa
from .pedido import Pedido
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from abstra_notas.nfse.sp.sao_paulo import Cliente, EnvioLoteRPS, RPS
from abstra_notas.validacoes.tipo_logradouro import TipoLogradouro
from datetime import date, timedelta
from datetime import date
from dotenv import load_dotenv
from os import getenv
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion abstra_notas/validacoes/xml_iguais.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from lxml.etree import fromstring, ElementBase, tostring
from lxml.etree import ElementBase
from typing import List


Expand Down

0 comments on commit d748e55

Please sign in to comment.