Skip to content

Commit bef1940

Browse files
author
Letícia Lopes
committed
Fazendo webservice GISS
1 parent a2ea8c9 commit bef1940

4 files changed

Lines changed: 78 additions & 70 deletions

File tree

src/OpenAC.Net.NFSe.Demo/FormMain.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ private void GerarRps()
578578
nfSe.RegimeEspecialTributacao = RegimeEspecialTributacao.SimplesNacional;
579579
nfSe.IncentivadorCultural = NFSeSimNao.Nao;
580580

581-
var itemListaServico = municipio.Provedor.IsIn(NFSeProvider.Betha, NFSeProvider.ISSe, NFSeProvider.ISSCuritiba) ? "0107" : "17.05";
581+
var itemListaServico = municipio.Provedor.IsIn(NFSeProvider.Betha, NFSeProvider.ISSe, NFSeProvider.ISSCuritiba, NFSeProvider.GISS) ? "1705" : "01.07";
582582
if (InputBox.Show("Item na lista de serviço", "Informe o item na lista de serviço.", ref itemListaServico).Equals(DialogResult.Cancel)) return;
583583

584584
// Setar o cnae de acordo com o schema aceito pelo provedor.
@@ -587,11 +587,12 @@ private void GerarRps()
587587
nfSe.Servico.CodigoCnae = cnae;
588588

589589
var CodigoTributacaoMunicipio = municipio.Provedor.IsIn(NFSeProvider.SiapNet, NFSeProvider.ABase) ? "5211701" :
590+
municipio.Provedor.IsIn(NFSeProvider.GISS) ? "88888888" :
590591
municipio.Provedor.IsIn(NFSeProvider.Sigep) ? "1" : "01.07.00 / 00010700";
591592

592593
nfSe.Servico.ItemListaServico = itemListaServico;
593594
nfSe.Servico.CodigoTributacaoMunicipio = CodigoTributacaoMunicipio;
594-
nfSe.Servico.Discriminacao = "MANUTENCAO TÉCNICA / VOCÊ PAGOU APROXIMADAMENTE R$ 41,15 DE TRIBUTOS FEDERAIS, R$ 8,26 DE TRIBUTOS MUNICIPAIS, R$ 256,57 PELOS PRODUTOS/SERVICOS, FONTE: IBPT.";
595+
nfSe.Servico.Discriminacao = "MANUTENCAO TÉCNICO";
595596
nfSe.Servico.CodigoMunicipio = municipio.Provedor == NFSeProvider.ISSDSF ? municipio.CodigoSiafi : municipio.Codigo;
596597
nfSe.Servico.Municipio = municipio.Nome;
597598
if (municipio.Provedor.IsIn(NFSeProvider.SiapNet))
@@ -611,7 +612,7 @@ private void GerarRps()
611612
nfSe.Servico.Valores.ValorIss = municipio.Provedor == NFSeProvider.SiapNet ? 2 : 0.20m;
612613
nfSe.Servico.Valores.ValorOutrasRetencoes = 0;
613614
nfSe.Servico.Valores.BaseCalculo = 1;
614-
nfSe.Servico.Valores.Aliquota = 2;
615+
nfSe.Servico.Valores.Aliquota = municipio.Provedor == NFSeProvider.GISS ? 0.0200m : 2;
615616
nfSe.Servico.Valores.ValorLiquidoNfse = 1;
616617
nfSe.Servico.Valores.ValorIssRetido = 0;
617618
nfSe.Servico.Valores.DescontoCondicionado = 0;
@@ -627,8 +628,13 @@ private void GerarRps()
627628
servico.Tributavel = NFSeSimNao.Sim;
628629
}
629630

631+
if (municipio.Provedor == NFSeProvider.GISS)
632+
{
633+
nfSe.Servico.MunicipioIncidencia = nfSe.Servico.CodigoMunicipio;
634+
}
635+
630636
nfSe.Tomador.CpfCnpj = "11656919000154";
631-
nfSe.Tomador.InscricaoMunicipal = "";
637+
nfSe.Tomador.InscricaoMunicipal = "1233653";
632638
nfSe.Tomador.RazaoSocial = "Nome";
633639

