Skip to content

Commit

Permalink
nfse: tribNac->tribFed adjust samples and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rvalyi committed May 26, 2024
1 parent 39a9503 commit 7307fce
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 74 deletions.
6 changes: 3 additions & 3 deletions nfelib/nfse/samples/v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribNac>
<tribFed>
<vRetCP>8.99</vRetCP>
<vRetIRRF>9.99</vRetIRRF>
<vRetCSLL>9.99</vRetCSLL>
</tribNac>
</tribFed>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
Expand Down Expand Up @@ -125,4 +125,4 @@
</X509Data>
</KeyInfo>
</Signature>
</NFSe>
</NFSe>
6 changes: 3 additions & 3 deletions nfelib/nfse/samples/v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribNac>
<tribFed>
<vRetCP>8.99</vRetCP>
<vRetIRRF>9.99</vRetIRRF>
<vRetCSLL>9.99</vRetCSLL>
</tribNac>
</tribFed>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
</trib>
</valores>
</infDPS>
</DPS>
</DPS>
60 changes: 60 additions & 0 deletions nfelib/nfse/samples/v1_0/dps-regime-normal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<DPS versao="1.00" xmlns="http://www.sped.fazenda.gov.br/nfse">
<infDPS Id="DPS420240420000000000000000007000000000000002">
<tpAmb>1</tpAmb>
<dhEmi>2023-09-09T09:42:06-03:00</dhEmi>
<verAplic>20220719</verAplic>
<serie>00007</serie>
<nDPS>2</nDPS>
<dCompet>2023-09-09</dCompet>
<tpEmit>1</tpEmit>
<cLocEmi>4202404</cLocEmi>
<prest>
<CNPJ>00000000000000</CNPJ>
<IM>152422</IM>
<regTrib>
<opSimpNac>2</opSimpNac>
<regEspTrib>0</regEspTrib>
</regTrib>
</prest>
<toma>
<CNPJ>00000000000000</CNPJ>
<IM>00000</IM>
<xNome>XXXXXXX XXXXXXXXXXX LTDA ME</xNome>
<end>
<xLgr>ARY XXXXXXX XXXXX</xLgr>
<nro>79</nro>
<xBairro>XXXXXXXX XXXXX</xBairro>
</end>
</toma>
<serv>
<locPrest>
<cLocPrestacao>4202404</cLocPrestacao>
</locPrest>
<cServ>
<cTribNac>010101</cTribNac>
<xDescServ>Teste de NF Nacional com imposto</xDescServ>
<cNBS>111111111</cNBS>
</cServ>
</serv>
<valores>
<vServPrest>
<vServ>20.00</vServ>
</vServPrest>
<trib>
<tribMun>
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribFed>
<vRetCP>0.40</vRetCP>
<vRetIRRF>0.00</vRetIRRF>
<vRetCSLL>0.00</vRetCSLL>
</tribFed>
<totTrib>
<indTotTrib>0</indTotTrib>
</totTrib>
</trib>
</valores>
</infDPS>
</DPS>
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,16 @@
<vDescCondIncond>
<vDescIncond>9999999.99</vDescIncond>
<vDescCond>9.99</vDescCond>
</vDescCondIncond>
<trib>
<tribMun>
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<tribNac>
<vRetCP>8.99</vRetCP>
<vRetIRRF>9.99</vRetIRRF>
<vRetCSLL>9.99</vRetCSLL>
</tribNac>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
</trib>
</vDescCondIncond>
<trib>
<tribMun>
<tribISSQN>1</tribISSQN>
<tpRetISSQN>1</tpRetISSQN>
</tribMun>
<totTrib>
<pTotTribSN>0.01</pTotTribSN>
</totTrib>
</trib>
</valores>
</infDPS>
</DPS>
</DPS>
106 changes: 54 additions & 52 deletions tests/nfse/test_nfse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (C) 2019 - TODAY Raphaël Valyi - Akretion
# Copyright (C) 2023 - TODAY Raphaël Valyi - Akretion

import os
from xmldiff import main
from unittest import TestCase

from xsdata.formats.dataclass.serializers.config import SerializerConfig
from xsdata.formats.dataclass.parsers import XmlParser
Expand All @@ -12,62 +13,63 @@
from nfelib.nfse.bindings.v1_0 import dps_v1_00


def test_in_out_nfse():
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["ConsultarNFSeEnvio-ped-sitnfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)
class NFseTests(TestCase):
def test_in_out_consulta(self):
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["ConsultarNFSeEnvio-ped-sitnfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)

output_file = "tests/output_nfse.xml"
with open(output_file, "w") as f:
f.write(xml)
output_file = "tests/output_nfse.xml"
with open(output_file, "w") as f:
f.write(xml)

diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break
diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break

def test_in_out_dps():
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["GerarNFSeEnvio-env-loterps.xml", "ConsultarNFSeRPS-ped-sitnfserps.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)
def test_in_out_dps(self):
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["dps-simples.xml", "dps-regime-normal.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)

output_file = "tests/output_nfse_dps.xml"
with open(output_file, "w") as f:
f.write(xml)
output_file = "tests/output_nfse_dps.xml"
with open(output_file, "w") as f:
f.write(xml)

diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break
diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break

def test_in_out_pedRegEvento():
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["CancelarNFSe-ped-cannfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)
def test_in_out_pedRegEvento(self):
path = os.path.join("nfelib", "nfse", "samples", "v1_0")
for filename in ["CancelarNFSe-ped-cannfse.xml"]:
input_file = os.path.join(path, filename)
parser = XmlParser()
obj = parser.from_path(Path(input_file))
serializer = XmlSerializer(config=SerializerConfig(pretty_print=True))
xml = serializer.render(
obj=obj, ns_map={None: "http://www.sped.fazenda.gov.br/nfse"}
)

output_file = "tests/output_nfse_pedRegEvento.xml"
with open(output_file, "w") as f:
f.write(xml)
output_file = "tests/output_nfse_pedRegEvento.xml"
with open(output_file, "w") as f:
f.write(xml)

diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break
diff = main.diff_files(input_file, output_file)
assert len(diff) == 0
if len(diff) != 0:
break

0 comments on commit 7307fce

Please sign in to comment.