Skip to content

Commit 2ee3f05

Browse files
Merge pull request #1564 from MauricioSuporte/feature/evento-ator-interessado
feat:Evento Ator Interessado na NF-e (NT 2020.007)
2 parents 12c7fa2 + 42ee166 commit 2ee3f05

File tree

12 files changed

+338
-16
lines changed

12 files changed

+338
-16
lines changed

NFe.AppTeste/MainWindow.xaml

+2
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,8 @@
974974
Margin="10,260,0,0" VerticalAlignment="Top" Width="177" Click="BtnConciliacaoFinanceira_Click" />
975975
<Button x:Name="BtnCancConciliacaoFinanceira" Content="Canc. Conciliação Financeira NFe" HorizontalAlignment="Left"
976976
Margin="192,260,0,0" VerticalAlignment="Top" Width="177" Click="BtnCancConciliacaoFinanceira_Click" />
977+
<Button x:Name="BtnAtorInteressado" Content="Ator Interessado NFe" HorizontalAlignment="Left"
978+
Margin="375,235,0,0" VerticalAlignment="Top" Width="177" Click="BtnAtorInteressado_Click" />
977979
</Grid>
978980
</TabItem>
979981

NFe.AppTeste/MainWindow.xaml.cs

+56-1
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,61 @@ private void BtnCancelarNFeSubstituicao_OnClick(object sender, RoutedEventArgs e
22632263
}
22642264
}
22652265

2266-
2266+
private void BtnAtorInteressado_Click(object sender, RoutedEventArgs e)
2267+
{
2268+
const string titulo = "Evento Ator Interessado na NF-e";
2269+
2270+
try
2271+
{
2272+
#region Evento Ator Interessado na NF-e
2273+
2274+
var idlote = Funcoes.InpuBox(this, titulo, "Identificador de controle do Lote de envio:", "1");
2275+
if (string.IsNullOrEmpty(idlote)) throw new Exception("A Id do Lote deve ser informada!");
2276+
2277+
var sequenciaEvento = Funcoes.InpuBox(this, titulo, "Número sequencial do evento:", "2");
2278+
if (string.IsNullOrEmpty(sequenciaEvento)) throw new Exception("O número sequencial deve ser informado!");
2279+
2280+
var chave = Funcoes.InpuBox(this, titulo, "Chave da NFe:", "28241132876302000114550010000090041001283454");
2281+
if (string.IsNullOrEmpty(chave)) throw new Exception("A Chave deve ser informada!");
2282+
if (chave.Length != 44) throw new Exception("Chave deve conter 44 caracteres!");
2283+
2284+
var cnpjTransportador = Funcoes.InpuBox(this, titulo, "CPF/CNPJ do Ator Interessado:", "10526704000156");
2285+
if (string.IsNullOrEmpty(cnpjTransportador)) throw new Exception("O CPF/CNPJ do Ator Interessado deve ser informado!");
2286+
if (cnpjTransportador.Length != 14 && cnpjTransportador.Length != 11) throw new Exception("O CPF/CNPJ deve conter 11 ou 14 caracteres!");
2287+
2288+
var servicoNFe = new ServicosNFe(_configuracoes.CfgServico);
2289+
var cpfcnpj = string.IsNullOrEmpty(_configuracoes.Emitente.CNPJ)
2290+
? _configuracoes.Emitente.CPF
2291+
: _configuracoes.Emitente.CNPJ;
2292+
2293+
var retornoAtorInteressado = servicoNFe.RecepcaoEventoAtorInteressado(
2294+
Convert.ToInt32(idlote),
2295+
Convert.ToInt16(sequenciaEvento),
2296+
cpfcnpj,
2297+
chave,
2298+
cnpjTransportador,
2299+
Classes.Servicos.Evento.TipoAutor.taEmpresaEmitente,
2300+
Classes.Servicos.Evento.TipoAutorizacao.Permite,
2301+
DFe.Classes.Entidades.Estado.SE);
2302+
2303+
TrataRetorno(retornoAtorInteressado);
2304+
2305+
#endregion
2306+
}
2307+
catch (ComunicacaoException ex)
2308+
{
2309+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
2310+
}
2311+
catch (ValidacaoSchemaException ex)
2312+
{
2313+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
2314+
}
2315+
catch (Exception ex)
2316+
{
2317+
if (!string.IsNullOrEmpty(ex.Message))
2318+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
2319+
}
2320+
}
2321+
22672322
}
22682323
}

