@alexssmusica/node-pdf-nfe 1.1.4 → 1.1.6
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/lib/application/helpers/generate-pdf/nfe/cria-layout.d.ts +1 -1
- package/lib/application/helpers/generate-pdf/nfe/cria-layout.js +7 -2
- package/lib/application/helpers/generate-pdf/nfe/gerar-itens.d.ts +1 -1
- package/lib/application/helpers/generate-pdf/nfe/gerar-itens.js +15 -13
- package/lib/application/helpers/generate-pdf/nfe/get-dados-emitente.js +20 -8
- package/lib/application/helpers/generate-pdf/nfe/get-destinatario-remetente.js +40 -8
- package/lib/application/helpers/generate-pdf/nfe/get-fatura-duplicata.js +4 -4
- package/lib/application/helpers/generate-pdf/nfe/get-homologacao.d.ts +1 -1
- package/lib/application/helpers/generate-pdf/nfe/get-homologacao.js +12 -1
- package/lib/application/helpers/generate-pdf/nfe/get-imposto.js +14 -14
- package/lib/application/helpers/generate-pdf/nfe/get-iss.js +12 -1
- 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 +17 -0
- package/lib/application/helpers/generate-pdf/nfe/get-recibo.js +1 -1
- package/lib/application/helpers/generate-pdf/nfe/get-transporte.js +58 -21
- package/lib/domain/use-cases/pdf/index.d.ts +2 -1
- package/lib/domain/use-cases/pdf/index.js +3 -3
- package/lib/domain/use-cases/pdf/pdf-NFCe.js +13 -13
- package/lib/domain/use-cases/pdf/pdf-NFe.d.ts +2 -2
- package/lib/domain/use-cases/pdf/pdf-NFe.js +13 -2
- package/lib/domain/use-cases/utils/current-date.d.ts +1 -0
- package/lib/domain/use-cases/utils/{data-atual.js → current-date.js} +3 -3
- package/lib/domain/use-cases/utils/format-cnpj.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-cnpj.js +9 -0
- package/lib/domain/use-cases/utils/format-cpf.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-cpf.js +9 -0
- package/lib/domain/use-cases/utils/format-date-time.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-date-time.js +11 -0
- package/lib/domain/use-cases/utils/format-date.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-date.js +10 -0
- package/lib/domain/use-cases/utils/format-key.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-key.js +7 -0
- package/lib/domain/use-cases/utils/format-number.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-number.js +7 -0
- package/lib/domain/use-cases/utils/format-phone.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-phone.js +21 -0
- package/lib/domain/use-cases/utils/format-plate.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-plate.js +17 -0
- package/lib/domain/use-cases/utils/format-postal-code.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-postal-code.js +9 -0
- package/lib/domain/use-cases/utils/format-protocol.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-protocol.js +9 -0
- package/lib/domain/use-cases/utils/format-state-registration.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-state-registration.js +50 -0
- package/lib/domain/use-cases/utils/format-time.d.ts +1 -0
- package/lib/domain/use-cases/utils/format-time.js +9 -0
- package/lib/domain/use-cases/utils/index.d.ts +10 -2
- package/lib/domain/use-cases/utils/index.js +10 -2
- 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 +24 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/generate-pdf.d.ts +15 -0
- package/package.json +3 -3
- package/lib/domain/use-cases/utils/data-atual.d.ts +0 -1
- package/lib/domain/use-cases/utils/intl-number-format.d.ts +0 -1
- package/lib/domain/use-cases/utils/intl-number-format.js +0 -7
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTransporte = void 0;
|
|
4
4
|
const utils_1 = require("../../../../domain/use-cases/utils");
|
|
5
|
+
const format_plate_1 = require("../../../../domain/use-cases/utils/format-plate");
|
|
5
6
|
const campo_1 = require("./campo");
|
|
6
7
|
const default_1 = require("./default");
|
|
7
8
|
const linha_horizontal_1 = require("./linha-horizontal");
|
|
@@ -26,17 +27,13 @@ function getTransporte({ y, doc, ajusteX, ajusteY, margemDireita, margemEsquerda
|
|
|
26
27
|
(0, linha_vertical_1.linhaVertical)({ y1: y + 8, y2: y + 68, x: larguraDoFormulario, doc, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
27
28
|
(0, secao_1.secao)({ doc, value: 'TRANSPORTADOR / VOLUMES TRANSPORTADOS', x: 1.5, y, largura: 0, ajusteX, ajusteY, margemEsquerda, margemTopo });
|
|
28
29
|
(0, titulo_1.titulo)({ value: 'NOME / RAZÃO SOCIAL', x: 1.5, y: y + 9.5, largura: 166.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
29
|
-
let tamanhoFonte = 6;
|
|
30
|
-
if (transp.transporta?.xNome && transp.transporta?.xNome.length > 40) {
|
|
31
|
-
tamanhoFonte = 5;
|
|
32
|
-
}
|
|
33
30
|
(0, campo_1.campo)({
|
|
34
31
|
value: transp.transporta?.xNome ?? '',
|
|
35
32
|
x: 1.5,
|
|
36
33
|
y: y + 17.5,
|
|
37
34
|
largura: 166.5,
|
|
38
35
|
alinhamento: 'left',
|
|
39
|
-
tamanho:
|
|
36
|
+
tamanho: (0, utils_1.returnFontSizeCarrier)(transp.transporta?.xNome ?? ''),
|
|
40
37
|
ajusteX,
|
|
41
38
|
ajusteY,
|
|
42
39
|
doc,
|
|
@@ -45,47 +42,77 @@ function getTransporte({ y, doc, ajusteX, ajusteY, margemDireita, margemEsquerda
|
|
|
45
42
|
});
|
|
46
43
|
function ModFrete(value) {
|
|
47
44
|
if (value === '0') {
|
|
48
|
-
return 'Por conta do
|
|
45
|
+
return '0 - Por conta do Remet';
|
|
49
46
|
}
|
|
50
47
|
else if (value === '1') {
|
|
51
|
-
return 'Por conta do
|
|
48
|
+
return '1 - Por conta do Dest';
|
|
52
49
|
}
|
|
53
50
|
else if (value === '2') {
|
|
54
|
-
return 'Por conta de
|
|
51
|
+
return '2 - Por conta de Terc';
|
|
55
52
|
}
|
|
56
53
|
else if (value === '3') {
|
|
57
|
-
return 'Por conta do
|
|
54
|
+
return '3 - Por conta do Remet';
|
|
58
55
|
}
|
|
59
56
|
else if (value === '4') {
|
|
60
|
-
return 'Por conta do
|
|
57
|
+
return '4 - Por conta do Dest';
|
|
61
58
|
}
|
|
62
59
|
else if (value === '9') {
|
|
63
|
-
return 'Sem
|
|
60
|
+
return '9 - Sem Ocorr de Transp';
|
|
64
61
|
}
|
|
65
|
-
return '
|
|
62
|
+
return '';
|
|
66
63
|
}
|
|
67
64
|
(0, titulo_1.titulo)({ value: 'FRETE POR CONTA', x: 171.5, y: y + 9.5, largura: 85, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
68
65
|
(0, campo_1.campo)({
|
|
69
66
|
value: ModFrete(transp.modFrete),
|
|
70
|
-
x:
|
|
67
|
+
x: 164,
|
|
71
68
|
y: y + 17.5,
|
|
72
|
-
largura:
|
|
69
|
+
largura: 100,
|
|
73
70
|
ajusteX,
|
|
74
71
|
ajusteY,
|
|
75
72
|
doc,
|
|
76
73
|
margemEsquerda,
|
|
77
74
|
margemTopo,
|
|
78
|
-
tamanho:
|
|
75
|
+
tamanho: 8.4
|
|
79
76
|
});
|
|
80
77
|
(0, titulo_1.titulo)({ value: 'CÓDIGO ANTT', x: 259.5, y: y + 9.5, largura: 84, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
81
78
|
(0, campo_1.campo)({ value: transp.veicTransp?.RNTC ?? '', x: 259.5, y: y + 17.5, largura: 84, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
82
79
|
(0, titulo_1.titulo)({ value: 'PLACA DO VEÍCULO', x: 347.5, y: y + 9.5, largura: 84, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
83
|
-
(0, campo_1.campo)({
|
|
80
|
+
(0, campo_1.campo)({
|
|
81
|
+
value: (0, format_plate_1.formatLicensePlate)(transp.veicTransp?.placa ?? ''),
|
|
82
|
+
x: 347.5,
|
|
83
|
+
y: y + 17.5,
|
|
84
|
+
largura: 84,
|
|
85
|
+
ajusteX,
|
|
86
|
+
ajusteY,
|
|
87
|
+
doc,
|
|
88
|
+
margemEsquerda,
|
|
89
|
+
margemTopo
|
|
90
|
+
});
|
|
84
91
|
(0, titulo_1.titulo)({ value: 'UF', x: 435.5, y: y + 9.5, largura: 19.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
85
92
|
(0, campo_1.campo)({ value: transp.veicTransp?.UF ?? '', x: 435.5, y: y + 17.5, largura: 19.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
86
93
|
(0, titulo_1.titulo)({ value: 'CNPJ / CPF', x: 458, y: y + 9.5, largura: 126.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
87
|
-
(0, campo_1.campo)({
|
|
88
|
-
|
|
94
|
+
(0, campo_1.campo)({
|
|
95
|
+
value: (0, utils_1.formatCnpj)(transp.transporta?.CNPJ ?? ''),
|
|
96
|
+
x: 458,
|
|
97
|
+
y: y + 17.5,
|
|
98
|
+
largura: 126.5,
|
|
99
|
+
ajusteX,
|
|
100
|
+
ajusteY,
|
|
101
|
+
doc,
|
|
102
|
+
margemEsquerda,
|
|
103
|
+
margemTopo
|
|
104
|
+
});
|
|
105
|
+
(0, campo_1.campo)({
|
|
106
|
+
value: (0, utils_1.formatCpf)(transp.transporta?.CPF ?? ''),
|
|
107
|
+
x: 458,
|
|
108
|
+
y: y + 17.5,
|
|
109
|
+
largura: 126.5,
|
|
110
|
+
ajusteX,
|
|
111
|
+
ajusteY,
|
|
112
|
+
doc,
|
|
113
|
+
margemEsquerda,
|
|
114
|
+
margemTopo
|
|
115
|
+
});
|
|
89
116
|
(0, titulo_1.titulo)({ value: 'ENDEREÇO', x: 1.5, y: y + 30, largura: 254, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
90
117
|
(0, campo_1.campo)({
|
|
91
118
|
value: transp.transporta?.xEnder ?? '',
|
|
@@ -105,7 +132,17 @@ function getTransporte({ y, doc, ajusteX, ajusteY, margemDireita, margemEsquerda
|
|
|
105
132
|
(0, titulo_1.titulo)({ value: 'UF', x: 435.5, y: y + 30, largura: 19.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
106
133
|
(0, campo_1.campo)({ value: transp.transporta?.uf ?? '', x: 435.5, y: y + 38.5, largura: 19.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
107
134
|
(0, titulo_1.titulo)({ value: 'INSCRIÇÃO ESTADUAL', x: 458, y: y + 30, largura: 126.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
108
|
-
(0, campo_1.campo)({
|
|
135
|
+
(0, campo_1.campo)({
|
|
136
|
+
value: (0, utils_1.formatStateRegistration)(transp.transporta?.ie ?? ''),
|
|
137
|
+
x: 458,
|
|
138
|
+
y: y + 38.5,
|
|
139
|
+
largura: 126.5,
|
|
140
|
+
ajusteX,
|
|
141
|
+
ajusteY,
|
|
142
|
+
doc,
|
|
143
|
+
margemEsquerda,
|
|
144
|
+
margemTopo
|
|
145
|
+
});
|
|
109
146
|
(0, titulo_1.titulo)({ value: 'QUANTIDADE', x: 1.5, y: y + 50, largura: 56.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
110
147
|
(0, campo_1.campo)({ value: transp.vol?.qVol ?? '', x: 1.5, y: y + 58, largura: 56.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
111
148
|
(0, titulo_1.titulo)({ value: 'ESPÉCIE', x: 60.8, y: y + 50, largura: 96, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
@@ -116,7 +153,7 @@ function getTransporte({ y, doc, ajusteX, ajusteY, margemDireita, margemEsquerda
|
|
|
116
153
|
(0, campo_1.campo)({ value: transp.vol?.nVol ?? '', x: 259.5, y: y + 58, largura: 96, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
117
154
|
(0, titulo_1.titulo)({ value: 'PESO BRUTO', x: 358.5, y: y + 50, largura: 112.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
118
155
|
(0, campo_1.campo)({
|
|
119
|
-
value: transp.vol?.pesoB ? (0, utils_1.
|
|
156
|
+
value: transp.vol?.pesoB ? (0, utils_1.formatNumber)(transp.vol?.pesoB, 3) : '',
|
|
120
157
|
x: 358.5,
|
|
121
158
|
y: y + 58,
|
|
122
159
|
largura: 112.5,
|
|
@@ -128,7 +165,7 @@ function getTransporte({ y, doc, ajusteX, ajusteY, margemDireita, margemEsquerda
|
|
|
128
165
|
});
|
|
129
166
|
(0, titulo_1.titulo)({ value: 'PESO LÍQUIDO', x: 474.5, y: y + 50, largura: 110.5, ajusteX, ajusteY, doc, margemEsquerda, margemTopo });
|
|
130
167
|
(0, campo_1.campo)({
|
|
131
|
-
value: transp.vol?.pesoL ? (0, utils_1.
|
|
168
|
+
value: transp.vol?.pesoL ? (0, utils_1.formatNumber)(transp.vol?.pesoL, 3) : '',
|
|
132
169
|
x: 474.5,
|
|
133
170
|
y: y + 58,
|
|
134
171
|
largura: 110.5,
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/// <reference types="pdfkit" />
|
|
2
|
-
|
|
2
|
+
import type { OpcoesPDF } from '../../../types';
|
|
3
|
+
export declare function gerarPDF(xmlNFe: string, opcoes?: OpcoesPDF): Promise<PDFKit.PDFDocument>;
|
|
@@ -4,7 +4,7 @@ exports.gerarPDF = void 0;
|
|
|
4
4
|
const xml_1 = require("../../../application/helpers/xml");
|
|
5
5
|
const pdf_NFCe_1 = require("./pdf-NFCe");
|
|
6
6
|
const pdf_NFe_1 = require("./pdf-NFe");
|
|
7
|
-
async function gerarPDF(xmlNFe,
|
|
7
|
+
async function gerarPDF(xmlNFe, opcoes) {
|
|
8
8
|
const nf = await (0, xml_1.deserializeXml)(xmlNFe);
|
|
9
9
|
const nfeProc = nf.nfeProc;
|
|
10
10
|
if (!(nfeProc.NFe.infNFe.det instanceof Array)) {
|
|
@@ -17,10 +17,10 @@ async function gerarPDF(xmlNFe, pathLogo) {
|
|
|
17
17
|
nfeProc.NFe.infNFe.cobr.dup = [nfeProc.NFe.infNFe.cobr?.dup];
|
|
18
18
|
}
|
|
19
19
|
if (nfeProc.NFe.infNFe.ide.mod === '55') {
|
|
20
|
-
return await (0, pdf_NFe_1.pdfNFe)(nfeProc,
|
|
20
|
+
return await (0, pdf_NFe_1.pdfNFe)(nfeProc, opcoes);
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
|
-
return await (0, pdf_NFCe_1.pdfNFCe)(nfeProc, pathLogo);
|
|
23
|
+
return await (0, pdf_NFCe_1.pdfNFCe)(nfeProc, opcoes?.pathLogo);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
exports.gerarPDF = gerarPDF;
|
|
@@ -41,7 +41,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
41
41
|
});
|
|
42
42
|
(0, negrito_1.negrito)({
|
|
43
43
|
doc,
|
|
44
|
-
value: emit.CNPJ
|
|
44
|
+
value: (0, utils_1.formatCnpj)(emit.CNPJ),
|
|
45
45
|
x: 0,
|
|
46
46
|
y: doc.y,
|
|
47
47
|
largura: larguraPagina,
|
|
@@ -53,7 +53,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
53
53
|
});
|
|
54
54
|
(0, normal_1.normal)({
|
|
55
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}. ${emit.enderEmit.CEP}`,
|
|
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
57
|
x: 0,
|
|
58
58
|
y: doc.y,
|
|
59
59
|
largura: larguraPagina,
|
|
@@ -199,7 +199,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
199
199
|
});
|
|
200
200
|
(0, normal_1.normal)({
|
|
201
201
|
doc,
|
|
202
|
-
value: (0, utils_1.
|
|
202
|
+
value: (0, utils_1.formatNumber)(element.prod.qCom, 3),
|
|
203
203
|
x: 120,
|
|
204
204
|
y: posicao,
|
|
205
205
|
largura: 20,
|
|
@@ -212,7 +212,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
212
212
|
});
|
|
213
213
|
(0, normal_1.normal)({
|
|
214
214
|
doc,
|
|
215
|
-
value: (0, utils_1.
|
|
215
|
+
value: (0, utils_1.formatNumber)(element.prod.vUnCom, 2),
|
|
216
216
|
x: 140,
|
|
217
217
|
y: posicao,
|
|
218
218
|
largura: 27,
|
|
@@ -225,7 +225,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
225
225
|
});
|
|
226
226
|
(0, normal_1.normal)({
|
|
227
227
|
doc,
|
|
228
|
-
value: (0, utils_1.
|
|
228
|
+
value: (0, utils_1.formatNumber)(element.prod.vProd, 2),
|
|
229
229
|
x: 167,
|
|
230
230
|
y: posicao,
|
|
231
231
|
largura: larguraPagina - 167,
|
|
@@ -282,7 +282,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
282
282
|
doc.y -= 7;
|
|
283
283
|
(0, normal_1.normal)({
|
|
284
284
|
doc,
|
|
285
|
-
value: (0, utils_1.
|
|
285
|
+
value: (0, utils_1.formatNumber)(total.ICMSTot.vProd, 2),
|
|
286
286
|
x: 0,
|
|
287
287
|
y: doc.y,
|
|
288
288
|
largura: larguraPagina - margemPadrao,
|
|
@@ -309,7 +309,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
309
309
|
doc.y -= 7;
|
|
310
310
|
(0, normal_1.normal)({
|
|
311
311
|
doc,
|
|
312
|
-
value: (0, utils_1.
|
|
312
|
+
value: (0, utils_1.formatNumber)(total.ICMSTot.vDesc, 2),
|
|
313
313
|
x: 0,
|
|
314
314
|
y: doc.y,
|
|
315
315
|
largura: larguraPagina - margemPadrao,
|
|
@@ -336,7 +336,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
336
336
|
doc.y -= 7;
|
|
337
337
|
(0, normal_1.normal)({
|
|
338
338
|
doc,
|
|
339
|
-
value: (0, utils_1.
|
|
339
|
+
value: (0, utils_1.formatNumber)(total.ICMSTot.vFrete, 2),
|
|
340
340
|
x: 0,
|
|
341
341
|
y: doc.y,
|
|
342
342
|
largura: larguraPagina - margemPadrao,
|
|
@@ -363,7 +363,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
363
363
|
doc.y -= 7;
|
|
364
364
|
(0, normal_1.normal)({
|
|
365
365
|
doc,
|
|
366
|
-
value: (0, utils_1.
|
|
366
|
+
value: (0, utils_1.formatNumber)(total.ICMSTot.vNF, 2),
|
|
367
367
|
x: 0,
|
|
368
368
|
y: doc.y,
|
|
369
369
|
largura: larguraPagina - margemPadrao,
|
|
@@ -419,7 +419,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
419
419
|
doc.y -= 7;
|
|
420
420
|
(0, normal_1.normal)({
|
|
421
421
|
doc,
|
|
422
|
-
value: (0, utils_1.
|
|
422
|
+
value: (0, utils_1.formatNumber)(element.vPag, 2),
|
|
423
423
|
x: 0,
|
|
424
424
|
y: doc.y,
|
|
425
425
|
largura: larguraPagina - margemPadrao,
|
|
@@ -447,7 +447,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
447
447
|
doc.y -= 7;
|
|
448
448
|
(0, normal_1.normal)({
|
|
449
449
|
doc,
|
|
450
|
-
value: (0, utils_1.
|
|
450
|
+
value: (0, utils_1.formatNumber)(pag.vTroco ?? 0, 2),
|
|
451
451
|
x: 0,
|
|
452
452
|
y: doc.y,
|
|
453
453
|
largura: larguraPagina - margemPadrao,
|
|
@@ -516,7 +516,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
516
516
|
if (dest?.CNPJ !== undefined) {
|
|
517
517
|
(0, normal_1.normal)({
|
|
518
518
|
doc,
|
|
519
|
-
value: 'CNPJ: ' + dest.CNPJ
|
|
519
|
+
value: 'CNPJ: ' + (0, utils_1.formatCnpj)(dest.CNPJ),
|
|
520
520
|
x: doc.x,
|
|
521
521
|
y: doc.y,
|
|
522
522
|
largura: 112,
|
|
@@ -531,7 +531,7 @@ async function pdfNFCe(nf, pathLogo) {
|
|
|
531
531
|
else if (dest?.CPF !== undefined) {
|
|
532
532
|
(0, normal_1.normal)({
|
|
533
533
|
doc,
|
|
534
|
-
value: 'CPF: ' + dest.CPF
|
|
534
|
+
value: 'CPF: ' + (0, utils_1.formatCpf)(dest.CPF),
|
|
535
535
|
x: doc.x,
|
|
536
536
|
y: doc.y,
|
|
537
537
|
largura: 112,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="pdfkit" />
|
|
2
|
-
import type { NFeProc } from '../../../types';
|
|
3
|
-
export declare function pdfNFe(nf: NFeProc,
|
|
2
|
+
import type { NFeProc, OpcoesPDF } from '../../../types';
|
|
3
|
+
export declare function pdfNFe(nf: NFeProc, opcoes?: OpcoesPDF): Promise<PDFKit.PDFDocument>;
|
|
@@ -13,12 +13,23 @@ const margemTopo = 2.8;
|
|
|
13
13
|
const margemEsquerda = 3;
|
|
14
14
|
const margemDireita = 589.65;
|
|
15
15
|
const larguraDoFormulario = margemDireita - margemEsquerda;
|
|
16
|
-
async function pdfNFe(nf,
|
|
16
|
+
async function pdfNFe(nf, opcoes) {
|
|
17
17
|
const ajusteY = 0;
|
|
18
18
|
const ajusteX = 0;
|
|
19
19
|
const doc = new pdfkit_1.default(options_doc_1.optionsDocNFe);
|
|
20
20
|
(0, load_fontes_1.loadFonts)(doc);
|
|
21
|
-
await (0, gerar_itens_1.gerarItens)({
|
|
21
|
+
await (0, gerar_itens_1.gerarItens)({
|
|
22
|
+
ajusteX,
|
|
23
|
+
ajusteY,
|
|
24
|
+
nf,
|
|
25
|
+
doc,
|
|
26
|
+
larguraDoFormulario,
|
|
27
|
+
margemDireita,
|
|
28
|
+
margemEsquerda,
|
|
29
|
+
margemTopo,
|
|
30
|
+
pathLogo: opcoes?.pathLogo,
|
|
31
|
+
cancelada: opcoes?.cancelada
|
|
32
|
+
});
|
|
22
33
|
const paginas = doc.bufferedPageRange();
|
|
23
34
|
for (let i = paginas.start; i < paginas.start + paginas.count; i++) {
|
|
24
35
|
doc.switchToPage(i);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getCurrentDate(): string;
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getCurrentDate = void 0;
|
|
7
7
|
const date_fns_1 = require("date-fns");
|
|
8
8
|
const pt_BR_1 = __importDefault(require("date-fns/locale/pt-BR"));
|
|
9
|
-
function
|
|
9
|
+
function getCurrentDate() {
|
|
10
10
|
return (0, date_fns_1.format)(new Date(), "yyyy-MM-dd'T'HH:mm:ssxxx", { locale: pt_BR_1.default });
|
|
11
11
|
}
|
|
12
|
-
exports.
|
|
12
|
+
exports.getCurrentDate = getCurrentDate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatCnpj(cnpj: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCnpj = void 0;
|
|
4
|
+
function formatCnpj(cnpj) {
|
|
5
|
+
if (!cnpj)
|
|
6
|
+
return '';
|
|
7
|
+
return cnpj.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/, '$1.$2.$3/$4-$5');
|
|
8
|
+
}
|
|
9
|
+
exports.formatCnpj = formatCnpj;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatCpf(cpf: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCpf = void 0;
|
|
4
|
+
function formatCpf(cpf) {
|
|
5
|
+
if (!cpf)
|
|
6
|
+
return '';
|
|
7
|
+
return cpf.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$4');
|
|
8
|
+
}
|
|
9
|
+
exports.formatCpf = formatCpf;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDateTime(date: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDateTime = void 0;
|
|
4
|
+
const format_date_1 = require("./format-date");
|
|
5
|
+
const format_time_1 = require("./format-time");
|
|
6
|
+
function formatDateTime(date) {
|
|
7
|
+
if (!date)
|
|
8
|
+
return '';
|
|
9
|
+
return `${(0, format_date_1.formatDate)(date)} ${(0, format_time_1.formatTime)(date)}`;
|
|
10
|
+
}
|
|
11
|
+
exports.formatDateTime = formatDateTime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatDate(date: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatDate = void 0;
|
|
4
|
+
function formatDate(date) {
|
|
5
|
+
if (!date)
|
|
6
|
+
return '';
|
|
7
|
+
const [ano, mes, dia] = date.substring(0, 10).split('-');
|
|
8
|
+
return dia.padStart(2, '0') + '/' + mes.toString().padStart(2, '0') + '/' + ano;
|
|
9
|
+
}
|
|
10
|
+
exports.formatDate = formatDate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatKey(key: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatNumber(number: number | string, decimals: number): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatNumber = void 0;
|
|
4
|
+
function formatNumber(number, decimals) {
|
|
5
|
+
return Intl.NumberFormat('pt-BR', { minimumFractionDigits: decimals }).format(Number(number));
|
|
6
|
+
}
|
|
7
|
+
exports.formatNumber = formatNumber;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatPhone(phone: string): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPhone = void 0;
|
|
4
|
+
function formatPhone(phone) {
|
|
5
|
+
if (!phone)
|
|
6
|
+
return '';
|
|
7
|
+
let cleaned = phone.replace(/\D/g, '');
|
|
8
|
+
if (cleaned.length >= 12) {
|
|
9
|
+
cleaned = cleaned.substring(2, cleaned.length);
|
|
10
|
+
}
|
|
11
|
+
const areaCode = cleaned.slice(0, 2);
|
|
12
|
+
const mainNumber = cleaned.slice(2);
|
|
13
|
+
if (mainNumber.length === 9) {
|
|
14
|
+
return `(${areaCode}) ${mainNumber.slice(0, 5)}-${mainNumber.slice(5)}`;
|
|
15
|
+
}
|
|
16
|
+
else if (mainNumber.length === 8) {
|
|
17
|
+
return `(${areaCode}) ${mainNumber.slice(0, 4)}-${mainNumber.slice(4)}`;
|
|
18
|
+
}
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
21
|
+
exports.formatPhone = formatPhone;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatLicensePlate(plate: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatLicensePlate = void 0;
|
|
4
|
+
function formatLicensePlate(plate) {
|
|
5
|
+
if (!plate)
|
|
6
|
+
return '';
|
|
7
|
+
const oldFormat = /^[A-Z]{3}[0-9]{4}$/;
|
|
8
|
+
const mercosulFormat = /^[A-Z]{3}[0-9][A-Z][0-9]{2}$/;
|
|
9
|
+
if (oldFormat.test(plate)) {
|
|
10
|
+
return `${plate.slice(0, 3)}-${plate.slice(3)}`;
|
|
11
|
+
}
|
|
12
|
+
else if (mercosulFormat.test(plate)) {
|
|
13
|
+
return `${plate.slice(0, 3)} ${plate.slice(3)}`;
|
|
14
|
+
}
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
exports.formatLicensePlate = formatLicensePlate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatPostalCode(postalCode: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPostalCode = void 0;
|
|
4
|
+
function formatPostalCode(postalCode) {
|
|
5
|
+
if (!postalCode)
|
|
6
|
+
return '';
|
|
7
|
+
return postalCode.replace(/^(\d{2})(\d{3})(\d{3})$/, '$1.$2-$3');
|
|
8
|
+
}
|
|
9
|
+
exports.formatPostalCode = formatPostalCode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatProtocol(protocol: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatProtocol = void 0;
|
|
4
|
+
function formatProtocol(protocol) {
|
|
5
|
+
if (!protocol)
|
|
6
|
+
return '';
|
|
7
|
+
return protocol.replace(/(.{3})(?=.)/g, '$1 ');
|
|
8
|
+
}
|
|
9
|
+
exports.formatProtocol = formatProtocol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatStateRegistration(stateRegistration: string): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatStateRegistration = void 0;
|
|
4
|
+
function formatStateRegistration(stateRegistration) {
|
|
5
|
+
if (!stateRegistration)
|
|
6
|
+
return '';
|
|
7
|
+
const cleanInscricao = stateRegistration.replace(/\D/g, '');
|
|
8
|
+
const formats = {
|
|
9
|
+
8: '$1.$2-$3',
|
|
10
|
+
9: '$1.$2.$3-$4',
|
|
11
|
+
10: '$1.$2.$3-$4',
|
|
12
|
+
11: '$1.$2.$3-$4',
|
|
13
|
+
12: '$1.$2.$3.$4-$5',
|
|
14
|
+
13: '$1.$2.$3-$4',
|
|
15
|
+
14: '$1.$2.$3.$4-$5'
|
|
16
|
+
};
|
|
17
|
+
const length = cleanInscricao.length;
|
|
18
|
+
const format = formats[length];
|
|
19
|
+
if (!format) {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
let regexPattern = new RegExp('');
|
|
23
|
+
if (length === 8) {
|
|
24
|
+
regexPattern = /(\d{3})(\d{3})(\d{2})/;
|
|
25
|
+
}
|
|
26
|
+
else if (length === 9) {
|
|
27
|
+
regexPattern = /(\d{2})(\d{3})(\d{3})(\d{1})/;
|
|
28
|
+
}
|
|
29
|
+
else if (length === 10) {
|
|
30
|
+
regexPattern = /(\d{2})(\d{3})(\d{3})(\d{2})/;
|
|
31
|
+
}
|
|
32
|
+
else if (length === 11) {
|
|
33
|
+
regexPattern = /(\d{3})(\d{3})(\d{3})(\d{2})/;
|
|
34
|
+
}
|
|
35
|
+
else if (length === 12) {
|
|
36
|
+
regexPattern = /(\d{2})(\d{3})(\d{3})(\d{3})(\d{1})/;
|
|
37
|
+
}
|
|
38
|
+
else if (length === 13) {
|
|
39
|
+
regexPattern = /(\d{2})(\d{3})(\d{3})(\d{2})(\d{2})/;
|
|
40
|
+
}
|
|
41
|
+
else if (length === 14) {
|
|
42
|
+
regexPattern = /(\d{3})(\d{3})(\d{3})(\d{3})(\d{2})/;
|
|
43
|
+
}
|
|
44
|
+
const match = cleanInscricao.match(regexPattern);
|
|
45
|
+
if (!match) {
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
return format.replace(/\$(\d+)/g, (_, index) => match[parseInt(index)] || '');
|
|
49
|
+
}
|
|
50
|
+
exports.formatStateRegistration = formatStateRegistration;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatTime(date: string): string;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './current-date';
|
|
2
|
+
export * from './format-cnpj';
|
|
3
|
+
export * from './format-cpf';
|
|
4
|
+
export * from './format-date';
|
|
5
|
+
export * from './format-key';
|
|
6
|
+
export * from './format-number';
|
|
7
|
+
export * from './format-phone';
|
|
8
|
+
export * from './format-postal-code';
|
|
9
|
+
export * from './format-state-registration';
|
|
10
|
+
export * from './return-font-size-carrier';
|
|
@@ -14,5 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./current-date"), exports);
|
|
18
|
+
__exportStar(require("./format-cnpj"), exports);
|
|
19
|
+
__exportStar(require("./format-cpf"), exports);
|
|
20
|
+
__exportStar(require("./format-date"), exports);
|
|
21
|
+
__exportStar(require("./format-key"), exports);
|
|
22
|
+
__exportStar(require("./format-number"), exports);
|
|
23
|
+
__exportStar(require("./format-phone"), exports);
|
|
24
|
+
__exportStar(require("./format-postal-code"), exports);
|
|
25
|
+
__exportStar(require("./format-state-registration"), exports);
|
|
26
|
+
__exportStar(require("./return-font-size-carrier"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function returnFontSizeCarrier(name: string): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.returnFontSizeCarrier = void 0;
|
|
4
|
+
function returnFontSizeCarrier(name) {
|
|
5
|
+
if (!name)
|
|
6
|
+
return 9.5;
|
|
7
|
+
if (name && name.length > 28 && name.length <= 31) {
|
|
8
|
+
return 8.5;
|
|
9
|
+
}
|
|
10
|
+
if (name && name.length > 31 && name.length <= 35) {
|
|
11
|
+
return 7.5;
|
|
12
|
+
}
|
|
13
|
+
if (name && name.length > 35 && name.length <= 41) {
|
|
14
|
+
return 6.5;
|
|
15
|
+
}
|
|
16
|
+
if (name && name.length > 41 && name.length <= 48) {
|
|
17
|
+
return 5.5;
|
|
18
|
+
}
|
|
19
|
+
if (name && name.length > 48) {
|
|
20
|
+
return 5;
|
|
21
|
+
}
|
|
22
|
+
return 9.5;
|
|
23
|
+
}
|
|
24
|
+
exports.returnFontSizeCarrier = returnFontSizeCarrier;
|