-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consulta por periodo (emitidas e recebidas)
- Loading branch information
1 parent
d748e55
commit e0c08e9
Showing
9 changed files
with
233 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
abstra_notas/nfse/sp/sao_paulo/consulta_nfe_periodo_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from unittest import TestCase | ||
from .consulta import ConsultaNFePeriodo | ||
from .cliente import ClienteMock | ||
from abstra_notas.assinatura import AssinadorMock | ||
from datetime import date | ||
|
||
|
||
class ConsultaTest(TestCase): | ||
def test_recebidas(self): | ||
assinador = AssinadorMock() | ||
self.maxDiff = None | ||
|
||
pedido = ConsultaNFePeriodo( | ||
remetente="75.551.583/0001-48", | ||
data_fim=date(2015, 1, 28), | ||
data_inicio=date(2015, 1, 28), | ||
pagina=1, | ||
recebidas_por="04.151.050/0001-20", | ||
) | ||
|
||
assinador.assinar_xml(pedido.gerar_xml(assinador=assinador)) | ||
|
||
cliente = ClienteMock() | ||
cliente.consultar_notas_periodo(pedido) | ||
|
||
def test_emitidas(self): | ||
assinador = AssinadorMock() | ||
self.maxDiff = None | ||
|
||
pedido = ConsultaNFePeriodo( | ||
remetente="75.551.583/0001-48", | ||
data_fim=date(2015, 1, 28), | ||
data_inicio=date(2015, 1, 28), | ||
pagina=1, | ||
inscricao_municipal="12345678", | ||
) | ||
|
||
assinador.assinar_xml(pedido.gerar_xml(assinador=assinador)) | ||
|
||
cliente = ClienteMock() | ||
cliente.consultar_notas_periodo(pedido) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
abstra_notas/nfse/sp/sao_paulo/templates/ConsultaNFePeriodo.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<p1:PedidoConsultaNFePeriodo xmlns:p1="http://www.prefeitura.sp.gov.br/nfe" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<Cabecalho Versao="1"> | ||
<CPFCNPJRemetente> | ||
<{{remetente_tipo}}>{{remetente}}</{{remetente_tipo}}> | ||
</CPFCNPJRemetente> | ||
<CPFCNPJ> | ||
{% if recebidas_por %} | ||
<{{recebidas_por_tipo}}>{{ recebidas_por }}</{{recebidas_por_tipo}}> | ||
{% else %} | ||
<{{remetente_tipo}}>{{remetente}}</{{remetente_tipo}}> | ||
{% endif %} | ||
</CPFCNPJ> | ||
{% if inscricao_municipal %} | ||
<Inscricao> | ||
{{inscricao_municipal}} | ||
</Inscricao> | ||
{% endif %} | ||
<dtInicio>{{data_inicio}}</dtInicio> | ||
<dtFim>{{data_fim}}</dtFim> | ||
<NumeroPagina>{{pagina}}</NumeroPagina> | ||
</Cabecalho> | ||
</p1:PedidoConsultaNFePeriodo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def normalizar_inscricao_municipal(inscricao_municipal, optional=False): | ||
if inscricao_municipal is None and optional: | ||
return None | ||
if isinstance(inscricao_municipal, int): | ||
inscricao_municipal = str(inscricao_municipal) | ||
inscricao_municipal = inscricao_municipal.zfill(8) | ||
assert ( | ||
len(inscricao_municipal) == 8 | ||
), f"A inscrição deve ter 8 caracteres. Recebido: {inscricao_municipal}" | ||
return inscricao_municipal | ||
|
||
|
||
def normalizar_codigo_verificacao(codigo, optional=False): | ||
if codigo is None and optional: | ||
return None | ||
codigo = "".join(filter(str.isalnum, codigo)).upper() | ||
assert ( | ||
codigo is None or isinstance(codigo, str) and len(codigo) == 8 | ||
), f"O código de verificação deve ter 8 caracteres. Recebido: {codigo}" | ||
return codigo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.