NFe.AppTeste/Schemas/110150_v1.00.xsd

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- edited with XMLSpy v2008 (http://www.altova.com) by sas-softwares@procergs.rs.gov.br (PROCERGS) -->
3+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/nfe" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/nfe" elementFormDefault="qualified" attributeFormDefault="unqualified">
4+
<xs:include schemaLocation="tiposBasico_v1.03.xsd"/>
5+
<xs:element name="detEvento">
6+
<xs:annotation>
7+
<xs:documentation>Schema XML de validação do evento de Ator Interessado na NF-e - Transportador (110150)”</xs:documentation>
8+
</xs:annotation>
9+
<xs:complexType>
10+
<xs:sequence>
11+
<xs:element name="descEvento">
12+
<xs:annotation>
13+
<xs:documentation>Descrição do Evento - "Ator interessado na NF-e”"</xs:documentation>
14+
</xs:annotation>
15+
<xs:simpleType>
16+
<xs:restriction base="TString">
17+
<xs:whiteSpace value="preserve"/>
18+
<xs:enumeration value="Ator interessado na NF-e"/>
19+
</xs:restriction>
20+
</xs:simpleType>
21+
</xs:element>
22+
<xs:element name="cOrgaoAutor" type="TCodUfIBGE"/>
23+
<xs:element name="tpAutor">
24+
<xs:annotation>
25+
<xs:documentation>Tipo do Órgão Autor do Evento. Informar uma das opções 1=Geração do Evento pelo Emitente; 2=Geração do Evento pelo Destinatário; 3=Geração do Evento pelo Transportador
26+
Outros valores: 1=Empresa Emitente, 2=Empresa destinatária; 3=Empresa; 5=Fisco; 6=RFB; 9=Outros Órgãos;</xs:documentation>
27+
</xs:annotation>
28+
<xs:simpleType>
29+
<xs:restriction base="xs:string">
30+
<xs:whiteSpace value="preserve"/>
31+
<xs:enumeration value="1"/>
32+
<xs:enumeration value="2"/>
33+
<xs:enumeration value="3"/>
34+
</xs:restriction>
35+
</xs:simpleType>
36+
</xs:element>
37+
<xs:element name="verAplic" type="TVerAplic">
38+
<xs:annotation>
39+
<xs:documentation>Versão do aplicativo do Autor do Evento.</xs:documentation>
40+
</xs:annotation>
41+
</xs:element>
42+
<xs:element name="autXML">
43+
<xs:annotation>
44+
<xs:documentation>Pessoas autorizadas a acessar o XML da NF-e</xs:documentation>
45+
</xs:annotation>
46+
<xs:complexType>
47+
<xs:choice>
48+
<xs:element name="CNPJ" type="TCnpj"/>
49+
<xs:element name="CPF" type="TCpf"/>
50+
</xs:choice>
51+
</xs:complexType>
52+
</xs:element>
53+
<xs:element name="tpAutorizacao" minOccurs="0">
54+
<xs:annotation>
55+
<xs:documentation>0 – Não permite; 1 – Permite o transportador autorizado pelo emitente ou destinatário autorizar outros transportadores para ter acesso ao download da NF-e
56+
</xs:documentation>
57+
</xs:annotation>
58+
<xs:simpleType>
59+
<xs:restriction base="xs:string">
60+
<xs:whiteSpace value="preserve"/>
61+
<xs:enumeration value="0"/>
62+
<xs:enumeration value="1"/>
63+
</xs:restriction>
64+
</xs:simpleType>
65+
</xs:element>
66+
<xs:element name="xCondUso" minOccurs="0">
67+
<xs:annotation>
68+
<xs:documentation>Texto Fixo com as Condição de uso do tipo de autorização para o transportador: </xs:documentation>
69+
</xs:annotation>
70+
<xs:simpleType>
71+
<xs:restriction base="xs:string">
72+
<xs:whiteSpace value="preserve"/>
73+
<xs:enumeration value="O emitente ou destinatário da NF-e, declara que permite o transportador declarado no campo CNPJ/CPF deste evento a autorizar os transportadores subcontratados ou redespachados a terem acesso ao download da NF-e"/>
74+
</xs:restriction>
75+
</xs:simpleType>
76+
</xs:element>
77+
</xs:sequence>
78+
<xs:attribute name="versao" use="required">
79+
<xs:simpleType>
80+
<xs:restriction base="xs:string">
81+
<xs:whiteSpace value="preserve"/>
82+
<xs:enumeration value="1.00"/>
83+
</xs:restriction>
84+
</xs:simpleType>
85+
</xs:attribute>
86+
</xs:complexType>
87+
</xs:element>
88+
</xs:schema>

NFe.Classes/Servicos/Evento/detEvento.cs

+41-14
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@
3232
/********************************************************************************/
3333
using System;
3434
using System.Collections.Generic;
35+
using System.Runtime.ConstrainedExecution;
3536
using System.Xml.Serialization;
3637
using DFe.Classes.Entidades;
3738
using DFe.Utils;
39+
using NFe.Classes.Informacoes;
3840
using NFe.Classes.Informacoes.Identificacao.Tipos;
3941
using Shared.NFe.Classes.Servicos.Evento;
4042

@@ -54,20 +56,6 @@ public class detEvento
5456
/// </summary>
5557
public string descEvento { get; set; }
5658

57-
#region Carta de Correção
58-
59-
/// <summary>
60-
/// HP20 - Correção a ser considerada, texto livre. A correção mais recente substitui as anteriores.
61-
/// </summary>
62-
public string xCorrecao { get; set; }
63-
64-
/// <summary>
65-
/// HP20a - Condições de uso da Carta de Correção
66-
/// </summary>
67-
public string xCondUso { get; set; }
68-
69-
#endregion
70-
7159
#region EPEC
7260

7361
/// <summary>
@@ -328,5 +316,44 @@ public bool ShouldSerializedetPag()
328316
}
329317

