From 39a95033255dab3e80a62353b7bb925f3ba7f5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Sun, 26 May 2024 18:12:35 -0300 Subject: [PATCH 1/2] nfse: XSD PATCH: tribNac -> tribFed it seems the official xsd file has an error with the tribNac tax field (inside the trib tag) while the other spec files and known NFSe's seem to use the tribFed tag instead. So we replaced tribNac by tribFed. The related ComplexField and inner attributes seem OK. --- nfelib/nfse/bindings/v1_0/tipos_complexos_v1_00.py | 4 ++-- nfelib/nfse/schemas/v1_0/tiposComplexos_v1.00.xsd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nfelib/nfse/bindings/v1_0/tipos_complexos_v1_00.py b/nfelib/nfse/bindings/v1_0/tipos_complexos_v1_00.py index 51028dbc..ad33d574 100644 --- a/nfelib/nfse/bindings/v1_0/tipos_complexos_v1_00.py +++ b/nfelib/nfse/bindings/v1_0/tipos_complexos_v1_00.py @@ -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 @@ -2470,7 +2470,7 @@ class Meta: "required": True, }, ) - tribNac: Optional[TctribNacional] = field( + tribFed: Optional[TctribNacional] = field( default=None, metadata={ "type": "Element", diff --git a/nfelib/nfse/schemas/v1_0/tiposComplexos_v1.00.xsd b/nfelib/nfse/schemas/v1_0/tiposComplexos_v1.00.xsd index 01d606aa..08483924 100644 --- a/nfelib/nfse/schemas/v1_0/tiposComplexos_v1.00.xsd +++ b/nfelib/nfse/schemas/v1_0/tiposComplexos_v1.00.xsd @@ -1255,7 +1255,7 @@ - + Grupo de informações de outros tributos relacionados ao serviço prestado From 7307fcefc88c2ef2c5c06e956f9b72836a8f2992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Sun, 26 May 2024 18:19:20 -0300 Subject: [PATCH 2/2] nfse: tribNac->tribFed adjust samples and tests --- .../v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml | 6 +- .../v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml | 6 +- .../nfse/samples/v1_0/dps-regime-normal.xml | 60 ++++++++++ ...eEnvio-env-loterps.xml => dps-simples.xml} | 27 ++--- tests/nfse/test_nfse.py | 106 +++++++++--------- 5 files changed, 131 insertions(+), 74 deletions(-) create mode 100644 nfelib/nfse/samples/v1_0/dps-regime-normal.xml rename nfelib/nfse/samples/v1_0/{GerarNFSeEnvio-env-loterps.xml => dps-simples.xml} (75%) diff --git a/nfelib/nfse/samples/v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml b/nfelib/nfse/samples/v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml index 9ae579e2..6b1775bf 100644 --- a/nfelib/nfse/samples/v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml +++ b/nfelib/nfse/samples/v1_0/ConsultarNFSeEnvio-ped-sitnfse.xml @@ -72,11 +72,11 @@ 1 1 - + 8.99 9.99 9.99 - + 0.01 @@ -125,4 +125,4 @@ - \ No newline at end of file + diff --git a/nfelib/nfse/samples/v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml b/nfelib/nfse/samples/v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml index c9c949d8..45b177bd 100644 --- a/nfelib/nfse/samples/v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml +++ b/nfelib/nfse/samples/v1_0/ConsultarNFSeRPS-ped-sitnfserps.xml @@ -40,15 +40,15 @@ 1 1 - + 8.99 9.99 9.99 - + 0.01 - \ No newline at end of file + diff --git a/nfelib/nfse/samples/v1_0/dps-regime-normal.xml b/nfelib/nfse/samples/v1_0/dps-regime-normal.xml new file mode 100644 index 00000000..02ec46c6 --- /dev/null +++ b/nfelib/nfse/samples/v1_0/dps-regime-normal.xml @@ -0,0 +1,60 @@ + + + + 1 + 2023-09-09T09:42:06-03:00 + 20220719 + 00007 + 2 + 2023-09-09 + 1 + 4202404 + + 00000000000000 + 152422 + + 2 + 0 + + + + 00000000000000 + 00000 + XXXXXXX XXXXXXXXXXX LTDA ME + + ARY XXXXXXX XXXXX + 79 + XXXXXXXX XXXXX + + + + + 4202404 + + + 010101 + Teste de NF Nacional com imposto + 111111111 + + + + + 20.00 + + + + 1 + 1 + + + 0.40 + 0.00 + 0.00 + + + 0 + + + + + diff --git a/nfelib/nfse/samples/v1_0/GerarNFSeEnvio-env-loterps.xml b/nfelib/nfse/samples/v1_0/dps-simples.xml similarity index 75% rename from nfelib/nfse/samples/v1_0/GerarNFSeEnvio-env-loterps.xml rename to nfelib/nfse/samples/v1_0/dps-simples.xml index c9c949d8..66ffa04a 100644 --- a/nfelib/nfse/samples/v1_0/GerarNFSeEnvio-env-loterps.xml +++ b/nfelib/nfse/samples/v1_0/dps-simples.xml @@ -34,21 +34,16 @@ 9999999.99 9.99 - - - - 1 - 1 - - - 8.99 - 9.99 - 9.99 - - - 0.01 - - + + + + 1 + 1 + + + 0.01 + + - \ No newline at end of file + diff --git a/tests/nfse/test_nfse.py b/tests/nfse/test_nfse.py index 7f7fc840..0d8831e3 100644 --- a/tests/nfse/test_nfse.py +++ b/tests/nfse/test_nfse.py @@ -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 @@ -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