634640
nfSe.Tomador.Endereco.TipoLogradouro = "";

src/OpenAC.Net.NFSe/Providers/GISS/GISSServiceClient.cs

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using OpenAC.Net.DFe.Core;
22
using System;
3+
using System.Linq;
34
using System.Security.Cryptography.X509Certificates;
45
using System.Text;
56
using OpenAC.Net.Core.Extensions;
@@ -32,15 +33,50 @@ public string Enviar(string cabec, string msg)
3233
var message = new StringBuilder();
3334
message.Append("<nfse:RecepcionarLoteRpsRequest>");
3435
message.Append("<nfseCabecMsg>");
35-
message.AppendCData("<cabecalho versao=\"2.00\"><versaoDados>2.00</versaoDados></cabecalho>");
36+
message.Append("<ns4:cabecalho versao=\"2.04\" xmlns:ns2=\"http://www.giss.com.br/tipos-v2_04.xsd\" xmlns:ns4=\"http://www.giss.com.br/enviar-lote-rps-envio-v2_04.xsd\" xmlns:nss03=\"http://www.w3.org/2000/09/xmldsig#\"><ns4:versaoDados>2.04</ns4:versaoDados></ns4:cabecalho>");
3637
message.Append("</nfseCabecMsg>");
3738
message.Append("<nfseDadosMsg>");
38-
message.AppendCData(msg);
39+
40+
msg = msg.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>", "");
41+
XDocument doc = XDocument.Parse(msg);
42+
XNamespace nsRoot = "http://www.giss.com.br/enviar-lote-rps-envio-v2_04.xsd";
43+
XNamespace nsChild = "http://www.giss.com.br/tipos-v2_04.xsd";
44+
45+
doc.Root.Name = nsRoot + doc.Root.Name.LocalName;
46+
47+
doc.Root.SetAttributeValue(XNamespace.Xmlns + "nss03", "http://www.w3.org/2000/09/xmldsig#");
48+
doc.Root.SetAttributeValue(XNamespace.Xmlns + "ns4", nsRoot);
49+
doc.Root.SetAttributeValue(XNamespace.Xmlns + "ns2", nsChild);
50+
doc.Root.SetAttributeValue(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance");
51+
52+
foreach (var element in doc.Descendants().ToList())
53+
{
54+
if (element.Name.LocalName == "Signature")
55+
{
56+
break;
57+
}
58+
element.Name = nsChild + element.Name.LocalName;
59+
}
60+
61+
var loteRps = doc.Descendants().First(x=>x.Name.LocalName == "LoteRps");
62+
loteRps.Name = nsRoot + loteRps.Name.LocalName;
63+
loteRps.RemoveAttributes();
64+
loteRps.SetAttributeValue("versao", "1.00");
65+
66+
var infDeclaracaoPrestacaoServico =
67+
doc.Descendants().First(x => x.Name.LocalName == "InfDeclaracaoPrestacaoServico");
68+
infDeclaracaoPrestacaoServico.RemoveAttributes();
69+
70+
doc.Root.Name = nsRoot + doc.Root.Name.LocalName;
71+
72+
var xml = /*"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +*/ doc.ToString();
73+
74+
message.Append(xml);
3975
message.Append("</nfseDadosMsg>");
4076

4177
message.Append("</nfse:RecepcionarLoteRpsRequest>");
4278

43-
return Execute("RecepcionarLoteRpsRequest", message.ToString(), "EnviarLoteRpsResposta");
79+
return Execute("http://nfse.abrasf.org.br/RecepcionarLoteRps", message.ToString(), "EnviarLoteRpsResposta");
4480
}
4581

4682
public string EnviarSincrono(string cabec, string msg) => throw new NotImplementedException("Função não implementada/suportada neste Provedor !");
@@ -103,16 +139,15 @@ public bool ValidarUsernamePassword()
103139

