Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajuste na Aplicação Teste para utilização de CPF no NfeDistDFeInteresse #1507

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions NFe.AppTeste/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
using DFe.Classes.Entidades;
using DFe.Classes.Flags;
using DFe.Utils;
using NFe.Classes;
Expand Down Expand Up @@ -1633,15 +1632,18 @@ private void btn_NFeDistribuicaoDFe_Click(object sender, RoutedEventArgs e)
{
#region NFeDistribuicaoDFe

var cnpj = Funcoes.InpuBox(this, "Consulta NFeDistribuicaoDFe", "CNPJ do destinatário da NFe:");
if (string.IsNullOrEmpty(cnpj)) throw new Exception("O CNPJ deve ser informado!");
if (cnpj.Length != 14) throw new Exception("O CNPJ deve conter 14 caracteres!");
var documento = Funcoes.InpuBox(this, "Consulta NFeDistribuicaoDFe", "CNPJ/CPF do destinatário da NFe:");
if (string.IsNullOrEmpty(documento))
throw new Exception("O CNPJ/CPF deve ser informado!");
if (documento.Length != 11 && documento.Length != 14)
throw new Exception("Se for CNPJ deve conter 14 caracteres.\r\nSe for CPF deve conter 11 caracteres.");

var nsu = Funcoes.InpuBox(this, "Consulta NFeDistribuicaoDFe", "Ultimo NSU Retornado");
if (string.IsNullOrEmpty(nsu))
nsu = "0";

if (int.Parse(nsu) < 0) throw new Exception("NSU deve ser maior ou igual a 0");
if (int.Parse(nsu) < 0)
throw new Exception("NSU deve ser maior ou igual a 0");

string chnfe = "";
if (string.IsNullOrEmpty(nsu) || int.Parse(nsu) <= 0)
Expand All @@ -1651,12 +1653,12 @@ private void btn_NFeDistribuicaoDFe_Click(object sender, RoutedEventArgs e)
throw new Exception("Último NSU ou Chave Eletrônica devem ser informados");

var servicoNFe = new ServicosNFe(_configuracoes.CfgServico);
var retornoNFeDistDFe = servicoNFe.NfeDistDFeInteresse(_configuracoes.EnderecoEmitente.UF.ToString(), cnpj, ultNSU: nsu, chNFE: chnfe);
var retornoNFeDistDFe = servicoNFe.NfeDistDFeInteresse(_configuracoes.EnderecoEmitente.UF.ToString(), documento, ultNSU: nsu, chNFE: chnfe);

TrataRetorno(retornoNFeDistDFe);

#endregion
}
#endregion
}
catch (ComunicacaoException ex)
{
Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK);
Expand Down
Loading