Skip to content

Commit 1f8f964

Browse files
author
Letícia Lopes
committed
Ajustando GISS
1 parent bef1940 commit 1f8f964

3 files changed

Lines changed: 92 additions & 16 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
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, NFSeProvider.GISS) ? "1705" : "01.07";
581+
var itemListaServico = municipio.Provedor.IsIn(NFSeProvider.Betha, NFSeProvider.ISSe, NFSeProvider.ISSCuritiba) ? "1705" : "17.05";
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.

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public string Enviar(string cabec, string msg)
3333
var message = new StringBuilder();
3434
message.Append("<nfse:RecepcionarLoteRpsRequest>");
3535
message.Append("<nfseCabecMsg>");
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>");
36+
message.AppendCData("<ns4:cabecalho versao=\"2.00\" xmlns:ns2=\"http://www.giss.com.br/tipos-v2_04.xsd\" xmlns:ns4=\"http://www.giss.com.br/cabecalho-v2_04.xsd\" xmlns:nss03=\"http://www.w3.org/2000/09/xmldsig#\"><ns4:versaoDados>2.00</ns4:versaoDados></ns4:cabecalho>");
3737
message.Append("</nfseCabecMsg>");
3838
message.Append("<nfseDadosMsg>");
3939

@@ -60,18 +60,13 @@ public string Enviar(string cabec, string msg)
6060

6161
var loteRps = doc.Descendants().First(x=>x.Name.LocalName == "LoteRps");
6262
loteRps.Name = nsRoot + loteRps.Name.LocalName;
63-
loteRps.RemoveAttributes();
6463
loteRps.SetAttributeValue("versao", "1.00");
65-
66-
var infDeclaracaoPrestacaoServico =
67-
doc.Descendants().First(x => x.Name.LocalName == "InfDeclaracaoPrestacaoServico");
68-
infDeclaracaoPrestacaoServico.RemoveAttributes();
6964

7065
doc.Root.Name = nsRoot + doc.Root.Name.LocalName;
7166

72-
var xml = /*"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +*/ doc.ToString();
67+
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + doc;
7368

74-
message.Append(xml);
69+
message.AppendCData(xml);
7570
message.Append("</nfseDadosMsg>");
7671

7772
message.Append("</nfse:RecepcionarLoteRpsRequest>");
@@ -132,11 +127,6 @@ private string Execute(string soapAction, string message, string responseTag)
132127
return Execute(soapAction, message, "", responseTag, "xmlns:nfse=\"http://nfse.abrasf.org.br\"");
133128
}
134129

135-
public bool ValidarUsernamePassword()
136-
{
137-
return !string.IsNullOrEmpty(Provider.Configuracoes.WebServices.Usuario) && !string.IsNullOrEmpty(Provider.Configuracoes.WebServices.Senha);
138-
}
139-
140130
protected override string TratarRetorno(XElement xElement, string[] responseTag)
141131
{
142132
var xmlValue = XDocument.Parse(xElement.Value);
@@ -151,7 +141,13 @@ protected override string TratarRetorno(XElement xElement, string[] responseTag)
151141
if (mensagem.Count == 0)
152142
return xElement.ToString();
153143
else
154-
return mensagem[0].InnerText;
144+
{
145+
var correcao = xmlDoc.GetElementsByTagName("Correcao");
146+
var correcaoText = "";
147+
if (correcao.Count > 0)
148+
correcaoText = " - Correção: " + correcao[0].InnerText;
149+
return mensagem[0].InnerText + correcaoText;
150+
}
155151
}
156152

