Skip to content

Commit

Permalink
Merge pull request #105 from akretion/tribNac-tribFed
Browse files Browse the repository at this point in the history
nfse: TribNac renamed to tribFed
  • Loading branch information
rvalyi authored Jun 15, 2024
2 parents 5c34247 + 7307fce commit 790a375
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 77 deletions.
4 changes: 2 additions & 2 deletions nfelib/nfse/bindings/v1_0/tipos_complexos_v1_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -2453,7 +2453,7 @@ class TcinfoTributacao(CommonMixin):
"""
:ivar tribMun: Grupo de informações relacionados ao Imposto Sobre
Serviços de Qualquer Natureza - ISSQN
:ivar tribNac: Grupo de informações de outros tributos relacionados
:ivar tribFed: Grupo de informações de outros tributos relacionados
ao serviço prestado
:ivar totTrib: Grupo de informações para totais aproximados dos
tributos relacionados ao serviço prestado
Expand All @@ -2470,7 +2470,7 @@ class Meta:
"required": True,
},
)
tribNac: Optional[TctribNacional] = field(
tribFed: Optional[TctribNacional] = field(
default=None,
metadata={
"type": "Element",
Expand Down
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>
2 changes: 1 addition & 1 deletion nfelib/nfse/schemas/v1_0/tiposComplexos_v1.00.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="tribNac" type="TCTribNacional" minOccurs="0">
<xs:element name="tribFed" type="TCTribNacional" minOccurs="0">
<xs:annotation>
<xs:documentation>
Grupo de informações de outros tributos relacionados ao serviço prestado
Expand Down
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 790a375

Please sign in to comment.