@mmachadosantos/nfe-danfe-pdf 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +719 -0
- package/lib/application/helpers/generate-pdf/fontes/Times New Roman Bold Italic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/Times New Roman Bold.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/Times New Roman Italic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/Times New Roman.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Black.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-BlackItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Bold.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-BoldItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ExtraBold.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ExtraBoldItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ExtraLight.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ExtraLightItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Italic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Light.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-LightItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Medium.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-MediumItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Regular.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-SemiBold.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-SemiBoldItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Thin.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ThinItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Bold.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-BoldItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Italic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Light.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-LightItalic.ttf +0 -0
- package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Regular.ttf +0 -0
- package/lib/application/helpers/generate-pdf/nfe/campo.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/campo.js +15 -0
- package/lib/application/helpers/generate-pdf/nfe/cria-layout.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/cria-layout.js +149 -0
- package/lib/application/helpers/generate-pdf/nfe/default.d.ts +23 -0
- package/lib/application/helpers/generate-pdf/nfe/default.js +26 -0
- package/lib/application/helpers/generate-pdf/nfe/gerar-itens.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/gerar-itens.js +291 -0
- package/lib/application/helpers/generate-pdf/nfe/get-dados-adicionais.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-dados-adicionais.js +269 -0
- package/lib/application/helpers/generate-pdf/nfe/get-dados-emitente.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-dados-emitente.js +319 -0
- package/lib/application/helpers/generate-pdf/nfe/get-destinatario-remetente.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-destinatario-remetente.js +154 -0
- package/lib/application/helpers/generate-pdf/nfe/get-fatura-duplicata.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-fatura-duplicata.js +118 -0
- package/lib/application/helpers/generate-pdf/nfe/get-homologacao.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-homologacao.js +36 -0
- package/lib/application/helpers/generate-pdf/nfe/get-imposto.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-imposto.js +219 -0
- package/lib/application/helpers/generate-pdf/nfe/get-iss.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-iss.js +73 -0
- package/lib/application/helpers/generate-pdf/nfe/get-menu-itens.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-menu-itens.js +199 -0
- package/lib/application/helpers/generate-pdf/nfe/get-nota-cancelada.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-nota-cancelada.js +16 -0
- package/lib/application/helpers/generate-pdf/nfe/get-recibo.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-recibo.js +101 -0
- package/lib/application/helpers/generate-pdf/nfe/get-transporte.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/get-transporte.js +179 -0
- package/lib/application/helpers/generate-pdf/nfe/italico.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/italico.js +16 -0
- package/lib/application/helpers/generate-pdf/nfe/linha-horizontal-tracejada.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/linha-horizontal-tracejada.js +7 -0
- package/lib/application/helpers/generate-pdf/nfe/linha-horizontal.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/linha-horizontal.js +26 -0
- package/lib/application/helpers/generate-pdf/nfe/linha-vertical.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/linha-vertical.js +14 -0
- package/lib/application/helpers/generate-pdf/nfe/load-fontes.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/load-fontes.js +30 -0
- package/lib/application/helpers/generate-pdf/nfe/negrito.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/negrito.js +16 -0
- package/lib/application/helpers/generate-pdf/nfe/normal.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/normal.js +16 -0
- package/lib/application/helpers/generate-pdf/nfe/options-doc.d.ts +10 -0
- package/lib/application/helpers/generate-pdf/nfe/options-doc.js +14 -0
- package/lib/application/helpers/generate-pdf/nfe/secao.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/secao.js +16 -0
- package/lib/application/helpers/generate-pdf/nfe/titulo.d.ts +2 -0
- package/lib/application/helpers/generate-pdf/nfe/titulo.js +17 -0
- package/lib/application/helpers/xml/deserialize.d.ts +2 -0
- package/lib/application/helpers/xml/deserialize.js +24 -0
- package/lib/application/helpers/xml/index.d.ts +1 -0
- package/lib/application/helpers/xml/index.js +17 -0
- package/lib/domain/use-cases/pdf/index.d.ts +2 -0
- package/lib/domain/use-cases/pdf/index.js +25 -0
- package/lib/domain/use-cases/pdf/pdf-NFCe.d.ts +2 -0
- package/lib/domain/use-cases/pdf/pdf-NFCe.js +687 -0
- package/lib/domain/use-cases/pdf/pdf-NFe.d.ts +2 -0
- package/lib/domain/use-cases/pdf/pdf-NFe.js +54 -0
- package/lib/domain/use-cases/utils/clean-html-entities.d.ts +2 -0
- package/lib/domain/use-cases/utils/clean-html-entities.js +45 -0
- package/lib/domain/use-cases/utils/current-date.d.ts +1 -0
- package/lib/domain/use-cases/utils/current-date.js +7 -0
- package/lib/domain/use-cases/utils/format-cnpj.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-cnpj.js +8 -0
- package/lib/domain/use-cases/utils/format-cpf.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-cpf.js +8 -0
- package/lib/domain/use-cases/utils/format-date-time.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-date-time.js +10 -0
- package/lib/domain/use-cases/utils/format-date.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-date.js +9 -0
- package/lib/domain/use-cases/utils/format-key.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-key.js +6 -0
- package/lib/domain/use-cases/utils/format-number.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-number.js +6 -0
- package/lib/domain/use-cases/utils/format-phone.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-phone.js +20 -0
- package/lib/domain/use-cases/utils/format-plate.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-plate.js +16 -0
- package/lib/domain/use-cases/utils/format-postal-code.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-postal-code.js +8 -0
- package/lib/domain/use-cases/utils/format-protocol.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-protocol.js +8 -0
- package/lib/domain/use-cases/utils/format-state-registration.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-state-registration.js +152 -0
- package/lib/domain/use-cases/utils/format-time.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-time.js +8 -0
- package/lib/domain/use-cases/utils/index.d.ts +15 -0
- package/lib/domain/use-cases/utils/index.js +31 -0
- package/lib/domain/use-cases/utils/return-font-size-carrier.d.ts +1 -0
- package/lib/domain/use-cases/utils/return-font-size-carrier.js +23 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/generate-pdf.d.ts +266 -0
- package/lib/types/generate-pdf.js +2 -0
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +19 -0
- package/lib/types/nfe-proc.d.ts +42 -0
- package/lib/types/nfe-proc.js +2 -0
- package/lib/types/schema.d.ts +876 -0
- package/lib/types/schema.js +2 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +6 -0
- package/package.json +59 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDadosAdicionais = getDadosAdicionais;
|
|
4
|
+
const utils_1 = require("../../../../utils");
|
|
5
|
+
const utils_2 = require("../../../../domain/use-cases/utils");
|
|
6
|
+
const date_fns_1 = require("date-fns");
|
|
7
|
+
const pt_BR_1 = require("date-fns/locale/pt-BR");
|
|
8
|
+
const italico_1 = require("./italico");
|
|
9
|
+
const linha_vertical_1 = require("./linha-vertical");
|
|
10
|
+
const normal_1 = require("./normal");
|
|
11
|
+
const secao_1 = require("./secao");
|
|
12
|
+
const titulo_1 = require("./titulo");
|
|
13
|
+
function quebrarTextoPorLargura(doc, texto, larguraMaxima, tamanhoFonte = 6) {
|
|
14
|
+
const linhas = [];
|
|
15
|
+
let textoRestante = texto.trim();
|
|
16
|
+
doc.fontSize(tamanhoFonte);
|
|
17
|
+
while (textoRestante.length > 0) {
|
|
18
|
+
const larguraCompleta = doc.widthOfString(textoRestante);
|
|
19
|
+
if (larguraCompleta <= larguraMaxima) {
|
|
20
|
+
linhas.push(textoRestante);
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
let inicio = 1;
|
|
24
|
+
let fim = textoRestante.length;
|
|
25
|
+
let melhorCorte = 1;
|
|
26
|
+
while (inicio <= fim) {
|
|
27
|
+
const meio = Math.floor((inicio + fim) / 2);
|
|
28
|
+
const textoTeste = textoRestante.substring(0, meio);
|
|
29
|
+
const larguraTeste = doc.widthOfString(textoTeste);
|
|
30
|
+
if (larguraTeste <= larguraMaxima) {
|
|
31
|
+
melhorCorte = meio;
|
|
32
|
+
inicio = meio + 1;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
fim = meio - 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let pontoCorte = melhorCorte;
|
|
39
|
+
const textoParaCorte = textoRestante.substring(0, melhorCorte);
|
|
40
|
+
const separadores = [' | ', ' - ', ': ', ' ', ',', '.', ';'];
|
|
41
|
+
for (const separador of separadores) {
|
|
42
|
+
const ultimaPosicao = textoParaCorte.lastIndexOf(separador);
|
|
43
|
+
if (ultimaPosicao > melhorCorte * 0.7) {
|
|
44
|
+
pontoCorte = ultimaPosicao + separador.length;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (pontoCorte === 0) {
|
|
49
|
+
pontoCorte = Math.max(1, melhorCorte);
|
|
50
|
+
}
|
|
51
|
+
linhas.push(textoRestante.substring(0, pontoCorte).trim());
|
|
52
|
+
textoRestante = textoRestante.substring(pontoCorte).trim();
|
|
53
|
+
}
|
|
54
|
+
return linhas;
|
|
55
|
+
}
|
|
56
|
+
function quebrarTextoInteligente(texto, maxCaracteres) {
|
|
57
|
+
const linhas = [];
|
|
58
|
+
let textoRestante = texto;
|
|
59
|
+
while (textoRestante.length > 0) {
|
|
60
|
+
if (textoRestante.length <= maxCaracteres) {
|
|
61
|
+
linhas.push(textoRestante);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
let pontoCorte = maxCaracteres;
|
|
65
|
+
const fatia = textoRestante.substring(0, maxCaracteres);
|
|
66
|
+
const separadores = [' | ', ' - ', ': ', ' ', ',', '.'];
|
|
67
|
+
let melhorCorte = -1;
|
|
68
|
+
for (const separador of separadores) {
|
|
69
|
+
const ultimaOcorrencia = fatia.lastIndexOf(separador);
|
|
70
|
+
if (ultimaOcorrencia > maxCaracteres * 0.7) {
|
|
71
|
+
melhorCorte = ultimaOcorrencia + separador.length;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (melhorCorte > -1) {
|
|
76
|
+
pontoCorte = melhorCorte;
|
|
77
|
+
}
|
|
78
|
+
linhas.push(textoRestante.substring(0, pontoCorte).trim());
|
|
79
|
+
textoRestante = textoRestante.substring(pontoCorte).trim();
|
|
80
|
+
}
|
|
81
|
+
return linhas;
|
|
82
|
+
}
|
|
83
|
+
function getDadosAdicionais({ doc, ajusteX, ajusteY, margemEsquerda, margemTopo, margemDireita, larguraDoFormulario, infAdic, extra, finalEspacoDet, textoRodape }) {
|
|
84
|
+
let alturaSecao = 821.8;
|
|
85
|
+
const informacoesComplementares = [];
|
|
86
|
+
if (infAdic?.infAdFisco) {
|
|
87
|
+
informacoesComplementares.push(`Inf. Fisco: ${(0, utils_2.cleanInfoComplementar)(infAdic.infAdFisco)}`);
|
|
88
|
+
}
|
|
89
|
+
if (infAdic?.infCpl) {
|
|
90
|
+
informacoesComplementares.push(`Inf. Contribuinte: ${(0, utils_2.cleanInfoComplementar)(infAdic.infCpl)}`);
|
|
91
|
+
}
|
|
92
|
+
if (infAdic?.obsCont) {
|
|
93
|
+
const obsContArray = Array.isArray(infAdic.obsCont) ? infAdic.obsCont : [infAdic.obsCont];
|
|
94
|
+
obsContArray.forEach((obs) => {
|
|
95
|
+
if (obs.xCampo && obs.xTexto) {
|
|
96
|
+
informacoesComplementares.push(`${obs.xCampo}: ${(0, utils_2.cleanInfoComplementar)(obs.xTexto)}`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (extra?.vTotTrib) {
|
|
101
|
+
informacoesComplementares.push(`Valor Aproximado dos Tributos: ${(0, utils_1.MoneyMaskBR)(Number(extra.vTotTrib ?? '0'))}`);
|
|
102
|
+
}
|
|
103
|
+
if (extra?.emailDest) {
|
|
104
|
+
informacoesComplementares.push(`Email do Destinatário: ${extra.emailDest}`);
|
|
105
|
+
}
|
|
106
|
+
const textoCompleto = informacoesComplementares.join(' | ');
|
|
107
|
+
const larguraDisponivel = 365;
|
|
108
|
+
const alturaLinha = 8;
|
|
109
|
+
let linhasNecessarias = 1;
|
|
110
|
+
if (informacoesComplementares.length > 0) {
|
|
111
|
+
doc.fontSize(6);
|
|
112
|
+
const larguraTexto = doc.widthOfString(textoCompleto);
|
|
113
|
+
if (larguraTexto > larguraDisponivel) {
|
|
114
|
+
const linhasSimuladas = quebrarTextoPorLargura(doc, textoCompleto, larguraDisponivel, 6);
|
|
115
|
+
linhasNecessarias = linhasSimuladas.length;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const alturaTexto = Math.max(1, linhasNecessarias) * alturaLinha;
|
|
119
|
+
const alturaMinima = finalEspacoDet + 25 + alturaTexto;
|
|
120
|
+
if (alturaMinima > alturaSecao) {
|
|
121
|
+
alturaSecao = Math.min(alturaMinima, 850);
|
|
122
|
+
}
|
|
123
|
+
doc
|
|
124
|
+
.lineWidth(0.5)
|
|
125
|
+
.roundedRect(margemEsquerda + ajusteX, margemTopo + ajusteY + finalEspacoDet + 8, larguraDoFormulario, alturaSecao - (finalEspacoDet + 8), 3)
|
|
126
|
+
.stroke()
|
|
127
|
+
.lineWidth(1);
|
|
128
|
+
(0, linha_vertical_1.linhaVertical)({ y1: finalEspacoDet + 8, y2: alturaSecao, x: 367, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
129
|
+
(0, secao_1.secao)({ doc, value: 'DADOS ADICIONAIS', x: 1.5, y: finalEspacoDet, largura: 0, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
130
|
+
(0, titulo_1.titulo)({
|
|
131
|
+
value: 'INFORMAÇÕES COMPLEMENTARES',
|
|
132
|
+
x: 1.5,
|
|
133
|
+
y: finalEspacoDet + 10,
|
|
134
|
+
largura: 365.5,
|
|
135
|
+
ajusteX,
|
|
136
|
+
ajusteY,
|
|
137
|
+
doc,
|
|
138
|
+
margemEsquerda,
|
|
139
|
+
margemTopo
|
|
140
|
+
});
|
|
141
|
+
(0, titulo_1.titulo)({
|
|
142
|
+
value: 'RESERVADO AO FISCO',
|
|
143
|
+
x: 369,
|
|
144
|
+
y: finalEspacoDet + 10,
|
|
145
|
+
largura: 213,
|
|
146
|
+
ajusteX,
|
|
147
|
+
ajusteY,
|
|
148
|
+
doc,
|
|
149
|
+
margemEsquerda,
|
|
150
|
+
margemTopo
|
|
151
|
+
});
|
|
152
|
+
if (informacoesComplementares.length > 0) {
|
|
153
|
+
const textoCompleto = informacoesComplementares.join(' | ');
|
|
154
|
+
const larguraDisponivel = 365;
|
|
155
|
+
const alturaLinha = 8;
|
|
156
|
+
doc.fontSize(6);
|
|
157
|
+
const larguraTexto = doc.widthOfString(textoCompleto);
|
|
158
|
+
if (larguraTexto > larguraDisponivel) {
|
|
159
|
+
const linhas = quebrarTextoPorLargura(doc, textoCompleto, larguraDisponivel, 6);
|
|
160
|
+
linhas.forEach((linha, index) => {
|
|
161
|
+
(0, normal_1.normal)({
|
|
162
|
+
doc,
|
|
163
|
+
value: linha,
|
|
164
|
+
x: 1,
|
|
165
|
+
y: finalEspacoDet + 17.5 + index * alturaLinha,
|
|
166
|
+
largura: 365,
|
|
167
|
+
alinhamento: 'left',
|
|
168
|
+
tamanho: 6,
|
|
169
|
+
ajusteX,
|
|
170
|
+
ajusteY,
|
|
171
|
+
margemEsquerda,
|
|
172
|
+
margemTopo
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
(0, normal_1.normal)({
|
|
178
|
+
doc,
|
|
179
|
+
value: textoCompleto,
|
|
180
|
+
x: 1,
|
|
181
|
+
y: finalEspacoDet + 17.5,
|
|
182
|
+
largura: 365,
|
|
183
|
+
alinhamento: 'justify',
|
|
184
|
+
tamanho: 6,
|
|
185
|
+
ajusteX,
|
|
186
|
+
ajusteY,
|
|
187
|
+
margemEsquerda,
|
|
188
|
+
margemTopo
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const informacoesFisco = [];
|
|
193
|
+
if (infAdic?.obsFisco) {
|
|
194
|
+
const obsFiscoArray = Array.isArray(infAdic.obsFisco) ? infAdic.obsFisco : [infAdic.obsFisco];
|
|
195
|
+
obsFiscoArray.forEach((obs) => {
|
|
196
|
+
if (obs.xCampo && obs.xTexto) {
|
|
197
|
+
informacoesFisco.push(`${obs.xCampo}: ${(0, utils_2.cleanInfoComplementar)(obs.xTexto)}`);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
const textoFisco = informacoesFisco.join(' | ');
|
|
201
|
+
const larguraFisco = 213;
|
|
202
|
+
doc.fontSize(6);
|
|
203
|
+
const larguraTextoFisco = doc.widthOfString(textoFisco);
|
|
204
|
+
if (larguraTextoFisco > larguraFisco) {
|
|
205
|
+
const linhasFisco = quebrarTextoPorLargura(doc, textoFisco, larguraFisco, 6);
|
|
206
|
+
linhasFisco.forEach((linha, index) => {
|
|
207
|
+
(0, normal_1.normal)({
|
|
208
|
+
doc,
|
|
209
|
+
value: linha,
|
|
210
|
+
x: 369,
|
|
211
|
+
y: finalEspacoDet + 17.5 + index * 8,
|
|
212
|
+
largura: 213,
|
|
213
|
+
alinhamento: 'left',
|
|
214
|
+
tamanho: 6,
|
|
215
|
+
ajusteX,
|
|
216
|
+
ajusteY,
|
|
217
|
+
margemEsquerda,
|
|
218
|
+
margemTopo
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
(0, normal_1.normal)({
|
|
224
|
+
doc,
|
|
225
|
+
value: textoFisco,
|
|
226
|
+
x: 369,
|
|
227
|
+
y: finalEspacoDet + 17.5,
|
|
228
|
+
largura: 213,
|
|
229
|
+
alinhamento: 'justify',
|
|
230
|
+
tamanho: 6,
|
|
231
|
+
ajusteX,
|
|
232
|
+
ajusteY,
|
|
233
|
+
margemEsquerda,
|
|
234
|
+
margemTopo
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const alturaRodape = 8;
|
|
239
|
+
const yRodape = finalEspacoDet + 61.5 + alturaRodape;
|
|
240
|
+
const dataHoraAtual = (0, date_fns_1.format)(new Date(), "dd/MM/yyyy 'às' HH:mm:ss", { locale: pt_BR_1.ptBR });
|
|
241
|
+
(0, italico_1.italico)({
|
|
242
|
+
doc,
|
|
243
|
+
value: `Impresso em ${dataHoraAtual}`,
|
|
244
|
+
x: 1.5,
|
|
245
|
+
y: yRodape,
|
|
246
|
+
largura: 280,
|
|
247
|
+
alinhamento: 'left',
|
|
248
|
+
tamanho: 6,
|
|
249
|
+
ajusteX,
|
|
250
|
+
ajusteY,
|
|
251
|
+
margemEsquerda,
|
|
252
|
+
margemTopo
|
|
253
|
+
});
|
|
254
|
+
if (textoRodape) {
|
|
255
|
+
(0, italico_1.italico)({
|
|
256
|
+
doc,
|
|
257
|
+
value: textoRodape,
|
|
258
|
+
x: 285,
|
|
259
|
+
y: yRodape,
|
|
260
|
+
largura: 295,
|
|
261
|
+
alinhamento: 'right',
|
|
262
|
+
tamanho: 6,
|
|
263
|
+
ajusteX,
|
|
264
|
+
ajusteY,
|
|
265
|
+
margemEsquerda,
|
|
266
|
+
margemTopo
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getDadosEmitente = getDadosEmitente;
|
|
7
|
+
const bwip_js_1 = __importDefault(require("bwip-js"));
|
|
8
|
+
const utils_1 = require("../../../../domain/use-cases/utils");
|
|
9
|
+
const campo_1 = require("./campo");
|
|
10
|
+
const default_1 = require("./default");
|
|
11
|
+
const italico_1 = require("./italico");
|
|
12
|
+
const linha_horizontal_1 = require("./linha-horizontal");
|
|
13
|
+
const linha_vertical_1 = require("./linha-vertical");
|
|
14
|
+
const negrito_1 = require("./negrito");
|
|
15
|
+
const normal_1 = require("./normal");
|
|
16
|
+
const titulo_1 = require("./titulo");
|
|
17
|
+
async function getDadosEmitente({ y, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo, larguraDoFormulario, emit, protNFe, pathLogo, ide, folha }) {
|
|
18
|
+
doc
|
|
19
|
+
.lineWidth(0.5)
|
|
20
|
+
.roundedRect(margemEsquerda + ajusteX, margemTopo + ajusteY + y + 15.25, larguraDoFormulario, 130.45, 3)
|
|
21
|
+
.stroke()
|
|
22
|
+
.lineWidth(1);
|
|
23
|
+
(0, linha_horizontal_1.linhaHorizontal)({ x1: 317, x2: -254.7, y: y + 53.1, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
24
|
+
(0, linha_horizontal_1.linhaHorizontal)({ x1: 317, x2: -254.7, y: y + 72.9, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
25
|
+
(0, linha_vertical_1.linhaVertical)({ y1: y + 53.1, y2: y + 72.9, x: 317.4, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
26
|
+
(0, linha_vertical_1.linhaVertical)({ y1: y + 53.1, y2: y + 72.9, x: 331.55, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
27
|
+
(0, linha_horizontal_1.linhaHorizontal)({ x1: 340.05, x2: 0, y: y + 60.5, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
28
|
+
(0, linha_horizontal_1.linhaHorizontal)({ x1: 340.05, x2: 0, y: y + 83.1, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
29
|
+
(0, linha_horizontal_1.linhaHorizontal)({ x1: 0, x2: 0, y: y + 105.9, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
30
|
+
(0, linha_horizontal_1.linhaHorizontal)({ x1: 0, x2: 0, y: y + 125.7, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
31
|
+
(0, linha_vertical_1.linhaVertical)({ y1: y + 15.25, y2: y + 105.7, x: 240.75, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
32
|
+
(0, linha_vertical_1.linhaVertical)({ y1: y + 15.25, y2: y + 125.7, x: 340.05, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
33
|
+
(0, linha_vertical_1.linhaVertical)({ y1: y + 125.7, y2: y + 145.7, x: 195.55, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
34
|
+
(0, linha_vertical_1.linhaVertical)({ y1: y + 125.7, y2: y + 145.7, x: 391, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
35
|
+
(0, titulo_1.titulo)({
|
|
36
|
+
value: 'DANFE',
|
|
37
|
+
x: 266.5,
|
|
38
|
+
y: y + 19.2,
|
|
39
|
+
largura: 197,
|
|
40
|
+
alinhamento: 'left',
|
|
41
|
+
tamanho: 14,
|
|
42
|
+
ajusteX,
|
|
43
|
+
ajusteY,
|
|
44
|
+
doc,
|
|
45
|
+
margemEsquerda,
|
|
46
|
+
margemTopo
|
|
47
|
+
});
|
|
48
|
+
(0, italico_1.italico)({
|
|
49
|
+
doc,
|
|
50
|
+
value: 'IDENTIFICAÇÃO DO EMITENTE',
|
|
51
|
+
x: 1,
|
|
52
|
+
y: y + 15.7,
|
|
53
|
+
largura: 238,
|
|
54
|
+
alinhamento: 'center',
|
|
55
|
+
tamanho: 10,
|
|
56
|
+
ajusteX,
|
|
57
|
+
ajusteY,
|
|
58
|
+
margemEsquerda,
|
|
59
|
+
margemTopo
|
|
60
|
+
});
|
|
61
|
+
const identificacaoDoEmitenteY = pathLogo !== undefined ? y + 33.7 : y + 39.7;
|
|
62
|
+
const identificacaoDoEmitenteX = pathLogo !== undefined ? 67 : 1.5;
|
|
63
|
+
const identificacaoDoEmitenteLargura = pathLogo !== undefined ? 172 : 237;
|
|
64
|
+
const identificacaoDoEmitenteFonte = pathLogo !== undefined ? 0 : 1.5;
|
|
65
|
+
if (pathLogo !== undefined) {
|
|
66
|
+
if (folha === 0) {
|
|
67
|
+
doc.image(pathLogo, margemEsquerda + ajusteX + 4.5, margemTopo + ajusteY + default_1.DEFAULT_NFE.ajusteYDoLogotipo + 78, {
|
|
68
|
+
fit: [60, 60]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
doc.image(pathLogo, margemEsquerda + ajusteX + 4.5, margemTopo + ajusteY + default_1.DEFAULT_NFE.ajusteYDoLogotipo + 33, {
|
|
73
|
+
fit: [60, 60]
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
(0, negrito_1.negrito)({
|
|
78
|
+
doc,
|
|
79
|
+
value: emit.xNome,
|
|
80
|
+
x: identificacaoDoEmitenteX,
|
|
81
|
+
y: identificacaoDoEmitenteY + default_1.DEFAULT_NFE.ajusteYDaIdentificacaoDoEmitente,
|
|
82
|
+
largura: identificacaoDoEmitenteLargura,
|
|
83
|
+
alinhamento: 'center',
|
|
84
|
+
tamanho: 8 + identificacaoDoEmitenteFonte,
|
|
85
|
+
ajusteX,
|
|
86
|
+
ajusteY,
|
|
87
|
+
margemEsquerda,
|
|
88
|
+
margemTopo
|
|
89
|
+
});
|
|
90
|
+
(0, normal_1.normal)({
|
|
91
|
+
doc,
|
|
92
|
+
value: `${emit.enderEmit.xLgr}, ${emit.enderEmit.nro} ${emit.enderEmit.xCpl ?? ''}`,
|
|
93
|
+
x: identificacaoDoEmitenteX,
|
|
94
|
+
y: doc.y - margemTopo + 2,
|
|
95
|
+
largura: identificacaoDoEmitenteLargura,
|
|
96
|
+
alinhamento: 'center',
|
|
97
|
+
tamanho: 6 + identificacaoDoEmitenteFonte,
|
|
98
|
+
ajusteX,
|
|
99
|
+
ajusteY,
|
|
100
|
+
margemEsquerda,
|
|
101
|
+
margemTopo
|
|
102
|
+
});
|
|
103
|
+
(0, normal_1.normal)({
|
|
104
|
+
doc,
|
|
105
|
+
value: `${emit.enderEmit.xBairro}. ${emit.enderEmit.xMun}-${emit.enderEmit.UF}`,
|
|
106
|
+
x: identificacaoDoEmitenteX,
|
|
107
|
+
y: doc.y - margemTopo,
|
|
108
|
+
largura: identificacaoDoEmitenteLargura,
|
|
109
|
+
alinhamento: 'center',
|
|
110
|
+
tamanho: 6 + identificacaoDoEmitenteFonte,
|
|
111
|
+
ajusteX,
|
|
112
|
+
ajusteY,
|
|
113
|
+
margemEsquerda,
|
|
114
|
+
margemTopo
|
|
115
|
+
});
|
|
116
|
+
if (emit.enderEmit && emit.enderEmit.fone !== undefined) {
|
|
117
|
+
(0, normal_1.normal)({
|
|
118
|
+
doc,
|
|
119
|
+
value: 'Telefone: ' + (0, utils_1.formatPhone)(emit.enderEmit.fone),
|
|
120
|
+
x: identificacaoDoEmitenteX,
|
|
121
|
+
y: doc.y - margemTopo + 2,
|
|
122
|
+
largura: identificacaoDoEmitenteLargura,
|
|
123
|
+
alinhamento: 'center',
|
|
124
|
+
tamanho: 6 + identificacaoDoEmitenteFonte,
|
|
125
|
+
ajusteX,
|
|
126
|
+
ajusteY,
|
|
127
|
+
margemEsquerda,
|
|
128
|
+
margemTopo
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
(0, normal_1.normal)({
|
|
132
|
+
doc,
|
|
133
|
+
value: 'Documento Auxiliar da Nota Fiscal Eletrônica',
|
|
134
|
+
x: 241.5,
|
|
135
|
+
y: y + 32.7,
|
|
136
|
+
largura: 99.5,
|
|
137
|
+
alinhamento: 'center',
|
|
138
|
+
tamanho: 10,
|
|
139
|
+
ajusteX,
|
|
140
|
+
ajusteY,
|
|
141
|
+
margemEsquerda,
|
|
142
|
+
margemTopo
|
|
143
|
+
});
|
|
144
|
+
(0, normal_1.normal)({
|
|
145
|
+
doc,
|
|
146
|
+
value: '0 - ENTRADA',
|
|
147
|
+
x: 248,
|
|
148
|
+
y: y + 55.7,
|
|
149
|
+
largura: 99.5,
|
|
150
|
+
alinhamento: 'left',
|
|
151
|
+
ajusteX,
|
|
152
|
+
ajusteY,
|
|
153
|
+
margemEsquerda,
|
|
154
|
+
margemTopo
|
|
155
|
+
});
|
|
156
|
+
(0, normal_1.normal)({
|
|
157
|
+
doc,
|
|
158
|
+
value: '1 - SAÍDA',
|
|
159
|
+
x: 248,
|
|
160
|
+
y: y + 64.2,
|
|
161
|
+
largura: 99.5,
|
|
162
|
+
alinhamento: 'left',
|
|
163
|
+
ajusteX,
|
|
164
|
+
ajusteY,
|
|
165
|
+
margemEsquerda,
|
|
166
|
+
margemTopo
|
|
167
|
+
});
|
|
168
|
+
(0, normal_1.normal)({
|
|
169
|
+
doc,
|
|
170
|
+
value: ide.tpNF,
|
|
171
|
+
x: 317.5,
|
|
172
|
+
y: y + 52.5,
|
|
173
|
+
largura: 14.5,
|
|
174
|
+
alinhamento: 'center',
|
|
175
|
+
tamanho: 18,
|
|
176
|
+
ajusteX,
|
|
177
|
+
ajusteY,
|
|
178
|
+
margemEsquerda,
|
|
179
|
+
margemTopo
|
|
180
|
+
});
|
|
181
|
+
(0, normal_1.normal)({
|
|
182
|
+
doc,
|
|
183
|
+
value: 'Consulta de autenticidade no portal nacional da NF-e',
|
|
184
|
+
x: 340.5,
|
|
185
|
+
y: y + 85.7,
|
|
186
|
+
largura: 244,
|
|
187
|
+
ajusteX,
|
|
188
|
+
ajusteY,
|
|
189
|
+
margemEsquerda,
|
|
190
|
+
margemTopo
|
|
191
|
+
});
|
|
192
|
+
(0, normal_1.normal)({
|
|
193
|
+
doc,
|
|
194
|
+
value: 'www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora',
|
|
195
|
+
x: 340.5,
|
|
196
|
+
y: y + 93.7,
|
|
197
|
+
largura: 244,
|
|
198
|
+
ajusteX,
|
|
199
|
+
ajusteY,
|
|
200
|
+
margemEsquerda,
|
|
201
|
+
margemTopo
|
|
202
|
+
});
|
|
203
|
+
(0, normal_1.normal)({
|
|
204
|
+
doc,
|
|
205
|
+
value: 'Nº. ' + ide.nNF.padStart(9, '0').replace(/(\d{3})(\d{3})(\d{3})/, '$1.$2.$3'),
|
|
206
|
+
x: 241.2,
|
|
207
|
+
y: y + 75.2,
|
|
208
|
+
largura: 98.5,
|
|
209
|
+
alinhamento: 'center',
|
|
210
|
+
tamanho: 10,
|
|
211
|
+
ajusteX,
|
|
212
|
+
ajusteY,
|
|
213
|
+
margemEsquerda,
|
|
214
|
+
margemTopo
|
|
215
|
+
});
|
|
216
|
+
(0, normal_1.normal)({
|
|
217
|
+
doc,
|
|
218
|
+
value: 'Série ' + ide.serie,
|
|
219
|
+
x: 241.2,
|
|
220
|
+
y: y + 85.2,
|
|
221
|
+
largura: 98.5,
|
|
222
|
+
alinhamento: 'center',
|
|
223
|
+
tamanho: 10,
|
|
224
|
+
ajusteX,
|
|
225
|
+
ajusteY,
|
|
226
|
+
margemEsquerda,
|
|
227
|
+
margemTopo
|
|
228
|
+
});
|
|
229
|
+
const options = {
|
|
230
|
+
bcid: 'code128',
|
|
231
|
+
text: protNFe.infProt.chNFe,
|
|
232
|
+
height: 15,
|
|
233
|
+
width: 130
|
|
234
|
+
};
|
|
235
|
+
const barcodeCep = await bwip_js_1.default.toBuffer(options);
|
|
236
|
+
doc.image(barcodeCep, 350, y + 22.7, { fit: [230, 50] });
|
|
237
|
+
(0, titulo_1.titulo)({ value: 'CHAVE DE ACESSO', x: 341.5, y: y + 61.2, largura: 244, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
238
|
+
(0, campo_1.campo)({
|
|
239
|
+
value: (0, utils_1.formatKey)(protNFe.infProt.chNFe),
|
|
240
|
+
x: 341.5,
|
|
241
|
+
y: y + 67.7,
|
|
242
|
+
largura: 244,
|
|
243
|
+
ajusteX,
|
|
244
|
+
ajusteY,
|
|
245
|
+
doc,
|
|
246
|
+
margemEsquerda,
|
|
247
|
+
margemTopo
|
|
248
|
+
});
|
|
249
|
+
(0, titulo_1.titulo)({
|
|
250
|
+
value: 'PROTOCOLO DE AUTORIZAÇÃO DE USO',
|
|
251
|
+
x: 341.5,
|
|
252
|
+
y: y + 106.7,
|
|
253
|
+
largura: 244,
|
|
254
|
+
ajusteX,
|
|
255
|
+
ajusteY,
|
|
256
|
+
doc,
|
|
257
|
+
margemEsquerda,
|
|
258
|
+
margemTopo
|
|
259
|
+
});
|
|
260
|
+
(0, campo_1.campo)({
|
|
261
|
+
value: `${(0, utils_1.formatProtocol)(protNFe.infProt.nProt)} - ${(0, utils_1.formatDateTime)(protNFe.infProt.dhRecbto)}`,
|
|
262
|
+
x: 341.5,
|
|
263
|
+
y: y + 114.1,
|
|
264
|
+
largura: 244,
|
|
265
|
+
ajusteX,
|
|
266
|
+
ajusteY,
|
|
267
|
+
doc,
|
|
268
|
+
margemEsquerda,
|
|
269
|
+
margemTopo
|
|
270
|
+
});
|
|
271
|
+
(0, titulo_1.titulo)({ value: 'NATUREZA DA OPERAÇÃO', x: 1.5, y: y + 106.7, largura: 338, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
272
|
+
(0, campo_1.campo)({ value: ide.natOp, x: 1.5, y: y + 114.1, largura: 338, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
273
|
+
(0, titulo_1.titulo)({ value: 'INSCRIÇÃO ESTADUAL', x: 1.5, y: y + 126.7, largura: 192.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
274
|
+
(0, campo_1.campo)({
|
|
275
|
+
value: (0, utils_1.formatStateRegistration)(emit.IE, emit.enderEmit.UF),
|
|
276
|
+
x: 1.5,
|
|
277
|
+
y: y + 134.1,
|
|
278
|
+
largura: 192.5,
|
|
279
|
+
ajusteX,
|
|
280
|
+
ajusteY,
|
|
281
|
+
doc,
|
|
282
|
+
margemEsquerda,
|
|
283
|
+
margemTopo
|
|
284
|
+
});
|
|
285
|
+
(0, titulo_1.titulo)({
|
|
286
|
+
value: 'INSCRIÇÃO ESTADUAL DO SUBST. TRIBUT.',
|
|
287
|
+
x: 197,
|
|
288
|
+
y: y + 126.7,
|
|
289
|
+
largura: 192.5,
|
|
290
|
+
ajusteX,
|
|
291
|
+
ajusteY,
|
|
292
|
+
doc,
|
|
293
|
+
margemEsquerda,
|
|
294
|
+
margemTopo
|
|
295
|
+
});
|
|
296
|
+
(0, campo_1.campo)({
|
|
297
|
+
value: (0, utils_1.formatStateRegistration)(emit.IEST ?? '', emit.enderEmit.UF) ?? '',
|
|
298
|
+
x: 197,
|
|
299
|
+
y: y + 134.1,
|
|
300
|
+
largura: 192.5,
|
|
301
|
+
ajusteX,
|
|
302
|
+
ajusteY,
|
|
303
|
+
doc,
|
|
304
|
+
margemEsquerda,
|
|
305
|
+
margemTopo
|
|
306
|
+
});
|
|
307
|
+
(0, titulo_1.titulo)({ value: 'CNPJ', x: 392.5, y: y + 126.7, largura: 192.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
308
|
+
(0, campo_1.campo)({
|
|
309
|
+
value: (0, utils_1.formatCnpj)(emit.CNPJ ?? ''),
|
|
310
|
+
x: 392.5,
|
|
311
|
+
y: y + 134.1,
|
|
312
|
+
largura: 192.5,
|
|
313
|
+
ajusteX,
|
|
314
|
+
ajusteY,
|
|
315
|
+
doc,
|
|
316
|
+
margemEsquerda,
|
|
317
|
+
margemTopo
|
|
318
|
+
});
|
|
319
|
+
}
|