Skip to content

Commit 3b5b17c

Browse files
Ajuste para carregar do xml o campo responsavel retenção e o campo incentivador cultural para o padrao ABRASF
1 parent 8b0c789 commit 3b5b17c

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

src/OpenAC.Net.NFSe/Providers/ProviderABRASF200.cs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public override NotaServico LoadXml(XDocument xml)
115115
LoadRps(ret, rootRps);
116116

117117
if (rootNFSe == null) return ret;
118-
118+
119119
LoadNFSe(ret, rootNFSe);
120120
if (rootSub != null) LoadNFSeSub(ret, rootSub);
121121
if (rootCanc != null) LoadNFSeCancelada(ret, rootCanc);
@@ -173,8 +173,9 @@ protected virtual void LoadRps(NotaServico nota, XElement rpsRoot)
173173

174174
nota.Servico.Valores.IssRetido = (rootServico.ElementAnyNs("IssRetido")?.GetValue<int>() ?? 0) == 1 ? SituacaoTributaria.Retencao : SituacaoTributaria.Normal;
175175

176+
// No xml o campo ReponsavelRetencao é gerado como 1 - Tomador / 2 - Prestador
176177
if (rootServico.ElementAnyNs("ResponsavelRetencao") != null)
177-
nota.Servico.ResponsavelRetencao = rootServico.ElementAnyNs("ResponsavelRetencao").GetValue<int>() == 1 ? ResponsavelRetencao.Prestador : ResponsavelRetencao.Tomador;
178+
nota.Servico.ResponsavelRetencao = rootServico.ElementAnyNs("ResponsavelRetencao").GetValue<int>() == 2 ? ResponsavelRetencao.Prestador : ResponsavelRetencao.Tomador;
178179

179180
nota.Servico.ItemListaServico = rootServico.ElementAnyNs("ItemListaServico")?.GetValue<string>() ?? string.Empty;
180181
nota.Servico.CodigoCnae = rootServico.ElementAnyNs("CodigoCnae")?.GetValue<string>() ?? string.Empty;
@@ -252,6 +253,11 @@ protected virtual void LoadRps(NotaServico nota, XElement rpsRoot)
252253
case 2:
253254
nota.IncentivadorCultural = NFSeSimNao.Nao;
254255
break;
256+
257+
// como o campo IncentivadorCultural não é nullable, caso não esteja presente no XML, por padrão ele ficaria como NÃO
258+
default:
259+
nota.IncentivadorCultural = NFSeSimNao.Nao;
260+
break;
255261
}
256262
}
257263

@@ -503,21 +509,21 @@ protected virtual XElement WriteValoresRps(NotaServico nota)
503509
{
504510
var valores = new XElement("Valores");
505511

506-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorServicos", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorServicos));
507-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorDeducoes", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorDeducoes));
508-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorPis", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorPis));
509-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorCofins", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorCofins));
510-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorInss", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorInss));
511-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorIr", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorIr));
512-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorCsll", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorCsll));
513-
valores.AddChild(AddTag(TipoCampo.De2, "", "OutrasRetencoes", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.OutrasRetencoes));
514-
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorIss", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorIss));
515-
if (Municipio.Provedor == NFSeProvider.Fiorilli)
516-
valores.AddChild(AddTag(TipoCampo.De4, "", "Aliquota", 1, 6, Ocorrencia.Obrigatoria, nota.Servico.Valores.Aliquota));
517-
else
518-
valores.AddChild(AddTag(TipoCampo.De4, "", "Aliquota", 1, 6, Ocorrencia.MaiorQueZero, nota.Servico.Valores.Aliquota));
519-
valores.AddChild(AddTag(TipoCampo.De2, "", "DescontoIncondicionado", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.DescontoIncondicionado));
520-
valores.AddChild(AddTag(TipoCampo.De2, "", "DescontoCondicionado", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.DescontoCondicionado));
512+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorServicos", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorServicos));
513+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorDeducoes", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorDeducoes));
514+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorPis", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorPis));
515+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorCofins", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorCofins));
516+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorInss", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorInss));
517+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorIr", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorIr));
518+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorCsll", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorCsll));
519+
valores.AddChild(AddTag(TipoCampo.De2, "", "OutrasRetencoes", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.OutrasRetencoes));
520+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorIss", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorIss));
521+
if (Municipio.Provedor == NFSeProvider.Fiorilli)
522+
valores.AddChild(AddTag(TipoCampo.De4, "", "Aliquota", 1, 6, Ocorrencia.Obrigatoria, nota.Servico.Valores.Aliquota));
523+
else
524+
valores.AddChild(AddTag(TipoCampo.De4, "", "Aliquota", 1, 6, Ocorrencia.MaiorQueZero, nota.Servico.Valores.Aliquota));
525+
valores.AddChild(AddTag(TipoCampo.De2, "", "DescontoIncondicionado", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.DescontoIncondicionado));
526+
valores.AddChild(AddTag(TipoCampo.De2, "", "DescontoCondicionado", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.DescontoCondicionado));
521527

522528
return valores;
523529
}
@@ -1409,10 +1415,10 @@ protected override void PrepararSubstituirNFSe(RetornoSubstituirNFSe retornoWebs
14091415
pedidoCancelamento.Append($"<Numero>{retornoWebservice.NumeroNFSe}</Numero>");
14101416
pedidoCancelamento.Append("<CpfCnpj>");
14111417
pedidoCancelamento.Append(Configuracoes.PrestadorPadrao.CpfCnpj.IsCNPJ() ? $"<Cnpj>{Configuracoes.PrestadorPadrao.CpfCnpj.ZeroFill(14)}</Cnpj>" : $"<Cpf>{Configuracoes.PrestadorPadrao.CpfCnpj.ZeroFill(11)}</Cpf>");
1412-
pedidoCancelamento.Append("</CpfCnpj>");
1413-
1418+
pedidoCancelamento.Append("</CpfCnpj>");
1419+
14141420
if (!Configuracoes.PrestadorPadrao.InscricaoMunicipal.IsEmpty()) pedidoCancelamento.Append($"<InscricaoMunicipal>{Configuracoes.PrestadorPadrao.InscricaoMunicipal}</InscricaoMunicipal>");
1415-
1421+
14161422
pedidoCancelamento.Append($"<CodigoMunicipio>{Configuracoes.PrestadorPadrao.Endereco.CodigoMunicipio}</CodigoMunicipio>");
14171423
pedidoCancelamento.Append("</IdentificacaoNfse>");
14181424
pedidoCancelamento.Append($"<CodigoCancelamento>{retornoWebservice.CodigoCancelamento}</CodigoCancelamento>");
@@ -1491,7 +1497,7 @@ protected override void TratarRetornoSubstituirNFSe(RetornoSubstituirNFSe retorn
14911497
var notaSubistituida = LoadXml(compNfse.ToString());
14921498

14931499
nota = notas.FirstOrDefault(x => x.IdentificacaoRps.Numero == notaSubistituida.IdentificacaoRps.Numero);
1494-
1500+
14951501
if (nota == null)
14961502
{
14971503
notas.Add(notaSubistituida);

0 commit comments

Comments
 (0)