@arcasdk/pdf 0.2.0
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 +114 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +18 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/voucher.constants.d.ts +24 -0
- package/lib/constants/voucher.constants.js +99 -0
- package/lib/constants/voucher.constants.js.map +1 -0
- package/lib/generator/index.d.ts +1 -0
- package/lib/generator/index.js +18 -0
- package/lib/generator/index.js.map +1 -0
- package/lib/generator/invoice-pdf-generator.d.ts +11 -0
- package/lib/generator/invoice-pdf-generator.js +204 -0
- package/lib/generator/invoice-pdf-generator.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/templates/arca-default/index.d.ts +1 -0
- package/lib/templates/arca-default/index.js +7 -0
- package/lib/templates/arca-default/index.js.map +1 -0
- package/lib/templates/arca-default/invoice-document.d.ts +3 -0
- package/lib/templates/arca-default/invoice-document.hbs +336 -0
- package/lib/templates/arca-default/invoice-document.js +14 -0
- package/lib/templates/arca-default/invoice-document.js.map +1 -0
- package/lib/templates/engine/index.d.ts +1 -0
- package/lib/templates/engine/index.js +8 -0
- package/lib/templates/engine/index.js.map +1 -0
- package/lib/templates/engine/template-engine.d.ts +5 -0
- package/lib/templates/engine/template-engine.js +88 -0
- package/lib/templates/engine/template-engine.js.map +1 -0
- package/lib/templates/index.d.ts +1 -0
- package/lib/templates/index.js +6 -0
- package/lib/templates/index.js.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +18 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/invoice-data.types.d.ts +225 -0
- package/lib/types/invoice-data.types.js +3 -0
- package/lib/types/invoice-data.types.js.map +1 -0
- package/lib/utils/format.utils.d.ts +22 -0
- package/lib/utils/format.utils.js +56 -0
- package/lib/utils/format.utils.js.map +1 -0
- package/lib/utils/index.d.ts +3 -0
- package/lib/utils/index.js +20 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/number-to-words.utils.d.ts +1 -0
- package/lib/utils/number-to-words.utils.js +99 -0
- package/lib/utils/number-to-words.utils.js.map +1 -0
- package/lib/utils/qr.utils.d.ts +8 -0
- package/lib/utils/qr.utils.js +56 -0
- package/lib/utils/qr.utils.js.map +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @arcasdk/pdf
|
|
2
|
+
|
|
3
|
+
Generador de comprobantes electrónicos en formato PDF con diseño oficial de ARCA (ex AFIP).
|
|
4
|
+
|
|
5
|
+
[](https://npmjs.org/package/@arcasdk/pdf)
|
|
6
|
+
|
|
7
|
+
## Características
|
|
8
|
+
|
|
9
|
+
- Genera PDFs de Facturas, Notas de Crédito y Notas de Débito (letras A, B, C)
|
|
10
|
+
- Diseño adaptado al formato oficial de ARCA
|
|
11
|
+
- Código QR de verificación automático
|
|
12
|
+
- Soporte para múltiples copias (Original, Duplicado, Triplicado, Cuadruplicado)
|
|
13
|
+
- Soporte para servicios (período facturado, vencimiento de pago)
|
|
14
|
+
- Soporte para tributos adicionales y comprobantes asociados
|
|
15
|
+
- Monedas: Pesos Argentinos (ARS) y Dólares Estadounidenses (USD)
|
|
16
|
+
- Templates personalizables
|
|
17
|
+
- Independiente de `@arcasdk/core` — se puede usar de forma standalone
|
|
18
|
+
|
|
19
|
+
## Instalación
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm i @arcasdk/pdf
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Uso rápido
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { InvoicePdfGenerator, InvoiceData } from "@arcasdk/pdf";
|
|
29
|
+
import { writeFileSync } from "fs";
|
|
30
|
+
|
|
31
|
+
const data: InvoiceData = {
|
|
32
|
+
emisor: {
|
|
33
|
+
razonSocial: "Mi Empresa S.A.",
|
|
34
|
+
domicilioComercial: "Av. Corrientes 1234, CABA",
|
|
35
|
+
condicionIva: "IVA Responsable Inscripto",
|
|
36
|
+
cuit: "20304050607",
|
|
37
|
+
iibb: "12-3456789-0",
|
|
38
|
+
fechaInicioActividades: "20180301",
|
|
39
|
+
},
|
|
40
|
+
receptor: {
|
|
41
|
+
razonSocial: "Cliente S.R.L.",
|
|
42
|
+
domicilio: "Calle Falsa 456, Rosario",
|
|
43
|
+
condicionIva: "IVA Responsable Inscripto",
|
|
44
|
+
documentoTipo: "CUIT",
|
|
45
|
+
documentoNro: "30712345678",
|
|
46
|
+
},
|
|
47
|
+
cbteTipo: 1,
|
|
48
|
+
cbteLetra: "A",
|
|
49
|
+
puntoVenta: 3,
|
|
50
|
+
cbteDesde: 152,
|
|
51
|
+
cbteHasta: 152,
|
|
52
|
+
cbteFecha: "20240515",
|
|
53
|
+
concepto: 1,
|
|
54
|
+
items: [
|
|
55
|
+
{
|
|
56
|
+
descripcion: "Servicio de consultoría",
|
|
57
|
+
cantidad: 10,
|
|
58
|
+
unidadMedida: "horas",
|
|
59
|
+
precioUnitario: 5000,
|
|
60
|
+
subtotal: 50000,
|
|
61
|
+
alicuotaIva: 21,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
importeNetoGravado: 50000,
|
|
65
|
+
importeIva: 10500,
|
|
66
|
+
iva: [{ id: 5, descripcion: "21%", baseImponible: 50000, importe: 10500 }],
|
|
67
|
+
importeTotal: 60500,
|
|
68
|
+
cae: "74512345678901",
|
|
69
|
+
caeFechaVencimiento: "20240525",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const generator = new InvoicePdfGenerator();
|
|
73
|
+
const pdfBuffer = await generator.generate(data);
|
|
74
|
+
writeFileSync("factura.pdf", pdfBuffer);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Opciones
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const generator = new InvoicePdfGenerator({
|
|
81
|
+
pageSize: "A4", // "A4" | "LETTER" | "LEGAL"
|
|
82
|
+
margin: 10, // Márgenes en puntos
|
|
83
|
+
includeQr: true, // Código QR de verificación ARCA
|
|
84
|
+
copy: "ORIGINAL", // Banner de copia
|
|
85
|
+
footerText: "Pie custom", // Texto en el footer
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Múltiples copias
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const generator = new InvoicePdfGenerator({
|
|
93
|
+
copies: ["ORIGINAL", "DUPLICADO", "TRIPLICADO"],
|
|
94
|
+
});
|
|
95
|
+
const pdf = await generator.generate(data);
|
|
96
|
+
// Un solo PDF con 3 copias completas
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Stream
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const stream = await generator.generateStream(data);
|
|
103
|
+
stream.pipe(res); // Express response
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Documentación
|
|
107
|
+
|
|
108
|
+
Para la documentación completa (tipos de comprobante, estructura de datos, templates personalizados, integración con `@arcasdk/core`):
|
|
109
|
+
|
|
110
|
+
📖 [Ver documentación completa](https://ralcorta.github.io/arcasdk/services/pdf)
|
|
111
|
+
|
|
112
|
+
## Licencia
|
|
113
|
+
|
|
114
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./voucher.constants";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./voucher.constants"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapeo de código de tipo de comprobante a su letra
|
|
3
|
+
*/
|
|
4
|
+
export declare const VOUCHER_TYPE_LETTER: Record<number, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Mapeo de código de tipo de comprobante a su descripción
|
|
7
|
+
*/
|
|
8
|
+
export declare const VOUCHER_TYPE_DESCRIPTION: Record<number, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Código del tipo de comprobante (letra) para el QR
|
|
11
|
+
*/
|
|
12
|
+
export declare const VOUCHER_TYPE_CODE: Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Mapeo de moneda ID a símbolo
|
|
15
|
+
*/
|
|
16
|
+
export declare const CURRENCY_SYMBOL: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Mapeo de moneda ID a nombre completo
|
|
19
|
+
*/
|
|
20
|
+
export declare const CURRENCY_NAME: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Mapeo de moneda ID a código ISO
|
|
23
|
+
*/
|
|
24
|
+
export declare const CURRENCY_CODE: Record<string, string>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CURRENCY_CODE = exports.CURRENCY_NAME = exports.CURRENCY_SYMBOL = exports.VOUCHER_TYPE_CODE = exports.VOUCHER_TYPE_DESCRIPTION = exports.VOUCHER_TYPE_LETTER = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Mapeo de código de tipo de comprobante a su letra
|
|
6
|
+
*/
|
|
7
|
+
exports.VOUCHER_TYPE_LETTER = {
|
|
8
|
+
1: "A", // Factura A
|
|
9
|
+
2: "A", // Nota de Débito A
|
|
10
|
+
3: "A", // Nota de Crédito A
|
|
11
|
+
6: "B", // Factura B
|
|
12
|
+
7: "B", // Nota de Débito B
|
|
13
|
+
8: "B", // Nota de Crédito B
|
|
14
|
+
11: "C", // Factura C
|
|
15
|
+
12: "C", // Nota de Débito C
|
|
16
|
+
13: "C", // Nota de Crédito C
|
|
17
|
+
19: "E", // Factura E (Exportación)
|
|
18
|
+
20: "E", // Nota de Débito E
|
|
19
|
+
21: "E", // Nota de Crédito E
|
|
20
|
+
51: "M", // Factura M
|
|
21
|
+
52: "M", // Nota de Débito M
|
|
22
|
+
53: "M", // Nota de Crédito M
|
|
23
|
+
201: "A", // Factura de Crédito Electrónica MiPyME A
|
|
24
|
+
202: "A", // Nota de Débito Electrónica MiPyME A
|
|
25
|
+
203: "A", // Nota de Crédito Electrónica MiPyME A
|
|
26
|
+
206: "B", // Factura de Crédito Electrónica MiPyME B
|
|
27
|
+
207: "B", // Nota de Débito Electrónica MiPyME B
|
|
28
|
+
208: "B", // Nota de Crédito Electrónica MiPyME B
|
|
29
|
+
211: "C", // Factura de Crédito Electrónica MiPyME C
|
|
30
|
+
212: "C", // Nota de Débito Electrónica MiPyME C
|
|
31
|
+
213: "C", // Nota de Crédito Electrónica MiPyME C
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Mapeo de código de tipo de comprobante a su descripción
|
|
35
|
+
*/
|
|
36
|
+
exports.VOUCHER_TYPE_DESCRIPTION = {
|
|
37
|
+
1: "FACTURA",
|
|
38
|
+
2: "NOTA DE DÉBITO",
|
|
39
|
+
3: "NOTA DE CRÉDITO",
|
|
40
|
+
6: "FACTURA",
|
|
41
|
+
7: "NOTA DE DÉBITO",
|
|
42
|
+
8: "NOTA DE CRÉDITO",
|
|
43
|
+
11: "FACTURA",
|
|
44
|
+
12: "NOTA DE DÉBITO",
|
|
45
|
+
13: "NOTA DE CRÉDITO",
|
|
46
|
+
19: "FACTURA",
|
|
47
|
+
20: "NOTA DE DÉBITO",
|
|
48
|
+
21: "NOTA DE CRÉDITO",
|
|
49
|
+
51: "FACTURA",
|
|
50
|
+
52: "NOTA DE DÉBITO",
|
|
51
|
+
53: "NOTA DE CRÉDITO",
|
|
52
|
+
201: "FACTURA DE CRÉDITO ELECTRÓNICA MiPyME",
|
|
53
|
+
202: "NOTA DE DÉBITO ELECTRÓNICA MiPyME",
|
|
54
|
+
203: "NOTA DE CRÉDITO ELECTRÓNICA MiPyME",
|
|
55
|
+
206: "FACTURA DE CRÉDITO ELECTRÓNICA MiPyME",
|
|
56
|
+
207: "NOTA DE DÉBITO ELECTRÓNICA MiPyME",
|
|
57
|
+
208: "NOTA DE CRÉDITO ELECTRÓNICA MiPyME",
|
|
58
|
+
211: "FACTURA DE CRÉDITO ELECTRÓNICA MiPyME",
|
|
59
|
+
212: "NOTA DE DÉBITO ELECTRÓNICA MiPyME",
|
|
60
|
+
213: "NOTA DE CRÉDITO ELECTRÓNICA MiPyME",
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Código del tipo de comprobante (letra) para el QR
|
|
64
|
+
*/
|
|
65
|
+
exports.VOUCHER_TYPE_CODE = {
|
|
66
|
+
A: "001",
|
|
67
|
+
B: "006",
|
|
68
|
+
C: "011",
|
|
69
|
+
E: "019",
|
|
70
|
+
M: "051",
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Mapeo de moneda ID a símbolo
|
|
74
|
+
*/
|
|
75
|
+
exports.CURRENCY_SYMBOL = {
|
|
76
|
+
PES: "$",
|
|
77
|
+
DOL: "US$",
|
|
78
|
+
"002": "US$",
|
|
79
|
+
"000": "$",
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Mapeo de moneda ID a nombre completo
|
|
83
|
+
*/
|
|
84
|
+
exports.CURRENCY_NAME = {
|
|
85
|
+
PES: "PESOS ARGENTINOS (ARS)",
|
|
86
|
+
DOL: "DÓLARES ESTADOUNIDENSES (USD)",
|
|
87
|
+
"002": "DÓLARES ESTADOUNIDENSES (USD)",
|
|
88
|
+
"000": "PESOS ARGENTINOS (ARS)",
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Mapeo de moneda ID a código ISO
|
|
92
|
+
*/
|
|
93
|
+
exports.CURRENCY_CODE = {
|
|
94
|
+
PES: "ARS",
|
|
95
|
+
DOL: "USD",
|
|
96
|
+
"002": "USD",
|
|
97
|
+
"000": "ARS",
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=voucher.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voucher.constants.js","sourceRoot":"","sources":["../../src/constants/voucher.constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,mBAAmB,GAA2B;IACzD,CAAC,EAAE,GAAG,EAAE,YAAY;IACpB,CAAC,EAAE,GAAG,EAAE,mBAAmB;IAC3B,CAAC,EAAE,GAAG,EAAE,oBAAoB;IAC5B,CAAC,EAAE,GAAG,EAAE,YAAY;IACpB,CAAC,EAAE,GAAG,EAAE,mBAAmB;IAC3B,CAAC,EAAE,GAAG,EAAE,oBAAoB;IAC5B,EAAE,EAAE,GAAG,EAAE,YAAY;IACrB,EAAE,EAAE,GAAG,EAAE,mBAAmB;IAC5B,EAAE,EAAE,GAAG,EAAE,oBAAoB;IAC7B,EAAE,EAAE,GAAG,EAAE,0BAA0B;IACnC,EAAE,EAAE,GAAG,EAAE,mBAAmB;IAC5B,EAAE,EAAE,GAAG,EA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,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;CACT,CAAC;AAEF;;GAEG;AACU,QAAA,eAAe,GAA2B;IACrD,GAAG,EAAE,GAAG;IACR,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,GAAG;CACX,CAAC;AAEF;;GAEG;AACU,QAAA,aAAa,GAA2B;IACnD,GAAG,EAAE,wBAAwB;IAC7B,GAAG,EAAE,+BAA+B;IACpC,KAAK,EAAE,+BAA+B;IACtC,KAAK,EAAE,wBAAwB;CAChC,CAAC;AAEF;;GAEG;AACU,QAAA,aAAa,GAA2B;IACnD,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;CACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./invoice-pdf-generator";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./invoice-pdf-generator"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Readable } from "stream";
|
|
2
|
+
import { InvoiceData, PdfGeneratorOptions } from "../types/invoice-data.types";
|
|
3
|
+
export declare class InvoicePdfGenerator {
|
|
4
|
+
private readonly opts;
|
|
5
|
+
private readonly renderTemplate;
|
|
6
|
+
constructor(options?: PdfGeneratorOptions);
|
|
7
|
+
generate(data: InvoiceData): Promise<Buffer>;
|
|
8
|
+
private _generateSingle;
|
|
9
|
+
generateStream(data: InvoiceData): Promise<Readable>;
|
|
10
|
+
private _mergeBuffers;
|
|
11
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
};
|
|
55
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
56
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.InvoicePdfGenerator = void 0;
|
|
60
|
+
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
61
|
+
const qrcode_1 = __importDefault(require("qrcode"));
|
|
62
|
+
const stream_1 = require("stream");
|
|
63
|
+
const qr_utils_1 = require("../utils/qr.utils");
|
|
64
|
+
const arca_default_1 = require("../templates/arca-default");
|
|
65
|
+
const engine_1 = require("../templates/engine");
|
|
66
|
+
const DEFAULT_MARGIN = 10;
|
|
67
|
+
const PAGE_DIMENSIONS = {
|
|
68
|
+
A4: { format: "A4", width: 210, height: 297 },
|
|
69
|
+
LETTER: { format: "Letter", width: 215.9, height: 279.4 },
|
|
70
|
+
LEGAL: { format: "Legal", width: 215.9, height: 355.6 },
|
|
71
|
+
};
|
|
72
|
+
class InvoicePdfGenerator {
|
|
73
|
+
constructor(options) {
|
|
74
|
+
const _a = options !== null && options !== void 0 ? options : {}, { template } = _a, rest = __rest(_a, ["template"]);
|
|
75
|
+
this.opts = Object.assign({ pageSize: "A4", margin: DEFAULT_MARGIN, includeQr: true }, rest);
|
|
76
|
+
if (typeof template === "string") {
|
|
77
|
+
this.renderTemplate = (0, engine_1.compileTemplate)(template);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.renderTemplate = template !== null && template !== void 0 ? template : arca_default_1.InvoiceDocument;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
generate(data) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const copies = this.opts.copies && this.opts.copies.length > 0
|
|
86
|
+
? this.opts.copies
|
|
87
|
+
: [this.opts.copy || "ORIGINAL"];
|
|
88
|
+
if (copies.length === 1) {
|
|
89
|
+
return this._generateSingle(data, copies[0]);
|
|
90
|
+
}
|
|
91
|
+
// Multiple copies: generate each and merge
|
|
92
|
+
const buffers = [];
|
|
93
|
+
for (const copy of copies) {
|
|
94
|
+
buffers.push(yield this._generateSingle(data, copy));
|
|
95
|
+
}
|
|
96
|
+
return this._mergeBuffers(buffers);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
_generateSingle(data, copy) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
let qrDataUrl;
|
|
102
|
+
if (this.opts.includeQr) {
|
|
103
|
+
const qrUrl = (0, qr_utils_1.buildArcaQrUrl)(data);
|
|
104
|
+
try {
|
|
105
|
+
qrDataUrl = yield qrcode_1.default.toDataURL(qrUrl, {
|
|
106
|
+
width: 200,
|
|
107
|
+
margin: 0,
|
|
108
|
+
errorCorrectionLevel: "M",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (_a) {
|
|
112
|
+
// skip QR on error
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const renderTemplate = this.renderTemplate;
|
|
116
|
+
const optsWithCopy = Object.assign(Object.assign({}, this.opts), { copy });
|
|
117
|
+
const html = renderTemplate({ data, options: optsWithCopy, qrDataUrl });
|
|
118
|
+
const browser = yield puppeteer_1.default.launch({ headless: true });
|
|
119
|
+
try {
|
|
120
|
+
const page = yield browser.newPage();
|
|
121
|
+
const { format: pageFormat, width: pageWidthMm, height: pageHeightMm, } = PAGE_DIMENSIONS[this.opts.pageSize || "A4"] || PAGE_DIMENSIONS.A4;
|
|
122
|
+
const marginTopMm = this.opts.margin;
|
|
123
|
+
const marginBottomMm = this.opts.margin + 8;
|
|
124
|
+
// Set viewport width to match PDF content width for accurate measurements
|
|
125
|
+
const contentWidthPx = Math.round(((pageWidthMm - 2 * this.opts.margin) * 96) / 25.4);
|
|
126
|
+
yield page.setViewport({ width: contentWidthPx, height: 800 });
|
|
127
|
+
yield page.setContent(html, { waitUntil: "domcontentloaded" });
|
|
128
|
+
const printableHeightPx = Math.floor(((pageHeightMm - marginTopMm - marginBottomMm) * 96) / 25.4);
|
|
129
|
+
yield page.evaluate(({ printableHeightPx }) => {
|
|
130
|
+
const summary = document.querySelector(".summary-final");
|
|
131
|
+
if (!summary)
|
|
132
|
+
return;
|
|
133
|
+
// Remove CSS auto margin to measure natural position
|
|
134
|
+
summary.style.marginTop = "0";
|
|
135
|
+
const summaryTop = summary.getBoundingClientRect().top + window.scrollY;
|
|
136
|
+
const summaryHeight = summary.getBoundingClientRect().height;
|
|
137
|
+
if (summaryHeight >= printableHeightPx)
|
|
138
|
+
return;
|
|
139
|
+
// Calculate which page the content ends on and push summary to its bottom
|
|
140
|
+
// Subtract a small buffer to prevent rounding differences from
|
|
141
|
+
// pushing the summary past the page boundary
|
|
142
|
+
const contentEnd = summaryTop + summaryHeight;
|
|
143
|
+
const numPages = Math.ceil(contentEnd / printableHeightPx);
|
|
144
|
+
const lastPageBottom = numPages * printableHeightPx;
|
|
145
|
+
const pushDownPx = Math.max(0, Math.floor(lastPageBottom - contentEnd) - 5);
|
|
146
|
+
if (pushDownPx > 1) {
|
|
147
|
+
// Use a spacer div — margin-top gets suppressed at page tops in paged media
|
|
148
|
+
const spacer = document.createElement("div");
|
|
149
|
+
spacer.style.height = `${pushDownPx}px`;
|
|
150
|
+
summary.parentNode.insertBefore(spacer, summary);
|
|
151
|
+
}
|
|
152
|
+
}, { printableHeightPx });
|
|
153
|
+
const pdfBuffer = yield page.pdf({
|
|
154
|
+
format: pageFormat,
|
|
155
|
+
displayHeaderFooter: true,
|
|
156
|
+
headerTemplate: "<span></span>",
|
|
157
|
+
footerTemplate: `
|
|
158
|
+
<div style="font-size: 9px; width: 100%; text-align: center; padding: 0 10mm; box-sizing: border-box; border-top: 1px solid #000;">
|
|
159
|
+
<span style="float: left; padding-top: 3px; margin-left: 10mm;">${this.opts.footerText || ""}</span>
|
|
160
|
+
<span style="float: right; padding-top: 3px; margin-right: 10mm;">Pág. <span class="pageNumber"></span>/<span class="totalPages"></span></span>
|
|
161
|
+
<div style="clear: both;"></div>
|
|
162
|
+
</div>
|
|
163
|
+
`,
|
|
164
|
+
margin: {
|
|
165
|
+
top: `${this.opts.margin}mm`,
|
|
166
|
+
right: `${this.opts.margin}mm`,
|
|
167
|
+
bottom: `${this.opts.margin + 8}mm`,
|
|
168
|
+
left: `${this.opts.margin}mm`,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
return pdfBuffer;
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
yield browser.close();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
generateStream(data) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
const buffer = yield this.generate(data);
|
|
181
|
+
const stream = new stream_1.Readable();
|
|
182
|
+
stream.push(buffer);
|
|
183
|
+
stream.push(null);
|
|
184
|
+
return stream;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
_mergeBuffers(buffers) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
const { PDFDocument } = yield Promise.resolve().then(() => __importStar(require("pdf-lib")));
|
|
190
|
+
const merged = yield PDFDocument.create();
|
|
191
|
+
for (const buf of buffers) {
|
|
192
|
+
const doc = yield PDFDocument.load(buf);
|
|
193
|
+
const pages = yield merged.copyPages(doc, doc.getPageIndices());
|
|
194
|
+
for (const p of pages) {
|
|
195
|
+
merged.addPage(p);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const bytes = yield merged.save();
|
|
199
|
+
return Buffer.from(bytes);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.InvoicePdfGenerator = InvoicePdfGenerator;
|
|
204
|
+
//# sourceMappingURL=invoice-pdf-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice-pdf-generator.js","sourceRoot":"","sources":["../../src/generator/invoice-pdf-generator.ts"],"names":[],"mappings":";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AAC;QAC5B,CAAC;KAAA;CACF;AApKD,kDAoKC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { InvoicePdfGenerator } from "./generator";
|
|
2
|
+
export { InvoiceDocument } from "./templates";
|
|
3
|
+
export { compileTemplate } from "./templates/engine";
|
|
4
|
+
export type { InvoiceData, PdfGeneratorOptions, ResolvedPdfOptions, InvoiceTemplateProps, EmisorData, ReceptorData, InvoiceItem, IvaDetail, TributoDetail, ComprobanteAsociado, CopyType, } from "./types";
|
|
5
|
+
export { VOUCHER_TYPE_LETTER, VOUCHER_TYPE_DESCRIPTION, CURRENCY_SYMBOL, } from "./constants";
|
|
6
|
+
export { formatDate, formatVoucherNumber, formatCuit, formatCurrency, buildArcaQrUrl, } from "./utils";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildArcaQrUrl = exports.formatCurrency = exports.formatCuit = exports.formatVoucherNumber = exports.formatDate = exports.CURRENCY_SYMBOL = exports.VOUCHER_TYPE_DESCRIPTION = exports.VOUCHER_TYPE_LETTER = exports.compileTemplate = exports.InvoiceDocument = exports.InvoicePdfGenerator = void 0;
|
|
4
|
+
var generator_1 = require("./generator");
|
|
5
|
+
Object.defineProperty(exports, "InvoicePdfGenerator", { enumerable: true, get: function () { return generator_1.InvoicePdfGenerator; } });
|
|
6
|
+
var templates_1 = require("./templates");
|
|
7
|
+
Object.defineProperty(exports, "InvoiceDocument", { enumerable: true, get: function () { return templates_1.InvoiceDocument; } });
|
|
8
|
+
var engine_1 = require("./templates/engine");
|
|
9
|
+
Object.defineProperty(exports, "compileTemplate", { enumerable: true, get: function () { return engine_1.compileTemplate; } });
|
|
10
|
+
var constants_1 = require("./constants");
|
|
11
|
+
Object.defineProperty(exports, "VOUCHER_TYPE_LETTER", { enumerable: true, get: function () { return constants_1.VOUCHER_TYPE_LETTER; } });
|
|
12
|
+
Object.defineProperty(exports, "VOUCHER_TYPE_DESCRIPTION", { enumerable: true, get: function () { return constants_1.VOUCHER_TYPE_DESCRIPTION; } });
|
|
13
|
+
Object.defineProperty(exports, "CURRENCY_SYMBOL", { enumerable: true, get: function () { return constants_1.CURRENCY_SYMBOL; } });
|
|
14
|
+
var utils_1 = require("./utils");
|
|
15
|
+
Object.defineProperty(exports, "formatDate", { enumerable: true, get: function () { return utils_1.formatDate; } });
|
|
16
|
+
Object.defineProperty(exports, "formatVoucherNumber", { enumerable: true, get: function () { return utils_1.formatVoucherNumber; } });
|
|
17
|
+
Object.defineProperty(exports, "formatCuit", { enumerable: true, get: function () { return utils_1.formatCuit; } });
|
|
18
|
+
Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return utils_1.formatCurrency; } });
|
|
19
|
+
Object.defineProperty(exports, "buildArcaQrUrl", { enumerable: true, get: function () { return utils_1.buildArcaQrUrl; } });
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAkD;AAAzC,gHAAA,mBAAmB,OAAA;AAC5B,yCAA8C;AAArC,4GAAA,eAAe,OAAA;AACxB,6CAAqD;AAA5C,yGAAA,eAAe,OAAA;AAcxB,yCAIqB;AAHnB,gHAAA,mBAAmB,OAAA;AACnB,qHAAA,wBAAwB,OAAA;AACxB,4GAAA,eAAe,OAAA;AAEjB,iCAMiB;AALf,mGAAA,UAAU,OAAA;AACV,4GAAA,mBAAmB,OAAA;AACnB,mGAAA,UAAU,OAAA;AACV,uGAAA,cAAc,OAAA;AACd,uGAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InvoiceDocument, defaultTemplateSource } from "./invoice-document";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultTemplateSource = exports.InvoiceDocument = void 0;
|
|
4
|
+
var invoice_document_1 = require("./invoice-document");
|
|
5
|
+
Object.defineProperty(exports, "InvoiceDocument", { enumerable: true, get: function () { return invoice_document_1.InvoiceDocument; } });
|
|
6
|
+
Object.defineProperty(exports, "defaultTemplateSource", { enumerable: true, get: function () { return invoice_document_1.defaultTemplateSource; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/arca-default/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4E;AAAnE,mHAAA,eAAe,OAAA;AAAE,yHAAA,qBAAqB,OAAA"}
|