@@ -34,11 +34,11 @@ public ProviderGISS(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(confi
3434
3535 #region RPS
3636
37- protected override XElement WriteRps ( NotaServico nota )
37+ /* protected override XElement WriteRps(NotaServico nota)
3838 {
3939 var rootRps = new XElement("Rps");
4040
41- var infServico = new XElement ( "InfDeclaracaoPrestacaoServico" , new XAttribute ( "Id" , $ "Id_RPS { nota . IdentificacaoRps . Numero . OnlyNumbers ( ) } ") ) ;
41+ var infServico = new XElement("InfDeclaracaoPrestacaoServico", new XAttribute("Id", $"Rps {nota.IdentificacaoRps.Numero.OnlyNumbers()}"));
4242 rootRps.Add(infServico);
4343
4444 infServico.Add(WriteRpsRps(nota));
@@ -71,34 +71,35 @@ protected override XElement WriteRps(NotaServico nota)
7171 infServico.AddChild(AdicionarTag(TipoCampo.Int, "", "IncentivoFiscal", 1, 1, Ocorrencia.Obrigatoria, nota.IncentivadorCultural == NFSeSimNao.Sim ? 1 : 2));
7272
7373 return rootRps;
74- }
74+ }*/
75+
7576 protected override XElement WriteValoresRps ( NotaServico nota )
7677 {
7778 var valores = new XElement ( "Valores" ) ;
7879
7980 valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorServicos" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorServicos ) ) ;
80- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorDeducoes" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorDeducoes ) ) ;
81- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorPis" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorPis ) ) ;
82- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorCofins" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorCofins ) ) ;
83- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorInss" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorInss ) ) ;
84- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorIr" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorIr ) ) ;
85- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorCsll" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValorCsll ) ) ;
86- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "OutrasRetencoes" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . OutrasRetencoes ) ) ;
87- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValTotTributos" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . ValTotTributos ) ) ;
81+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorDeducoes" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValorDeducoes ) ) ;
82+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorPis" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValorPis ) ) ;
83+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorCofins" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValorCofins ) ) ;
84+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorInss" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValorInss ) ) ;
85+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorIr" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValorIr ) ) ;
86+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorCsll" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValorCsll ) ) ;
87+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "OutrasRetencoes" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . OutrasRetencoes ) ) ;
88+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValTotTributos" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . ValTotTributos ) ) ;
8889
8990 var valorISS = nota . Servico . Valores . ValorIss ;
9091
9192 if ( valorISS <= 0 && nota . Servico . Valores . IssRetido == SituacaoTributaria . Retencao && nota . Servico . Valores . ValorIssRetido > 0 )
9293 valorISS = nota . Servico . Valores . ValorIssRetido ;
9394
9495 if ( nota . Prestador . Endereco . CodigoMunicipio != nota . Servico . MunicipioIncidencia )
95- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorIss" , 1 , 15 , Ocorrencia . Obrigatoria , valorISS ) ) ;
96+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "ValorIss" , 1 , 15 , Ocorrencia . MaiorQueZero , valorISS ) ) ;
9697
9798 if ( nota . RegimeEspecialTributacao == RegimeEspecialTributacao . SimplesNacional || nota . Prestador . Endereco . CodigoMunicipio != nota . Servico . MunicipioIncidencia )
98- valores . AddChild ( AdicionarTag ( TipoCampo . De4 , "" , "Aliquota" , 1 , 5 , Ocorrencia . Obrigatoria , nota . Servico . Valores . Aliquota ) ) ;
99+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "Aliquota" , 1 , 5 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . Aliquota ) ) ;
99100
100- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "DescontoIncondicionado" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . DescontoIncondicionado ) ) ;
101- valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "DescontoCondicionado" , 1 , 15 , Ocorrencia . Obrigatoria , nota . Servico . Valores . DescontoCondicionado ) ) ;
101+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "DescontoIncondicionado" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . DescontoIncondicionado ) ) ;
102+ valores . AddChild ( AdicionarTag ( TipoCampo . De2 , "" , "DescontoCondicionado" , 1 , 15 , Ocorrencia . MaiorQueZero , nota . Servico . Valores . DescontoCondicionado ) ) ;
102103
103104 return valores ;
104105 }
@@ -124,7 +125,7 @@ protected override void PrepararEnviar(RetornoEnviar retornoWebservice, NotaServ
124125
125126 var xmlLote = new StringBuilder ( ) ;
126127 xmlLote . Append ( $ "<EnviarLoteRpsEnvio { GetNamespace ( ) } >") ;
127- xmlLote . Append ( $ "<LoteRps Id=\" ID_lote { retornoWebservice . Lote } \" { GetVersao ( ) } >") ;
128+ xmlLote . Append ( $ "<LoteRps Id=\" lote { retornoWebservice . Lote } \" { GetVersao ( ) } >") ;
128129 xmlLote . Append ( $ "<NumeroLote>{ retornoWebservice . Lote } </NumeroLote>") ;
129130 if ( UsaPrestadorEnvio ) xmlLote . Append ( "<Prestador>" ) ;
130131 xmlLote . Append ( "<CpfCnpj>" ) ;
@@ -140,16 +141,39 @@ protected override void PrepararEnviar(RetornoEnviar retornoWebservice, NotaServ
140141 xmlLote . Append ( "</ListaRps>" ) ;
141142 xmlLote . Append ( "</LoteRps>" ) ;
142143 xmlLote . Append ( "</EnviarLoteRpsEnvio>" ) ;
143-
144- retornoWebservice . XmlEnvio = xmlLote . ToString ( ) ;
144+
145+ var xmlstring = xmlLote . ToString ( ) . Replace ( "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>" , "" ) ;
146+ XDocument doc = XDocument . Parse ( xmlstring ) ;
147+ XNamespace nsRoot = "http://www.giss.com.br/enviar-lote-rps-envio-v2_04.xsd" ;
148+ XNamespace nsChild = "http://www.giss.com.br/tipos-v2_04.xsd" ;
149+
150+ doc . Root . Name = nsRoot + doc . Root . Name . LocalName ;
151+
152+ doc . Root . SetAttributeValue ( XNamespace . Xmlns + "ds" , "http://www.w3.org/2000/09/xmldsig#" ) ;
153+ doc . Root . SetAttributeValue ( XNamespace . Xmlns + "ns4" , nsRoot ) ;
154+ doc . Root . SetAttributeValue ( XNamespace . Xmlns + "ns2" , nsChild ) ;
155+ doc . Root . SetAttributeValue ( XNamespace . Xmlns + "xsi" , "http://www.w3.org/2001/XMLSchema-instance" ) ;
156+
157+ foreach ( var element in doc . Descendants ( ) . ToList ( ) )
158+ element . Name = nsChild + element . Name . LocalName ;
159+
160+ var loteRps = doc . Descendants ( ) . First ( x=> x . Name . LocalName == "LoteRps" ) ;
161+ loteRps . Name = nsRoot + loteRps . Name . LocalName ;
162+ loteRps . SetAttributeValue ( "versao" , "1.00" ) ;
163+
164+ doc . Root . Name = nsRoot + doc . Root . Name . LocalName ;
165+
166+ var xml = "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>" + doc ;
167+
168+ retornoWebservice . XmlEnvio = xml ;
145169 }
146170
147171 protected override void AssinarEnviar ( RetornoEnviar retornoWebservice )
148172 {
149- // retornoWebservice.XmlEnvio = XmlSigning.AssinarXmlTodos (retornoWebservice.XmlEnvio, "Rps", "InfDeclaracaoPrestacaoServico", Certificado);
150- retornoWebservice . XmlEnvio = XmlSigning . AssinarXml ( retornoWebservice . XmlEnvio , "EnviarLoteRpsEnvio" , "LoteRps" , Certificado ) ;
173+ retornoWebservice . XmlEnvio = XmlSigning . AssinarXml ( retornoWebservice . XmlEnvio , "ns2: Rps" , "ns2: InfDeclaracaoPrestacaoServico" , Certificado ) ;
174+ retornoWebservice . XmlEnvio = XmlSigning . AssinarXml ( retornoWebservice . XmlEnvio , "ns4: EnviarLoteRpsEnvio" , "ns4: LoteRps" , Certificado ) ;
151175 }
152-
176+
153177 /// <inheritdoc />
154178 protected override void TratarRetornoEnviarSincrono ( RetornoEnviar retornoWebservice ,
155179 NotaServicoCollection notas )
0 commit comments