330318
#endregion
319+
320+
#region Ator Interessado NFe
321+
/// <summary>
322+
/// P23 - Pessoas autorizadas a acessar o XML da NF-e
323+
/// </summary>
324+
[XmlElement("autXML")]
325+
public List<autXML> autXML { get; set; }
326+
327+
/// <summary>
328+
/// P26 - 0 = Não permite;
329+
/// 1 = Permite o transportador autorizado pelo
330+
/// emitente ou destinatário autorizar outros
331+
/// transportadores para ter acesso ao download da
332+
/// NF-e
333+
/// </summary>
334+
public TipoAutorizacao? tpAutorizacao { get; set; }
335+
336+
public bool ShouldSerializetpAutorizacao()
337+
{
338+
return tpAutorizacao != null;
339+
}
340+
341+
#endregion
342+
343+
#region Carta de Correção
344+
345+
/// <summary>
346+
/// HP20 - Correção a ser considerada, texto livre. A correção mais recente substitui as anteriores.
347+
/// </summary>
348+
public string xCorrecao { get; set; }
349+
350+
/// <summary>
351+
/// HP20a - Condições de uso da Carta de Correção.
352+
/// P27 - Condição de uso do tipo de autorização para o transportador.
353+
/// </summary>
354+
public string xCondUso { get; set; }
355+
356+
#endregion
357+
331358
}
332359
}

NFe.Classes/Servicos/Evento/detEventoTipos.cs

+28
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
/* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */
3232
/********************************************************************************/
3333
using System.ComponentModel;
34+
using System.Runtime.ConstrainedExecution;
3435
using System.Xml.Serialization;
3536

