Skip to content

Commit 82f88d9

Browse files
authored
Merge pull request #315 from marcianobandeira/loadxml
Load XML Abrasf
2 parents 8b0c789 + 6a53b68 commit 82f88d9

2 files changed

Lines changed: 27 additions & 26 deletions

File tree

src/OpenAC.Net.NFSe/Nota/NotaServico.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ public NotaServico(ConfigNFSe config, DadosPrestador prestador) : this(config)
137137
public RegimeEspecialTributacao RegimeEspecialTributacao { get; set; }
138138

139139
public NFSeSimNao OptanteSimplesNacional { get; set; }
140-
140+
141141
public NFSeSimNao OptanteMEISimei { get; set; }
142142

143143
public DateTime DataOptanteSimplesNacional { get; set; }
144144

145-
public NFSeSimNao IncentivadorCultural { get; set; }
145+
public NFSeSimNao? IncentivadorCultural { get; set; }
146146

147147
public NFSeSimNao Producao { get; set; }
148148

@@ -151,15 +151,15 @@ public NotaServico(ConfigNFSe config, DadosPrestador prestador) : this(config)
151151
public TipoLocalServico LocalServico { get; set; }
152152

153153
public int NumeroLote { get; set; }
154-
154+
155155
public string Protocolo { get; set; }
156156

157157
public DateTime Competencia { get; set; }
158158

159159
public string OutrasInformacoes { get; set; }
160160

161161
public string DiscriminacaoImpostos { get; set; }
162-
162+
163163
public string InformacoesComplementares { get; set; }
164164

165165
public string DescricaoCodigoTributacaoMunicipio { get; set; }
@@ -177,7 +177,7 @@ public NotaServico(ConfigNFSe config, DadosPrestador prestador) : this(config)
177177
public DFeSignature Signature { get; set; }
178178

179179
public string XmlOriginal { get; set; }
180-
180+
181181
public string LinkNFSe { get; set; }
182182

183183
public EventoRps? Evento { get; set; }

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

Lines changed: 22 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;
@@ -503,21 +504,21 @@ protected virtual XElement WriteValoresRps(NotaServico nota)
503504
{
504505
var valores = new XElement("Valores");
505506

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));
507+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorServicos", 1, 15, Ocorrencia.Obrigatoria, nota.Servico.Valores.ValorServicos));
508+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorDeducoes", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorDeducoes));
509+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorPis", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorPis));
510+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorCofins", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorCofins));
511+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorInss", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorInss));
512+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorIr", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorIr));
513+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorCsll", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorCsll));
514+
valores.AddChild(AddTag(TipoCampo.De2, "", "OutrasRetencoes", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.OutrasRetencoes));
515+
valores.AddChild(AddTag(TipoCampo.De2, "", "ValorIss", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.ValorIss));
516+
if (Municipio.Provedor == NFSeProvider.Fiorilli)
517+
valores.AddChild(AddTag(TipoCampo.De4, "", "Aliquota", 1, 6, Ocorrencia.Obrigatoria, nota.Servico.Valores.Aliquota));
518+
else
519+
valores.AddChild(AddTag(TipoCampo.De4, "", "Aliquota", 1, 6, Ocorrencia.MaiorQueZero, nota.Servico.Valores.Aliquota));
520+
valores.AddChild(AddTag(TipoCampo.De2, "", "DescontoIncondicionado", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.DescontoIncondicionado));
521+
valores.AddChild(AddTag(TipoCampo.De2, "", "DescontoCondicionado", 1, 15, Ocorrencia.MaiorQueZero, nota.Servico.Valores.DescontoCondicionado));
521522

522523
return valores;
523524
}
@@ -1409,10 +1410,10 @@ protected override void PrepararSubstituirNFSe(RetornoSubstituirNFSe retornoWebs
14091410
pedidoCancelamento.Append($"<Numero>{retornoWebservice.NumeroNFSe}</Numero>");
14101411
pedidoCancelamento.Append("<CpfCnpj>");
14111412
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-
1413+
pedidoCancelamento.Append("</CpfCnpj>");
1414+
14141415
if (!Configuracoes.PrestadorPadrao.InscricaoMunicipal.IsEmpty()) pedidoCancelamento.Append($"<InscricaoMunicipal>{Configuracoes.PrestadorPadrao.InscricaoMunicipal}</InscricaoMunicipal>");
1415-
1416+
14161417
pedidoCancelamento.Append($"<CodigoMunicipio>{Configuracoes.PrestadorPadrao.Endereco.CodigoMunicipio}</CodigoMunicipio>");
14171418
pedidoCancelamento.Append("</IdentificacaoNfse>");
14181419
pedidoCancelamento.Append($"<CodigoCancelamento>{retornoWebservice.CodigoCancelamento}</CodigoCancelamento>");
@@ -1491,7 +1492,7 @@ protected override void TratarRetornoSubstituirNFSe(RetornoSubstituirNFSe retorn
14911492
var notaSubistituida = LoadXml(compNfse.ToString());
14921493

14931494
nota = notas.FirstOrDefault(x => x.IdentificacaoRps.Numero == notaSubistituida.IdentificacaoRps.Numero);
1494-
1495+
14951496
if (nota == null)
14961497
{
14971498
notas.Add(notaSubistituida);

0 commit comments

Comments
 (0)