157153
#endregion Methods

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

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,44 @@ public ProviderGISS(ConfigNFSe config, OpenMunicipioNFSe municipio) : base(confi
3434

3535
#region RPS
3636

37-
37+
protected override XElement WriteRps(NotaServico nota)
38+
{
39+
var rootRps = new XElement("Rps");
40+
41+
var infServico = new XElement("InfDeclaracaoPrestacaoServico", new XAttribute("Id", $"Id_RPS{nota.IdentificacaoRps.Numero.OnlyNumbers()}"));
42+
rootRps.Add(infServico);
43+
44+
infServico.Add(WriteRpsRps(nota));
45+
46+
infServico.AddChild(AdicionarTag(TipoCampo.Dat, "", "Competencia", 10, 10, Ocorrencia.Obrigatoria, nota.Competencia));
47+
48+
infServico.AddChild(WriteServicosRps(nota));
49+
infServico.AddChild(WritePrestadorRps(nota));
50+
infServico.AddChild(WriteTomadorRps(nota));
51+
infServico.AddChild(WriteIntermediarioRps(nota));
52+
infServico.AddChild(WriteConstrucaoCivilRps(nota));
53+
54+
string regimeEspecialTributacao;
55+
string optanteSimplesNacional;
56+
if (nota.RegimeEspecialTributacao == RegimeEspecialTributacao.SimplesNacional)
57+
{
58+
regimeEspecialTributacao = "6";
59+
optanteSimplesNacional = "1";
60+
}
61+
else
62+
{
63+
regimeEspecialTributacao = ((int)nota.RegimeEspecialTributacao).ToString();
64+
optanteSimplesNacional = "2";
65+
}
66+
67+
if (nota.RegimeEspecialTributacao != RegimeEspecialTributacao.Nenhum)
68+
infServico.AddChild(AdicionarTag(TipoCampo.Int, "", "RegimeEspecialTributacao", 1, 1, Ocorrencia.NaoObrigatoria, regimeEspecialTributacao));
69+
70+
infServico.AddChild(AdicionarTag(TipoCampo.Int, "", "OptanteSimplesNacional", 1, 1, Ocorrencia.Obrigatoria, optanteSimplesNacional));
71+
infServico.AddChild(AdicionarTag(TipoCampo.Int, "", "IncentivoFiscal", 1, 1, Ocorrencia.Obrigatoria, nota.IncentivadorCultural == NFSeSimNao.Sim ? 1 : 2));
72+
73+
return rootRps;
74+
}
3875
protected override XElement WriteValoresRps(NotaServico nota)
3976
{
4077
var valores = new XElement("Valores");
@@ -69,6 +106,49 @@ protected override XElement WriteValoresRps(NotaServico nota)
69106
#endregion RPS
70107

71108
#region Services
109+
110+
protected override void PrepararEnviar(RetornoEnviar retornoWebservice, NotaServicoCollection notas)
111+
{
112+
if (retornoWebservice.Lote == 0) retornoWebservice.Erros.Add(new Evento { Codigo = "0", Descricao = "Lote não informado." });
113+
if (notas.Count == 0) retornoWebservice.Erros.Add(new Evento { Codigo = "0", Descricao = "RPS não informado." });
114+
if (retornoWebservice.Erros.Any()) return;
115+
116+
var xmlLoteRps = new StringBuilder();
117+
118+
foreach (var nota in notas)
119+
{
120+
var xmlRps = WriteXmlRps(nota, false, false);
121+
GravarRpsEmDisco(xmlRps, $"Rps-{nota.IdentificacaoRps.DataEmissao:yyyyMMdd}-{nota.IdentificacaoRps.Numero}.xml", nota.IdentificacaoRps.DataEmissao);
122+
xmlLoteRps.Append(xmlRps);
123+
}
124+
125+
var xmlLote = new StringBuilder();
126+
xmlLote.Append($"<EnviarLoteRpsEnvio {GetNamespace()}>");
127+
xmlLote.Append($"<LoteRps Id=\"ID_lote{retornoWebservice.Lote}\" {GetVersao()}>");
128+
xmlLote.Append($"<NumeroLote>{retornoWebservice.Lote}</NumeroLote>");
129+
if (UsaPrestadorEnvio) xmlLote.Append("<Prestador>");
130+
xmlLote.Append("<CpfCnpj>");
131+
xmlLote.Append(Configuracoes.PrestadorPadrao.CpfCnpj.IsCNPJ()
132+
? $"<Cnpj>{Configuracoes.PrestadorPadrao.CpfCnpj.ZeroFill(14)}</Cnpj>"
133+
: $"<Cpf>{Configuracoes.PrestadorPadrao.CpfCnpj.ZeroFill(11)}</Cpf>");
134+
xmlLote.Append("</CpfCnpj>");
135+
if (!Configuracoes.PrestadorPadrao.InscricaoMunicipal.IsEmpty()) xmlLote.Append($"<InscricaoMunicipal>{Configuracoes.PrestadorPadrao.InscricaoMunicipal}</InscricaoMunicipal>");
136+
if (UsaPrestadorEnvio) xmlLote.Append("</Prestador>");
137+
xmlLote.Append($"<QuantidadeRps>{notas.Count}</QuantidadeRps>");
138+
xmlLote.Append("<ListaRps>");
139+
xmlLote.Append(xmlLoteRps);
140+
xmlLote.Append("</ListaRps>");
141+
xmlLote.Append("</LoteRps>");
142+
xmlLote.Append("</EnviarLoteRpsEnvio>");
143+
144+
retornoWebservice.XmlEnvio = xmlLote.ToString();
145+
}
146+
147+
protected override void AssinarEnviar(RetornoEnviar retornoWebservice)
148+
{
149+
//retornoWebservice.XmlEnvio = XmlSigning.AssinarXmlTodos(retornoWebservice.XmlEnvio, "Rps", "InfDeclaracaoPrestacaoServico", Certificado);
150+
retornoWebservice.XmlEnvio = XmlSigning.AssinarXml(retornoWebservice.XmlEnvio, "EnviarLoteRpsEnvio", "LoteRps", Certificado);
151+
}
72152

73153
/// <inheritdoc />
74154
protected override void TratarRetornoEnviarSincrono(RetornoEnviar retornoWebservice,

0 commit comments

Comments
 (0)