@dwast/verifactu-lib 0.1.0-beta.0 → 0.1.0-beta.1
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/dist/cjs/aeat/client.d.ts.map +1 -0
- package/dist/cjs/aeat/client.js +91 -0
- package/dist/cjs/aeat/client.js.map +1 -0
- package/dist/cjs/aeat/index.d.ts.map +1 -0
- package/dist/cjs/aeat/index.js +18 -0
- package/dist/cjs/aeat/index.js.map +1 -0
- package/dist/cjs/core/hash/chain.d.ts.map +1 -0
- package/dist/cjs/core/hash/chain.js +127 -0
- package/dist/cjs/core/hash/chain.js.map +1 -0
- package/dist/cjs/core/hash/index.d.ts.map +1 -0
- package/dist/cjs/core/hash/index.js +18 -0
- package/dist/cjs/core/hash/index.js.map +1 -0
- package/dist/cjs/core/index.d.ts.map +1 -0
- package/dist/cjs/core/index.js +21 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/core/models/event.d.ts.map +1 -0
- package/dist/cjs/core/models/event.js +3 -0
- package/dist/{core → cjs/core}/models/event.js.map +1 -1
- package/dist/cjs/core/models/index.d.ts.map +1 -0
- package/dist/cjs/core/models/index.js +19 -0
- package/dist/cjs/core/models/index.js.map +1 -0
- package/dist/cjs/core/models/invoice.d.ts.map +1 -0
- package/dist/cjs/core/models/invoice.js +3 -0
- package/dist/{core → cjs/core}/models/invoice.js.map +1 -1
- package/dist/cjs/core/qr/index.d.ts.map +1 -0
- package/dist/cjs/core/qr/index.js +18 -0
- package/dist/cjs/core/qr/index.js.map +1 -0
- package/dist/cjs/core/qr/qr.d.ts.map +1 -0
- package/dist/cjs/core/qr/qr.js +19 -0
- package/dist/cjs/core/qr/qr.js.map +1 -0
- package/dist/cjs/core/xml/generator.d.ts.map +1 -0
- package/dist/cjs/core/xml/generator.js +107 -0
- package/dist/cjs/core/xml/generator.js.map +1 -0
- package/dist/cjs/core/xml/index.d.ts.map +1 -0
- package/dist/cjs/core/xml/index.js +18 -0
- package/dist/cjs/core/xml/index.js.map +1 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/integration/index.d.ts.map +1 -0
- package/dist/cjs/integration/index.js +19 -0
- package/dist/cjs/integration/index.js.map +1 -0
- package/dist/cjs/integration/repository.d.ts.map +1 -0
- package/dist/cjs/integration/repository.js +3 -0
- package/dist/cjs/integration/repository.js.map +1 -0
- package/dist/cjs/integration/service.d.ts.map +1 -0
- package/dist/cjs/integration/service.js +144 -0
- package/dist/cjs/integration/service.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/aeat/client.d.ts +57 -0
- package/dist/esm/aeat/client.d.ts.map +1 -0
- package/dist/esm/aeat/client.js.map +1 -0
- package/dist/esm/aeat/index.d.ts +2 -0
- package/dist/esm/aeat/index.d.ts.map +1 -0
- package/dist/esm/aeat/index.js.map +1 -0
- package/dist/esm/core/hash/chain.d.ts +97 -0
- package/dist/esm/core/hash/chain.d.ts.map +1 -0
- package/dist/esm/core/hash/chain.js.map +1 -0
- package/dist/esm/core/hash/index.d.ts +2 -0
- package/dist/esm/core/hash/index.d.ts.map +1 -0
- package/dist/esm/core/hash/index.js.map +1 -0
- package/dist/esm/core/index.d.ts +5 -0
- package/dist/esm/core/index.d.ts.map +1 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/models/event.d.ts +25 -0
- package/dist/esm/core/models/event.d.ts.map +1 -0
- package/dist/esm/core/models/event.js.map +1 -0
- package/dist/esm/core/models/index.d.ts +3 -0
- package/dist/esm/core/models/index.d.ts.map +1 -0
- package/dist/esm/core/models/index.js.map +1 -0
- package/dist/esm/core/models/invoice.d.ts +90 -0
- package/dist/esm/core/models/invoice.d.ts.map +1 -0
- package/dist/esm/core/models/invoice.js.map +1 -0
- package/dist/esm/core/qr/index.d.ts +2 -0
- package/dist/esm/core/qr/index.d.ts.map +1 -0
- package/dist/esm/core/qr/index.js.map +1 -0
- package/dist/esm/core/qr/qr.d.ts +13 -0
- package/dist/esm/core/qr/qr.d.ts.map +1 -0
- package/dist/esm/core/qr/qr.js.map +1 -0
- package/dist/esm/core/xml/generator.d.ts +32 -0
- package/dist/esm/core/xml/generator.d.ts.map +1 -0
- package/dist/esm/core/xml/generator.js.map +1 -0
- package/dist/esm/core/xml/index.d.ts +2 -0
- package/dist/esm/core/xml/index.d.ts.map +1 -0
- package/dist/esm/core/xml/index.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/integration/index.d.ts +3 -0
- package/dist/esm/integration/index.d.ts.map +1 -0
- package/dist/esm/integration/index.js.map +1 -0
- package/dist/esm/integration/repository.d.ts +77 -0
- package/dist/esm/integration/repository.d.ts.map +1 -0
- package/dist/esm/integration/repository.js.map +1 -0
- package/dist/esm/integration/service.d.ts +36 -0
- package/dist/esm/integration/service.d.ts.map +1 -0
- package/dist/esm/integration/service.js.map +1 -0
- package/package.json +43 -13
- package/dist/aeat/client.d.ts.map +0 -1
- package/dist/aeat/client.js.map +0 -1
- package/dist/aeat/index.d.ts.map +0 -1
- package/dist/aeat/index.js.map +0 -1
- package/dist/core/hash/chain.d.ts.map +0 -1
- package/dist/core/hash/chain.js.map +0 -1
- package/dist/core/hash/index.d.ts.map +0 -1
- package/dist/core/hash/index.js.map +0 -1
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/models/event.d.ts.map +0 -1
- package/dist/core/models/index.d.ts.map +0 -1
- package/dist/core/models/index.js.map +0 -1
- package/dist/core/models/invoice.d.ts.map +0 -1
- package/dist/core/qr/index.d.ts.map +0 -1
- package/dist/core/qr/index.js.map +0 -1
- package/dist/core/qr/qr.d.ts.map +0 -1
- package/dist/core/qr/qr.js.map +0 -1
- package/dist/core/xml/generator.d.ts.map +0 -1
- package/dist/core/xml/generator.js.map +0 -1
- package/dist/core/xml/index.d.ts.map +0 -1
- package/dist/core/xml/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integration/index.d.ts.map +0 -1
- package/dist/integration/index.js.map +0 -1
- package/dist/integration/repository.d.ts.map +0 -1
- package/dist/integration/repository.js.map +0 -1
- package/dist/integration/service.d.ts.map +0 -1
- package/dist/integration/service.js.map +0 -1
- /package/dist/{aeat → cjs/aeat}/client.d.ts +0 -0
- /package/dist/{aeat → cjs/aeat}/index.d.ts +0 -0
- /package/dist/{core → cjs/core}/hash/chain.d.ts +0 -0
- /package/dist/{core → cjs/core}/hash/index.d.ts +0 -0
- /package/dist/{core → cjs/core}/index.d.ts +0 -0
- /package/dist/{core → cjs/core}/models/event.d.ts +0 -0
- /package/dist/{core → cjs/core}/models/index.d.ts +0 -0
- /package/dist/{core → cjs/core}/models/invoice.d.ts +0 -0
- /package/dist/{core → cjs/core}/qr/index.d.ts +0 -0
- /package/dist/{core → cjs/core}/qr/qr.d.ts +0 -0
- /package/dist/{core → cjs/core}/xml/generator.d.ts +0 -0
- /package/dist/{core → cjs/core}/xml/index.d.ts +0 -0
- /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/dist/{integration → cjs/integration}/index.d.ts +0 -0
- /package/dist/{integration → cjs/integration}/repository.d.ts +0 -0
- /package/dist/{integration → cjs/integration}/service.d.ts +0 -0
- /package/dist/{aeat → esm/aeat}/client.js +0 -0
- /package/dist/{aeat → esm/aeat}/index.js +0 -0
- /package/dist/{core → esm/core}/hash/chain.js +0 -0
- /package/dist/{core → esm/core}/hash/index.js +0 -0
- /package/dist/{core → esm/core}/index.js +0 -0
- /package/dist/{core → esm/core}/models/event.js +0 -0
- /package/dist/{core → esm/core}/models/index.js +0 -0
- /package/dist/{core → esm/core}/models/invoice.js +0 -0
- /package/dist/{core → esm/core}/qr/index.js +0 -0
- /package/dist/{core → esm/core}/qr/qr.js +0 -0
- /package/dist/{core → esm/core}/xml/generator.js +0 -0
- /package/dist/{core → esm/core}/xml/index.js +0 -0
- /package/dist/{index.js → esm/index.js} +0 -0
- /package/dist/{integration → esm/integration}/index.js +0 -0
- /package/dist/{integration → esm/integration}/repository.js +0 -0
- /package/dist/{integration → esm/integration}/service.js +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
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("./repository.js"), exports);
|
|
18
|
+
__exportStar(require("./service.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,+CAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../../src/integration/repository.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,SAA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AAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACpD,kEAAkE;IAClE,aAAa,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC9C,mCAAmC;IACnC,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,6CAA6C;IAC7C,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC1D,wBAAwB;IACxB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../../src/integration/repository.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/integration/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,UAAU,EAAE,mBAAmB,EAC/B,MAAM,EAAE,eAAe;IAG1C;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;IAmD9D;;;;;OAKG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA8D5D;;;;;;OAMG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;CAOzF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerifactuService = void 0;
|
|
4
|
+
const generator_js_1 = require("../core/xml/generator.js");
|
|
5
|
+
const chain_js_1 = require("../core/hash/chain.js");
|
|
6
|
+
const qr_js_1 = require("../core/qr/qr.js");
|
|
7
|
+
/**
|
|
8
|
+
* Servicio de orquestación de Verifactu.
|
|
9
|
+
*
|
|
10
|
+
* Une el núcleo puro (generación XML + hash) con el cliente AEAT y la
|
|
11
|
+
* persistencia. El sistema consumidor DEBE proporcionar un repositorio que
|
|
12
|
+
* implemente `VerifactuRepository` (ver `repository.ts` y `schema.sql`).
|
|
13
|
+
*/
|
|
14
|
+
class VerifactuService {
|
|
15
|
+
repository;
|
|
16
|
+
client;
|
|
17
|
+
constructor(repository, client) {
|
|
18
|
+
this.repository = repository;
|
|
19
|
+
this.client = client;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Registra una factura: genera el XML, calcula el hash encadenado, guarda
|
|
23
|
+
* el registro y lo envía a AEAT, persistiendo la respuesta.
|
|
24
|
+
*/
|
|
25
|
+
async registerInvoice(invoice) {
|
|
26
|
+
// 1. Obtener el hash del último registro para encadenar.
|
|
27
|
+
const last = await this.repository.getLastRecord();
|
|
28
|
+
const previousHash = last?.hash ?? null;
|
|
29
|
+
// 2. Generar XML y calcular la huella (hash) del registro.
|
|
30
|
+
const xml = (0, generator_js_1.generateInvoiceXml)(invoice, previousHash);
|
|
31
|
+
const hash = (0, chain_js_1.computeRegistroAlta)({
|
|
32
|
+
idEmisorFactura: invoice.emisor.nif,
|
|
33
|
+
numSerieFactura: `${invoice.id.serie ?? ''}${invoice.id.numero}`,
|
|
34
|
+
fechaExpedicionFactura: invoice.id.fechaExpedicion,
|
|
35
|
+
tipoFactura: invoice.tipoFactura,
|
|
36
|
+
cuotaTotal: invoice.desglose.cuotaTotal.toFixed(2),
|
|
37
|
+
importeTotal: invoice.desglose.importeTotal.toFixed(2),
|
|
38
|
+
huellaAnterior: previousHash,
|
|
39
|
+
fechaHoraHusoGenRegistro: new Date().toISOString(),
|
|
40
|
+
});
|
|
41
|
+
// 3. Persistir el registro como PENDING.
|
|
42
|
+
const now = new Date().toISOString();
|
|
43
|
+
const record = {
|
|
44
|
+
id: `${invoice.id.serie ?? ''}${invoice.id.numero}`,
|
|
45
|
+
invoiceId: `${invoice.id.serie ?? ''}${invoice.id.numero}`,
|
|
46
|
+
xml,
|
|
47
|
+
hash,
|
|
48
|
+
previousHash,
|
|
49
|
+
qrPayload: (0, qr_js_1.buildQrPayload)(hash),
|
|
50
|
+
status: 'PENDING',
|
|
51
|
+
createdAt: now,
|
|
52
|
+
updatedAt: now,
|
|
53
|
+
};
|
|
54
|
+
await this.repository.saveRecord(record);
|
|
55
|
+
// 4. Enviar a AEAT y persistir la respuesta.
|
|
56
|
+
const result = await this.client.sendRecord(xml);
|
|
57
|
+
await this.repository.saveResponse({
|
|
58
|
+
id: `${record.id}-${Date.now()}`,
|
|
59
|
+
recordId: record.id,
|
|
60
|
+
operationId: result.operationId,
|
|
61
|
+
status: result.status,
|
|
62
|
+
message: result.message,
|
|
63
|
+
receivedAt: new Date().toISOString(),
|
|
64
|
+
});
|
|
65
|
+
// 5. Actualizar el estado del registro según la respuesta.
|
|
66
|
+
const status = result.status === 'OK' ? 'CONFIRMED' : 'REJECTED';
|
|
67
|
+
await this.repository.updateRecordStatus(record.id, status);
|
|
68
|
+
return { ...record, status };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Anula una factura previamente registrada.
|
|
72
|
+
*
|
|
73
|
+
* Genera un registro de anulación que referencia la factura anulada,
|
|
74
|
+
* lo envía a AEAT y marca la factura original como ANNULLED.
|
|
75
|
+
*/
|
|
76
|
+
async annulInvoice(invoiceId) {
|
|
77
|
+
// 1. Obtener la factura original (para su huella) y el último registro.
|
|
78
|
+
const original = await this.repository.getRecord(invoiceId);
|
|
79
|
+
if (!original) {
|
|
80
|
+
throw new Error(`No existe el registro a anular: ${invoiceId}`);
|
|
81
|
+
}
|
|
82
|
+
const last = await this.repository.getLastRecord();
|
|
83
|
+
const previousHash = last?.hash ?? null;
|
|
84
|
+
// 2. Generar XML de anulación y calcular la huella.
|
|
85
|
+
const xml = (0, generator_js_1.generateAnulacionXml)({
|
|
86
|
+
idEmisorFacturaAnulada: original.invoiceId,
|
|
87
|
+
numSerieFacturaAnulada: original.invoiceId,
|
|
88
|
+
fechaExpedicionFacturaAnulada: new Date().toISOString().slice(0, 10),
|
|
89
|
+
huellaFacturaAnulada: original.hash,
|
|
90
|
+
}, previousHash);
|
|
91
|
+
const hash = (0, chain_js_1.computeRegistroAnulacion)({
|
|
92
|
+
idEmisorFacturaAnulada: original.invoiceId,
|
|
93
|
+
numSerieFacturaAnulada: original.invoiceId,
|
|
94
|
+
fechaExpedicionFacturaAnulada: new Date().toISOString().slice(0, 10),
|
|
95
|
+
huellaAnterior: previousHash,
|
|
96
|
+
fechaHoraHusoGenRegistro: new Date().toISOString(),
|
|
97
|
+
});
|
|
98
|
+
// 3. Persistir el registro de anulación como PENDING.
|
|
99
|
+
const now = new Date().toISOString();
|
|
100
|
+
const record = {
|
|
101
|
+
id: `${invoiceId}-ANUL`,
|
|
102
|
+
invoiceId,
|
|
103
|
+
xml,
|
|
104
|
+
hash,
|
|
105
|
+
previousHash,
|
|
106
|
+
status: 'PENDING',
|
|
107
|
+
createdAt: now,
|
|
108
|
+
updatedAt: now,
|
|
109
|
+
};
|
|
110
|
+
await this.repository.saveRecord(record);
|
|
111
|
+
// 4. Enviar a AEAT y persistir la respuesta.
|
|
112
|
+
const result = await this.client.sendRecord(xml);
|
|
113
|
+
await this.repository.saveResponse({
|
|
114
|
+
id: `${record.id}-${Date.now()}`,
|
|
115
|
+
recordId: record.id,
|
|
116
|
+
operationId: result.operationId,
|
|
117
|
+
status: result.status,
|
|
118
|
+
message: result.message,
|
|
119
|
+
receivedAt: new Date().toISOString(),
|
|
120
|
+
});
|
|
121
|
+
// 5. Actualizar estados.
|
|
122
|
+
const status = result.status === 'OK' ? 'CONFIRMED' : 'REJECTED';
|
|
123
|
+
await this.repository.updateRecordStatus(record.id, status);
|
|
124
|
+
if (result.status === 'OK') {
|
|
125
|
+
await this.repository.updateRecordStatus(invoiceId, 'ANNULLED');
|
|
126
|
+
}
|
|
127
|
+
return { ...record, status };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Modifica una factura previamente registrada.
|
|
131
|
+
*
|
|
132
|
+
* Verifactu no tiene un tipo "modificación": se implementa como anulación
|
|
133
|
+
* del registro original + alta con los datos corregidos. El usuario solo
|
|
134
|
+
* envía la referencia a la factura original y la factura corregida.
|
|
135
|
+
*/
|
|
136
|
+
async modifyInvoice(invoiceId, correctedInvoice) {
|
|
137
|
+
// 1. Anular la factura original.
|
|
138
|
+
await this.annulInvoice(invoiceId);
|
|
139
|
+
// 2. Emitir la factura corregida como un nuevo alta.
|
|
140
|
+
return this.registerInvoice(correctedInvoice);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.VerifactuService = VerifactuService;
|
|
144
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/integration/service.ts"],"names":[],"mappings":";;;AACA,2DAAoF;AACpF,oDAAsF;AACtF,4CAAkD;AAIlD;;;;;;GAMG;AACH,MAAa,gBAAgB;IAER;IACA;IAFnB,YACmB,UAA+B,EAC/B,MAAuB;QADvB,eAAU,GAAV,UAAU,CAAqB;QAC/B,WAAM,GAAN,MAAM,CAAiB;IACvC,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,eAAe,CAAC,OAAgB;QACpC,yDAAyD;QACzD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;QACnD,MAA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AM,CAAC,OAAO;YACvB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC,CAAC,CAAC;QAEH,yBAAyB;QACzB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC;QACjE,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,SAAiB,EAAE,gBAAyB;QAC9D,iCAAiC;QACjC,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAEnC,qDAAqD;QACrD,OAAO,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;IAChD,CAAC;CACF;AA/ID,4CA+IC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cliente para los servicios web de AEAT (Verifactu).
|
|
3
|
+
*
|
|
4
|
+
* Capa de red, separada del núcleo puro. Depende de credenciales y entornos
|
|
5
|
+
* (producción vs. pruebas), por lo que no debe acoplarse a la lógica de
|
|
6
|
+
* negocio.
|
|
7
|
+
*
|
|
8
|
+
* NOTA: los endpoints y el formato de petición/respuesta deben ajustarse a
|
|
9
|
+
* la documentación oficial de la AEAT (remisión voluntaria / bajo
|
|
10
|
+
* requerimiento). Este cliente expone una implementación base con `fetch`
|
|
11
|
+
* y rutas configurables.
|
|
12
|
+
*/
|
|
13
|
+
export interface VerifactuClientConfig {
|
|
14
|
+
/** URL base del servicio AEAT. */
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
/** Token de autenticación (OAuth) o certificado. */
|
|
17
|
+
authToken?: string;
|
|
18
|
+
/** Ruta del endpoint de envío de registros. */
|
|
19
|
+
sendPath?: string;
|
|
20
|
+
/** Ruta del endpoint de consulta de estado. */
|
|
21
|
+
statusPath?: string;
|
|
22
|
+
/** Timeout de petición en ms. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface SendResult {
|
|
26
|
+
/** Identificador de la operación devuelto por AEAT. */
|
|
27
|
+
operationId: string;
|
|
28
|
+
/** Estado de la respuesta. */
|
|
29
|
+
status: 'OK' | 'ERROR';
|
|
30
|
+
/** Mensaje de la AEAT. */
|
|
31
|
+
message?: string;
|
|
32
|
+
/** Código de error de AEAT (si lo hay). */
|
|
33
|
+
errorCode?: string;
|
|
34
|
+
/** Cuerpo completo de la respuesta (para auditoría). */
|
|
35
|
+
rawResponse?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Cliente de servicios AEAT para Verifactu.
|
|
39
|
+
*/
|
|
40
|
+
export declare class VerifactuClient {
|
|
41
|
+
private readonly config;
|
|
42
|
+
constructor(config: VerifactuClientConfig);
|
|
43
|
+
/**
|
|
44
|
+
* Envía un registro (factura o evento) a AEAT.
|
|
45
|
+
*/
|
|
46
|
+
sendRecord(xml: string): Promise<SendResult>;
|
|
47
|
+
/**
|
|
48
|
+
* Consulta el estado de una operación enviada.
|
|
49
|
+
*/
|
|
50
|
+
getOperationStatus(operationId: string): Promise<SendResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Parsea la respuesta de AEAT. La estructura exacta depende del servicio;
|
|
53
|
+
* este es un mapeo base que el consumidor puede sobrescribir.
|
|
54
|
+
*/
|
|
55
|
+
protected parseResponse(raw: string, httpStatus: number): SendResult;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/aeat/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,8BAA8B;IAC9B,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;IACvB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAUD;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE5B,MAAM,EAAE,qBAAqB;IASzC;;OAEG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA0BlD;;OAEG;IACG,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAkBlE;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU;CAqBrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/aeat/client.ts"],"names":[],"mappings":"AA8CA;;GAEG;AACH,MAAM,OAAO,eAAe;IACT,MAAM,CAAiB;IAExC,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG;YAC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,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;gBACpD,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YACvB,CAAC;YACD,OAAO,GAAG,IAAI,CAAC,OAA6B,CAAC;YAC7C,SAAS,GAAG,IAAI,CAAC,SAA+B,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,yDAAyD;YACzD,OAAO,GAAG,GAAG,CAAC;QAChB,CAAC;QAED,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/aeat/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/aeat/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calcula el hash SHA-256 de un dato en hexadecimal MAYÚSCULA.
|
|
3
|
+
* Verifactu exige el hash en hexadecimal en mayúsculas (64 caracteres).
|
|
4
|
+
*/
|
|
5
|
+
export declare function sha256(data: string | Buffer): string;
|
|
6
|
+
/**
|
|
7
|
+
* Concatena los campos de un registro en el formato Verifactu:
|
|
8
|
+
* `nombreCampo1=valor1&nombreCampo2=valor2&...`
|
|
9
|
+
*
|
|
10
|
+
* Reglas de normalización (AEAT):
|
|
11
|
+
* - Se eliminan los espacios al inicio y final de cada valor (trim).
|
|
12
|
+
* - Los campos vacíos o ausentes se incluyen como `nombreCampo=` (sin valor).
|
|
13
|
+
* - No se aplica URL-encoding ni escaping a caracteres especiales.
|
|
14
|
+
*/
|
|
15
|
+
export declare function concatenateFields(fields: Array<[string, string | null | undefined]>): string;
|
|
16
|
+
/**
|
|
17
|
+
* Campos de un registro de alta (RegistroAlta) para el cálculo de la huella.
|
|
18
|
+
*/
|
|
19
|
+
export interface RegistroAltaInput {
|
|
20
|
+
/** Identificador del emisor (NIF). */
|
|
21
|
+
idEmisorFactura: string;
|
|
22
|
+
/** Número y serie de la factura. */
|
|
23
|
+
numSerieFactura: string;
|
|
24
|
+
/** Fecha de expedición de la factura. */
|
|
25
|
+
fechaExpedicionFactura: string;
|
|
26
|
+
/** Tipo de factura (F1, F2, ...). */
|
|
27
|
+
tipoFactura: string;
|
|
28
|
+
/** Cuota total. */
|
|
29
|
+
cuotaTotal: string;
|
|
30
|
+
/** Importe total. */
|
|
31
|
+
importeTotal: string;
|
|
32
|
+
/** Huella (hash) del registro anterior, o null para el primero. */
|
|
33
|
+
huellaAnterior: string | null;
|
|
34
|
+
/** Fecha/hora de generación con huso horario. */
|
|
35
|
+
fechaHoraHusoGenRegistro: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Campos de un registro de anulación (RegistroAnulacion).
|
|
39
|
+
*/
|
|
40
|
+
export interface RegistroAnulacionInput {
|
|
41
|
+
/** Identificador del emisor de la factura anulada. */
|
|
42
|
+
idEmisorFacturaAnulada: string;
|
|
43
|
+
/** Número y serie de la factura anulada. */
|
|
44
|
+
numSerieFacturaAnulada: string;
|
|
45
|
+
/** Fecha de expedición de la factura anulada. */
|
|
46
|
+
fechaExpedicionFacturaAnulada: string;
|
|
47
|
+
/** Huella (hash) del registro anterior. */
|
|
48
|
+
huellaAnterior: string | null;
|
|
49
|
+
/** Fecha/hora de generación con huso horario. */
|
|
50
|
+
fechaHoraHusoGenRegistro: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Construye la cadena canónica a hashear de un registro de alta.
|
|
54
|
+
*/
|
|
55
|
+
export declare function concatenateRegistroAlta(input: RegistroAltaInput): string;
|
|
56
|
+
/**
|
|
57
|
+
* Construye la cadena canónica a hashear de un registro de anulación.
|
|
58
|
+
*/
|
|
59
|
+
export declare function concatenateRegistroAnulacion(input: RegistroAnulacionInput): string;
|
|
60
|
+
/**
|
|
61
|
+
* Calcula la huella (hash) de un registro de alta.
|
|
62
|
+
*/
|
|
63
|
+
export declare function computeRegistroAlta(input: RegistroAltaInput): string;
|
|
64
|
+
/**
|
|
65
|
+
* Calcula la huella (hash) de un registro de anulación.
|
|
66
|
+
*/
|
|
67
|
+
export declare function computeRegistroAnulacion(input: RegistroAnulacionInput): string;
|
|
68
|
+
/**
|
|
69
|
+
* Verifica que el hash de un registro de alta coincide con el esperado.
|
|
70
|
+
*/
|
|
71
|
+
export declare function verifyRegistroAlta(input: RegistroAltaInput, expectedHash: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Verifica que el hash de un registro de anulación coincide con el esperado.
|
|
74
|
+
*/
|
|
75
|
+
export declare function verifyRegistroAnulacion(input: RegistroAnulacionInput, expectedHash: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Cadena de hash con estado, para encadenar registros de forma secuencial.
|
|
78
|
+
*/
|
|
79
|
+
export declare class HashChain {
|
|
80
|
+
private _lastHash;
|
|
81
|
+
private _count;
|
|
82
|
+
/** Hash del último registro encadenado, o `null` si aún no hay ninguno. */
|
|
83
|
+
get lastHash(): string | null;
|
|
84
|
+
/** Número de registros encadenados hasta ahora. */
|
|
85
|
+
get count(): number;
|
|
86
|
+
/**
|
|
87
|
+
* Encadena un nuevo registro de alta y devuelve su huella.
|
|
88
|
+
*/
|
|
89
|
+
pushAlta(input: Omit<RegistroAltaInput, 'huellaAnterior'>): string;
|
|
90
|
+
/**
|
|
91
|
+
* Encadena un nuevo registro de anulación y devuelve su huella.
|
|
92
|
+
*/
|
|
93
|
+
pushAnulacion(input: Omit<RegistroAnulacionInput, 'huellaAnterior'>): string;
|
|
94
|
+
/** Reinicia la cadena. */
|
|
95
|
+
reset(): void;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../src/core/hash/chain.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAO5F;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iDAAiD;IACjD,wBAAwB,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,sDAAsD;IACtD,sBAAsB,EAAE,MAAM,CAAC;IAC/B,4CAA4C;IAC5C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iDAAiD;IACjD,6BAA6B,EAAE,MAAM,CAAC;IACtC,2CAA2C;IAC3C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iDAAiD;IACjD,wBAAwB,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAWxE;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,KAA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,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0BAA0B;IAC1B,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/hash/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/hash/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos de evento de registro Verifactu.
|
|
3
|
+
* - ALTA: alta de una factura.
|
|
4
|
+
* - ANULACION: anulación de una factura previamente registrada.
|
|
5
|
+
* - MODIFICACION: modificación de una factura.
|
|
6
|
+
*/
|
|
7
|
+
export type EventType = 'ALTA' | 'ANULACION' | 'MODIFICACION';
|
|
8
|
+
/**
|
|
9
|
+
* Evento de registro Verifactu.
|
|
10
|
+
*/
|
|
11
|
+
export interface Event {
|
|
12
|
+
/** Tipo de evento. */
|
|
13
|
+
type: EventType;
|
|
14
|
+
/** Fecha/hora del evento en formato ISO 8601. */
|
|
15
|
+
fechaHora: string;
|
|
16
|
+
/** Referencia a la factura asociada. */
|
|
17
|
+
invoiceId: string;
|
|
18
|
+
/** Motivo de anulación (obligatorio si type === 'ANULACION'). */
|
|
19
|
+
motivoAnulacion?: string;
|
|
20
|
+
/** Referencia a la factura que se anula (para ANULACION). */
|
|
21
|
+
facturaAnulada?: string;
|
|
22
|
+
/** Metadatos adicionales. */
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../../src/core/models/event.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,cAAc,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,sBAAsB;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../../src/core/models/event.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datos identificativos del emisor de la factura.
|
|
3
|
+
* Verifactu exige identificar al emisor (NIF, nombre/razón social).
|
|
4
|
+
*/
|
|
5
|
+
export interface Emisor {
|
|
6
|
+
/** NIF del emisor. */
|
|
7
|
+
nif: string;
|
|
8
|
+
/** Nombre o razón social. */
|
|
9
|
+
nombreRazon: string;
|
|
10
|
+
/** Código de país (ISO 3166-1 alpha-2). Opcional si es España. */
|
|
11
|
+
pais?: string;
|
|
12
|
+
/** Código postal. */
|
|
13
|
+
codigoPostal?: string;
|
|
14
|
+
/** Municipio. */
|
|
15
|
+
municipio?: string;
|
|
16
|
+
/** Dirección. */
|
|
17
|
+
direccion?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Identificación de la factura.
|
|
21
|
+
*/
|
|
22
|
+
export interface FacturaId {
|
|
23
|
+
/** Serie de la factura (opcional). */
|
|
24
|
+
serie?: string;
|
|
25
|
+
/** Número de la factura. */
|
|
26
|
+
numero: string;
|
|
27
|
+
/** Fecha de expedición en formato ISO (YYYY-MM-DD). */
|
|
28
|
+
fechaExpedicion: string;
|
|
29
|
+
/** Fecha de operación (opcional). */
|
|
30
|
+
fechaOperacion?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Tipo de factura Verifactu (F1–F9).
|
|
34
|
+
*/
|
|
35
|
+
export type TipoFactura = 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9';
|
|
36
|
+
/**
|
|
37
|
+
* Tipo de desglose Verifactu (S1–S6).
|
|
38
|
+
*/
|
|
39
|
+
export type TipoDesglose = 'S1' | 'S2' | 'S3' | 'S4' | 'S5' | 'S6';
|
|
40
|
+
/**
|
|
41
|
+
* Detalle de IVA de una línea de desglose.
|
|
42
|
+
*/
|
|
43
|
+
export interface DetalleIva {
|
|
44
|
+
/** Tipo impositivo (%). */
|
|
45
|
+
tipoImpositivo: number;
|
|
46
|
+
/** Base imponible. */
|
|
47
|
+
baseImponible: number;
|
|
48
|
+
/** Cuota repercutida. */
|
|
49
|
+
cuotaRepercutida: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Desglose de la operación por tipo de operación e IVA.
|
|
53
|
+
*/
|
|
54
|
+
export interface DesgloseTipoOperacion {
|
|
55
|
+
/** Clave de tipo de operación (p. ej. '01'). */
|
|
56
|
+
tipoOperacion: string;
|
|
57
|
+
/** Detalles de IVA. */
|
|
58
|
+
detallesIva: DetalleIva[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Desglose completo de la factura.
|
|
62
|
+
*/
|
|
63
|
+
export interface Desglose {
|
|
64
|
+
/** Desglose por tipo de operación. */
|
|
65
|
+
tipoOperaciones: DesgloseTipoOperacion[];
|
|
66
|
+
/** Cuota total de la factura. */
|
|
67
|
+
cuotaTotal: number;
|
|
68
|
+
/** Importe total de la factura. */
|
|
69
|
+
importeTotal: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Factura en el modelo de datos Verifactu.
|
|
73
|
+
*/
|
|
74
|
+
export interface Invoice {
|
|
75
|
+
/** Identificación de la factura. */
|
|
76
|
+
id: FacturaId;
|
|
77
|
+
/** Emisor de la factura. */
|
|
78
|
+
emisor: Emisor;
|
|
79
|
+
/** Desglose de la factura. */
|
|
80
|
+
desglose: Desglose;
|
|
81
|
+
/** Tipo de factura. */
|
|
82
|
+
tipoFactura: TipoFactura;
|
|
83
|
+
/** Tipo de desglose. */
|
|
84
|
+
tipoDesglose: TipoDesglose;
|
|
85
|
+
/** Descripción de la operación. */
|
|
86
|
+
descripcion?: string;
|
|
87
|
+
/** Metadatos adicionales libres. */
|
|
88
|
+
metadata?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=invoice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice.d.ts","sourceRoot":"","sources":["../../../../src/core/models/invoice.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,sBAAsB;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACnB,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAET;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,sBAAsB;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,sCAAsC;IACtC,eAAe,EAAE,qBAAqB,EAAE,CAAC;IACzC,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,oCAAoC;IACpC,EAAE,EAAE,SAAS,CAAC;IACd,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,uBAAuB;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,wBAAwB;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice.js","sourceRoot":"","sources":["../../../../src/core/models/invoice.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/qr/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/qr/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Construye el payload del QR Verifactu.
|
|
3
|
+
*
|
|
4
|
+
* El QR Verifactu codifica una URL de verificación que incluye el hash del
|
|
5
|
+
* registro, de modo que cualquier persona pueda verificar la integridad de
|
|
6
|
+
* la factura contra la AEAT.
|
|
7
|
+
*
|
|
8
|
+
* @param hash Hash del registro (encadenado).
|
|
9
|
+
* @param baseUrl URL base de verificación de la AEAT.
|
|
10
|
+
* @param extraParams Parámetros adicionales a incluir en la URL.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildQrPayload(hash: string, baseUrl?: string, extraParams?: Record<string, string>): string;
|
|
13
|
+
//# sourceMappingURL=qr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr.d.ts","sourceRoot":"","sources":["../../../../src/core/qr/qr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,SAA8D,EACrE,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACvC,MAAM,CAGR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qr.js","sourceRoot":"","sources":["../../../../src/core/qr/qr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,OAAO,GAAG,2DAA2D,EACrE,cAAsC,EAAE;IAExC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;IAC7D,OAAO,GAAG,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Invoice } from '../models/invoice.js';
|
|
2
|
+
/**
|
|
3
|
+
* Datos de la factura que se anula.
|
|
4
|
+
*/
|
|
5
|
+
export interface AnulacionInput {
|
|
6
|
+
/** NIF del emisor de la factura anulada. */
|
|
7
|
+
idEmisorFacturaAnulada: string;
|
|
8
|
+
/** Número y serie de la factura anulada. */
|
|
9
|
+
numSerieFacturaAnulada: string;
|
|
10
|
+
/** Fecha de expedición de la factura anulada. */
|
|
11
|
+
fechaExpedicionFacturaAnulada: string;
|
|
12
|
+
/** Huella (hash) de la factura anulada. */
|
|
13
|
+
huellaFacturaAnulada: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Genera el XML Verifactu de una factura (registro de alta).
|
|
17
|
+
*
|
|
18
|
+
* Estructura basada en el RD 1007/2023 y la documentación técnica de la
|
|
19
|
+
* AEAT. NOTA: el esquema XSD oficial debe validarse antes de producción;
|
|
20
|
+
* este esqueleto refleja los bloques principales (IDFactura, IDEmisorFactura,
|
|
21
|
+
* TipoFactura, TipoDesglose, Desglose, CuotaTotal, Encadenamiento, Huella).
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateInvoiceXml(invoice: Invoice, previousHash: string | null): string;
|
|
24
|
+
/**
|
|
25
|
+
* Genera el XML Verifactu de un registro de anulación.
|
|
26
|
+
*
|
|
27
|
+
* Referencia la factura anulada (IDFactura + Huella) y encadena con el hash
|
|
28
|
+
* anterior. Estructura basada en el RD 1007/2023; validar contra el XSD
|
|
29
|
+
* oficial antes de producción.
|
|
30
|
+
*/
|
|
31
|
+
export declare function generateAnulacionXml(anulacion: AnulacionInput, previousHash: string | null): string;
|
|
32
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/core/xml/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,4CAA4C;IAC5C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iDAAiD;IACjD,6BAA6B,EAAE,MAAM,CAAC;IACtC,2CAA2C;IAC3C,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAqBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAwDxF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,cAAc,EACzB,YAAY,EAAE,MAAM,GAAG,IAAI,GAC1B,MAAM,CAqBR"}
|