@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
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Black.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-BlackItalic.ttf
ADDED
|
Binary file
|
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-BoldItalic.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ExtraBold.ttf
ADDED
|
Binary file
|
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ExtraLight.ttf
ADDED
|
Binary file
|
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Italic.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Light.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-LightItalic.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Medium.ttf
ADDED
|
Binary file
|
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-Regular.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-SemiBold.ttf
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/barlow-condensed/BarlowCondensed-ThinItalic.ttf
ADDED
|
Binary file
|
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-BoldItalic.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Italic.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Light.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-LightItalic.ttf
ADDED
|
Binary file
|
package/lib/application/helpers/generate-pdf/fontes/roboto-condensed/RobotoCondensed-Regular.ttf
ADDED
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.campo = campo;
|
|
4
|
+
const default_1 = require("./default");
|
|
5
|
+
function campo({ ajusteX, ajusteY, doc, largura, margemEsquerda, margemTopo, value, x, y, alinhamento, tamanho }) {
|
|
6
|
+
const alignValue = (alinhamento ?? default_1.DEFAULT_NFE.alinhamentoDoCampo);
|
|
7
|
+
doc
|
|
8
|
+
.font('negrito')
|
|
9
|
+
.fillColor(default_1.DEFAULT_NFE.corDoCampo)
|
|
10
|
+
.fontSize(tamanho ?? default_1.DEFAULT_NFE.tamanhoDaFonteDoCampo)
|
|
11
|
+
.text(value, margemEsquerda + ajusteX + x, margemTopo + ajusteY + y, {
|
|
12
|
+
width: largura,
|
|
13
|
+
align: alignValue
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.criaLayout = criaLayout;
|
|
4
|
+
const default_1 = require("./default");
|
|
5
|
+
const get_dados_adicionais_1 = require("./get-dados-adicionais");
|
|
6
|
+
const get_dados_emitente_1 = require("./get-dados-emitente");
|
|
7
|
+
const get_destinatario_remetente_1 = require("./get-destinatario-remetente");
|
|
8
|
+
const get_fatura_duplicata_1 = require("./get-fatura-duplicata");
|
|
9
|
+
const get_homologacao_1 = require("./get-homologacao");
|
|
10
|
+
const get_imposto_1 = require("./get-imposto");
|
|
11
|
+
const get_iss_1 = require("./get-iss");
|
|
12
|
+
const get_menu_itens_1 = require("./get-menu-itens");
|
|
13
|
+
const get_nota_cancelada_1 = require("./get-nota-cancelada");
|
|
14
|
+
const get_recibo_1 = require("./get-recibo");
|
|
15
|
+
const get_transporte_1 = require("./get-transporte");
|
|
16
|
+
async function criaLayout({ pathLogo, nf, ajusteX, ajusteY, doc, margemEsquerda, margemTopo, larguraDoFormulario, margemDireita, folha, cancelada, textoRodape }) {
|
|
17
|
+
const { dest, emit, ide, infAdic, total, transp, cobr } = nf.NFe.infNFe;
|
|
18
|
+
let y = 0;
|
|
19
|
+
const finalEspacoDet = folha === 0 ? default_1.DEFAULT_NFE.finalTamanhoDet1 : default_1.DEFAULT_NFE.finalTamanhoDetDemais;
|
|
20
|
+
if (ide.tpAmb === '2') {
|
|
21
|
+
(0, get_homologacao_1.getHomologacao)({
|
|
22
|
+
ajusteX,
|
|
23
|
+
ajusteY,
|
|
24
|
+
doc,
|
|
25
|
+
margemEsquerda,
|
|
26
|
+
margemTopo,
|
|
27
|
+
larguraDoFormulario,
|
|
28
|
+
protNFe: nf.protNFe,
|
|
29
|
+
cancelada
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else if (ide.tpAmb === '1' && cancelada) {
|
|
33
|
+
(0, get_nota_cancelada_1.getNotaCancelada)({ ajusteX, ajusteY, doc, margemEsquerda, margemTopo, larguraDoFormulario });
|
|
34
|
+
}
|
|
35
|
+
if (folha === 0) {
|
|
36
|
+
y = (0, get_recibo_1.getRecibo)({
|
|
37
|
+
y,
|
|
38
|
+
ajusteX,
|
|
39
|
+
ajusteY,
|
|
40
|
+
dest,
|
|
41
|
+
doc,
|
|
42
|
+
emit,
|
|
43
|
+
larguraDoFormulario,
|
|
44
|
+
margemDireita,
|
|
45
|
+
margemEsquerda,
|
|
46
|
+
margemTopo,
|
|
47
|
+
total,
|
|
48
|
+
ide
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
await (0, get_dados_emitente_1.getDadosEmitente)({
|
|
52
|
+
ajusteX,
|
|
53
|
+
ajusteY,
|
|
54
|
+
doc,
|
|
55
|
+
emit,
|
|
56
|
+
larguraDoFormulario,
|
|
57
|
+
margemDireita,
|
|
58
|
+
margemEsquerda,
|
|
59
|
+
margemTopo,
|
|
60
|
+
protNFe: nf.protNFe,
|
|
61
|
+
y,
|
|
62
|
+
pathLogo,
|
|
63
|
+
ide,
|
|
64
|
+
folha
|
|
65
|
+
});
|
|
66
|
+
y = (0, get_destinatario_remetente_1.getDestinatarioRemetente)({
|
|
67
|
+
ajusteX,
|
|
68
|
+
ajusteY,
|
|
69
|
+
dest,
|
|
70
|
+
doc,
|
|
71
|
+
larguraDoFormulario,
|
|
72
|
+
margemDireita,
|
|
73
|
+
margemEsquerda,
|
|
74
|
+
margemTopo,
|
|
75
|
+
y: doc.y,
|
|
76
|
+
ide
|
|
77
|
+
});
|
|
78
|
+
if (folha === 0) {
|
|
79
|
+
y = (0, get_fatura_duplicata_1.getFaturaDuplicata)({
|
|
80
|
+
ajusteX,
|
|
81
|
+
ajusteY,
|
|
82
|
+
doc,
|
|
83
|
+
larguraDoFormulario,
|
|
84
|
+
margemDireita,
|
|
85
|
+
margemEsquerda,
|
|
86
|
+
margemTopo,
|
|
87
|
+
cobr,
|
|
88
|
+
y
|
|
89
|
+
});
|
|
90
|
+
y = (0, get_imposto_1.getImposto)({
|
|
91
|
+
ajusteX,
|
|
92
|
+
ajusteY,
|
|
93
|
+
doc,
|
|
94
|
+
larguraDoFormulario,
|
|
95
|
+
margemDireita,
|
|
96
|
+
margemEsquerda,
|
|
97
|
+
margemTopo,
|
|
98
|
+
total,
|
|
99
|
+
y
|
|
100
|
+
});
|
|
101
|
+
y = (0, get_transporte_1.getTransporte)({
|
|
102
|
+
ajusteX,
|
|
103
|
+
ajusteY,
|
|
104
|
+
doc,
|
|
105
|
+
larguraDoFormulario,
|
|
106
|
+
margemDireita,
|
|
107
|
+
margemEsquerda,
|
|
108
|
+
margemTopo,
|
|
109
|
+
transp,
|
|
110
|
+
y
|
|
111
|
+
});
|
|
112
|
+
y = (0, get_iss_1.getIss)({
|
|
113
|
+
ajusteX,
|
|
114
|
+
ajusteY,
|
|
115
|
+
doc,
|
|
116
|
+
emit,
|
|
117
|
+
larguraDoFormulario,
|
|
118
|
+
margemDireita,
|
|
119
|
+
margemEsquerda,
|
|
120
|
+
margemTopo,
|
|
121
|
+
total,
|
|
122
|
+
y
|
|
123
|
+
});
|
|
124
|
+
(0, get_dados_adicionais_1.getDadosAdicionais)({
|
|
125
|
+
ajusteX,
|
|
126
|
+
ajusteY,
|
|
127
|
+
doc,
|
|
128
|
+
infAdic,
|
|
129
|
+
larguraDoFormulario,
|
|
130
|
+
margemDireita,
|
|
131
|
+
margemEsquerda,
|
|
132
|
+
margemTopo,
|
|
133
|
+
finalEspacoDet,
|
|
134
|
+
extra: { vTotTrib: total.ICMSTot.vTotTrib, emailDest: dest.email },
|
|
135
|
+
textoRodape
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
y = (0, get_menu_itens_1.getMenuItens)({
|
|
139
|
+
ajusteX,
|
|
140
|
+
ajusteY,
|
|
141
|
+
doc,
|
|
142
|
+
margemEsquerda,
|
|
143
|
+
margemTopo,
|
|
144
|
+
y,
|
|
145
|
+
margemDireita,
|
|
146
|
+
finalEspacoDet,
|
|
147
|
+
larguraDoFormulario
|
|
148
|
+
});
|
|
149
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const DEFAULT_NFE: {
|
|
2
|
+
larguraDaPagina: number;
|
|
3
|
+
alturaDaPagina: number;
|
|
4
|
+
tamanhoDaFonteDoTitulo: number;
|
|
5
|
+
corDoTitulo: string;
|
|
6
|
+
alinhamentoDoTitulo: "left";
|
|
7
|
+
alinhamentoDoTituloDaTabela: "center";
|
|
8
|
+
tamanhoDaFonteDaSecao: number;
|
|
9
|
+
corDaSecao: string;
|
|
10
|
+
tamanhoDaFonteDoCampo: number;
|
|
11
|
+
alinhamentoDoCampo: "center";
|
|
12
|
+
corDoCampo: string;
|
|
13
|
+
tamanhoDaFonteDosItens: number;
|
|
14
|
+
separadorDeItens: boolean;
|
|
15
|
+
ajusteYDoLogotipo: number;
|
|
16
|
+
ajusteYDaIdentificacaoDoEmitente: number;
|
|
17
|
+
opacidadeDaHomologacao: number;
|
|
18
|
+
ajusteYDaHomologacao: number;
|
|
19
|
+
tamanhoDoCodigoDeBarras: number;
|
|
20
|
+
corDoLayout: string;
|
|
21
|
+
finalTamanhoDet1: number;
|
|
22
|
+
finalTamanhoDetDemais: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_NFE = void 0;
|
|
4
|
+
exports.DEFAULT_NFE = {
|
|
5
|
+
larguraDaPagina: 595.44,
|
|
6
|
+
alturaDaPagina: 841.68,
|
|
7
|
+
tamanhoDaFonteDoTitulo: 6,
|
|
8
|
+
corDoTitulo: 'black',
|
|
9
|
+
alinhamentoDoTitulo: 'left',
|
|
10
|
+
alinhamentoDoTituloDaTabela: 'center',
|
|
11
|
+
tamanhoDaFonteDaSecao: 7,
|
|
12
|
+
corDaSecao: 'black',
|
|
13
|
+
tamanhoDaFonteDoCampo: 9.5,
|
|
14
|
+
alinhamentoDoCampo: 'center',
|
|
15
|
+
corDoCampo: 'black',
|
|
16
|
+
tamanhoDaFonteDosItens: 5.5,
|
|
17
|
+
separadorDeItens: true,
|
|
18
|
+
ajusteYDoLogotipo: 0,
|
|
19
|
+
ajusteYDaIdentificacaoDoEmitente: 0,
|
|
20
|
+
opacidadeDaHomologacao: 0.4,
|
|
21
|
+
ajusteYDaHomologacao: 275,
|
|
22
|
+
tamanhoDoCodigoDeBarras: 32,
|
|
23
|
+
corDoLayout: 'black',
|
|
24
|
+
finalTamanhoDet1: 752,
|
|
25
|
+
finalTamanhoDetDemais: 822
|
|
26
|
+
};
|
|
@@ -0,0 +1,291 @@
|
|
|
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.gerarItens = gerarItens;
|
|
7
|
+
const ordate_1 = __importDefault(require("ordate"));
|
|
8
|
+
const utils_1 = require("../../../../domain/use-cases/utils");
|
|
9
|
+
const cria_layout_1 = require("./cria-layout");
|
|
10
|
+
const default_1 = require("./default");
|
|
11
|
+
const linha_horizontal_tracejada_1 = require("./linha-horizontal-tracejada");
|
|
12
|
+
const normal_1 = require("./normal");
|
|
13
|
+
const options_doc_1 = require("./options-doc");
|
|
14
|
+
async function gerarItens({ nf, ajusteX, ajusteY, doc, margemEsquerda, margemTopo, margemDireita, larguraDoFormulario, pathLogo, cancelada, textoRodape }) {
|
|
15
|
+
let folha = 0;
|
|
16
|
+
await (0, cria_layout_1.criaLayout)({
|
|
17
|
+
ajusteX,
|
|
18
|
+
ajusteY,
|
|
19
|
+
nf,
|
|
20
|
+
doc,
|
|
21
|
+
larguraDoFormulario,
|
|
22
|
+
margemDireita,
|
|
23
|
+
margemEsquerda,
|
|
24
|
+
margemTopo,
|
|
25
|
+
pathLogo,
|
|
26
|
+
folha,
|
|
27
|
+
cancelada,
|
|
28
|
+
textoRodape
|
|
29
|
+
});
|
|
30
|
+
let maiorY = doc.y;
|
|
31
|
+
for (let i = 0; i < nf.NFe.infNFe.det.length; i++) {
|
|
32
|
+
const item = nf.NFe.infNFe.det[i];
|
|
33
|
+
const rastroInfo = item.prod.rastro || item.rastro;
|
|
34
|
+
const formatRastro = (rast) => `Lote:${rast.nLote} ${rast.dVal ? `Val:${ordate_1.default.toUTC(rast.dVal).toLocaleDateString()}` : ''} ${rast.qLote ? `Qnt:${rast.qLote}` : ''}`.trim();
|
|
35
|
+
const rastroOutput = Array.isArray(rastroInfo)
|
|
36
|
+
? rastroInfo.length > 0
|
|
37
|
+
? `\n${rastroInfo.map(formatRastro).join('\n')}`
|
|
38
|
+
: ''
|
|
39
|
+
: rastroInfo?.nLote
|
|
40
|
+
? formatRastro(rastroInfo)
|
|
41
|
+
: '';
|
|
42
|
+
function renderizarLinha(pdf) {
|
|
43
|
+
const y = maiorY + 2;
|
|
44
|
+
(0, normal_1.normal)({
|
|
45
|
+
doc,
|
|
46
|
+
value: item.prod.cProd,
|
|
47
|
+
x: 1.5,
|
|
48
|
+
y,
|
|
49
|
+
largura: 51,
|
|
50
|
+
alinhamento: 'center',
|
|
51
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
52
|
+
ajusteX,
|
|
53
|
+
ajusteY,
|
|
54
|
+
margemEsquerda,
|
|
55
|
+
margemTopo
|
|
56
|
+
});
|
|
57
|
+
(0, normal_1.normal)({
|
|
58
|
+
doc,
|
|
59
|
+
value: `${item.prod.xProd}${item.infAdProd ? `\n${item.infAdProd}` : ''}${rastroOutput}`,
|
|
60
|
+
x: 55.5,
|
|
61
|
+
y,
|
|
62
|
+
largura: 178,
|
|
63
|
+
alinhamento: 'justify',
|
|
64
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
65
|
+
ajusteX,
|
|
66
|
+
ajusteY,
|
|
67
|
+
margemEsquerda,
|
|
68
|
+
margemTopo
|
|
69
|
+
});
|
|
70
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
71
|
+
(0, normal_1.normal)({
|
|
72
|
+
doc,
|
|
73
|
+
value: item.prod.NCM,
|
|
74
|
+
x: 235.5,
|
|
75
|
+
y,
|
|
76
|
+
largura: 32.5,
|
|
77
|
+
alinhamento: 'center',
|
|
78
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
79
|
+
ajusteX,
|
|
80
|
+
ajusteY,
|
|
81
|
+
margemEsquerda,
|
|
82
|
+
margemTopo
|
|
83
|
+
});
|
|
84
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
85
|
+
(0, normal_1.normal)({
|
|
86
|
+
doc,
|
|
87
|
+
value: item.prod.CFOP,
|
|
88
|
+
x: 293.5,
|
|
89
|
+
y,
|
|
90
|
+
largura: 21,
|
|
91
|
+
alinhamento: 'center',
|
|
92
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
93
|
+
ajusteX,
|
|
94
|
+
ajusteY,
|
|
95
|
+
margemEsquerda,
|
|
96
|
+
margemTopo
|
|
97
|
+
});
|
|
98
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
99
|
+
(0, normal_1.normal)({
|
|
100
|
+
doc,
|
|
101
|
+
value: item.prod.uCom,
|
|
102
|
+
x: 315.5,
|
|
103
|
+
y,
|
|
104
|
+
largura: 16.5,
|
|
105
|
+
alinhamento: 'center',
|
|
106
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
107
|
+
ajusteX,
|
|
108
|
+
ajusteY,
|
|
109
|
+
margemEsquerda,
|
|
110
|
+
margemTopo
|
|
111
|
+
});
|
|
112
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
113
|
+
(0, normal_1.normal)({
|
|
114
|
+
doc,
|
|
115
|
+
value: (0, utils_1.formatNumber)(item.prod.qCom, 4),
|
|
116
|
+
x: 335,
|
|
117
|
+
y,
|
|
118
|
+
largura: 37,
|
|
119
|
+
alinhamento: 'center',
|
|
120
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
121
|
+
ajusteX,
|
|
122
|
+
ajusteY,
|
|
123
|
+
margemEsquerda,
|
|
124
|
+
margemTopo
|
|
125
|
+
});
|
|
126
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
127
|
+
(0, normal_1.normal)({
|
|
128
|
+
doc,
|
|
129
|
+
value: (0, utils_1.formatNumber)(item.prod.vUnCom, 2),
|
|
130
|
+
x: 375,
|
|
131
|
+
y,
|
|
132
|
+
largura: 32.5,
|
|
133
|
+
alinhamento: 'center',
|
|
134
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
135
|
+
ajusteX,
|
|
136
|
+
ajusteY,
|
|
137
|
+
margemEsquerda,
|
|
138
|
+
margemTopo
|
|
139
|
+
});
|
|
140
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
141
|
+
(0, normal_1.normal)({
|
|
142
|
+
doc,
|
|
143
|
+
value: (0, utils_1.formatNumber)(item.prod.vProd, 2),
|
|
144
|
+
x: 409.5,
|
|
145
|
+
y,
|
|
146
|
+
largura: 31,
|
|
147
|
+
alinhamento: 'center',
|
|
148
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
149
|
+
ajusteX,
|
|
150
|
+
ajusteY,
|
|
151
|
+
margemEsquerda,
|
|
152
|
+
margemTopo
|
|
153
|
+
});
|
|
154
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
155
|
+
const keys = Object.keys(item.imposto);
|
|
156
|
+
for (let i = 0; i < keys.length; i++) {
|
|
157
|
+
if (keys[i].includes('ICMS') && !keys[i].includes('UFDest')) {
|
|
158
|
+
const newKeys = Object.keys(item.imposto[keys[i]]);
|
|
159
|
+
(0, normal_1.normal)({
|
|
160
|
+
doc,
|
|
161
|
+
value: item.imposto[keys[i]][newKeys[0]].CST
|
|
162
|
+
? `${item.imposto[keys[i]][newKeys[0]].orig}/${item.imposto[keys[i]][newKeys[0]].CST}`
|
|
163
|
+
: '',
|
|
164
|
+
x: 270,
|
|
165
|
+
y,
|
|
166
|
+
largura: 21,
|
|
167
|
+
alinhamento: 'center',
|
|
168
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
169
|
+
ajusteX,
|
|
170
|
+
ajusteY,
|
|
171
|
+
margemEsquerda,
|
|
172
|
+
margemTopo
|
|
173
|
+
});
|
|
174
|
+
(0, normal_1.normal)({
|
|
175
|
+
doc,
|
|
176
|
+
value: item.imposto[keys[i]][newKeys[0]].CSOSN
|
|
177
|
+
? `${item.imposto[keys[i]][newKeys[0]].orig}/${item.imposto[keys[i]][newKeys[0]].CSOSN}`
|
|
178
|
+
: '',
|
|
179
|
+
x: 270,
|
|
180
|
+
y,
|
|
181
|
+
largura: 21,
|
|
182
|
+
alinhamento: 'center',
|
|
183
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
184
|
+
ajusteX,
|
|
185
|
+
ajusteY,
|
|
186
|
+
margemEsquerda,
|
|
187
|
+
margemTopo
|
|
188
|
+
});
|
|
189
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
190
|
+
(0, normal_1.normal)({
|
|
191
|
+
doc,
|
|
192
|
+
value: (0, utils_1.formatNumber)(item.imposto[keys[i]][newKeys[0]].vBC ?? 0, 2),
|
|
193
|
+
x: 443,
|
|
194
|
+
y,
|
|
195
|
+
largura: 32.5,
|
|
196
|
+
alinhamento: 'center',
|
|
197
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
198
|
+
ajusteX,
|
|
199
|
+
ajusteY,
|
|
200
|
+
margemEsquerda,
|
|
201
|
+
margemTopo
|
|
202
|
+
});
|
|
203
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
204
|
+
(0, normal_1.normal)({
|
|
205
|
+
doc,
|
|
206
|
+
value: (0, utils_1.formatNumber)(item.imposto[keys[i]][newKeys[0]].vICMS ?? 0, 2),
|
|
207
|
+
x: 476,
|
|
208
|
+
y,
|
|
209
|
+
largura: 32,
|
|
210
|
+
alinhamento: 'center',
|
|
211
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
212
|
+
ajusteX,
|
|
213
|
+
ajusteY,
|
|
214
|
+
margemEsquerda,
|
|
215
|
+
margemTopo
|
|
216
|
+
});
|
|
217
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
218
|
+
(0, normal_1.normal)({
|
|
219
|
+
doc,
|
|
220
|
+
value: (0, utils_1.formatNumber)(item.imposto[keys[i]][newKeys[0]].pICMS ?? 0, 2),
|
|
221
|
+
x: 532,
|
|
222
|
+
y: y + 0.65,
|
|
223
|
+
largura: 28,
|
|
224
|
+
alinhamento: 'center',
|
|
225
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
226
|
+
ajusteX,
|
|
227
|
+
ajusteY,
|
|
228
|
+
margemEsquerda,
|
|
229
|
+
margemTopo
|
|
230
|
+
});
|
|
231
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
(0, normal_1.normal)({
|
|
235
|
+
doc,
|
|
236
|
+
value: (0, utils_1.formatNumber)(item.imposto.IPI?.IPITrib?.vIPI ?? 0, 2),
|
|
237
|
+
x: 507.5,
|
|
238
|
+
y,
|
|
239
|
+
largura: 26,
|
|
240
|
+
alinhamento: 'center',
|
|
241
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
242
|
+
ajusteX,
|
|
243
|
+
ajusteY,
|
|
244
|
+
margemEsquerda,
|
|
245
|
+
margemTopo
|
|
246
|
+
});
|
|
247
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
248
|
+
(0, normal_1.normal)({
|
|
249
|
+
doc,
|
|
250
|
+
value: (0, utils_1.formatNumber)(item.imposto.IPI?.IPITrib?.pIPI ?? 0, 2),
|
|
251
|
+
x: 557.75,
|
|
252
|
+
y,
|
|
253
|
+
largura: 29,
|
|
254
|
+
alinhamento: 'center',
|
|
255
|
+
tamanho: default_1.DEFAULT_NFE.tamanhoDaFonteDosItens,
|
|
256
|
+
ajusteX,
|
|
257
|
+
ajusteY,
|
|
258
|
+
margemEsquerda,
|
|
259
|
+
margemTopo
|
|
260
|
+
});
|
|
261
|
+
maiorY = Math.max(maiorY, pdf.y);
|
|
262
|
+
return Number(maiorY) + (default_1.DEFAULT_NFE.separadorDeItens !== undefined ? 2 : 0);
|
|
263
|
+
}
|
|
264
|
+
maiorY = renderizarLinha(doc);
|
|
265
|
+
if (doc.y > (folha === 0 ? default_1.DEFAULT_NFE.finalTamanhoDet1 - 26 : 800)) {
|
|
266
|
+
doc.addPage(options_doc_1.optionsDocNFe);
|
|
267
|
+
doc.y = 0;
|
|
268
|
+
folha++;
|
|
269
|
+
await (0, cria_layout_1.criaLayout)({
|
|
270
|
+
ajusteX,
|
|
271
|
+
ajusteY,
|
|
272
|
+
nf,
|
|
273
|
+
doc,
|
|
274
|
+
larguraDoFormulario,
|
|
275
|
+
margemDireita,
|
|
276
|
+
margemEsquerda,
|
|
277
|
+
margemTopo,
|
|
278
|
+
pathLogo,
|
|
279
|
+
folha,
|
|
280
|
+
cancelada,
|
|
281
|
+
textoRodape
|
|
282
|
+
});
|
|
283
|
+
maiorY = doc.y;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
if (default_1.DEFAULT_NFE.separadorDeItens !== undefined) {
|
|
287
|
+
(0, linha_horizontal_tracejada_1.linhaHorizontalTracejada)({ x1: 0, x2: 0, y: maiorY - 1, doc, ajusteX, ajusteY, margemDireita, margemEsquerda, margemTopo });
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|