3637
namespace NFe.Classes.Servicos.Evento
@@ -128,4 +129,31 @@ public enum MotivoInsucesso
128129
[XmlEnum("4")]
129130
Outros = 4
130131
}
132+
133+
/// <summary>
134+
/// 0 – Não permite;
135+
/// 1 – Permite o transportador autorizado pelo
136+
/// emitente ou destinatário autorizar outros
137+
/// transportadores para ter acesso ao download da
138+
/// NF-e
139+
/// </summary>
140+
public enum TipoAutorizacao
141+
{
142+
/// <summary>
143+
/// 0 – Não permite
144+
/// </summary>
145+
[Description("Não permite")]
146+
[XmlEnum("0")]
147+
NaoPermite = 0,
148+
149+
/// <summary>
150+
/// 1 – Permite o transportador autorizado pelo
151+
/// emitente ou destinatário autorizar outros
152+
/// transportadores para ter acesso ao download da
153+
/// NF-e
154+
/// </summary>
155+
[Description("Permite")]
156+
[XmlEnum("1")]
157+
Permite = 1
158+
}
131159
}

NFe.Classes/Servicos/Evento/retEvento.cs

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
/* Rua Comendador Francisco josé da Cunha, 111 - Itabaiana - SE - 49500-000 */
3232
/********************************************************************************/
3333
using System.Xml.Serialization;
34+
using DFe.Classes.Assinatura;
3435

3536
namespace NFe.Classes.Servicos.Evento
3637
{
@@ -47,5 +48,12 @@ public class retEvento
4748
/// HR11 - Grupo de informações do registro do Evento
4849
/// </summary>
4950
public infEventoRet infEvento { get; set; }
51+
52+
/// <summary>
53+
/// HR91 - Assinatura Digital do documento XML, a assinatura deverá ser aplicada no elemento infEvento.
54+
/// A decisão de assinar a mensagem fica da critério da UF.
55+
/// </summary>
56+
[XmlElement(Namespace = "http://www.w3.org/2000/09/xmldsig#")]
57+
public Signature Signature { get; set; }
5058
}
5159
}

NFe.Classes/Servicos/Tipos/NFeServicosTipos.cs

+13
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public enum ServicoNFe
8989
/// </summary>
9090
RecepcaoEventoManifestacaoDestinatario,
9191

92+
/// <summary>
93+
/// serviço destinado à recepção de mensagem do Evento de Ator Interessado da NF-e
94+
/// </summary>
95+
RecepcaoEventoAtorInteressado,
96+
9297
/// <summary>
9398
/// serviço destinado à recepção de mensagens de lote de NF-e versão 2.0
9499
/// </summary>
@@ -184,6 +189,7 @@ public enum IndicadorSincronizacao
184189
/// 110112 - Cancelamento por substituição
185190
/// 110130 - Comprovante de Entrega da NF-e
186191
/// 110131 - Cancelamento Comprovante de Entrega da NF-e
192+
/// 110150 - Ator Interessado na NF-e
187193
/// 110192 - Insucesso na Entrega da NF-e
188194
/// 110193 - Cancelamento Insucesso na Entrega da NF-e
189195
/// 110750 - Conciliação Financeira da NF-e
@@ -222,6 +228,13 @@ public enum NFeTipoEvento
222228
[Description("Cancelamento por substituicao")]
223229
[XmlEnum("110112")]
224230
TeNfeCancelamentoSubstituicao = 110112,
231+
232+
/// <summary>
233+
/// 110150 - Ator interessado na NF-e
234+
/// </summary>
235+
[Description("Ator interessado na NF-e")]
236+
[XmlEnum("110150")]
237+
TeNfeAtorInteressadoNFe = 110150,
225238

226239
/// <summary>
227240
/// 110192 - Insucesso na Entrega da NF-e

NFe.Servicos/ServicoNfeFactory.cs

+3
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ public static INfeServico CriaWsdlOutros(ServicoNFe servico, ConfiguracaoServico
249249

250250
return new RecepcaoEvento(url, certificado, cfg.TimeOut);
251251

252+
case ServicoNFe.RecepcaoEventoAtorInteressado:
253+
return new RecepcaoEvento4AN(url, certificado, cfg.TimeOut);
254+
252255
case ServicoNFe.RecepcaoEventoEpec:
253256
if (cfg.VersaoRecepcaoEventoEpec == VersaoServico.Versao400)
254257
{

0 commit comments

Comments
 (0)