Skip to content

Commit 3dbf741

Browse files
author
Letícia Lopes
committed
Finalizado recepcionarlote
1 parent 1f8f964 commit 3dbf741

3 files changed

Lines changed: 58 additions & 61 deletions

File tree

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ private void GerarRps()
529529
var municipio = cmbCidades.GetSelectedValue<OpenMunicipioNFSe>();
530530
if (municipio == null) return;
531531

532-
var numeroRps = "1";
532+
var numeroRps = "475";
533533
if (InputBox.Show("Nº RPS", "Informe o número do RPS.", ref numeroRps).Equals(DialogResult.Cancel)) return;
534534

535535
openNFSe.NotasServico.Clear();
@@ -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) ? "1705" : "17.05";
581+
var itemListaServico = municipio.Provedor.IsIn(NFSeProvider.Betha, NFSeProvider.ISSe, NFSeProvider.ISSCuritiba) ? "1705" : "07.10";
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,12 +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" :
590+
municipio.Provedor.IsIn(NFSeProvider.GISS) ? "0710" :
591591
municipio.Provedor.IsIn(NFSeProvider.Sigep) ? "1" : "01.07.00 / 00010700";
592592

593593
nfSe.Servico.ItemListaServico = itemListaServico;
594594
nfSe.Servico.CodigoTributacaoMunicipio = CodigoTributacaoMunicipio;
595-
nfSe.Servico.Discriminacao = "MANUTENCAO TÉCNICO";
595+
nfSe.Servico.Discriminacao = "MANUTENCAO";
596596
nfSe.Servico.CodigoMunicipio = municipio.Provedor == NFSeProvider.ISSDSF ? municipio.CodigoSiafi : municipio.Codigo;
597597
nfSe.Servico.Municipio = municipio.Nome;
598598
if (municipio.Provedor.IsIn(NFSeProvider.SiapNet))
@@ -601,6 +601,9 @@ private void GerarRps()
601601
nfSe.Servico.MunicipioIncidencia = nfSe.Servico.CodigoMunicipio;
602602
}
603603

604+
if (municipio.Provedor.IsIn(NFSeProvider.GISS))
605+
nfSe.Servico.CodigoPais = 1058;
606+
604607
nfSe.Servico.Valores.ValorServicos = 1;
605608
nfSe.Servico.Valores.ValorDeducoes = 0;
606609
nfSe.Servico.Valores.ValorPis = 0;
@@ -612,7 +615,7 @@ private void GerarRps()
612615
nfSe.Servico.Valores.ValorIss = municipio.Provedor == NFSeProvider.SiapNet ? 2 : 0.20m;
613616
nfSe.Servico.Valores.ValorOutrasRetencoes = 0;
614617
nfSe.Servico.Valores.BaseCalculo = 1;
615-
nfSe.Servico.Valores.Aliquota = municipio.Provedor == NFSeProvider.GISS ? 0.0200m : 2;
618+
nfSe.Servico.Valores.Aliquota = /*municipio.Provedor == NFSeProvider.GISS ? 0.0200m :*/ 2;
616619
nfSe.Servico.Valores.ValorLiquidoNfse = 1;
617620
nfSe.Servico.Valores.ValorIssRetido = 0;
618621
nfSe.Servico.Valores.DescontoCondicionado = 0;
@@ -633,8 +636,8 @@ private void GerarRps()
633636
nfSe.Servico.MunicipioIncidencia = nfSe.Servico.CodigoMunicipio;
634637
}
635638

636-
nfSe.Tomador.CpfCnpj = "11656919000154";
637-
nfSe.Tomador.InscricaoMunicipal = "1233653";
639+
nfSe.Tomador.CpfCnpj = "49413978867";
640+
nfSe.Tomador.InscricaoMunicipal = "";
638641
nfSe.Tomador.RazaoSocial = "Nome";
639642

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

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

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,7 @@ public string Enviar(string cabec, string msg)
3636
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>");
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.SetAttributeValue("versao", "1.00");
64-
65-
doc.Root.Name = nsRoot + doc.Root.Name.LocalName;
66-
67-
var xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + doc;
68-
69-
message.AppendCData(xml);
39+
message.AppendCData(msg);
7040
message.Append("</nfseDadosMsg>");
7141

7242
message.Append("</nfse:RecepcionarLoteRpsRequest>");
@@ -132,14 +102,14 @@ protected override string TratarRetorno(XElement xElement, string[] responseTag)
132102
var xmlValue = XDocument.Parse(xElement.Value);
133103
var reader = xmlValue.ElementAnyNs(responseTag[0]).CreateReader();
134104
reader.MoveToContent();
135-
var xml = reader.ReadInnerXml().Replace("ns2:", string.Empty);
105+
var xml = reader.ReadOuterXml().Replace("ns2:", string.Empty).Replace("ns3:", string.Empty);
136106

137107
XmlDocument xmlDoc = new XmlDocument();
138108
xmlDoc.LoadXml(xml);
139109

140110
var mensagem = xmlDoc.GetElementsByTagName("Mensagem");
141111
if (mensagem.Count == 0)
142-
return xElement.ToString();
112+
return xml;
143113
else
144114
{
145115
var correcao = xmlDoc.GetElementsByTagName("Correcao");

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

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)