Skip to content

Commit 53b9945

Browse files
authored
Merge pull request #44 from neicecilio/feature/conciliacao-financeira
feat:Evento de Conciliação Financeira para NFe (NT 2024.002)
2 parents 9376e70 + 05b5621 commit 53b9945

24 files changed

+1319
-11
lines changed

NFe.AppTeste/MainWindow.xaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@
904904
</TabControl>
905905
</StackPanel>
906906
</GroupBox>
907-
<TabControl Name="TabSuperior" Height="291" Margin="510,10,-0,0" VerticalAlignment="Top">
907+
<TabControl Name="TabSuperior" Height="316" Margin="510,10,-0,0" VerticalAlignment="Top">
908908
<TabItem Header="NF-e/NFC-e">
909909
<Grid Background="White">
910910
<Button x:Name="BtnStatusServico" Content="Status do Serviço" HorizontalAlignment="Left"
@@ -970,11 +970,15 @@
970970
Margin="10,235,0,0" VerticalAlignment="Top" Width="177" Click="BtnComprovanteEntrega_Click" />
971971
<Button x:Name="BtnCancComprovanteEntrega" Content="Canc. Comprovante Entrega NFe" HorizontalAlignment="Left"
972972
Margin="192,235,0,0" VerticalAlignment="Top" Width="177" Click="BtnCancComprovanteEntrega_Click" />
973+
<Button x:Name="BtnConciliacaoFinanceira" Content="Conciliação Financeira NFe" HorizontalAlignment="Left"
974+
Margin="10,260,0,0" VerticalAlignment="Top" Width="177" Click="BtnConciliacaoFinanceira_Click" />
975+
<Button x:Name="BtnCancConciliacaoFinanceira" Content="Canc. Conciliação Financeira NFe" HorizontalAlignment="Left"
976+
Margin="192,260,0,0" VerticalAlignment="Top" Width="177" Click="BtnCancConciliacaoFinanceira_Click" />
973977
</Grid>
974978
</TabItem>
975979

976980
</TabControl>
977-
<TabControl Name="TabInferior" Margin="509,306,0,0">
981+
<TabControl Name="TabInferior" Margin="509,331,0,0">
978982
<TabItem Header="Envio">
979983
<Grid Background="#FFE5E5E5">
980984
<Grid.ColumnDefinitions>

NFe.AppTeste/MainWindow.xaml.cs

+120
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,126 @@ private void BtnCancComprovanteEntrega_Click(object sender, RoutedEventArgs e)
572572
}
573573
}
574574

