diff --git a/NFe.AppTeste/Schemas/leiauteNFe_v4.00.xsd b/NFe.AppTeste/Schemas/leiauteNFe_v4.00.xsd
index 9e86de93b..24d27e5e7 100644
--- a/NFe.AppTeste/Schemas/leiauteNFe_v4.00.xsd
+++ b/NFe.AppTeste/Schemas/leiauteNFe_v4.00.xsd
@@ -561,7 +561,7 @@ Preencher com "2B", quando se tratar de Cupom Fiscal emitido por máqu
Endereço do emitente
-
+
Inscrição Estadual do Emitente
diff --git a/NFe.Servicos/ServicoNfeFactory.cs b/NFe.Servicos/ServicoNfeFactory.cs
index b068c4621..43f18288a 100644
--- a/NFe.Servicos/ServicoNfeFactory.cs
+++ b/NFe.Servicos/ServicoNfeFactory.cs
@@ -33,6 +33,13 @@ namespace NFe.Servicos
{
public static class ServicoNfeFactory
{
+ ///
+ /// Verifica se a NF-e do emitente sem IE deve usar os servicos da SVRS.
+ ///
+ private static bool UsaSvrsParaContribuinteExclusivo(ConfiguracaoServico cfg)
+ {
+ return cfg.ContribuinteExclusivoIbsCbsSemIe && cfg.ModeloDocumento == ModeloDocumento.NFe;
+ }
///
/// Cria o cliente para o serviço de Autorização
///
@@ -43,12 +50,12 @@ public static INfeServicoAutorizacao CriaWsdlAutorizacao(ConfiguracaoServico cfg
{
string url = Enderecador.ObterUrlServico(ServicoNFe.NFeAutorizacao, cfg);
- if (cfg.UsaSvanNFe4(cfg.VersaoNFeAutorizacao))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvanNFe4(cfg.VersaoNFeAutorizacao))
{
return new NFeAutorizacao4SVAN(url, certificado, cfg.TimeOut);
}
- if (cfg.UsaSvcanNFe4(cfg.VersaoNFeAutorizacao))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvcanNFe4(cfg.VersaoNFeAutorizacao))
{
return new NFeAutorizacao4SVCAN(url, certificado, cfg.TimeOut);
}
@@ -97,12 +104,12 @@ public static INfeServico CriaWsdlOutros(ServicoNFe servico, ConfiguracaoServico
switch (servico)
{
case ServicoNFe.NfeStatusServico:
- if (cfg.UsaSvanNFe4(cfg.VersaoNfeStatusServico))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvanNFe4(cfg.VersaoNfeStatusServico))
{
return new NfeStatusServico4NFeSVAN(url, certificado, cfg.TimeOut);
}
- if (cfg.UsaSvcanNFe4(cfg.VersaoNfeStatusServico))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvcanNFe4(cfg.VersaoNfeStatusServico))
{
return new NfeStatusServico4NFeSVCAN(url, certificado, cfg.TimeOut);
}
@@ -125,12 +132,12 @@ public static INfeServico CriaWsdlOutros(ServicoNFe servico, ConfiguracaoServico
return new NfeStatusServico2(url, certificado, cfg.TimeOut);
case ServicoNFe.NfeConsultaProtocolo:
- if (cfg.UsaSvanNFe4(cfg.VersaoNfeConsultaProtocolo))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvanNFe4(cfg.VersaoNfeConsultaProtocolo))
{
return new NfeConsultaProtocolo4SVAN(url, certificado, cfg.TimeOut);
}
- if (cfg.UsaSvcanNFe4(cfg.VersaoNfeConsultaProtocolo))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvcanNFe4(cfg.VersaoNfeConsultaProtocolo))
{
return new NfeConsultaProtocolo4SVCAN(url, certificado, cfg.TimeOut);
}
@@ -165,12 +172,12 @@ public static INfeServico CriaWsdlOutros(ServicoNFe servico, ConfiguracaoServico
MethodBase.GetCurrentMethod().Name));
case ServicoNFe.NFeRetAutorizacao:
- if (cfg.UsaSvanNFe4(cfg.VersaoNFeRetAutorizacao))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvanNFe4(cfg.VersaoNFeRetAutorizacao))
{
return new NfeRetAutorizacao4SVAN(url, certificado, cfg.TimeOut);
}
- if (cfg.UsaSvcanNFe4(cfg.VersaoNFeRetAutorizacao))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvcanNFe4(cfg.VersaoNFeRetAutorizacao))
{
return new NfeRetAutorizacao4SVCAN(url, certificado, cfg.TimeOut);
}
@@ -212,12 +219,12 @@ public static INfeServico CriaWsdlOutros(ServicoNFe servico, ConfiguracaoServico
case ServicoNFe.RecepcaoEventoCancelmento:
case ServicoNFe.RecepcaoEventoCartaCorrecao:
- if (cfg.UsaSvanNFe4(cfg.VersaoRecepcaoEventoCceCancelamento))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvanNFe4(cfg.VersaoRecepcaoEventoCceCancelamento))
{
return new RecepcaoEvento4SVAN(url, certificado, cfg.TimeOut);
}
- if (cfg.UsaSvcanNFe4(cfg.VersaoRecepcaoEventoCceCancelamento))
+ if (!UsaSvrsParaContribuinteExclusivo(cfg) && cfg.UsaSvcanNFe4(cfg.VersaoRecepcaoEventoCceCancelamento))
{
return new RecepcaoEvento4SVCAN(url, certificado, cfg.TimeOut);
}
@@ -308,4 +315,4 @@ public static INfeServico CriaWsdlOutros(ServicoNFe servico, ConfiguracaoServico
return null;
}
}
-}
\ No newline at end of file
+}
diff --git a/NFe.Servicos/ServicosNFe.cs b/NFe.Servicos/ServicosNFe.cs
index 5bc761f06..a08edcb48 100644
--- a/NFe.Servicos/ServicosNFe.cs
+++ b/NFe.Servicos/ServicosNFe.cs
@@ -650,7 +650,8 @@ private RetornoRecepcaoEvento RecepcaoEventoCancelamento(NFeTipoEvento tipoEvent
};
var infEvento = new infEventoEnv
{
- cOrgao = _cFgServico.cUF,
+ cOrgao = _cFgServico.ContribuinteExclusivoIbsCbsSemIe && _cFgServico.ModeloDocumento == ModeloDocumento.NFe
+ ? Estado.SVRS : _cFgServico.cUF,
tpAmb = _cFgServico.tpAmb,
chNFe = chaveNFe,
dhEvento = dhEvento ?? DateTime.Now,
@@ -768,7 +769,8 @@ public RetornoRecepcaoEvento RecepcaoEventoCartaCorrecao(int idlote, int sequenc
}
var infEvento = new infEventoEnv
{
- cOrgao = _cFgServico.cUF,
+ cOrgao = _cFgServico.ContribuinteExclusivoIbsCbsSemIe && _cFgServico.ModeloDocumento == ModeloDocumento.NFe
+ ? Estado.SVRS : _cFgServico.cUF,
tpAmb = _cFgServico.tpAmb,
chNFe = chaveNFe,
dhEvento = dhEvento ?? DateTime.Now,
diff --git a/NFe.Utils.Testes/EnderecadorTestes.cs b/NFe.Utils.Testes/EnderecadorTestes.cs
index c3eb90acb..107f51513 100644
--- a/NFe.Utils.Testes/EnderecadorTestes.cs
+++ b/NFe.Utils.Testes/EnderecadorTestes.cs
@@ -58,6 +58,91 @@ public void DeveUrlSpEstarCorretaParaNFeAutorizacaoVersao4()
TipoAmbiente.Producao, ModeloDocumento.NFe, TipoEmissao.teNormal);
Assert.Equal("https://nfe.fazenda.sp.gov.br/ws/nfeautorizacao4.asmx", url);
}
+
+ ///
+ /// Dado emitente exclusivo sem IE, quando autoriza NF-e, entao usa a SVRS e preserva a UF.
+ ///
+ [Theory]
+ [InlineData(Estado.SP, TipoAmbiente.Homologacao, "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx")]
+ [InlineData(Estado.SP, TipoAmbiente.Producao, "https://nfe.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx")]
+ [InlineData(Estado.BA, TipoAmbiente.Homologacao, "https://nfe-homologacao.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx")]
+ [InlineData(Estado.MA, TipoAmbiente.Producao, "https://nfe.svrs.rs.gov.br/ws/NfeAutorizacao/NFeAutorizacao4.asmx")]
+ public void DadoEmitenteExclusivoSemIe_QuandoAutorizaNFe_EntaoUsaSvrsSemAlterarUf(
+ Estado uf, TipoAmbiente ambiente, string urlEsperada)
+ {
+ var configuracao = new ConfiguracaoServico
+ {
+ cUF = uf,
+ tpAmb = ambiente,
+ ModeloDocumento = ModeloDocumento.NFe,
+ tpEmis = TipoEmissao.teNormal,
+ VersaoNFeAutorizacao = VersaoServico.Versao400,
+ ContribuinteExclusivoIbsCbsSemIe = true
+ };
+
+ Assert.Equal(urlEsperada, Enderecador.ObterUrlServico(ServicoNFe.NFeAutorizacao, configuracao));
+ Assert.Equal(uf, configuracao.cUF);
+ }
+
+ ///
+ /// Dado emitente exclusivo sem IE, quando consulta ou cancela, entao usa a SVRS.
+ ///
+ [Fact]
+ public void DadoEmitenteExclusivoSemIe_QuandoConsultaOuCancela_EntaoUsaSvrs()
+ {
+ var configuracao = new ConfiguracaoServico
+ {
+ cUF = Estado.SP,
+ tpAmb = TipoAmbiente.Homologacao,
+ ModeloDocumento = ModeloDocumento.NFe,
+ tpEmis = TipoEmissao.teNormal,
+ VersaoNfeConsultaProtocolo = VersaoServico.Versao400,
+ VersaoRecepcaoEventoCceCancelamento = VersaoServico.Versao400,
+ ContribuinteExclusivoIbsCbsSemIe = true
+ };
+
+ Assert.Contains("svrs.rs.gov.br", Enderecador.ObterUrlServico(ServicoNFe.NfeConsultaProtocolo, configuracao));
+ Assert.Contains("svrs.rs.gov.br", Enderecador.ObterUrlServico(ServicoNFe.RecepcaoEventoCancelmento, configuracao));
+ }
+
+ ///
+ /// Dada NFC-e, quando a opcao exclusiva esta ativa, entao preserva a rota normal.
+ ///
+ [Fact]
+ public void DadaNfce_QuandoOpcaoExclusivaEstaAtiva_EntaoPreservaRotaNormal()
+ {
+ var configuracao = new ConfiguracaoServico
+ {
+ cUF = Estado.SP,
+ tpAmb = TipoAmbiente.Producao,
+ ModeloDocumento = ModeloDocumento.NFCe,
+ tpEmis = TipoEmissao.teNormal,
+ VersaoNFeAutorizacao = VersaoServico.Versao400,
+ ContribuinteExclusivoIbsCbsSemIe = true
+ };
+
+ var url = Enderecador.ObterUrlServico(ServicoNFe.NFeAutorizacao, configuracao);
+ Assert.DoesNotContain("svrs.rs.gov.br", url);
+ }
+
+ ///
+ /// Dado emitente comum, quando autoriza NF-e, entao preserva a rota de sua UF.
+ ///
+ [Fact]
+ public void DadoEmitenteComum_QuandoAutorizaNFe_EntaoPreservaRotaDaUf()
+ {
+ var configuracao = new ConfiguracaoServico
+ {
+ cUF = Estado.SP,
+ tpAmb = TipoAmbiente.Producao,
+ ModeloDocumento = ModeloDocumento.NFe,
+ tpEmis = TipoEmissao.teNormal,
+ VersaoNFeAutorizacao = VersaoServico.Versao400
+ };
+
+ var url = Enderecador.ObterUrlServico(ServicoNFe.NFeAutorizacao, configuracao);
+ Assert.Equal("https://nfe.fazenda.sp.gov.br/ws/nfeautorizacao4.asmx", url);
+ }
}
public class EstadosData : TheoryData
diff --git a/NFe.Utils/ConfiguracaoServico.cs b/NFe.Utils/ConfiguracaoServico.cs
index 64834ae0b..8c4d03401 100644
--- a/NFe.Utils/ConfiguracaoServico.cs
+++ b/NFe.Utils/ConfiguracaoServico.cs
@@ -102,6 +102,13 @@ static ConfiguracaoServico()
///
public ConfiguracaoCertificado Certificado { get; set; }
+ ///
+ /// Direciona os servicos da NF-e modelo 55 do emitente sem IE, contribuinte
+ /// exclusivo do IBS/CBS, para a SVRS (NT 2026.007). Mantem cUF como a UF
+ /// do emitente para a chave de acesso e para o XML.
+ ///
+ public bool ContribuinteExclusivoIbsCbsSemIe { get; set; }
+
///
/// Tempo máximo de espera pela resposta do webservice, em milisegundos
///
@@ -644,4 +651,4 @@ private void OnPropertyChanged([CallerMemberName] string propertyName = null)
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
-}
\ No newline at end of file
+}
diff --git a/NFe.Utils/Enderecos/Enderecador.cs b/NFe.Utils/Enderecos/Enderecador.cs
index 1868705a9..8b90d80f6 100644
--- a/NFe.Utils/Enderecos/Enderecador.cs
+++ b/NFe.Utils/Enderecos/Enderecador.cs
@@ -1667,6 +1667,30 @@ private static List CarregarEnderecosServicos()
}
#endregion
+ // NT 2026.007: a NF-e do contribuinte exclusivo do IBS/CBS sem IE
+ // usa a SVRS mesmo quando sua UF possui outra autorizadora.
+ // Reaproveita somente os enderecos SVRS ja cadastrados para AC.
+ var servicosContribuinteExclusivo = new[]
+ {
+ ServicoNFe.NFeAutorizacao,
+ ServicoNFe.NFeRetAutorizacao,
+ ServicoNFe.NfeConsultaProtocolo,
+ ServicoNFe.NfeStatusServico,
+ ServicoNFe.RecepcaoEventoCancelmento,
+ ServicoNFe.RecepcaoEventoCartaCorrecao
+ };
+ var enderecosSvrs = endServico.Where(endereco =>
+ endereco.Estado == Estado.AC &&
+ endereco.ModeloDocumento == ModeloDocumento.NFe &&
+ servicosContribuinteExclusivo.Contains(endereco.ServicoNFe) &&
+ endereco.Url.Contains("svrs.rs.gov.br")).ToList();
+ foreach (var endereco in enderecosSvrs)
+ {
+ endServico.Add(new EnderecoServico(endereco.ServicoNFe, endereco.VersaoServico,
+ endereco.TipoAmbiente, endereco.TipoEmissao, Estado.SVRS,
+ endereco.ModeloDocumento, endereco.Url));
+ }
+
return endServico;
}
@@ -1823,6 +1847,18 @@ public static string ObterUrlServico(ServicoNFe servico, ConfiguracaoServico cfg
if (!string.IsNullOrWhiteSpace(uf))
estado = estado.SiglaParaEstado(uf);
+ // A NT 2026.007 centraliza na SVRS a NF-e do emitente contribuinte
+ // exclusivo do IBS/CBS sem IE. cUF permanece a UF real do emitente.
+ if (cfgServico.ContribuinteExclusivoIbsCbsSemIe &&
+ cfgServico.ModeloDocumento == ModeloDocumento.NFe &&
+ (servico == ServicoNFe.NFeAutorizacao ||
+ servico == ServicoNFe.NFeRetAutorizacao ||
+ servico == ServicoNFe.NfeConsultaProtocolo ||
+ servico == ServicoNFe.NfeStatusServico ||
+ servico == ServicoNFe.RecepcaoEventoCancelmento ||
+ servico == ServicoNFe.RecepcaoEventoCartaCorrecao))
+ estado = Estado.SVRS;
+
return ObterUrlServico(servico, versaoServico.GetValueOrDefault(), estado, cfgServico.tpAmb, cfgServico.ModeloDocumento, cfgServico.tpEmis);
}
@@ -1863,4 +1899,4 @@ into g
}
}
-}
\ No newline at end of file
+}