104140
protected override string TratarRetorno(XElement xElement, string[] responseTag)
105141
{
106-
var reader = xElement.ElementAnyNs(responseTag[0]).CreateReader();
142+
var xmlValue = XDocument.Parse(xElement.Value);
143+
var reader = xmlValue.ElementAnyNs(responseTag[0]).CreateReader();
107144
reader.MoveToContent();
108145
var xml = reader.ReadInnerXml().Replace("ns2:", string.Empty);
109146

110147
XmlDocument xmlDoc = new XmlDocument();
111148
xmlDoc.LoadXml(xml);
112149

113-
XmlDocument xmlMensagem = new XmlDocument();
114-
xmlMensagem.LoadXml(xmlDoc.LastChild.InnerText);
115-
var mensagem = xmlMensagem.GetElementsByTagName("Mensagem");
150+
var mensagem = xmlDoc.GetElementsByTagName("Mensagem");
116151
if (mensagem.Count == 0)
117152
return xElement.ToString();
118153
else

src/OpenAC.Net.NFSe/Providers/GISS/ProviderGISS.cs

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace OpenAC.Net.NFSe.Providers.GISS
1717
{
18-
internal class ProviderGISS : ProviderABRASF203
18+
internal class ProviderGISS : ProviderABRASF204
1919
{
2020
#region Constructors
2121

@@ -31,74 +31,39 @@ public ProviderGISS(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(confi
3131
#region Methods
3232

3333
#region Protected Methods
34-
34+
3535
#region RPS
3636

37-
protected override XElement WriteTomadorRps(NotaServico nota)
37+
38+
protected override XElement WriteValoresRps(NotaServico nota)
3839
{
39-
if (nota.Tomador.CpfCnpj.IsEmpty()) return null;
40-
41-
var tomador = new XElement("TomadorServico");
42-
43-
var idTomador = new XElement("IdentificacaoTomador");
44-
tomador.Add(idTomador);
45-
46-
var cpfCnpjTomador = new XElement("CpfCnpj");
47-
idTomador.Add(cpfCnpjTomador);
40+
var valores = new XElement("Valores");
4841

49-
cpfCnpjTomador.AddChild(AdicionarTagCNPJCPF("", "Cpf", "Cnpj", nota.Tomador.CpfCnpj));
42+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorServicos", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorServicos));
43+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorDeducoes", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorDeducoes));
44+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorPis", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorPis));
45+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorCofins", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorCofins));
46+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorInss", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorInss));
47+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorIr", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorIr));
48+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorCsll", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorCsll));
49+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "OutrasRetencoes", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.OutrasRetencoes));
50+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValTotTributos", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValTotTributos));
5051

51-
idTomador.AddChild(AdicionarTag(TipoCampo.Str, "", "InscricaoMunicipal", 1, 150, Ocorrencia.NaoObrigatoria,
52-
nota.Tomador.InscricaoMunicipal));
52+
var valorISS = nota.Servico.Valores.ValorIss;
5353

54-
tomador.AddChild(AdicionarTag(TipoCampo.Str, "", "NifTomador", 1, 150, Ocorrencia.NaoObrigatoria,
55-
nota.Tomador.DocTomadorEstrangeiro));
56-
tomador.AddChild(AdicionarTag(TipoCampo.Str, "", "RazaoSocial", 1, 150, Ocorrencia.Obrigatoria,
57-
nota.Tomador.RazaoSocial));
58-
59-
if (nota.Tomador.EnderecoExterior.CodigoPais > 0)
60-
{
61-
var enderecoExt = new XElement("EnderecoExterior");
62-
tomador.Add(enderecoExt);
63-
64-
enderecoExt.AddChild(AdicionarTag(TipoCampo.Int, "", "CodigoPais", 8, 8, Ocorrencia.Obrigatoria,
65-
nota.Tomador.EnderecoExterior.CodigoPais));
66-
enderecoExt.AddChild(AdicionarTag(TipoCampo.Str, "", "EnderecoCompletoExterior", 8, 8,
67-
Ocorrencia.Obrigatoria, nota.Tomador.EnderecoExterior.EnderecoCompleto));
68-
}
69-
else if (nota.Tomador.Endereco.CodigoMunicipio > 0)
70-
{
71-
var endereco = new XElement("Endereco");
72-
tomador.Add(endereco);
73-
74-
endereco.AddChild(AdicionarTag(TipoCampo.Str, "", "Endereco", 1, 125, Ocorrencia.Obrigatoria,
75-
nota.Tomador.Endereco.Logradouro));
76-
endereco.AddChild(AdicionarTag(TipoCampo.Str, "", "Numero", 1, 10, Ocorrencia.Obrigatoria,
77-
nota.Tomador.Endereco.Numero));
78-
endereco.AddChild(AdicionarTag(TipoCampo.Str, "", "Complemento", 1, 60, Ocorrencia.NaoObrigatoria,
79-
nota.Tomador.Endereco.Complemento));
80-
endereco.AddChild(AdicionarTag(TipoCampo.Str, "", "Bairro", 1, 60, Ocorrencia.Obrigatoria,
81-
nota.Tomador.Endereco.Bairro));
82-
endereco.AddChild(AdicionarTag(TipoCampo.Int, "", "CodigoMunicipio", 7, 7, Ocorrencia.Obrigatoria,
83-
nota.Tomador.Endereco.CodigoMunicipio));
84-
endereco.AddChild(AdicionarTag(TipoCampo.Str, "", "Uf", 2, 2, Ocorrencia.Obrigatoria,
85-
nota.Tomador.Endereco.Uf));
86-
endereco.AddChild(AdicionarTag(TipoCampo.StrNumber, "", "Cep", 8, 8, Ocorrencia.Obrigatoria,
87-
nota.Tomador.Endereco.Cep));
88-
}
54+
if (valorISS <= 0 && nota.Servico.Valores.IssRetido == SituacaoTributaria.Retencao && nota.Servico.Valores.ValorIssRetido > 0)
55+
valorISS = nota.Servico.Valores.ValorIssRetido;
8956

90-
if (nota.Tomador.DadosContato.Email.IsEmpty() && nota.Tomador.DadosContato.Telefone.IsEmpty())
91-
return tomador;
57+
if (nota.Prestador.Endereco.CodigoMunicipio != nota.Servico.MunicipioIncidencia)
58+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "ValorIss", 1, 15, Ocorrencia.Obrigatoria, valorISS));
9259

93-
var contato = new XElement("Contato");
94-
tomador.Add(contato);
60+
if (nota.RegimeEspecialTributacao == RegimeEspecialTributacao.SimplesNacional || nota.Prestador.Endereco.CodigoMunicipio != nota.Servico.MunicipioIncidencia)
61+
valores.AddChild(AdicionarTag(TipoCampo.De4, "", "Aliquota", 1, 5, Ocorrencia.Obrigatoria, nota.Servico.Valores.Aliquota));
9562

96-
contato.AddChild(AdicionarTag(TipoCampo.Str, "", "Telefone", 8, 8, Ocorrencia.NaoObrigatoria,
97-
nota.Tomador.DadosContato.Telefone));
98-
contato.AddChild(AdicionarTag(TipoCampo.Str, "", "Email", 8, 8, Ocorrencia.NaoObrigatoria,
99-
nota.Tomador.DadosContato.Email));
63+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "DescontoIncondicionado", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.DescontoIncondicionado));
64+
valores.AddChild(AdicionarTag(TipoCampo.De2, "", "DescontoCondicionado", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.DescontoCondicionado));
10065

101-
return tomador;
66+
return valores;
10267
}
10368

10469
#endregion RPS
@@ -283,6 +248,7 @@ protected override void TratarRetornoConsultarNFSeRps(RetornoConsultarNFSeRps re
283248
protected override IServiceClient GetClient(TipoUrl tipo) => new GISSServiceClient(this, tipo, Certificado);
284249

285250
protected override string GetSchema(TipoUrl tipo) => "nfse_v2-04.xsd";
251+
protected override string GetNamespace() => "";
286252

287253
#endregion Protected Methods
288254

src/OpenAC.Net.NFSe/Resources/Municipios.nfse

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,7 @@
26092609
</Item>
26102610
<Item>
26112611
<TipoUrl>EnviarSincrono</TipoUrl>
2612+
<Url>https://ws-jaboticabal.giss.com.br/service-ws/nf/nfse-ws?wsdl</Url>
26122613
</Item>
26132614
<Item>
26142615
<TipoUrl>CancelarNFSe</TipoUrl>

0 commit comments

Comments
 (0)