575+
private void BtnConciliacaoFinanceira_Click(object sender, RoutedEventArgs e)
576+
{
577+
const string titulo = "Conciliação Financeira NFe";
578+
579+
try
580+
{
581+
#region Conciliação Financeira NFe
582+
583+
var idlote = Funcoes.InpuBox(this, titulo, "Identificador de controle do Lote de envio:", "1");
584+
if (string.IsNullOrEmpty(idlote)) throw new Exception("A Id do Lote deve ser informada!");
585+
586+
var sequenciaEvento = Funcoes.InpuBox(this, titulo, "Número sequencial do evento:", "1");
587+
if (string.IsNullOrEmpty(sequenciaEvento))
588+
throw new Exception("O número sequencial deve ser informado!");
589+
590+
var chave = Funcoes.InpuBox(this, titulo, "Chave da NFe:", "35240311656919000154550750000008281647961399");
591+
if (string.IsNullOrEmpty(chave)) throw new Exception("A Chave deve ser informada!");
592+
if (chave.Length != 44) throw new Exception("Chave deve conter 44 caracteres!");
593+
594+
var meioPagamento = Funcoes.InpuBox(this, titulo, "Meio de Pagamento:", "17");
595+
if (string.IsNullOrEmpty(meioPagamento)) throw new Exception("Código do Meio de pagamento deve ser informado!");
596+
597+
var dhPagamentoStr = Funcoes.InpuBox(this, titulo, "Data de Pagamento:", DateTime.Now.ToString("dd/MM/yyyy"));
598+
if (string.IsNullOrEmpty(dhPagamentoStr)) throw new Exception("A data de pagamento deve ser informada!");
599+
600+
if (!DateTime.TryParse(dhPagamentoStr, out DateTime dhPagamento))
601+
throw new Exception("Data inválida!");
602+
603+
decimal? valorPagamento = null;
604+
var valorPagamentoStr = Funcoes.InpuBox(this, titulo, "Valor do Pagamento:", "1");
605+
if (string.IsNullOrEmpty(valorPagamentoStr)) throw new Exception("Valor do pagamento deve ser informado!");
606+
if (!string.IsNullOrEmpty(valorPagamentoStr)) valorPagamento = Convert.ToDecimal(valorPagamentoStr);
607+
608+
609+
var servicoNFe = new ServicosNFe(_configuracoes.CfgServico);
610+
var cpfcnpj = string.IsNullOrEmpty(_configuracoes.Emitente.CNPJ)
611+
? _configuracoes.Emitente.CPF
612+
: _configuracoes.Emitente.CNPJ;
613+
614+
var _pagamento = new Classes.Servicos.Evento.detPagEvento()
615+
{
616+
tPag = (FormaPagamento)Convert.ToInt32(meioPagamento),
617+
dPag = dhPagamento,
618+
vPag = valorPagamento.GetValueOrDefault()
619+
};
620+
var retornoConciliacao = servicoNFe.RecepcaoEventoConciliacaoFinanceira(Convert.ToInt32(idlote),
621+
Convert.ToInt16(sequenciaEvento), cpfcnpj, chave, new List<Classes.Servicos.Evento.detPagEvento>() { _pagamento }, DFe.Classes.Entidades.Estado.SP);
622+
623+
TrataRetorno(retornoConciliacao);
624+
625+
#endregion
626+
}
627+
catch (ComunicacaoException ex)
628+
{
629+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
630+
}
631+
catch (ValidacaoSchemaException ex)
632+
{
633+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
634+
}
635+
catch (Exception ex)
636+
{
637+
if (!string.IsNullOrEmpty(ex.Message))
638+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
639+
}
640+
}
641+
642+
private void BtnCancConciliacaoFinanceira_Click(object sender, RoutedEventArgs e)
643+
{
644+
const string titulo = "Cancelar Conciliação Financeira NFe";
645+
646+
try
647+
{
648+
#region Cancelar Conciliação Financeira NFe
649+
650+
var idlote = Funcoes.InpuBox(this, titulo, "Identificador de controle do Lote de envio:", "1");
651+
if (string.IsNullOrEmpty(idlote)) throw new Exception("A Id do Lote deve ser informada!");
652+
653+
var sequenciaEvento = Funcoes.InpuBox(this, titulo, "Número sequencial do evento:", "1");
654+
if (string.IsNullOrEmpty(sequenciaEvento))
655+
throw new Exception("O número sequencial deve ser informado!");
656+
657+
var chave = Funcoes.InpuBox(this, titulo, "Chave da NFe:", "35240311656919000154550750000008281647961399");
658+
if (string.IsNullOrEmpty(chave)) throw new Exception("A Chave deve ser informada!");
659+
if (chave.Length != 44) throw new Exception("Chave deve conter 44 caracteres!");
660+
661+
var nProtEvento = Funcoes.InpuBox(this, titulo, "Nº Prot Evento:");
662+
663+
if (string.IsNullOrEmpty(nProtEvento))
664+
throw new Exception("O nº Prot Evento deve ser informado!");
665+
666+
667+
668+
var servicoNFe = new ServicosNFe(_configuracoes.CfgServico);
669+
var cpfcnpj = string.IsNullOrEmpty(_configuracoes.Emitente.CNPJ)
670+
? _configuracoes.Emitente.CPF
671+
: _configuracoes.Emitente.CNPJ;
672+
673+
var retornoConciliacao = servicoNFe.RecepcaoEventoCancConciliacaoFinanceira(Convert.ToInt32(idlote),
674+
Convert.ToInt16(sequenciaEvento), cpfcnpj, chave, nProtEvento);
675+
676+
TrataRetorno(retornoConciliacao);
677+
678+
#endregion
679+
}
680+
catch (ComunicacaoException ex)
681+
{
682+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
683+
}
684+
catch (ValidacaoSchemaException ex)
685+
{
686+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
687+
}
688+
catch (Exception ex)
689+
{
690+
if (!string.IsNullOrEmpty(ex.Message))
691+
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
692+
}
693+
}
694+
575695
private void BtnConsultaXml_Click(object sender, RoutedEventArgs e)
576696
{
577697
try

NFe.AppTeste/NFe.AppTeste.csproj

+44-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
1515
<WarningLevel>4</WarningLevel>
1616
<NuGetPackageImportStamp>e0fff804</NuGetPackageImportStamp>
17-
<SccProjectName>SAK</SccProjectName>
18-
<SccLocalPath>SAK</SccLocalPath>
19-
<SccAuxPath>SAK</SccAuxPath>
20-
<SccProvider>SAK</SccProvider>
17+
<SccProjectName>
18+
</SccProjectName>
19+
<SccLocalPath>
20+
</SccLocalPath>
21+
<SccAuxPath>
22+
</SccAuxPath>
23+
<SccProvider>
24+
</SccProvider>
2125
<TargetFrameworkProfile />
2226
</PropertyGroup>
2327
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -259,6 +263,12 @@
259263
<SubType>Designer</SubType>
260264
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
261265
</None>
266+
<None Include="Schemas\e110750_v1.00.xsd">
267+
<SubType>Designer</SubType>
268+
</None>
269+
<None Include="Schemas\e110751_v1.00.xsd">
270+
<SubType>Designer</SubType>
271+
</None>
262272
<None Include="Schemas\e111500_v1.00.xsd">
263273
<SubType>Designer</SubType>
264274
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -359,6 +369,9 @@
359369
<SubType>Designer</SubType>
360370
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
361371
</None>
372+
<None Include="Schemas\envEventoCancEConf_v1.00.xsd">
373+
<SubType>Designer</SubType>
374+
</None>
362375
<None Include="Schemas\envEventoCancEntregaNFe_v1.00.xsd">
363376
<SubType>Designer</SubType>
364377
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -371,6 +384,9 @@
371384
<SubType>Designer</SubType>
372385
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
373386
</None>
387+
<None Include="Schemas\envEventoEConf_v1.00.xsd">
388+
<SubType>Designer</SubType>
389+
</None>
374390
<None Include="Schemas\envEventoEntregaNFe_v1.00.xsd">
375391
<SubType>Designer</SubType>
376392
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -419,6 +435,9 @@
419435
<SubType>Designer</SubType>
420436
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
421437
</None>
438+
<None Include="Schemas\EventoCancEConf_v1.00.xsd">
439+
<SubType>Designer</SubType>
440+
</None>
422441
<None Include="Schemas\eventoCancEntregaNFe_v1.00.xsd">
423442
<SubType>Designer</SubType>
424443
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -431,6 +450,9 @@
431450
<SubType>Designer</SubType>
432451
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
433452
</None>
453+
<None Include="Schemas\EventoEConf_v1.00.xsd">
454+
<SubType>Designer</SubType>
455+
</None>
434456
<None Include="Schemas\eventoEntregaNFe_v1.00.xsd">
435457
<SubType>Designer</SubType>
436458
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -543,6 +565,9 @@
543565
<SubType>Designer</SubType>
544566
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
545567
</None>
568+
<None Include="Schemas\leiauteEventoCancEConf_v1.00.xsd">
569+
<SubType>Designer</SubType>
570+
</None>
546571
<None Include="Schemas\leiauteEventoCancEntregaNFe_v1.00.xsd">
547572
<SubType>Designer</SubType>
548573
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -555,6 +580,9 @@
555580
<SubType>Designer</SubType>
556581
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
557582
</None>
583+
<None Include="Schemas\leiauteEventoEConf_v1.00.xsd">
584+
<SubType>Designer</SubType>
585+
</None>
558586
<None Include="Schemas\leiauteEventoEntregaNFe_v1.00.xsd">
559587
<SubType>Designer</SubType>
560588
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -675,6 +703,9 @@
675703
<SubType>Designer</SubType>
676704
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
677705
</None>
706+
<None Include="Schemas\procEventoCancEConf_v1.00.xsd">
707+
<SubType>Designer</SubType>
708+
</None>
678709
<None Include="Schemas\procEventoCancEntregaNFe_v1.00.xsd">
679710
<SubType>Designer</SubType>
680711
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -687,6 +718,9 @@
687718
<SubType>Designer</SubType>
688719
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
689720
</None>
721+
<None Include="Schemas\procEventoEConf_v1.00.xsd">
722+
<SubType>Designer</SubType>
723+
</None>
690724
<None Include="Schemas\procEventoEntregaNFe_v1.00.xsd">
691725
<SubType>Designer</SubType>
692726
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@@ -891,10 +925,16 @@
891925
<SubType>Designer</SubType>
892926
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
893927
</None>
928+
<None Include="Schemas\retEventoCancEConf_v1.00.xsd">
929+
<SubType>Designer</SubType>
930+
</None>
894931
<None Include="Schemas\retEventoCancEntregaNFe_v1.00.xsd">
895932
<SubType>Designer</SubType>
896933
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
897934
</None>
935+
<None Include="Schemas\retEventoEConf_v1.00.xsd">
936+
<SubType>Designer</SubType>
937+
</None>
898938
<None Include="Schemas\retEventoEntregaNFe_v1.00.xsd">
899939
<SubType>Designer</SubType>
900940
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:include schemaLocation="leiauteEventoCancEConf_v1.00.xsd"/>
4+
<xs:element name="evento" type="TEvento">
5+
<xs:annotation>
6+
<xs:documentation>Schema XML de validação do evento de Cancelamento do Comprovante de Entrega da NFe</xs:documentation>
7+
</xs:annotation>
8+
</xs:element>
9+
</xs:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<xs:include schemaLocation="leiauteEventoEConf_v1.00.xsd"/>
4+
<xs:element name="evento" type="TEvento">
5+
<xs:annotation>
6+
<xs:documentation>Schema XML de validação do evento de Conciliação Financeira</xs:documentation>
7+
</xs:annotation>
8+
</xs:element>
9+
</xs:schema>

0 commit comments

Comments
 (0)