Skip to content

Commit 33bdd78

Browse files
authored
Merge pull request #111 from guidi/fix/danfe-quest-pdf-contingencia
Fix/danfe quest pdf contingencia
2 parents e413bf6 + a08cc85 commit 33bdd78

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

NFe.Danfe.QuestPdf/ImpressaoNfce/DanfeNfceDocument.cs

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using DFe.Utils;
44
using NFe.Classes;
55
using NFe.Classes.Informacoes.Destinatario;
6+
using NFe.Classes.Informacoes.Identificacao.Tipos;
67
using NFe.Classes.Informacoes.Pagamento;
78
using NFe.Utils;
89
using NFe.Utils.InformacoesSuplementares;
@@ -349,6 +350,27 @@ private void Rodape(IContainer container)
349350

350351
column.Item().LineHorizontal(1);
351352

353+
if (DeveExibirMensagemContingencia())
354+
{
355+
column.Item().Row(r =>
356+
{
357+
r.RelativeItem().AlignCenter().Column(c =>
358+
{
359+
c.Item().AlignCenter().Text("EMITIDA EM CONTINGÊNCIA").FontSize(_tamanhoFontePadrao).ExtraBlack();
360+
});
361+
});
362+
363+
column.Item().Row(r =>
364+
{
365+
r.RelativeItem().AlignCenter().Column(c =>
366+
{
367+
c.Item().AlignCenter().Text("Pendente de autorização").FontSize(_tamanhoFontePadrao).ExtraBlack();
368+
});
369+
});
370+
371+
column.Item().LineHorizontal(1);
372+
}
373+
352374
column.Item().Row(r =>
353375
{
354376
r.RelativeItem().AlignCenter().Column(c =>
@@ -372,11 +394,18 @@ private void Rodape(IContainer container)
372394
t.Cell().AlignCenter().Image(ImagemQrCode());
373395
t.Cell().AlignLeft().Column(c =>
374396
{
375-
c.Item().Text($"Série: {_nfe.infNFe.ide.serie:D3}").FontSize(_tamanhoFontePadrao);
376-
c.Item().Text($"Número: {_nfe.infNFe.ide.nNF:D9}").FontSize(_tamanhoFontePadrao);
377-
c.Item().Text($"Emissão: {_nfeProc.NFe.infNFe.ide.dhEmi:G}").FontSize(_tamanhoFontePadrao);
378-
c.Item().Text($"Protocolo: {_nfeProc.protNFe.infProt.nProt}").FontSize(_tamanhoFontePadrao);
379-
c.Item().Text($"Autorização: {_nfeProc.protNFe.infProt.dhRecbto:G}").FontSize(_tamanhoFontePadrao);
397+
if (_nfe?.infNFe?.ide != null)
398+
{
399+
c.Item().Text($"Série: {_nfe.infNFe.ide.serie:D3}").FontSize(_tamanhoFontePadrao);
400+
c.Item().Text($"Número: {_nfe.infNFe.ide.nNF:D9}").FontSize(_tamanhoFontePadrao);
401+
c.Item().Text($"Emissão: {_nfe.infNFe.ide.dhEmi:G}").FontSize(_tamanhoFontePadrao);
402+
}
403+
404+
if (DeveExibirDadosProtocolo())
405+
{
406+
c.Item().Text($"Protocolo: {_nfeProc!.protNFe!.infProt.nProt}").FontSize(_tamanhoFontePadrao);
407+
c.Item().Text($"Autorização: {_nfeProc!.protNFe!.infProt.dhRecbto:G}").FontSize(_tamanhoFontePadrao);
408+
}
380409
});
381410
});
382411
});
@@ -554,6 +583,8 @@ private void CarregarXml(string xml)
554583
{
555584
try
556585
{
586+
_nfeProc = null;
587+
_nfe = null;
557588
_nfeProc = FuncoesXml.XmlStringParaClasse<nfeProc>(xml);
558589
_nfe = _nfeProc.NFe;
559590
}
@@ -563,6 +594,7 @@ private void CarregarXml(string xml)
563594
{
564595
NFe.Classes.NFe nfe = FuncoesXml.XmlStringParaClasse<NFe.Classes.NFe>(xml);
565596
_nfe = nfe;
597+
_nfeProc = null;
566598
}
567599
catch (Exception)
568600
{
@@ -572,6 +604,16 @@ private void CarregarXml(string xml)
572604
}
573605
}
574606

607+
private bool DeveExibirMensagemContingencia()
608+
{
609+
return _nfe?.infNFe?.ide?.tpEmis == TipoEmissao.teOffLine && _nfeProc == null;
610+
}
611+
612+
private bool DeveExibirDadosProtocolo()
613+
{
614+
return _nfeProc?.protNFe?.infProt != null && !DeveExibirMensagemContingencia();
615+
}
616+
575617
private string ObtemDescricao(FormaPagamento? formaPagamento)
576618
{
577619
var existeEnum = Enum

0 commit comments

Comments
 (0)