@alexssmusica/node-pdf-nfe 1.2.3 → 1.2.5

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.
Files changed (102) hide show
  1. package/lib/application/helpers/generate-pdf/nfe/campo.js +14 -15
  2. package/lib/application/helpers/generate-pdf/nfe/cria-layout.js +147 -148
  3. package/lib/application/helpers/generate-pdf/nfe/default.js +26 -26
  4. package/lib/application/helpers/generate-pdf/nfe/gerar-itens.js +276 -277
  5. package/lib/application/helpers/generate-pdf/nfe/get-dados-adicionais.js +52 -53
  6. package/lib/application/helpers/generate-pdf/nfe/get-dados-emitente.js +333 -319
  7. package/lib/application/helpers/generate-pdf/nfe/get-destinatario-remetente.js +153 -154
  8. package/lib/application/helpers/generate-pdf/nfe/get-fatura-duplicata.js +63 -64
  9. package/lib/application/helpers/generate-pdf/nfe/get-homologacao.js +36 -37
  10. package/lib/application/helpers/generate-pdf/nfe/get-imposto.js +218 -219
  11. package/lib/application/helpers/generate-pdf/nfe/get-iss.js +73 -74
  12. package/lib/application/helpers/generate-pdf/nfe/get-menu-itens.js +198 -199
  13. package/lib/application/helpers/generate-pdf/nfe/get-nota-cancelada.js +16 -17
  14. package/lib/application/helpers/generate-pdf/nfe/get-recibo.js +100 -102
  15. package/lib/application/helpers/generate-pdf/nfe/get-transporte.js +178 -179
  16. package/lib/application/helpers/generate-pdf/nfe/italico.js +15 -16
  17. package/lib/application/helpers/generate-pdf/nfe/linha-horizontal-tracejada.js +7 -8
  18. package/lib/application/helpers/generate-pdf/nfe/linha-horizontal.js +15 -16
  19. package/lib/application/helpers/generate-pdf/nfe/linha-vertical.js +9 -10
  20. package/lib/application/helpers/generate-pdf/nfe/load-fontes.js +30 -31
  21. package/lib/application/helpers/generate-pdf/nfe/negrito.js +15 -16
  22. package/lib/application/helpers/generate-pdf/nfe/normal.js +15 -16
  23. package/lib/application/helpers/generate-pdf/nfe/options-doc.js +14 -14
  24. package/lib/application/helpers/generate-pdf/nfe/secao.js +16 -17
  25. package/lib/application/helpers/generate-pdf/nfe/titulo.js +16 -17
  26. package/lib/application/helpers/xml/deserialize.js +24 -25
  27. package/lib/application/helpers/xml/index.js +17 -17
  28. package/lib/domain/use-cases/pdf/index.js +25 -26
  29. package/lib/domain/use-cases/pdf/pdf-NFCe.js +688 -688
  30. package/lib/domain/use-cases/pdf/pdf-NFe.js +54 -54
  31. package/lib/domain/use-cases/utils/current-date.js +8 -12
  32. package/lib/domain/use-cases/utils/format-cnpj.js +8 -9
  33. package/lib/domain/use-cases/utils/format-cpf.js +8 -9
  34. package/lib/domain/use-cases/utils/format-date-time.js +10 -11
  35. package/lib/domain/use-cases/utils/format-date.js +9 -10
  36. package/lib/domain/use-cases/utils/format-key.js +6 -7
  37. package/lib/domain/use-cases/utils/format-number.js +6 -7
  38. package/lib/domain/use-cases/utils/format-phone.js +20 -21
  39. package/lib/domain/use-cases/utils/format-plate.js +16 -17
  40. package/lib/domain/use-cases/utils/format-postal-code.js +12 -9
  41. package/lib/domain/use-cases/utils/format-protocol.js +8 -9
  42. package/lib/domain/use-cases/utils/format-state-registration.js +49 -50
  43. package/lib/domain/use-cases/utils/format-time.js +8 -9
  44. package/lib/domain/use-cases/utils/index.js +30 -30
  45. package/lib/domain/use-cases/utils/return-font-size-carrier.js +23 -24
  46. package/lib/index.js +5 -5
  47. package/lib/tsconfig.tsbuildinfo +1 -1
  48. package/lib/types/generate-pdf.js +2 -2
  49. package/lib/types/index.js +19 -19
  50. package/lib/types/nfe-proc.js +2 -2
  51. package/lib/types/schema.js +2 -2
  52. package/package.json +32 -28
  53. package/lib/application/helpers/generate-pdf/nfe/campo.d.ts +0 -2
  54. package/lib/application/helpers/generate-pdf/nfe/cria-layout.d.ts +0 -2
  55. package/lib/application/helpers/generate-pdf/nfe/default.d.ts +0 -23
  56. package/lib/application/helpers/generate-pdf/nfe/gerar-itens.d.ts +0 -2
  57. package/lib/application/helpers/generate-pdf/nfe/get-dados-adicionais.d.ts +0 -2
  58. package/lib/application/helpers/generate-pdf/nfe/get-dados-emitente.d.ts +0 -2
  59. package/lib/application/helpers/generate-pdf/nfe/get-destinatario-remetente.d.ts +0 -2
  60. package/lib/application/helpers/generate-pdf/nfe/get-fatura-duplicata.d.ts +0 -2
  61. package/lib/application/helpers/generate-pdf/nfe/get-homologacao.d.ts +0 -2
  62. package/lib/application/helpers/generate-pdf/nfe/get-imposto.d.ts +0 -2
  63. package/lib/application/helpers/generate-pdf/nfe/get-iss.d.ts +0 -2
  64. package/lib/application/helpers/generate-pdf/nfe/get-menu-itens.d.ts +0 -2
  65. package/lib/application/helpers/generate-pdf/nfe/get-nota-cancelada.d.ts +0 -2
  66. package/lib/application/helpers/generate-pdf/nfe/get-recibo.d.ts +0 -2
  67. package/lib/application/helpers/generate-pdf/nfe/get-transporte.d.ts +0 -2
  68. package/lib/application/helpers/generate-pdf/nfe/italico.d.ts +0 -2
  69. package/lib/application/helpers/generate-pdf/nfe/linha-horizontal-tracejada.d.ts +0 -2
  70. package/lib/application/helpers/generate-pdf/nfe/linha-horizontal.d.ts +0 -2
  71. package/lib/application/helpers/generate-pdf/nfe/linha-vertical.d.ts +0 -2
  72. package/lib/application/helpers/generate-pdf/nfe/load-fontes.d.ts +0 -3
  73. package/lib/application/helpers/generate-pdf/nfe/negrito.d.ts +0 -2
  74. package/lib/application/helpers/generate-pdf/nfe/normal.d.ts +0 -2
  75. package/lib/application/helpers/generate-pdf/nfe/options-doc.d.ts +0 -10
  76. package/lib/application/helpers/generate-pdf/nfe/secao.d.ts +0 -2
  77. package/lib/application/helpers/generate-pdf/nfe/titulo.d.ts +0 -2
  78. package/lib/application/helpers/xml/deserialize.d.ts +0 -2
  79. package/lib/application/helpers/xml/index.d.ts +0 -1
  80. package/lib/domain/use-cases/pdf/index.d.ts +0 -3
  81. package/lib/domain/use-cases/pdf/pdf-NFCe.d.ts +0 -3
  82. package/lib/domain/use-cases/pdf/pdf-NFe.d.ts +0 -3
  83. package/lib/domain/use-cases/utils/current-date.d.ts +0 -1
  84. package/lib/domain/use-cases/utils/format-cnpj.d.ts +0 -1
  85. package/lib/domain/use-cases/utils/format-cpf.d.ts +0 -1
  86. package/lib/domain/use-cases/utils/format-date-time.d.ts +0 -1
  87. package/lib/domain/use-cases/utils/format-date.d.ts +0 -1
  88. package/lib/domain/use-cases/utils/format-key.d.ts +0 -1
  89. package/lib/domain/use-cases/utils/format-number.d.ts +0 -1
  90. package/lib/domain/use-cases/utils/format-phone.d.ts +0 -1
  91. package/lib/domain/use-cases/utils/format-plate.d.ts +0 -1
  92. package/lib/domain/use-cases/utils/format-postal-code.d.ts +0 -1
  93. package/lib/domain/use-cases/utils/format-protocol.d.ts +0 -1
  94. package/lib/domain/use-cases/utils/format-state-registration.d.ts +0 -1
  95. package/lib/domain/use-cases/utils/format-time.d.ts +0 -1
  96. package/lib/domain/use-cases/utils/index.d.ts +0 -14
  97. package/lib/domain/use-cases/utils/return-font-size-carrier.d.ts +0 -1
  98. package/lib/index.d.ts +0 -1
  99. package/lib/types/generate-pdf.d.ts +0 -259
  100. package/lib/types/index.d.ts +0 -3
  101. package/lib/types/nfe-proc.d.ts +0 -42
  102. package/lib/types/schema.d.ts +0 -875
