From 9b9518389a76c0c8f474c424f306b379f86c191c Mon Sep 17 00:00:00 2001 From: Henrique Clausing Date: Mon, 11 Sep 2023 21:57:33 -0300 Subject: [PATCH] =?UTF-8?q?REINF:=20Testes=20de=20desserializa=C3=A7=C3=A3?= =?UTF-8?q?o=20do=20evento=20de=20retorno=20da=20s=C3=A9rie=20R-4000=20(R-?= =?UTF-8?q?9005).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Schemas/EFD-Reinf/BaseReturnClasses.cs | 1 + .../Schemas/EFD-Reinf/R-9005.cs | 4 +- .../Resources/Schemas/EFD-Reinf.Designer.cs | 22 +++++ .../Resources/Schemas/EFD-Reinf.resx | 87 +++++++++++++++++++ .../Schemas/EFD-Reinf/R-9005.cs | 56 ++++++++++++ 5 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 src/Tests/EficazFramework.Tests/Schemas/EFD-Reinf/R-9005.cs diff --git a/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/BaseReturnClasses.cs b/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/BaseReturnClasses.cs index 95cad98f..80f0d20b 100644 --- a/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/BaseReturnClasses.cs +++ b/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/BaseReturnClasses.cs @@ -11,6 +11,7 @@ public abstract class EventoRetorno : EfdReinfBindableObject /// /// do schema para leitura / escrita /// + [XmlIgnore] public Versao Versao { get; set; } = Versao.v2_01_02; // Base Members diff --git a/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/R-9005.cs b/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/R-9005.cs index f97516d2..b1525407 100644 --- a/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/R-9005.cs +++ b/src/Core/EficazFramework.SPED/Schemas/EFD-Reinf/R-9005.cs @@ -9,7 +9,7 @@ public partial class R9005 : EventoRetorno private R9005EventoRetornoTotal evtRetField; private SignatureType signatureField; - [XmlElement(Order = 0)] + [XmlElement()] public R9005EventoRetornoTotal evtRet { get => evtRetField; @@ -21,7 +21,7 @@ public R9005EventoRetornoTotal evtRet } /// - [XmlElement(Namespace = "http://www.w3.org/2000/09/xmldsig#", Order = 1)] + [XmlElement(Namespace = "http://www.w3.org/2000/09/xmldsig#")] public SignatureType Signature { get => signatureField; diff --git a/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.Designer.cs b/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.Designer.cs index abce33a4..eef138c8 100644 --- a/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.Designer.cs +++ b/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.Designer.cs @@ -60,6 +60,28 @@ internal EFD_Reinf() { } } + /// + /// Consulta uma cadeia de caracteres localizada semelhante a <Reinf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.reinf.esocial.gov.br/schemas/evtRet/v2_01_02"> + /// <evtRet id="ID9005000000000000000000000601050088"> + /// <ideEvento> + /// <perApur>2023-08</perApur> + /// </ideEvento> + /// <ideContri> + /// <tpInsc>1</tpInsc> + /// <nrInsc>34785515</nrInsc> + /// </ideContri> + /// <ideRecRetorno> + /// <ideStatus> + /// <cdRetorno>0</cdRetorno> + /// <descRetorno>SUCESSO</descRetorno> + /// [o restante da cadeia de caracteres foi truncado]";. + /// + public static string Content_R9005_v2_01_02_B { + get { + return ResourceManager.GetString("Content_R9005_v2_01_02_B", resourceCulture); + } + } + /// /// Consulta uma cadeia de caracteres localizada semelhante a <Reinf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.reinf.esocial.gov.br/schemas/evtRetCons/v2_01_02"> /// <evtRetCons id="ID9015000000000000000000000323704091"> diff --git a/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.resx b/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.resx index a9919296..56ccb579 100644 --- a/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.resx +++ b/src/Tests/EficazFramework.Tests/Resources/Schemas/EFD-Reinf.resx @@ -117,6 +117,93 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + <Reinf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.reinf.esocial.gov.br/schemas/evtRet/v2_01_02"> + <evtRet id="ID9005000000000000000000000601050088"> + <ideEvento> + <perApur>2023-08</perApur> + </ideEvento> + <ideContri> + <tpInsc>1</tpInsc> + <nrInsc>34785515</nrInsc> + </ideContri> + <ideRecRetorno> + <ideStatus> + <cdRetorno>0</cdRetorno> + <descRetorno>SUCESSO</descRetorno> + </ideStatus> + </ideRecRetorno> + <infoRecEv> + <nrRecArqBase>26072-02-4020-2308-26072</nrRecArqBase> + <nrProtLote>2.202309.1247674</nrProtLote> + <dhRecepcao>2023-09-11T21:43:41.877</dhRecepcao> + <dhProcess>2023-09-11T21:43:42.5914104-03:00</dhProcess> + <tpEv>4020</tpEv> + <idEv>ID1000000112116922023091121434100001</idEv> + <hash>NBZkwxhz0EL9Uxq0UQxgz/BJZF72DtqKkYB4az7Bqf0=</hash> + </infoRecEv> + <infoTotal> + <ideEstab> + <tpInsc>1</tpInsc> + <nrInsc>61918769000188</nrInsc> + <nrInscBenef>10608025000126</nrInscBenef> + <totApurMen> + <CRMen>170806</CRMen> + <vlrBaseCRMen>152725,25</vlrBaseCRMen> + <natRend>15010</natRend> + <totApurTribMen> + <vlrCRMenInf>2290,88</vlrCRMenInf> + </totApurTribMen> + </totApurMen> + <totApurMen> + <CRMen>598707</CRMen> + <vlrBaseCRMen>152725,25</vlrBaseCRMen> + <natRend>15010</natRend> + <totApurTribMen> + <vlrCRMenInf>15272,53</vlrCRMenInf> + </totApurTribMen> + </totApurMen> + <totApurMen> + <CRMen>596007</CRMen> + <vlrBaseCRMen>152725,25</vlrBaseCRMen> + <natRend>15010</natRend> + <totApurTribMen> + <vlrCRMenInf>4581,76</vlrCRMenInf> + </totApurTribMen> + </totApurMen> + <totApurMen> + <CRMen>597907</CRMen> + <vlrBaseCRMen>152725,25</vlrBaseCRMen> + <natRend>15010</natRend> + <totApurTribMen> + <vlrCRMenInf>992,71</vlrCRMenInf> + </totApurTribMen> + </totApurMen> + </ideEstab> + </infoTotal> + </evtRet> + <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> + <SignedInfo> + <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /> + <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" /> + <Reference URI="#ID9005000000000000000000000601050088"> + <Transforms> + <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /> + <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /> + </Transforms> + <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> + <DigestValue>bhXx4bp4kReZvKn6oDPKKdCFGBi2RaiP1MWzxAOozSE=</DigestValue> + </Reference> + </SignedInfo> + <SignatureValue>s0qAJrcU2N5WpjFsWUbK5qsG2CTcn5qO93xKtqy6lld2prLZrjE/rlGhUU24h+Nt5xYbd77EYptIyzyJoFge+jtgEbSkAdefvzWzgQN3r22cblaX2Bfx7chv9lzN3ilLQ/Kx4vuLuNV0Md0F2RT9qSr7smeluAxKCiO0S7IAcWgFYEPNvEKQ8bRw5cY1khNZaM9yLypvGlnAEUoyh8lTa83697SWSeh2aVvfsDXL+RY7TF2CES85wQSXTLh5P6HfviRdYukFo4N+YxMMCgm42O0doa59bg+zzqHZIqht4GblVwD0XL6iUg7SG0HMqAZFImwG6oEyZFdzlWh395MW8g==</SignatureValue> + <KeyInfo> + <X509Data> + <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3gEoB8XALkbWXe8PfOD36Za70XrnB03f8DI17MA0GCSqGSIb3DQEBCwUAA4ICAQAedpP6FuSoJHRfsUH2gFuWz2TTG5F0S+6K35mesMI6Ybr/SvaCWAG8skpkxtG4ygeWtYAmPi/Zxd6FW4QvFwM443jrm8rkXU1nT3T1O2efdy9rGWoqLtph/rv4W0PALCYIT8XAuqMf5X1EbRuauZojbPldYhhucHCTLfsvYIbL9QWiwqDPZBoQYgu/MehUEtWuvSUyEbaAIASEtfsn5sN1YXAwvRZBQvDRkh1Q8/NZXxJshK6IBRzG2pbysBdq/HUJi3bIeg1UEdDDJfP21v6fJ7cSRrNxdcLa3tRO3QoREos1wiXR9yE+LnbPix6obFddup7ebeoRs1urHXM+52pTgUCZ9lUqhRcI7evDJ7+hGYd+ADrnCKcAKXxpxsZVCficxtAy/C4jwu0VT0Pj4injebosSZOBoO+4C5ELWULFJZTC4BkHk0gp4Pa/Ad9HqT3ihddtTpgelRnzLGJolAds6rpXqO4QWVJzKYNDEFtW0kydwRF+C6azgEVXo6rU0MJYe3pPIJxJA6LzKFSuYnSoKs1yzlZSPzvhkgBrm7MEPO89Zoq6M3MZjjFQvSdNu04PQtapvsGGXGyoBDnVIEONRjpeFEdySrvisGmnE0IuPyD++n+V7JX1W1A0ufGKgY6BNFO10KgA4YOArPSRSW3iu51hUtco9t1baM50z1RR+w==</X509Certificate> + </X509Data> + </KeyInfo> + </Signature> +</Reinf> + <Reinf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.reinf.esocial.gov.br/schemas/evtRetCons/v2_01_02"> <evtRetCons id="ID9015000000000000000000000323704091"> diff --git a/src/Tests/EficazFramework.Tests/Schemas/EFD-Reinf/R-9005.cs b/src/Tests/EficazFramework.Tests/Schemas/EFD-Reinf/R-9005.cs new file mode 100644 index 00000000..e697a68f --- /dev/null +++ b/src/Tests/EficazFramework.Tests/Schemas/EFD-Reinf/R-9005.cs @@ -0,0 +1,56 @@ +using System.Linq.Expressions; + +namespace EficazFramework.SPED.Schemas.EFD_Reinf; + +public class R9005Test +{ + [Test] + [TestCase(Versao.v2_01_02)] + public void ValidaRetornoEnvio(Versao versao) + { + R9005 instancia = new() + { + Versao = versao + }; + instancia = (R9005)instancia.Read(Resources.Schemas.EFD_Reinf.Content_R9005_v2_01_02_B); + instancia.evtRet.id.Should().Be("ID9005000000000000000000000601050088"); + instancia.evtRet.ideEvento.perApur.Should().Be("2023-08"); + instancia.evtRet.ideContri.tpInsc.Should().Be(PersonalidadeJuridica.CNPJ); + instancia.evtRet.ideContri.nrInsc.Should().Be("34785515"); + instancia.evtRet.ideRecRetorno.ideStatus.cdRetorno.Should().Be("0"); + instancia.evtRet.ideRecRetorno.ideStatus.descRetorno.Should().Be("SUCESSO"); + instancia.evtRet.infoRecEv.nrRecArqBase.Should().Be("26072-02-4020-2308-26072"); + instancia.evtRet.infoRecEv.nrProtLote.Should().Be("2.202309.1247674"); + instancia.evtRet.infoRecEv.dhRecepcao.Date.Should().Be(new DateTime(2023, 09, 11)); + instancia.evtRet.infoRecEv.dhRecepcao.Hour.Should().Be(21); + instancia.evtRet.infoRecEv.dhRecepcao.Minute.Should().Be(43); + instancia.evtRet.infoRecEv.dhRecepcao.Second.Should().Be(41); + instancia.evtRet.infoRecEv.dhProcess.Date.Should().Be(new DateTime(2023, 09, 11)); + instancia.evtRet.infoRecEv.dhProcess.Hour.Should().Be(21); + instancia.evtRet.infoRecEv.dhProcess.Minute.Should().Be(43); + instancia.evtRet.infoRecEv.dhProcess.Second.Should().Be(42); + instancia.evtRet.infoRecEv.tpEv.Should().Be("4020"); + instancia.evtRet.infoRecEv.idEv.Should().Be("ID1000000112116922023091121434100001"); + instancia.evtRet.infoRecEv.hash.Should().Be("NBZkwxhz0EL9Uxq0UQxgz/BJZF72DtqKkYB4az7Bqf0="); + instancia.evtRet.infoRecEv.fechRet.Should().BeNull(); + + instancia.evtRet.infoTotal.ideEstab.tpInsc.Should().Be(PersonalidadeJuridica.CNPJ); + instancia.evtRet.infoTotal.ideEstab.nrInsc.Should().Be("61918769000188"); + instancia.evtRet.infoTotal.ideEstab.nrInscBenef.Should().Be("10608025000126"); + instancia.evtRet.infoTotal.ideEstab.TotalApuracaoQuinzenal.Should().BeNull(); + instancia.evtRet.infoTotal.ideEstab.TotalApuracaoDecendial.Should().BeNull(); + instancia.evtRet.infoTotal.ideEstab.TotalApuracaoSemanal.Should().BeNull(); + instancia.evtRet.infoTotal.ideEstab.TotalApuracaoDiaria.Should().BeNull(); + var totalMesNR = instancia.evtRet.infoTotal.ideEstab.TotalApuracaoMensal; + totalMesNR.Should().NotBeNull(); + totalMesNR.Where(e => e.CodigoReceita == "170806") + .Sum(e => decimal.Parse(e.ValorBaseCR ?? "0")) + .Should().Be(152725.25M); + totalMesNR.Where(e => e.CodigoReceita == "170806") + .Sum(e => decimal.Parse(e.TotalApuracaoTributo.ValorCRInformado ?? "0")) + .Should().Be(2290.88M); + totalMesNR.Sum(e => decimal.Parse(e.ValorBaseCR ?? "0")).Should().Be(610901M); + totalMesNR.Sum(e => decimal.Parse(e.TotalApuracaoTributo.ValorCRInformado ?? "0")).Should().Be(23137.88M); + } + +} \ No newline at end of file