@@ -1,688 +1,688 @@
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.pdfNFCe = void 0;
7
- const date_fns_1 = require("date-fns");
8
- const pdfkit_1 = __importDefault(require("pdfkit"));
9
- const qrcode_1 = __importDefault(require("qrcode"));
10
- const load_fontes_1 = require("../../../application/helpers/generate-pdf/nfe/load-fontes");
11
- const negrito_1 = require("../../../application/helpers/generate-pdf/nfe/negrito");
12
- const normal_1 = require("../../../application/helpers/generate-pdf/nfe/normal");
13
- const utils_1 = require("../utils");
14
- async function pdfNFCe(nf, pathLogo) {
15
- const { NFe, protNFe } = nf;
16
- const { infProt } = protNFe;
17
- const { ide, emit, det, total, pag, dest, infAdic } = NFe.infNFe;
18
- const larguraPagina = 201;
19
- const margemPadrao = 2.5;
20
- const doc = new pdfkit_1.default({
21
- size: [larguraPagina, 1000],
22
- margins: {
23
- top: margemPadrao,
24
- bottom: 0,
25
- left: margemPadrao,
26
- right: margemPadrao
27
- }
28
- });
29
- (0, load_fontes_1.loadFontsNFCe)(doc);
30
- (0, negrito_1.negrito)({
31
- doc,
32
- value: emit.xNome,
33
- x: 0,
34
- y: doc.y,
35
- largura: larguraPagina,
36
- tamanho: 10,
37
- ajusteX: 0,
38
- ajusteY: 0,
39
- margemEsquerda: 0,
40
- margemTopo: 0
41
- });
42
- (0, negrito_1.negrito)({
43
- doc,
44
- value: (0, utils_1.formatCnpj)(emit.CNPJ),
45
- x: 0,
46
- y: doc.y,
47
- largura: larguraPagina,
48
- tamanho: 10,
49
- ajusteX: 0,
50
- ajusteY: 0,
51
- margemEsquerda: 0,
52
- margemTopo: 0
53
- });
54
- (0, normal_1.normal)({
55
- doc,
56
- value: `${emit.enderEmit.xLgr}, ${emit.enderEmit.nro}${emit.enderEmit.xCpl !== undefined ? ' ' + emit.enderEmit.xCpl : ''}. ${emit.enderEmit.xBairro}, ${emit.enderEmit.xMun}-${emit.enderEmit.UF}. ${(0, utils_1.formatPostalCode)(emit.enderEmit.CEP ?? '')}`,
57
- x: 0,
58
- y: doc.y,
59
- largura: larguraPagina,
60
- tamanho: 8,
61
- ajusteX: 0,
62
- ajusteY: 0,
63
- margemEsquerda: 0,
64
- margemTopo: 0
65
- });
66
- doc.y += 5;
67
- (0, negrito_1.negrito)({
68
- doc,
69
- value: 'Documento Auxiliar da Nota Fiscal de Consumidor Eletronica',
70
- x: 0,
71
- y: doc.y,
72
- largura: larguraPagina,
73
- tamanho: 8,
74
- ajusteX: 0,
75
- ajusteY: 0,
76
- margemEsquerda: 0,
77
- margemTopo: 0
78
- });
79
- doc.y += 5;
80
- let posicao = doc.y;
81
- (0, negrito_1.negrito)({
82
- doc,
83
- value: 'CODIGO',
84
- x: 0,
85
- y: posicao,
86
- largura: 26.5,
87
- tamanho: 8,
88
- ajusteX: 0,
89
- ajusteY: 0,
90
- margemEsquerda: margemPadrao,
91
- margemTopo: 0,
92
- alinhamento: 'left'
93
- });
94
- (0, negrito_1.negrito)({
95
- doc,
96
- value: 'DESCRICAO',
97
- x: 31,
98
- y: posicao,
99
- largura: 74.5,
100
- tamanho: 8,
101
- ajusteX: 0,
102
- ajusteY: 0,
103
- margemEsquerda: 0,
104
- margemTopo: 0,
105
- alinhamento: 'left'
106
- });
107
- (0, negrito_1.negrito)({
108
- doc,
109
- value: 'UN',
110
- x: 105,
111
- y: posicao,
112
- largura: 15,
113
- tamanho: 8,
114
- ajusteX: 0,
115
- ajusteY: 0,
116
- margemEsquerda: 0,
117
- margemTopo: 0,
118
- alinhamento: 'center'
119
- });
120
- (0, negrito_1.negrito)({
121
- doc,
122
- value: 'QTD',
123
- x: 120,
124
- y: posicao,
125
- largura: 20,
126
- tamanho: 8,
127
- ajusteX: 0,
128
- ajusteY: 0,
129
- margemEsquerda: 0,
130
- margemTopo: 0,
131
- alinhamento: 'center'
132
- });
133
- (0, negrito_1.negrito)({
134
- doc,
135
- value: 'VL UN',
136
- x: 140,
137
- y: posicao,
138
- largura: 27,
139
- tamanho: 8,
140
- ajusteX: 0,
141
- ajusteY: 0,
142
- margemEsquerda: 0,
143
- margemTopo: 0,
144
- alinhamento: 'center'
145
- });
146
- (0, negrito_1.negrito)({
147
- doc,
148
- value: 'VL TOTAL',
149
- x: 167,
150
- y: posicao,
151
- largura: larguraPagina - 167,
152
- tamanho: 8,
153
- ajusteX: 0,
154
- ajusteY: 0,
155
- margemEsquerda: 0,
156
- margemTopo: 0,
157
- alinhamento: 'center'
158
- });
159
- det.forEach((element) => {
160
- posicao = doc.y;
161
- (0, normal_1.normal)({
162
- doc,
163
- value: element.prod.cProd.padStart(9, '0').substring(0, 9),
164
- x: 0 + margemPadrao,
165
- y: posicao,
166
- largura: 28,
167
- tamanho: 6,
168
- ajusteX: 0,
169
- ajusteY: 0,
170
- margemEsquerda: 0,
171
- margemTopo: 0,
172
- alinhamento: 'left'
173
- });
174
- (0, normal_1.normal)({
175
- doc,
176
- value: ajusteTamanhoTexto(doc, ide.tpAmb === '1' ? element.prod.xProd.substring(0, 26) : 'NOTA FISCAL EMITIDA EM AMB', 73.5),
177
- x: 31,
178
- y: posicao,
179
- largura: 73.5,
180
- tamanho: 6,
181
- ajusteX: 0,
182
- ajusteY: 0,
183
- margemEsquerda: 0,
184
- margemTopo: 0,
185
- alinhamento: 'left'
186
- });
187
- (0, normal_1.normal)({
188
- doc,
189
- value: element.prod.uCom,
190
- x: 105,
191
- y: posicao,
192
- largura: 15,
193
- tamanho: 6,
194
- ajusteX: 0,
195
- ajusteY: 0,
196
- margemEsquerda: 0,
197
- margemTopo: 0,
198
- alinhamento: 'center'
199
- });
200
- (0, normal_1.normal)({
201
- doc,
202
- value: (0, utils_1.formatNumber)(element.prod.qCom, 3),
203
- x: 120,
204
- y: posicao,
205
- largura: 20,
206
- tamanho: 6,
207
- ajusteX: 0,
208
- ajusteY: 0,
209
- margemEsquerda: 0,
210
- margemTopo: 0,
211
- alinhamento: 'center'
212
- });
213
- (0, normal_1.normal)({
214
- doc,
215
- value: (0, utils_1.formatNumber)(element.prod.vUnCom, 2),
216
- x: 140,
217
- y: posicao,
218
- largura: 27,
219
- tamanho: 6,
220
- ajusteX: 0,
221
- ajusteY: 0,
222
- margemEsquerda: 0,
223
- margemTopo: 0,
224
- alinhamento: 'center'
225
- });
226
- (0, normal_1.normal)({
227
- doc,
228
- value: (0, utils_1.formatNumber)(element.prod.vProd, 2),
229
- x: 167,
230
- y: posicao,
231
- largura: larguraPagina - 167,
232
- tamanho: 6,
233
- ajusteX: 0,
234
- ajusteY: 0,
235
- margemEsquerda: 0,
236
- margemTopo: 0,
237
- alinhamento: 'center'
238
- });
239
- posicao += 7;
240
- });
241
- doc.y += 2;
242
- (0, normal_1.normal)({
243
- doc,
244
- value: 'Quantidade Total de Itens',
245
- x: margemPadrao,
246
- y: doc.y,
247
- largura: larguraPagina,
248
- tamanho: 7,
249
- ajusteX: 0,
250
- ajusteY: 0,
251
- margemEsquerda: 0,
252
- margemTopo: 0,
253
- alinhamento: 'left'
254
- });
255
- doc.y -= 7;
256
- (0, normal_1.normal)({
257
- doc,
258
- value: String(det.length),
259
- x: 0,
260
- y: doc.y,
261
- largura: larguraPagina - margemPadrao,
262
- tamanho: 7,
263
- ajusteX: 0,
264
- ajusteY: 0,
265
- margemEsquerda: 0,
266
- margemTopo: 0,
267
- alinhamento: 'right'
268
- });
269
- (0, normal_1.normal)({
270
- doc,
271
- value: 'Valor Total',
272
- x: margemPadrao,
273
- y: doc.y,
274
- largura: larguraPagina,
275
- tamanho: 7,
276
- ajusteX: 0,
277
- ajusteY: 0,
278
- margemEsquerda: 0,
279
- margemTopo: 0,
280
- alinhamento: 'left'
281
- });
282
- doc.y -= 7;
283
- (0, normal_1.normal)({
284
- doc,
285
- value: (0, utils_1.formatNumber)(total.ICMSTot.vProd, 2),
286
- x: 0,
287
- y: doc.y,
288
- largura: larguraPagina - margemPadrao,
289
- tamanho: 7,
290
- ajusteX: 0,
291
- ajusteY: 0,
292
- margemEsquerda: 0,
293
- margemTopo: 0,
294
- alinhamento: 'right'
295
- });
296
- (0, normal_1.normal)({
297
- doc,
298
- value: 'Desconto',
299
- x: margemPadrao,
300
- y: doc.y,
301
- largura: larguraPagina,
302
- tamanho: 7,
303
- ajusteX: 0,
304
- ajusteY: 0,
305
- margemEsquerda: 0,
306
- margemTopo: 0,
307
- alinhamento: 'left'
308
- });
309
- doc.y -= 7;
310
- (0, normal_1.normal)({
311
- doc,
312
- value: (0, utils_1.formatNumber)(total.ICMSTot.vDesc, 2),
313
- x: 0,
314
- y: doc.y,
315
- largura: larguraPagina - margemPadrao,
316
- tamanho: 7,
317
- ajusteX: 0,
318
- ajusteY: 0,
319
- margemEsquerda: 0,
320
- margemTopo: 0,
321
- alinhamento: 'right'
322
- });
323
- (0, normal_1.normal)({
324
- doc,
325
- value: 'Adicional/Frete/Seguro',
326
- x: margemPadrao,
327
- y: doc.y,
328
- largura: larguraPagina,
329
- tamanho: 7,
330
- ajusteX: 0,
331
- ajusteY: 0,
332
- margemEsquerda: 0,
333
- margemTopo: 0,
334
- alinhamento: 'left'
335
- });
336
- doc.y -= 7;
337
- (0, normal_1.normal)({
338
- doc,
339
- value: (0, utils_1.formatNumber)(total.ICMSTot.vFrete, 2),
340
- x: 0,
341
- y: doc.y,
342
- largura: larguraPagina - margemPadrao,
343
- tamanho: 7,
344
- ajusteX: 0,
345
- ajusteY: 0,
346
- margemEsquerda: 0,
347
- margemTopo: 0,
348
- alinhamento: 'right'
349
- });
350
- (0, normal_1.normal)({
351
- doc,
352
- value: 'Valor a Pagar',
353
- x: margemPadrao,
354
- y: doc.y,
355
- largura: larguraPagina,
356
- tamanho: 7,
357
- ajusteX: 0,
358
- ajusteY: 0,
359
- margemEsquerda: 0,
360
- margemTopo: 0,
361
- alinhamento: 'left'
362
- });
363
- doc.y -= 7;
364
- (0, normal_1.normal)({
365
- doc,
366
- value: (0, utils_1.formatNumber)(total.ICMSTot.vNF, 2),
367
- x: 0,
368
- y: doc.y,
369
- largura: larguraPagina - margemPadrao,
370
- tamanho: 7,
371
- ajusteX: 0,
372
- ajusteY: 0,
373
- margemEsquerda: 0,
374
- margemTopo: 0,
375
- alinhamento: 'right'
376
- });
377
- doc.y += 5;
378
- (0, normal_1.normal)({
379
- doc,
380
- value: 'FORMA DE PAGAMENTO',
381
- x: margemPadrao,
382
- y: doc.y,
383
- largura: larguraPagina,
384
- tamanho: 7,
385
- ajusteX: 0,
386
- ajusteY: 0,
387
- margemEsquerda: 0,
388
- margemTopo: 0,
389
- alinhamento: 'left'
390
- });
391
- doc.y -= 7;
392
- (0, normal_1.normal)({
393
- doc,
394
- value: 'VALOR PAGO',
395
- x: 0,
396
- y: doc.y,
397
- largura: larguraPagina - margemPadrao,
398
- tamanho: 7,
399
- ajusteX: 0,
400
- ajusteY: 0,
401
- margemEsquerda: 0,
402
- margemTopo: 0,
403
- alinhamento: 'right'
404
- });
405
- pag.detPag.forEach((element) => {
406
- (0, normal_1.normal)({
407
- doc,
408
- value: getPagName(element.tPag),
409
- x: margemPadrao,
410
- y: doc.y,
411
- largura: larguraPagina,
412
- tamanho: 7,
413
- ajusteX: 0,
414
- ajusteY: 0,
415
- margemEsquerda: 0,
416
- margemTopo: 0,
417
- alinhamento: 'left'
418
- });
419
- doc.y -= 7;
420
- (0, normal_1.normal)({
421
- doc,
422
- value: (0, utils_1.formatNumber)(element.vPag, 2),
423
- x: 0,
424
- y: doc.y,
425
- largura: larguraPagina - margemPadrao,
426
- tamanho: 7,
427
- ajusteX: 0,
428
- ajusteY: 0,
429
- margemEsquerda: 0,
430
- margemTopo: 0,
431
- alinhamento: 'right'
432
- });
433
- });
434
- (0, normal_1.normal)({
435
- doc,
436
- value: 'TROCO',
437
- x: margemPadrao,
438
- y: doc.y,
439
- largura: larguraPagina,
440
- tamanho: 7,
441
- ajusteX: 0,
442
- ajusteY: 0,
443
- margemEsquerda: 0,
444
- margemTopo: 0,
445
- alinhamento: 'left'
446
- });
447
- doc.y -= 7;
448
- (0, normal_1.normal)({
449
- doc,
450
- value: (0, utils_1.formatNumber)(pag.vTroco ?? 0, 2),
451
- x: 0,
452
- y: doc.y,
453
- largura: larguraPagina - margemPadrao,
454
- tamanho: 7,
455
- ajusteX: 0,
456
- ajusteY: 0,
457
- margemEsquerda: 0,
458
- margemTopo: 0,
459
- alinhamento: 'right'
460
- });
461
- doc.y += 7;
462
- (0, negrito_1.negrito)({
463
- doc,
464
- value: 'Consulte pela chave de acesso em',
465
- x: 0,
466
- y: doc.y,
467
- largura: larguraPagina - margemPadrao * 2,
468
- tamanho: 8,
469
- ajusteX: 0,
470
- ajusteY: 0,
471
- margemEsquerda: 0,
472
- margemTopo: 0,
473
- alinhamento: 'center'
474
- });
475
- (0, normal_1.normal)({
476
- doc,
477
- value: NFe.infNFeSupl?.urlChave ?? '',
478
- x: 0,
479
- y: doc.y,
480
- largura: larguraPagina - margemPadrao,
481
- tamanho: 7,
482
- ajusteX: 0,
483
- ajusteY: 0,
484
- margemEsquerda: 0,
485
- margemTopo: 0,
486
- alinhamento: 'center'
487
- });
488
- doc.y += 7;
489
- (0, normal_1.normal)({
490
- doc,
491
- value: nf.protNFe.infProt.chNFe.replace(/(.{4})(?=.)/g, '$1 '),
492
- x: 0,
493
- y: doc.y,
494
- largura: larguraPagina - margemPadrao,
495
- tamanho: 7,
496
- ajusteX: 0,
497
- ajusteY: 0,
498
- margemEsquerda: 0,
499
- margemTopo: 0,
500
- alinhamento: 'center'
501
- });
502
- doc.y += 7;
503
- (0, normal_1.normal)({
504
- doc,
505
- value: dest?.xNome !== undefined ? dest.xNome : 'CONSUMIDOR NAO IDENTIFICADO',
506
- x: margemPadrao,
507
- y: doc.y,
508
- largura: larguraPagina - margemPadrao,
509
- tamanho: 7,
510
- ajusteX: 0,
511
- ajusteY: 0,
512
- margemEsquerda: 0,
513
- margemTopo: 0,
514
- alinhamento: 'justify'
515
- });
516
- if (dest?.CNPJ !== undefined) {
517
- (0, normal_1.normal)({
518
- doc,
519
- value: 'CNPJ: ' + (0, utils_1.formatCnpj)(dest.CNPJ),
520
- x: doc.x,
521
- y: doc.y,
522
- largura: 112,
523
- tamanho: 7,
524
- ajusteX: 0,
525
- ajusteY: 0,
526
- margemEsquerda: 0,
527
- margemTopo: 0,
528
- alinhamento: 'left'
529
- });
530
- }
531
- else if (dest?.CPF !== undefined) {
532
- (0, normal_1.normal)({
533
- doc,
534
- value: 'CPF: ' + (0, utils_1.formatCpf)(dest.CPF),
535
- x: doc.x,
536
- y: doc.y,
537
- largura: 112,
538
- tamanho: 7,
539
- ajusteX: 0,
540
- ajusteY: 0,
541
- margemEsquerda: 0,
542
- margemTopo: 0,
543
- alinhamento: 'left'
544
- });
545
- }
546
- doc.y += 7;
547
- (0, normal_1.normal)({
548
- doc,
549
- value: `NFC-e Série ${ide.serie} Nº ${ide.nNF} Data Emissão: ${(0, date_fns_1.format)((0, date_fns_1.parseISO)(ide.dhEmi), 'dd/MM/yyyy HH:mm:ss')}`,
550
- x: doc.x,
551
- y: doc.y,
552
- largura: larguraPagina - margemPadrao,
553
- tamanho: 7,
554
- ajusteX: 0,
555
- ajusteY: 0,
556
- margemEsquerda: 0,
557
- margemTopo: 0,
558
- alinhamento: 'center'
559
- });
560
- (0, normal_1.normal)({
561
- doc,
562
- value: 'Consulta via Leitor QR Code',
563
- x: margemPadrao,
564
- y: doc.y,
565
- largura: larguraPagina - margemPadrao,
566
- tamanho: 7,
567
- ajusteX: 0,
568
- ajusteY: 0,
569
- margemEsquerda: 0,
570
- margemTopo: 0,
571
- alinhamento: 'center'
572
- });
573
- (0, normal_1.normal)({
574
- doc,
575
- value: `Protocolo de Autorização: ${infProt.nProt}`,
576
- x: doc.x,
577
- y: doc.y,
578
- largura: larguraPagina - margemPadrao,
579
- tamanho: 7,
580
- ajusteX: 0,
581
- ajusteY: 0,
582
- margemEsquerda: 0,
583
- margemTopo: 0,
584
- alinhamento: 'left'
585
- });
586
- (0, normal_1.normal)({
587
- doc,
588
- value: infProt.dhRecbto ? `Data Autorização: ${(0, date_fns_1.format)((0, date_fns_1.parseISO)(infProt.dhRecbto), 'dd/MM/yyyy HH:mm:ss')}` : '',
589
- x: doc.x,
590
- y: doc.y,
591
- largura: 112,
592
- tamanho: 7,
593
- ajusteX: 0,
594
- ajusteY: 0,
595
- margemEsquerda: 0,
596
- margemTopo: 0,
597
- alinhamento: 'left'
598
- });
599
- doc.y += 7;
600
- (0, normal_1.normal)({
601
- doc,
602
- value: 'Informacoes de interesse do contribuinte:',
603
- x: 0,
604
- y: doc.y,
605
- largura: larguraPagina - margemPadrao,
606
- tamanho: 7,
607
- ajusteX: 0,
608
- ajusteY: 0,
609
- margemEsquerda: 0,
610
- margemTopo: 0,
611
- alinhamento: 'center'
612
- });
613
- (0, normal_1.normal)({
614
- doc,
615
- value: infAdic?.infCpl ?? '',
616
- x: 0,
617
- y: doc.y,
618
- largura: larguraPagina - margemPadrao,
619
- tamanho: 7,
620
- ajusteX: 0,
621
- ajusteY: 0,
622
- margemEsquerda: 0,
623
- margemTopo: 0,
624
- alinhamento: 'center'
625
- });
626
- const qrImage = await qrcode_1.default.toDataURL(NFe.infNFeSupl?.qrCode ?? '');
627
- doc.image(qrImage, larguraPagina / 2 - 45, doc.y, { fit: [90, 90], align: 'center' });
628
- doc.end();
629
- return doc;
630
- }
631
- exports.pdfNFCe = pdfNFCe;
632
- function ajusteTamanhoTexto(doc, value, tamanho) {
633
- while (doc.widthOfString(value) > tamanho) {
634
- value = value.substring(0, value.length - 1);
635
- }
636
- return value;
637
- }
638
- function getPagName(value) {
639
- if (value === '01') {
640
- return 'Dinheiro';
641
- }
642
- if (value === '02') {
643
- return 'Cheque';
644
- }
645
- if (value === '03') {
646
- return 'Cartão de Crédito';
647
- }
648
- if (value === '04') {
649
- return 'Cartão de Débito';
650
- }
651
- if (value === '05') {
652
- return 'Crédito Loja';
653
- }
654
- if (value === '10') {
655
- return 'Vale Alimentação';
656
- }
657
- if (value === '11') {
658
- return 'Vale Refeição';
659
- }
660
- if (value === '12') {
661
- return 'Vale Presente';
662
- }
663
- if (value === '13') {
664
- return 'Vale Combustível';
665
- }
666
- if (value === '14') {
667
- return 'Duplicata Mercantil';
668
- }
669
- if (value === '15') {
670
- return 'Boleto Bancário';
671
- }
672
- if (value === '16') {
673
- return 'Depósito Bancário';
674
- }
675
- if (value === '17') {
676
- return 'Pagamento Instantâneo (PIX)';
677
- }
678
- if (value === '18') {
679
- return 'Transferência bancária, Carteira Digital';
680
- }
681
- if (value === '19') {
682
- return 'Programa de fidelidade, CashBack, Crédito Virtual';
683
- }
684
- if (value === '90') {
685
- return 'Sem pagamento';
686
- }
687
- return 'Outros';
688
- }
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.pdfNFCe = pdfNFCe;
7
+ const date_fns_1 = require("date-fns");
8
+ const pdfkit_1 = __importDefault(require("pdfkit"));
9
+ const qrcode_1 = __importDefault(require("qrcode"));
10
+ const load_fontes_1 = require("../../../application/helpers/generate-pdf/nfe/load-fontes");
11
+ const negrito_1 = require("../../../application/helpers/generate-pdf/nfe/negrito");
12
+ const normal_1 = require("../../../application/helpers/generate-pdf/nfe/normal");
13
+ const utils_1 = require("../utils");
14
+ async function pdfNFCe(nf, opcoes) {
15
+ const { NFe, protNFe } = nf;
16
+ const { infProt } = protNFe;
17
+ const { ide, emit, det, total, pag, dest, infAdic } = NFe.infNFe;
18
+ const larguraPagina = 207.5;
19
+ const margemPadrao = 2.5;
20
+ const doc = new pdfkit_1.default({
21
+ size: [larguraPagina, 1000],
22
+ margins: {
23
+ top: margemPadrao,
24
+ bottom: 0,
25
+ left: margemPadrao,
26
+ right: margemPadrao
27
+ }
28
+ });
29
+ (0, load_fontes_1.loadFontsNFCe)(doc);
30
+ (0, negrito_1.negrito)({
31
+ doc,
32
+ value: emit.xNome,
33
+ x: 0,
34
+ y: doc.y,
35
+ largura: larguraPagina,
36
+ tamanho: 10,
37
+ ajusteX: 0,
38
+ ajusteY: 0,
39
+ margemEsquerda: 0,
40
+ margemTopo: 0
41
+ });
42
+ (0, negrito_1.negrito)({
43
+ doc,
44
+ value: (0, utils_1.formatCnpj)(emit.CNPJ),
45
+ x: 0,
46
+ y: doc.y,
47
+ largura: larguraPagina,
48
+ tamanho: 10,
49
+ ajusteX: 0,
50
+ ajusteY: 0,
51
+ margemEsquerda: 0,
52
+ margemTopo: 0
53
+ });
54
+ (0, normal_1.normal)({
55
+ doc,
56
+ value: `${emit.enderEmit.xLgr}, ${emit.enderEmit.nro}${emit.enderEmit.xCpl !== undefined ? ' ' + emit.enderEmit.xCpl : ''}. ${emit.enderEmit.xBairro}, ${emit.enderEmit.xMun}-${emit.enderEmit.UF}. ${(0, utils_1.formatPostalCode)(emit.enderEmit.CEP ?? '')}`,
57
+ x: 0,
58
+ y: doc.y,
59
+ largura: larguraPagina,
60
+ tamanho: 8,
61
+ ajusteX: 0,
62
+ ajusteY: 0,
63
+ margemEsquerda: 0,
64
+ margemTopo: 0
65
+ });
66
+ doc.y += 5;
67
+ (0, negrito_1.negrito)({
68
+ doc,
69
+ value: 'Documento Auxiliar da Nota Fiscal de Consumidor Eletronica',
70
+ x: 0,
71
+ y: doc.y,
72
+ largura: larguraPagina,
73
+ tamanho: 8,
74
+ ajusteX: 0,
75
+ ajusteY: 0,
76
+ margemEsquerda: 0,
77
+ margemTopo: 0
78
+ });
79
+ doc.y += 5;
80
+ let posicao = doc.y;
81
+ (0, negrito_1.negrito)({
82
+ doc,
83
+ value: 'CODIGO',
84
+ x: 0,
85
+ y: posicao,
86
+ largura: 26.5,
87
+ tamanho: 8,
88
+ ajusteX: 0,
89
+ ajusteY: 0,
90
+ margemEsquerda: margemPadrao,
91
+ margemTopo: 0,
92
+ alinhamento: 'left'
93
+ });
94
+ (0, negrito_1.negrito)({
95
+ doc,
96
+ value: 'DESCRICAO',
97
+ x: 31,
98
+ y: posicao,
99
+ largura: 74.5,
100
+ tamanho: 8,
101
+ ajusteX: 0,
102
+ ajusteY: 0,
103
+ margemEsquerda: 0,
104
+ margemTopo: 0,
105
+ alinhamento: 'left'
106
+ });
107
+ (0, negrito_1.negrito)({
108
+ doc,
109
+ value: 'UN',
110
+ x: 105,
111
+ y: posicao,
112
+ largura: 15,
113
+ tamanho: 8,
114
+ ajusteX: 0,
115
+ ajusteY: 0,
116
+ margemEsquerda: 0,
117
+ margemTopo: 0,
118
+ alinhamento: 'center'
119
+ });
120
+ (0, negrito_1.negrito)({
121
+ doc,
122
+ value: 'QTD',
123
+ x: 120,
124
+ y: posicao,
125
+ largura: 20,
126
+ tamanho: 8,
127
+ ajusteX: 0,
128
+ ajusteY: 0,
129
+ margemEsquerda: 0,
130
+ margemTopo: 0,
131
+ alinhamento: 'center'
132
+ });
133
+ (0, negrito_1.negrito)({
134
+ doc,
135
+ value: 'VL UN',
136
+ x: 140,
137
+ y: posicao,
138
+ largura: 27,
139
+ tamanho: 8,
140
+ ajusteX: 0,
141
+ ajusteY: 0,
142
+ margemEsquerda: 0,
143
+ margemTopo: 0,
144
+ alinhamento: 'center'
145
+ });
146
+ (0, negrito_1.negrito)({
147
+ doc,
148
+ value: 'VL TOTAL',
149
+ x: 167,
150
+ y: posicao,
151
+ largura: larguraPagina - 167,
152
+ tamanho: 8,
153
+ ajusteX: 0,
154
+ ajusteY: 0,
155
+ margemEsquerda: 0,
156
+ margemTopo: 0,
157
+ alinhamento: 'center'
158
+ });
159
+ det.forEach((element) => {
160
+ posicao = doc.y;
161
+ (0, normal_1.normal)({
162
+ doc,
163
+ value: element.prod.cProd.padStart(9, '0').substring(0, 9),
164
+ x: 0 + margemPadrao,
165
+ y: posicao,
166
+ largura: 28,
167
+ tamanho: 6,
168
+ ajusteX: 0,
169
+ ajusteY: 0,
170
+ margemEsquerda: 0,
171
+ margemTopo: 0,
172
+ alinhamento: 'left'
173
+ });
174
+ (0, normal_1.normal)({
175
+ doc,
176
+ value: ajusteTamanhoTexto(doc, ide.tpAmb === '1' ? element.prod.xProd.substring(0, 26) : 'NOTA FISCAL EMITIDA EM AMB', 73.5),
177
+ x: 31,
178
+ y: posicao,
179
+ largura: 73.5,
180
+ tamanho: 6,
181
+ ajusteX: 0,
182
+ ajusteY: 0,
183
+ margemEsquerda: 0,
184
+ margemTopo: 0,
185
+ alinhamento: 'left'
186
+ });
187
+ (0, normal_1.normal)({
188
+ doc,
189
+ value: element.prod.uCom,
190
+ x: 105,
191
+ y: posicao,
192
+ largura: 15,
193
+ tamanho: 6,
194
+ ajusteX: 0,
195
+ ajusteY: 0,
196
+ margemEsquerda: 0,
197
+ margemTopo: 0,
198
+ alinhamento: 'center'
199
+ });
200
+ (0, normal_1.normal)({
201
+ doc,
202
+ value: (0, utils_1.formatNumber)(element.prod.qCom, 3),
203
+ x: 120,
204
+ y: posicao,
205
+ largura: 20,
206
+ tamanho: 6,
207
+ ajusteX: 0,
208
+ ajusteY: 0,
209
+ margemEsquerda: 0,
210
+ margemTopo: 0,
211
+ alinhamento: 'center'
212
+ });
213
+ (0, normal_1.normal)({
214
+ doc,
215
+ value: (0, utils_1.formatNumber)(element.prod.vUnCom, 2),
216
+ x: 140,
217
+ y: posicao,
218
+ largura: 27,
219
+ tamanho: 6,
220
+ ajusteX: 0,
221
+ ajusteY: 0,
222
+ margemEsquerda: 0,
223
+ margemTopo: 0,
224
+ alinhamento: 'center'
225
+ });
226
+ (0, normal_1.normal)({
227
+ doc,
228
+ value: (0, utils_1.formatNumber)(element.prod.vProd, 2),
229
+ x: 167,
230
+ y: posicao,
231
+ largura: larguraPagina - 167,
232
+ tamanho: 6,
233
+ ajusteX: 0,
234
+ ajusteY: 0,
235
+ margemEsquerda: 0,
236
+ margemTopo: 0,
237
+ alinhamento: 'center'
238
+ });
239
+ posicao += 7;
240
+ });
241
+ doc.y += 2;
242
+ (0, normal_1.normal)({
243
+ doc,
244
+ value: 'Quantidade Total de Itens',
245
+ x: margemPadrao,
246
+ y: doc.y,
247
+ largura: larguraPagina,
248
+ tamanho: 7,
249
+ ajusteX: 0,
250
+ ajusteY: 0,
251
+ margemEsquerda: 0,
252
+ margemTopo: 0,
253
+ alinhamento: 'left'
254
+ });
255
+ doc.y -= 7;
256
+ (0, normal_1.normal)({
257
+ doc,
258
+ value: String(det.length),
259
+ x: 0,
260
+ y: doc.y,
261
+ largura: larguraPagina - margemPadrao,
262
+ tamanho: 7,
263
+ ajusteX: 0,
264
+ ajusteY: 0,
265
+ margemEsquerda: 0,
266
+ margemTopo: 0,
267
+ alinhamento: 'right'
268
+ });
269
+ (0, normal_1.normal)({
270
+ doc,
271
+ value: 'Valor Total',
272
+ x: margemPadrao,
273
+ y: doc.y,
274
+ largura: larguraPagina,
275
+ tamanho: 7,
276
+ ajusteX: 0,
277
+ ajusteY: 0,
278
+ margemEsquerda: 0,
279
+ margemTopo: 0,
280
+ alinhamento: 'left'
281
+ });
282
+ doc.y -= 7;
283
+ (0, normal_1.normal)({
284
+ doc,
285
+ value: (0, utils_1.formatNumber)(total.ICMSTot.vProd, 2),
286
+ x: 0,
287
+ y: doc.y,
288
+ largura: larguraPagina - margemPadrao,
289
+ tamanho: 7,
290
+ ajusteX: 0,
291
+ ajusteY: 0,
292
+ margemEsquerda: 0,
293
+ margemTopo: 0,
294
+ alinhamento: 'right'
295
+ });
296
+ (0, normal_1.normal)({
297
+ doc,
298
+ value: 'Desconto',
299
+ x: margemPadrao,
300
+ y: doc.y,
301
+ largura: larguraPagina,
302
+ tamanho: 7,
303
+ ajusteX: 0,
304
+ ajusteY: 0,
305
+ margemEsquerda: 0,
306
+ margemTopo: 0,
307
+ alinhamento: 'left'
308
+ });
309
+ doc.y -= 7;
310
+ (0, normal_1.normal)({
311
+ doc,
312
+ value: (0, utils_1.formatNumber)(total.ICMSTot.vDesc, 2),
313
+ x: 0,
314
+ y: doc.y,
315
+ largura: larguraPagina - margemPadrao,
316
+ tamanho: 7,
317
+ ajusteX: 0,
318
+ ajusteY: 0,
319
+ margemEsquerda: 0,
320
+ margemTopo: 0,
321
+ alinhamento: 'right'
322
+ });
323
+ (0, normal_1.normal)({
324
+ doc,
325
+ value: 'Adicional/Frete/Seguro',
326
+ x: margemPadrao,
327
+ y: doc.y,
328
+ largura: larguraPagina,
329
+ tamanho: 7,
330
+ ajusteX: 0,
331
+ ajusteY: 0,
332
+ margemEsquerda: 0,
333
+ margemTopo: 0,
334
+ alinhamento: 'left'
335
+ });
336
+ doc.y -= 7;
337
+ (0, normal_1.normal)({
338
+ doc,
339
+ value: (0, utils_1.formatNumber)(total.ICMSTot.vFrete, 2),
340
+ x: 0,
341
+ y: doc.y,
342
+ largura: larguraPagina - margemPadrao,
343
+ tamanho: 7,
344
+ ajusteX: 0,
345
+ ajusteY: 0,
346
+ margemEsquerda: 0,
347
+ margemTopo: 0,
348
+ alinhamento: 'right'
349
+ });
350
+ (0, normal_1.normal)({
351
+ doc,
352
+ value: 'Valor a Pagar',
353
+ x: margemPadrao,
354
+ y: doc.y,
355
+ largura: larguraPagina,
356
+ tamanho: 7,
357
+ ajusteX: 0,
358
+ ajusteY: 0,
359
+ margemEsquerda: 0,
360
+ margemTopo: 0,
361
+ alinhamento: 'left'
362
+ });
363
+ doc.y -= 7;
364
+ (0, normal_1.normal)({
365
+ doc,
366
+ value: (0, utils_1.formatNumber)(total.ICMSTot.vNF, 2),
367
+ x: 0,
368
+ y: doc.y,
369
+ largura: larguraPagina - margemPadrao,
370
+ tamanho: 7,
371
+ ajusteX: 0,
372
+ ajusteY: 0,
373
+ margemEsquerda: 0,
374
+ margemTopo: 0,
375
+ alinhamento: 'right'
376
+ });
377
+ doc.y += 5;
378
+ (0, normal_1.normal)({
379
+ doc,
380
+ value: 'FORMA DE PAGAMENTO',
381
+ x: margemPadrao,
382
+ y: doc.y,
383
+ largura: larguraPagina,
384
+ tamanho: 7,
385
+ ajusteX: 0,
386
+ ajusteY: 0,
387
+ margemEsquerda: 0,
388
+ margemTopo: 0,
389
+ alinhamento: 'left'
390
+ });
391
+ doc.y -= 7;
392
+ (0, normal_1.normal)({
393
+ doc,
394
+ value: 'VALOR PAGO',
395
+ x: 0,
396
+ y: doc.y,
397
+ largura: larguraPagina - margemPadrao,
398
+ tamanho: 7,
399
+ ajusteX: 0,
400
+ ajusteY: 0,
401
+ margemEsquerda: 0,
402
+ margemTopo: 0,
403
+ alinhamento: 'right'
404
+ });
405
+ pag.detPag.forEach((element) => {
406
+ (0, normal_1.normal)({
407
+ doc,
408
+ value: getPagName(element.tPag),
409
+ x: margemPadrao,
410
+ y: doc.y,
411
+ largura: larguraPagina,
412
+ tamanho: 7,
413
+ ajusteX: 0,
414
+ ajusteY: 0,
415
+ margemEsquerda: 0,
416
+ margemTopo: 0,
417
+ alinhamento: 'left'
418
+ });
419
+ doc.y -= 7;
420
+ (0, normal_1.normal)({
421
+ doc,
422
+ value: (0, utils_1.formatNumber)(element.vPag, 2),
423
+ x: 0,
424
+ y: doc.y,
425
+ largura: larguraPagina - margemPadrao,
426
+ tamanho: 7,
427
+ ajusteX: 0,
428
+ ajusteY: 0,
429
+ margemEsquerda: 0,
430
+ margemTopo: 0,
431
+ alinhamento: 'right'
432
+ });
433
+ });
434
+ (0, normal_1.normal)({
435
+ doc,
436
+ value: 'TROCO',
437
+ x: margemPadrao,
438
+ y: doc.y,
439
+ largura: larguraPagina,
440
+ tamanho: 7,
441
+ ajusteX: 0,
442
+ ajusteY: 0,
443
+ margemEsquerda: 0,
444
+ margemTopo: 0,
445
+ alinhamento: 'left'
446
+ });
447
+ doc.y -= 7;
448
+ (0, normal_1.normal)({
449
+ doc,
450
+ value: (0, utils_1.formatNumber)(pag.vTroco ?? 0, 2),
451
+ x: 0,
452
+ y: doc.y,
453
+ largura: larguraPagina - margemPadrao,
454
+ tamanho: 7,
455
+ ajusteX: 0,
456
+ ajusteY: 0,
457
+ margemEsquerda: 0,
458
+ margemTopo: 0,
459
+ alinhamento: 'right'
460
+ });
461
+ doc.y += 7;
462
+ (0, negrito_1.negrito)({
463
+ doc,
464
+ value: 'Consulte pela chave de acesso em',
465
+ x: 0,
466
+ y: doc.y,
467
+ largura: larguraPagina - margemPadrao * 2,
468
+ tamanho: 8,
469
+ ajusteX: 0,
470
+ ajusteY: 0,
471
+ margemEsquerda: 0,
472
+ margemTopo: 0,
473
+ alinhamento: 'center'
474
+ });
475
+ (0, normal_1.normal)({
476
+ doc,
477
+ value: NFe.infNFeSupl?.urlChave ?? '',
478
+ x: 0,
479
+ y: doc.y,
480
+ largura: larguraPagina - margemPadrao,
481
+ tamanho: 7,
482
+ ajusteX: 0,
483
+ ajusteY: 0,
484
+ margemEsquerda: 0,
485
+ margemTopo: 0,
486
+ alinhamento: 'center'
487
+ });
488
+ doc.y += 7;
489
+ (0, normal_1.normal)({
490
+ doc,
491
+ value: nf.protNFe.infProt.chNFe.replace(/(.{4})(?=.)/g, '$1 '),
492
+ x: 0,
493
+ y: doc.y,
494
+ largura: larguraPagina - margemPadrao,
495
+ tamanho: 7,
496
+ ajusteX: 0,
497
+ ajusteY: 0,
498
+ margemEsquerda: 0,
499
+ margemTopo: 0,
500
+ alinhamento: 'center'
501
+ });
502
+ doc.y += 7;
503
+ (0, normal_1.normal)({
504
+ doc,
505
+ value: dest?.xNome !== undefined ? dest.xNome : 'CONSUMIDOR NAO IDENTIFICADO',
506
+ x: margemPadrao,
507
+ y: doc.y,
508
+ largura: larguraPagina - margemPadrao,
509
+ tamanho: 7,
510
+ ajusteX: 0,
511
+ ajusteY: 0,
512
+ margemEsquerda: 0,
513
+ margemTopo: 0,
514
+ alinhamento: 'justify'
515
+ });
516
+ if (dest?.CNPJ !== undefined) {
517
+ (0, normal_1.normal)({
518
+ doc,
519
+ value: 'CNPJ: ' + (0, utils_1.formatCnpj)(dest.CNPJ),
520
+ x: doc.x,
521
+ y: doc.y,
522
+ largura: 112,
523
+ tamanho: 7,
524
+ ajusteX: 0,
525
+ ajusteY: 0,
526
+ margemEsquerda: 0,
527
+ margemTopo: 0,
528
+ alinhamento: 'left'
529
+ });
530
+ }
531
+ else if (dest?.CPF !== undefined) {
532
+ (0, normal_1.normal)({
533
+ doc,
534
+ value: 'CPF: ' + (0, utils_1.formatCpf)(dest.CPF),
535
+ x: doc.x,
536
+ y: doc.y,
537
+ largura: 112,
538
+ tamanho: 7,
539
+ ajusteX: 0,
540
+ ajusteY: 0,
541
+ margemEsquerda: 0,
542
+ margemTopo: 0,
543
+ alinhamento: 'left'
544
+ });
545
+ }
546
+ doc.y += 7;
547
+ (0, normal_1.normal)({
548
+ doc,
549
+ value: `NFC-e Série ${ide.serie} Nº ${ide.nNF} Data Emissão: ${(0, date_fns_1.format)((0, date_fns_1.parseISO)(ide.dhEmi), 'dd/MM/yyyy HH:mm:ss')}`,
550
+ x: doc.x,
551
+ y: doc.y,
552
+ largura: larguraPagina - margemPadrao,
553
+ tamanho: 7,
554
+ ajusteX: 0,
555
+ ajusteY: 0,
556
+ margemEsquerda: 0,
557
+ margemTopo: 0,
558
+ alinhamento: 'center'
559
+ });
560
+ (0, normal_1.normal)({
561
+ doc,
562
+ value: 'Consulta via Leitor QR Code',
563
+ x: margemPadrao,
564
+ y: doc.y,
565
+ largura: larguraPagina - margemPadrao,
566
+ tamanho: 7,
567
+ ajusteX: 0,
568
+ ajusteY: 0,
569
+ margemEsquerda: 0,
570
+ margemTopo: 0,
571
+ alinhamento: 'center'
572
+ });
573
+ (0, normal_1.normal)({
574
+ doc,
575
+ value: `Protocolo de Autorização: ${infProt.nProt}`,
576
+ x: doc.x,
577
+ y: doc.y,
578
+ largura: larguraPagina - margemPadrao,
579
+ tamanho: 7,
580
+ ajusteX: 0,
581
+ ajusteY: 0,
582
+ margemEsquerda: 0,
583
+ margemTopo: 0,
584
+ alinhamento: 'left'
585
+ });
586
+ (0, normal_1.normal)({
587
+ doc,
588
+ value: infProt.dhRecbto ? `Data Autorização: ${(0, date_fns_1.format)((0, date_fns_1.parseISO)(infProt.dhRecbto), 'dd/MM/yyyy HH:mm:ss')}` : '',
589
+ x: doc.x,
590
+ y: doc.y,
591
+ largura: 112,
592
+ tamanho: 7,
593
+ ajusteX: 0,
594
+ ajusteY: 0,
595
+ margemEsquerda: 0,
596
+ margemTopo: 0,
597
+ alinhamento: 'left'
598
+ });
599
+ doc.y += 7;
600
+ (0, normal_1.normal)({
601
+ doc,
602
+ value: 'Informacoes de interesse do contribuinte:',
603
+ x: 0,
604
+ y: doc.y,
605
+ largura: larguraPagina - margemPadrao,
606
+ tamanho: 7,
607
+ ajusteX: 0,
608
+ ajusteY: 0,
609
+ margemEsquerda: 0,
610
+ margemTopo: 0,
611
+ alinhamento: 'center'
612
+ });
613
+ (0, normal_1.normal)({
614
+ doc,
615
+ value: infAdic.infCpl ?? '',
616
+ x: 0,
617
+ y: doc.y,
618
+ largura: larguraPagina - margemPadrao,
619
+ tamanho: 7,
620
+ ajusteX: 0,
621
+ ajusteY: 0,
622
+ margemEsquerda: 0,
623
+ margemTopo: 0,
624
+ alinhamento: 'center'
625
+ });
626
+ const qrImage = await qrcode_1.default.toDataURL(NFe.infNFeSupl?.qrCode ?? '');
627
+ doc.image(qrImage, larguraPagina / 2 - 45, doc.y + 5, { fit: [90, 90], align: 'center' });
628
+ if (!opcoes || !opcoes.notEndDocument)
629
+ doc.end();
630
+ return doc;
631
+ }
632
+ function ajusteTamanhoTexto(doc, value, tamanho) {
633
+ while (doc.widthOfString(value) > tamanho) {
634
+ value = value.substring(0, value.length - 1);
635
+ }
636
+ return value;
637
+ }
638
+ function getPagName(value) {
639
+ if (value === '01') {
640
+ return 'Dinheiro';
641
+ }
642
+ if (value === '02') {
643
+ return 'Cheque';
644
+ }
645
+ if (value === '03') {
646
+ return 'Cartão de Crédito';
647
+ }
648
+ if (value === '04') {
649
+ return 'Cartão de Débito';
650
+ }
651
+ if (value === '05') {
652
+ return 'Crédito Loja';
653
+ }
654
+ if (value === '10') {
655
+ return 'Vale Alimentação';
656
+ }
657
+ if (value === '11') {
658
+ return 'Vale Refeição';
659
+ }
660
+ if (value === '12') {
661
+ return 'Vale Presente';
662
+ }
663
+ if (value === '13') {
664
+ return 'Vale Combustível';
665
+ }
666
+ if (value === '14') {
667
+ return 'Duplicata Mercantil';
668
+ }
669
+ if (value === '15') {
670
+ return 'Boleto Bancário';
671
+ }
672
+ if (value === '16') {
673
+ return 'Depósito Bancário';
674
+ }
675
+ if (value === '17') {
676
+ return 'Pagamento Instantâneo (PIX)';
677
+ }
678
+ if (value === '18') {
679
+ return 'Transferência bancária, Carteira Digital';
680
+ }
681
+ if (value === '19') {
682
+ return 'Programa de fidelidade, CashBack, Crédito Virtual';
683
+ }
684
+ if (value === '90') {
685
+ return 'Sem pagamento';
686
+ }
687
+ return 'Outros';
688
+ }