facturas 0.22.1 → 0.23.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/index.mjs CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  arcaQrPayload,
8
8
  arcaQrUrl,
9
9
  assertArcaClientConfig,
10
+ calculateWsfeAmounts,
10
11
  createArcaClient,
11
12
  createArcaClientConfigFromEnv,
12
13
  createFileStore,
@@ -14,11 +15,12 @@ import {
14
15
  createWsfexService,
15
16
  describeVoucherType,
16
17
  matchWsfeVoucherIdentity,
18
+ settleVatItems,
17
19
  storeCall,
18
20
  throwIfAborted,
19
21
  voucherDateWindow,
20
22
  withLease
21
- } from "./chunk-6BLEIM5F.mjs";
23
+ } from "./chunk-GERGSYQC.mjs";
22
24
  import {
23
25
  ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
24
26
  ARCA_INVOICE_CLASS_BY_ISSUER,
@@ -30,7 +32,8 @@ import {
30
32
  createPadronService
31
33
  } from "./chunk-FSJHE4VS.mjs";
32
34
  import {
33
- createWsfeService
35
+ createWsfeService,
36
+ normalizeArcaAmountToMinorUnits
34
37
  } from "./chunk-67ISWKGE.mjs";
35
38
  import {
36
39
  createWsmtxcaService
@@ -51,6 +54,391 @@ import {
51
54
  toArcaSafeErrorMetadata
52
55
  } from "./chunk-Q7IURW54.mjs";
53
56
 
57
+ // src/services/voucher-document.ts
58
+ var PRINTED_VOUCHER_TEXT = {
59
+ /** L4, before the voucher type code. */
60
+ code: "C\xF3digo N\xBA",
61
+ /** C7, before the start of activities. */
62
+ activitiesStart: "INICIO DE ACTIVIDADES",
63
+ /** C8 and L9, before the CAE. */
64
+ cae: "C.A.E. N\xB0",
65
+ /** C9 and L9, before the CAE due date, in type of at least 12 pt. */
66
+ caeDueDate: "Fecha Vto.:",
67
+ /** L8, the title of the consumer transparency block. */
68
+ transparencyTitle: "R\xE9gimen de Transparencia Fiscal al Consumidor (Ley 27.743)",
69
+ /** L8, the VAT contained in the price. */
70
+ vatContained: "IVA Contenido",
71
+ /** L8 and C24, the other national indirect taxes. */
72
+ otherNationalIndirectTaxes: "Otros Impuestos Nacionales Indirectos"
73
+ };
74
+ var PRINTED_CAE_DUE_DATE_MIN_FONT_SIZE_PT = 12;
75
+ var ISSUER_LEGENDS = {
76
+ responsable_inscripto: "IVA RESPONSABLE INSCRIPTO",
77
+ exento: "IVA EXENTO",
78
+ no_alcanzado: "NO RESPONSABLE IVA",
79
+ monotributo: "RESPONSABLE MONOTRIBUTO",
80
+ monotributo_social: "MONOTRIBUTISTA SOCIAL",
81
+ monotributo_trabajador_independiente_promovido: "MONOTRIBUTO TRABAJADOR INDEPENDIENTE PROMOVIDO"
82
+ };
83
+ var RECEIVER_LEGENDS = {
84
+ 1: "IVA RESPONSABLE INSCRIPTO",
85
+ 4: "IVA EXENTO",
86
+ 5: "A CONSUMIDOR FINAL",
87
+ 6: "RESPONSABLE MONOTRIBUTO",
88
+ 7: "SUJETO NO CATEGORIZADO",
89
+ // Apartado A names no legend for these: ARCA's own condition names.
90
+ 8: "PROVEEDOR DEL EXTERIOR",
91
+ 9: "CLIENTE DEL EXTERIOR",
92
+ 10: "IVA LIBERADO - LEY N\xBA 19.640",
93
+ 13: "MONOTRIBUTISTA SOCIAL",
94
+ 15: "NO RESPONSABLE IVA",
95
+ 16: "MONOTRIBUTO TRABAJADOR INDEPENDIENTE PROMOVIDO"
96
+ };
97
+ var CONSUMIDOR_FINAL = 5;
98
+ var VAT_CONTAINED_RECEIVERS = /* @__PURE__ */ new Set([4, 5, 15]);
99
+ var MONOTRIBUTO_RECEIVERS = /* @__PURE__ */ new Set([6, 13, 16]);
100
+ var DOCUMENT_LABELS = {
101
+ 80: "CUIT",
102
+ 86: "CUIL",
103
+ 87: "CDI",
104
+ 94: "Pasaporte",
105
+ 96: "DNI"
106
+ };
107
+ var UNIDENTIFIED_DOCUMENT = 99;
108
+ var ARCA_OBSERVATIONS_LABEL = "Observaciones de ARCA:";
109
+ var MONOTRIBUTO_CREDIT_LEGEND = "El cr\xE9dito fiscal discriminado en el presente comprobante, s\xF3lo podr\xE1 ser computado a efectos del R\xE9gimen de Sostenimiento e Inclusi\xF3n Fiscal para Peque\xF1os Contribuyentes de la Ley N\xBA 27.618";
110
+ var NATIONAL_INDIRECT_TAX_IDS = /* @__PURE__ */ new Set([1, 4]);
111
+ var TAX_NAMES = {
112
+ 1: "Impuestos nacionales",
113
+ 2: "Impuestos provinciales",
114
+ 3: "Impuestos municipales",
115
+ 4: "Impuestos internos",
116
+ 5: "Ingresos brutos",
117
+ 6: "Percepci\xF3n de IVA",
118
+ 7: "Percepci\xF3n de ingresos brutos",
119
+ 8: "Percepciones por impuestos municipales",
120
+ 9: "Otras percepciones",
121
+ 13: "Percepci\xF3n de IVA a no categorizado",
122
+ 99: "Otros tributos"
123
+ };
124
+ var RETENTION_LEGEND_FROM = "2025-12-01";
125
+ var TITLES = {
126
+ invoice: "FACTURA",
127
+ debit_note: "NOTA DE D\xC9BITO",
128
+ credit_note: "NOTA DE CR\xC9DITO"
129
+ };
130
+ function buildVoucherDocument(input) {
131
+ const { voucher, issuer } = input;
132
+ const info = describeVoucherType(voucher.voucherType);
133
+ if (info.family === "fce") {
134
+ invalid(
135
+ "voucher.voucherType",
136
+ "a class A, B or C invoice or note: FCE vouchers are not rendered yet"
137
+ );
138
+ }
139
+ if (info.family === "retention_legend" && voucher.date < RETENTION_LEGEND_FROM) {
140
+ invalid(
141
+ "voucher.voucherType",
142
+ "a voucher issued from 2025-12-01: types 51 to 53 were class M before RG 5762"
143
+ );
144
+ }
145
+ const voucherClass = voucher.voucherClass;
146
+ assertIssuerMatchesClass(issuer.condition, voucherClass);
147
+ if (voucher.qr === void 0) {
148
+ invalid("voucher.qr", "the QR every printed voucher carries");
149
+ }
150
+ const taxId = digits(issuer.taxId);
151
+ if (taxId.length !== 11 || voucher.qrPayload !== void 0 && String(voucher.qrPayload.cuit) !== taxId) {
152
+ invalid("issuer.taxId", "the 11-digit CUIT the voucher was issued under");
153
+ }
154
+ const lines = documentLines(input, voucherClass);
155
+ const header = voucher.header;
156
+ const receiver = documentReceiver(input, header);
157
+ return {
158
+ voucherClass,
159
+ voucherType: voucher.voucherType,
160
+ code: String(voucher.voucherType).padStart(3, "0"),
161
+ ...letterLegend(info.family, voucherClass, issuer.paymentToInformedCbu),
162
+ title: TITLES[info.kind],
163
+ number: `${String(voucher.salesPoint).padStart(5, "0")}-${String(voucher.number).padStart(8, "0")}`,
164
+ issueDate: voucher.date,
165
+ issuer: {
166
+ ...issuer.tradeName ? { tradeName: required(issuer.tradeName, "issuer.tradeName") } : {},
167
+ legalName: required(issuer.legalName, "issuer.legalName"),
168
+ address: required(issuer.address, "issuer.address"),
169
+ taxId,
170
+ conditionLegend: ISSUER_LEGENDS[issuer.condition],
171
+ grossIncome: required(issuer.grossIncome, "issuer.grossIncome"),
172
+ ...activitiesStart(issuer.activitiesStartDate)
173
+ },
174
+ receiver,
175
+ saleConditions: required(input.saleConditions, "saleConditions"),
176
+ remitos: (input.remitos ?? []).map(
177
+ (remito, index) => required(remito, `remitos[${index}]`)
178
+ ),
179
+ ...header.serviceStartDate && header.serviceEndDate ? {
180
+ servicePeriod: {
181
+ from: header.serviceStartDate,
182
+ to: header.serviceEndDate
183
+ }
184
+ } : {},
185
+ ...header.paymentDueDate ? { paymentDueDate: header.paymentDueDate } : {},
186
+ currency: {
187
+ id: header.currencyId,
188
+ ...header.currencyId !== "PES" && header.exchangeRate !== void 0 ? { exchangeRate: header.exchangeRate } : {}
189
+ },
190
+ lines: lines.lines,
191
+ totals: {
192
+ subtotal: lines.subtotal,
193
+ exempt: voucher.totals.exempt,
194
+ untaxed: voucher.totals.untaxed,
195
+ vatRates: voucherClass === "A" ? voucher.totals.vatRates : [],
196
+ otherTaxes: voucher.totals.taxes.map((tax) => ({
197
+ id: tax.id,
198
+ description: tax.description ?? TAX_NAMES[tax.id] ?? "Otros tributos",
199
+ amount: tax.amount
200
+ })),
201
+ adjustment: lines.adjustment,
202
+ total: voucher.totals.total
203
+ },
204
+ ...voucherClass === "B" && VAT_CONTAINED_RECEIVERS.has(header.receiverVatConditionId) ? {
205
+ transparency: {
206
+ vatContained: voucher.totals.vat,
207
+ otherNationalIndirectTaxes: voucher.totals.taxes.filter((tax) => NATIONAL_INDIRECT_TAX_IDS.has(tax.id)).reduce((sum, tax) => sum + tax.amount, 0)
208
+ }
209
+ } : {},
210
+ authorization: {
211
+ kind: "CAE",
212
+ code: voucher.cae,
213
+ dueDate: voucher.caeExpiry
214
+ },
215
+ qr: voucher.qr,
216
+ legends: legends(input, voucherClass)
217
+ };
218
+ }
219
+ function letterLegend(family, voucherClass, paymentToInformedCbu) {
220
+ if (family === "retention_legend") {
221
+ return { letterLegend: "OPERACI\xD3N SUJETA A RETENCI\xD3N" };
222
+ }
223
+ return voucherClass === "A" && paymentToInformedCbu === true ? { letterLegend: "PAGO EN CBU INFORMADA" } : {};
224
+ }
225
+ function legends(input, voucherClass) {
226
+ if (voucherClass !== "A") {
227
+ return [];
228
+ }
229
+ const found = [];
230
+ if (MONOTRIBUTO_RECEIVERS.has(input.voucher.header.receiverVatConditionId)) {
231
+ found.push({ rule: "G1", text: MONOTRIBUTO_CREDIT_LEGEND });
232
+ }
233
+ const codes = [
234
+ ...new Set(
235
+ (input.observations ?? []).map((observation) => String(observation.code ?? "").trim()).filter((code) => code !== "")
236
+ )
237
+ ];
238
+ if (codes.length > 0) {
239
+ found.push({
240
+ rule: "G3",
241
+ text: `${ARCA_OBSERVATIONS_LABEL} ${codes.join(", ")}`
242
+ });
243
+ }
244
+ return found;
245
+ }
246
+ function assertIssuerMatchesClass(condition, voucherClass) {
247
+ if (!Object.hasOwn(ISSUER_LEGENDS, condition)) {
248
+ invalid("issuer.condition", Object.keys(ISSUER_LEGENDS).join(", "));
249
+ }
250
+ const vatRegistered = condition === "responsable_inscripto";
251
+ if (vatRegistered !== (voucherClass !== "C")) {
252
+ invalid(
253
+ "issuer.condition",
254
+ vatRegistered ? "a condition that issues class C vouchers" : "responsable_inscripto, the only condition that issues class A and B vouchers"
255
+ );
256
+ }
257
+ }
258
+ function documentReceiver(input, header) {
259
+ const condition = header.receiverVatConditionId;
260
+ const conditionLegend = RECEIVER_LEGENDS[condition];
261
+ if (conditionLegend === void 0) {
262
+ invalid(
263
+ "voucher.header.receiverVatConditionId",
264
+ "a receiver condition the SDK renders: 1, 4 to 10, 13, 15 or 16"
265
+ );
266
+ }
267
+ const name = input.receiver?.name?.trim();
268
+ const address = input.receiver?.address?.trim();
269
+ if (condition !== CONSUMIDOR_FINAL) {
270
+ required(name, "receiver.name");
271
+ required(address, "receiver.address");
272
+ }
273
+ const identified = header.documentType !== UNIDENTIFIED_DOCUMENT && /[1-9]/.test(header.documentNumber);
274
+ if (!identified && condition !== CONSUMIDOR_FINAL) {
275
+ throw new ArcaInputError(
276
+ "Only a consumidor final may be unidentified on a printed voucher.",
277
+ {
278
+ code: "ARCA_INPUT_MISSING_FIELD",
279
+ field: "voucher.header.documentNumber",
280
+ expected: "the receiver's document (C13 to C17)"
281
+ }
282
+ );
283
+ }
284
+ const label = DOCUMENT_LABELS[header.documentType];
285
+ return {
286
+ conditionLegend,
287
+ ...name ? { name } : {},
288
+ ...address ? { address } : {},
289
+ ...identified ? {
290
+ document: {
291
+ type: header.documentType,
292
+ ...label === void 0 ? {} : { label },
293
+ number: header.documentNumber
294
+ }
295
+ } : {}
296
+ };
297
+ }
298
+ function documentLines(input, voucherClass) {
299
+ const { items } = input;
300
+ const totals = input.voucher.totals;
301
+ if (!Array.isArray(items) || items.length === 0) {
302
+ invalid("items", "the items the voucher was issued from");
303
+ }
304
+ let computed;
305
+ try {
306
+ computed = calculateWsfeAmounts({
307
+ voucherClass,
308
+ items,
309
+ total: totals.total - totals.otherTaxes
310
+ });
311
+ } catch (error) {
312
+ if (error instanceof ArcaInputError && error.code === "ARCA_INPUT_AMOUNT_MISMATCH") {
313
+ mismatch("total");
314
+ }
315
+ throw error;
316
+ }
317
+ assertItemsMatchTotals(computed.data, totals, voucherClass);
318
+ const settled = voucherClass === "C" ? void 0 : settleVatItems({ voucherClass, items }, computed.amounts.vatAdjustment);
319
+ const lines = items.map((item, index) => {
320
+ const path = `items[${index}]`;
321
+ const money = settled?.items[index];
322
+ const amount = money === void 0 ? item.amount : voucherClass === "A" ? money.amount - money.vat : money.amount;
323
+ return {
324
+ ...item.code === void 0 ? {} : { code: item.code },
325
+ description: required(item.description, `${path}.description`),
326
+ ...lineQuantity(item, amount, path),
327
+ ...item.unit === void 0 ? {} : { unit: item.unit },
328
+ ...item.discount ? { discount: item.discount } : {},
329
+ amount,
330
+ ...voucherClass === "A" && money !== void 0 ? { vatRate: money.rate } : {}
331
+ };
332
+ });
333
+ const sum = lines.reduce((total, line) => total + line.amount, 0);
334
+ if (voucherClass === "A") {
335
+ const rows = totals.vatRates.reduce((total, row) => total + row.amount, 0);
336
+ return {
337
+ lines,
338
+ subtotal: totals.netTaxed,
339
+ adjustment: totals.vat - rows
340
+ };
341
+ }
342
+ return { lines, subtotal: sum, adjustment: settled?.unabsorbed ?? 0 };
343
+ }
344
+ function assertItemsMatchTotals(data, totals, voucherClass) {
345
+ const minor = (value) => Number(normalizeArcaAmountToMinorUnits(value, "items"));
346
+ for (const [field, value, authorized] of [
347
+ ["netTaxed", data.netAmount, totals.netTaxed],
348
+ ["exempt", data.exemptAmount, totals.exempt],
349
+ ["untaxed", data.nonTaxableAmount, totals.untaxed],
350
+ ["vat", data.vatAmount, totals.vat]
351
+ ]) {
352
+ if (minor(value) !== authorized) {
353
+ mismatch(field);
354
+ }
355
+ }
356
+ if (voucherClass === "C") {
357
+ return;
358
+ }
359
+ const bases = (rows) => rows.filter((row) => row.base !== 0).map((row) => `${row.id}:${row.base}`).sort().join(",");
360
+ const computedBases = (data.vatRates ?? []).map((row) => ({
361
+ id: row.id,
362
+ base: minor(row.baseAmount)
363
+ }));
364
+ if (bases(computedBases) !== bases(totals.vatRates)) {
365
+ mismatch("vatRates");
366
+ }
367
+ }
368
+ function lineQuantity(item, amount, path) {
369
+ const discount = item.discount ?? 0;
370
+ if (!(Number.isSafeInteger(discount) && discount >= 0)) {
371
+ invalid(`${path}.discount`, "a non-negative safe integer in minor units");
372
+ }
373
+ if (item.quantity === void 0 && item.unitPrice === void 0) {
374
+ return { quantity: 1, unitPrice: majorUnits(amount + discount) };
375
+ }
376
+ const { quantity, unitPrice } = item;
377
+ if (!(typeof quantity === "number" && Number.isFinite(quantity) && quantity > 0)) {
378
+ invalid(`${path}.quantity`, "a positive quantity, given with unitPrice");
379
+ }
380
+ if (typeof unitPrice !== "string" || !/^\d+(\.\d{1,6})?$/.test(unitPrice)) {
381
+ invalid(
382
+ `${path}.unitPrice`,
383
+ "a major-unit decimal string with at most six decimals, given with quantity"
384
+ );
385
+ }
386
+ const printed = Math.round(quantity * Number(unitPrice) * 100) - discount;
387
+ if (Math.abs(printed - amount) > 1) {
388
+ throw new ArcaInputError(
389
+ `${path}: quantity \xD7 unitPrice \u2212 discount does not match the line amount.`,
390
+ {
391
+ code: "ARCA_INPUT_AMOUNT_MISMATCH",
392
+ field: `${path}.unitPrice`,
393
+ expected: `${amount} minor units, within one: without VAT on class A, with VAT on class B`
394
+ }
395
+ );
396
+ }
397
+ return { quantity, unitPrice };
398
+ }
399
+ function activitiesStart(date) {
400
+ if (date === null) {
401
+ return {};
402
+ }
403
+ if (typeof date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(date)) {
404
+ invalid(
405
+ "issuer.activitiesStartDate",
406
+ "YYYY-MM-DD, or null for the exceptions of RG 1415, Anexo II, A, V 6"
407
+ );
408
+ }
409
+ return { activitiesStartDate: date };
410
+ }
411
+ function majorUnits(minor) {
412
+ const cents = String(minor).padStart(3, "0");
413
+ return `${cents.slice(0, -2)}.${cents.slice(-2)}`;
414
+ }
415
+ function digits(value) {
416
+ return typeof value === "string" ? value.replace(/\D/g, "") : "";
417
+ }
418
+ function required(value, field) {
419
+ if (typeof value !== "string" || value.trim() === "") {
420
+ throw new ArcaInputError(`${field} is required on a printed voucher.`, {
421
+ code: "ARCA_INPUT_MISSING_FIELD",
422
+ field
423
+ });
424
+ }
425
+ return value.trim();
426
+ }
427
+ function mismatch(field) {
428
+ throw new ArcaInputError("items do not add up to the authorized voucher.", {
429
+ code: "ARCA_INPUT_AMOUNT_MISMATCH",
430
+ field: `items (${field})`,
431
+ expected: "the items the voucher was issued from"
432
+ });
433
+ }
434
+ function invalid(field, expected) {
435
+ throw new ArcaInputError(`${field} must be ${expected}.`, {
436
+ code: "ARCA_INPUT_INVALID_VALUE",
437
+ field,
438
+ expected
439
+ });
440
+ }
441
+
54
442
  // src/store/memory.ts
55
443
  function createMemoryStore() {
56
444
  const values = /* @__PURE__ */ new Map();
@@ -257,9 +645,13 @@ export {
257
645
  ArcaServiceError,
258
646
  ArcaSoapFaultError,
259
647
  ArcaTransportError,
648
+ MONOTRIBUTO_CREDIT_LEGEND,
649
+ PRINTED_CAE_DUE_DATE_MIN_FONT_SIZE_PT,
650
+ PRINTED_VOUCHER_TEXT,
260
651
  arcaQrPayload,
261
652
  arcaQrUrl,
262
653
  assertArcaClientConfig,
654
+ buildVoucherDocument,
263
655
  createArcaClient,
264
656
  createArcaClientConfigFromEnv,
265
657
  createFileStore,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/store/memory.ts","../src/store/postgres.ts","../src/store/redis.ts"],"sourcesContent":["import { abortable } from \"../internal/abort\";\nimport { throwIfAborted } from \"./lock\";\nimport type { ArcaStore } from \"./types\";\n\n/** In-process store for tests; reservations do not survive a restart. */\nexport function createMemoryStore(): ArcaStore {\n const values = new Map<string, string>();\n const locks = new Map<string, Promise<void>>();\n return {\n get: (key) => Promise.resolve(values.get(key) ?? null),\n set(key, value) {\n values.set(key, value);\n return Promise.resolve();\n },\n add(key, value) {\n if (values.has(key)) {\n return Promise.resolve(false);\n }\n values.set(key, value);\n return Promise.resolve(true);\n },\n delete(key) {\n values.delete(key);\n return Promise.resolve();\n },\n async withLock(key, fn, { signal } = {}) {\n throwIfAborted(signal);\n const previous = locks.get(key) ?? Promise.resolve();\n let release: () => void = () => undefined;\n const current = new Promise<void>((resolve) => {\n release = resolve;\n });\n const queued = previous.catch(() => undefined).then(() => current);\n locks.set(key, queued);\n // An abort ends the wait early; the check below reports it.\n await abortable(\n previous.catch(() => undefined),\n signal\n ).catch(() => undefined);\n if (signal?.aborted) {\n // Hand the turn on, but keep this call's place until the holder\n // before it finishes: a caller arriving now must still wait for it.\n release();\n queued.then(() => {\n if (locks.get(key) === queued) {\n locks.delete(key);\n }\n });\n throwIfAborted(signal);\n }\n try {\n return await fn();\n } finally {\n release();\n if (locks.get(key) === queued) {\n locks.delete(key);\n }\n }\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaStore, storeCall } from \"./types\";\n\ntype Row = { key?: string; value?: string };\n/** Uses the caller's SQL client; provision the table before use. */\nexport function createPostgresStore({\n query,\n table = \"arca_store\",\n}: {\n query: (text: string, params: string[]) => Promise<Row[] | { rows: Row[] }>;\n table?: string;\n}): ArcaStore {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(table)) {\n throw new ArcaConfigurationError(\"Invalid ARCA store table identifier.\");\n }\n const name = `\"${table}\"`;\n const lease = Math.round(ARCA_LEASE_MS / 1000);\n const run = (text: string, params: string[]) =>\n storeCall(async () => {\n const result = await query(text, params);\n return Array.isArray(result) ? result : result.rows;\n });\n return {\n async get(key) {\n return (\n (await run(`SELECT value FROM ${name} WHERE key = $1`, [key]))[0]\n ?.value ?? null\n );\n },\n async set(key, value) {\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = now()`,\n [key, value]\n );\n },\n async add(key, value) {\n return (\n (\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, value]\n )\n ).length > 0\n );\n },\n async delete(key) {\n await run(`DELETE FROM ${name} WHERE key = $1`, [key]);\n },\n withLock(key, fn, options) {\n // A lease row, not an advisory lock: it survives a transaction-mode\n // pooler, where a session-scoped lock would be taken on another backend.\n return withLease(\n {\n async acquire(owner) {\n const taken = await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, owner]\n );\n if (taken.length > 0) {\n return true;\n }\n const expired = await run(\n `UPDATE ${name} SET value = $2, updated_at = now() WHERE key = $1 AND updated_at < now() - interval '${lease} seconds' RETURNING key`,\n [key, owner]\n );\n return expired.length > 0;\n },\n async renew(owner) {\n await run(\n `UPDATE ${name} SET updated_at = now() WHERE key = $1 AND value = $2`,\n [key, owner]\n );\n },\n async release(owner) {\n await run(`DELETE FROM ${name} WHERE key = $1 AND value = $2`, [\n key,\n owner,\n ]);\n },\n },\n fn,\n options\n );\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaLockOptions, type ArcaStore, storeCall } from \"./types\";\n\ntype RedisClient = {\n get(key: string): Promise<unknown>;\n set(key: string, value: string): Promise<unknown>;\n call?(...args: string[]): Promise<unknown>;\n del?(key: string): Promise<unknown>;\n};\n/** Uses ioredis or Upstash without importing either driver. */\nexport function createRedisStore(\n client: RedisClient,\n options: { flavor?: \"ioredis\" | \"upstash\" } = {}\n): ArcaStore {\n const flavor =\n options.flavor ??\n (typeof client.call === \"function\" ? \"ioredis\" : \"upstash\");\n if (flavor === \"ioredis\" && !client.call) {\n throw new ArcaConfigurationError(\n \"ARCA Redis ioredis flavor requires client.call.\"\n );\n }\n // The public structural type accepts ioredis's overloaded set method.\n // Only the Upstash flavor invokes its options-object overload.\n const upstashSet = client.set as (\n key: string,\n value: string,\n options: { nx?: true; xx?: true; px?: number }\n ) => Promise<unknown>;\n const read = async (key: string) => {\n const value = await client.get(key);\n if (value === null || value === undefined) {\n return null;\n }\n // Upstash can deserialize stored JSON automatically.\n return typeof value === \"string\" ? value : JSON.stringify(value);\n };\n // A lease, so a crashed holder frees the key; a renewal keeps a live one.\n const lease = (key: string, owner: string, mode: \"nx\" | \"xx\") =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\n \"SET\",\n key,\n owner,\n mode.toUpperCase(),\n \"PX\",\n String(ARCA_LEASE_MS)\n )\n : await upstashSet.call(client, key, owner, {\n [mode]: true,\n px: ARCA_LEASE_MS,\n })) === \"OK\"\n );\n return {\n get: (key) => storeCall(() => read(key)),\n set: (key, value) =>\n storeCall(async () => {\n await client.set(key, value);\n }),\n add: (key, value) =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\"SET\", key, value, \"NX\")\n : await upstashSet.call(client, key, value, { nx: true })) === \"OK\"\n ),\n ...(client.del\n ? {\n delete: (key: string) =>\n storeCall(async () => {\n await client.del?.(key);\n }),\n withLock: <T>(\n key: string,\n fn: () => Promise<T>,\n options?: ArcaLockOptions\n ) =>\n withLease(\n {\n acquire: (owner) => lease(key, owner, \"nx\"),\n renew: async (owner) => {\n // Check and set: only the holder extends its own lease.\n if ((await storeCall(() => read(key))) === owner) {\n await lease(key, owner, \"xx\");\n }\n },\n release: async (owner) => {\n await storeCall(async () => {\n if ((await read(key)) === owner) {\n await client.del?.(key);\n }\n });\n },\n },\n fn,\n options\n ),\n }\n : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,SAAS,oBAA+B;AAC7C,QAAM,SAAS,oBAAI,IAAoB;AACvC,QAAM,QAAQ,oBAAI,IAA2B;AAC7C,SAAO;AAAA,IACL,KAAK,CAAC,QAAQ,QAAQ,QAAQ,OAAO,IAAI,GAAG,KAAK,IAAI;AAAA,IACrD,IAAI,KAAK,OAAO;AACd,aAAO,IAAI,KAAK,KAAK;AACrB,aAAO,QAA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M,WAAW,KAAK,QAAQ,KAAK,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO;AAAA,IACrE;AAAA,IACF,GAAI,OAAO,MACP;AAAA,MACE,QAAQ,CAAC,QACP,UAAU,YAAY;AACpB,cAAM,OAAO,MAAM,GAAG;AAAA,MACxB,CAAC;AAAA,MACH,UAAU,CACR,KACA,IACAA,aAEA;AAAA,QACE;AAAA,UACE,SAAS,CAAC,UAAU,MAAM,KAAK,OAAO,IAAI;AAAA,UAC1C,OAAO,OAAO,UAAU;AAEtB,gBAAK,MAAM,UAAU,MAAM,KAAK,GAAG,CAAC,MAAO,OAAO;AAChD,oBAAM,MAAM,KAAK,OAAO,IAAI;AAAA,YAC9B;AAAA,UACF;AAAA,UACA,SAAS,OAAO,UAAU;AACxB,kBAAM,UAAU,YAAY;AAC1B,kBAAK,MAAM,KAAK,GAAG,MAAO,OAAO;AAC/B,sBAAM,OAAO,MAAM,GAAG;AAAA,cACxB;AAAA,YACF,CAAC;AAAA,UACH;AAAA,QACF;AAAA,QACA;AAAA,QACAA;AAAA,MACF;AAAA,IACJ,IACA,CAAC;AAAA,EACP;AACF;","names":["options"]}
1
+ {"version":3,"sources":["../src/services/voucher-document.ts","../src/store/memory.ts","../src/store/postgres.ts","../src/store/redis.ts"],"sourcesContent":["import { ArcaInputError } from \"../errors\";\nimport { normalizeArcaAmountToMinorUnits } from \"../internal/decimal\";\nimport { describeVoucherType } from \"./issuance-fields\";\nimport type { IssuedVoucher, VoucherTotals } from \"./vouchers-types\";\nimport {\n type AmountItem,\n calculateWsfeAmounts,\n settleVatItems,\n type VatItem,\n type VatRate,\n} from \"./wsfe-amounts\";\n\n/**\n * Fixed texts a printed voucher carries, as the norms word them. Rule ids\n * refer to `.github/PRINTED_VOUCHER_SOURCES.md`.\n */\nexport const PRINTED_VOUCHER_TEXT = {\n /** L4, before the voucher type code. */\n code: \"Código Nº\",\n /** C7, before the start of activities. */\n activitiesStart: \"INICIO DE ACTIVIDADES\",\n /** C8 and L9, before the CAE. */\n cae: \"C.A.E. N°\",\n /** C9 and L9, before the CAE due date, in type of at least 12 pt. */\n caeDueDate: \"Fecha Vto.:\",\n /** L8, the title of the consumer transparency block. */\n transparencyTitle:\n \"Régimen de Transparencia Fiscal al Consumidor (Ley 27.743)\",\n /** L8, the VAT contained in the price. */\n vatContained: \"IVA Contenido\",\n /** L8 and C24, the other national indirect taxes. */\n otherNationalIndirectTaxes: \"Otros Impuestos Nacionales Indirectos\",\n} as const;\n\n/** L9 asks for at least this type size for the CAE due date. */\nexport const PRINTED_CAE_DUE_DATE_MIN_FONT_SIZE_PT = 12;\n\n/** The issuer conditions a printed voucher can name (C5). */\nexport type PrintedIssuerCondition =\n | \"responsable_inscripto\"\n | \"exento\"\n | \"no_alcanzado\"\n | \"monotributo\"\n | \"monotributo_social\"\n | \"monotributo_trabajador_independiente_promovido\";\n\nexport type VoucherDocumentInput = {\n /** The voucher `issue()`, a note method or `recover()` answered authorized. */\n voucher: IssuedVoucher;\n /** The same items the voucher was issued from, each with its description. */\n items: readonly (VatItem | AmountItem)[];\n issuer: {\n /** C1. */\n legalName: string;\n /** L1, only when the issuer has one. */\n tradeName?: string;\n /** C2: where the voucher is issued, or the fiscal address for travelling sellers. */\n address: string;\n /** C3, checked against the voucher's QR. */\n taxId: string;\n /** C5. */\n condition: PrintedIssuerCondition;\n /** C4: the ingresos brutos number, or the non-contributor condition. */\n grossIncome: string;\n /**\n * C7 as `YYYY-MM-DD`. `null` only for university professionals billing\n * their fees and service providers without premises (Anexo II, A, V 6).\n */\n activitiesStartDate: string | null;\n /**\n * G5: the issuer opted to issue class A \"PAGO EN CBU INFORMADA\" (RG 5762,\n * art. 20 and 21). Only class A vouchers print it.\n */\n paymentToInformedCbu?: boolean;\n };\n /**\n * G3: the observations ARCA returned with the CAE, as\n * `authorization.observations` of an `authorized` outcome carries them. On a\n * class A voucher their codes are printed (RG 4291, art. 12 and 14 c)).\n */\n observations?: readonly { code?: string | number }[];\n /** C13 to C17. Name and address are required unless the receiver is a consumidor final. */\n receiver?: { name?: string; address?: string };\n /** L6: contado, cuenta corriente and so on. */\n saleConditions: string;\n /** C12: the remitos issued for the operation, when there are any. */\n remitos?: readonly string[];\n};\n\nexport type VoucherDocumentLine = {\n code?: string;\n description: string;\n quantity: number;\n unit?: number;\n /** Major-unit decimal string: without VAT on class A, with VAT on class B. */\n unitPrice: string;\n discount?: number;\n /** Minor units: without VAT on class A, with VAT on class B, as issued on class C. */\n amount: number;\n /** Class A only: the line's rate, `exempt` or `untaxed`. */\n vatRate?: VatRate;\n};\n\n/**\n * Everything a printed voucher shows, derived and checked. Money is in minor\n * units of the voucher currency and dates are `YYYY-MM-DD`. Formatting and\n * layout belong to the renderer.\n */\nexport type VoucherDocument = {\n voucherClass: \"A\" | \"B\" | \"C\";\n voucherType: number;\n /** L4: the type code, three digits. */\n code: string;\n /** G4 and G5: the legend printed next to the letter A, when there is one. */\n letterLegend?: \"OPERACIÓN SUJETA A RETENCIÓN\" | \"PAGO EN CBU INFORMADA\";\n title: \"FACTURA\" | \"NOTA DE DÉBITO\" | \"NOTA DE CRÉDITO\";\n /** C6: sales point and number, `00003-00000041`. */\n number: string;\n /** C11. */\n issueDate: string;\n issuer: {\n tradeName?: string;\n legalName: string;\n address: string;\n taxId: string;\n conditionLegend: string;\n grossIncome: string;\n activitiesStartDate?: string;\n };\n receiver: {\n conditionLegend: string;\n name?: string;\n address?: string;\n /** Absent for an unidentified consumidor final. */\n document?: { type: number; label?: string; number: string };\n };\n saleConditions: string;\n remitos: string[];\n /** Concepts 2 and 3. */\n servicePeriod?: { from: string; to: string };\n paymentDueDate?: string;\n /** C22: the exchange rate is present for any currency but pesos. */\n currency: { id: string; exchangeRate?: string };\n lines: VoucherDocumentLine[];\n totals: {\n /** Class A: net taxed. Class B: the lines with VAT. Class C: the lines. */\n subtotal: number;\n exempt: number;\n untaxed: number;\n /** C25 and L7, class A only: one row per rate, as authorized. */\n vatRates: { id: number; rate?: number; base: number; amount: number }[];\n /** C23: ARCA's Tributos. */\n otherTaxes: { id: number; description: string; amount: number }[];\n /** C23: a VAT adjustment of the header that no line could carry. */\n adjustment: number;\n total: number;\n };\n /** L8 and G2, class B only. */\n transparency?: { vatContained: number; otherNationalIndirectTaxes: number };\n /** C8, C9 and L9. */\n authorization: { kind: \"CAE\"; code: string; dueDate: string };\n /** Q1 and Q2. */\n qr: string;\n /** Conditional legends, in order, each with its rule id. */\n legends: { rule: \"G1\" | \"G3\"; text: string }[];\n};\n\nconst ISSUER_LEGENDS: Record<PrintedIssuerCondition, string> = {\n responsable_inscripto: \"IVA RESPONSABLE INSCRIPTO\",\n exento: \"IVA EXENTO\",\n no_alcanzado: \"NO RESPONSABLE IVA\",\n monotributo: \"RESPONSABLE MONOTRIBUTO\",\n monotributo_social: \"MONOTRIBUTISTA SOCIAL\",\n monotributo_trabajador_independiente_promovido:\n \"MONOTRIBUTO TRABAJADOR INDEPENDIENTE PROMOVIDO\",\n};\n\n/** ARCA receiver IVA condition ids and their C13 to C17 legends. */\nconst RECEIVER_LEGENDS: Record<number, string> = {\n 1: \"IVA RESPONSABLE INSCRIPTO\",\n 4: \"IVA EXENTO\",\n 5: \"A CONSUMIDOR FINAL\",\n 6: \"RESPONSABLE MONOTRIBUTO\",\n 7: \"SUJETO NO CATEGORIZADO\",\n // Apartado A names no legend for these: ARCA's own condition names.\n 8: \"PROVEEDOR DEL EXTERIOR\",\n 9: \"CLIENTE DEL EXTERIOR\",\n 10: \"IVA LIBERADO - LEY Nº 19.640\",\n 13: \"MONOTRIBUTISTA SOCIAL\",\n 15: \"NO RESPONSABLE IVA\",\n 16: \"MONOTRIBUTO TRABAJADOR INDEPENDIENTE PROMOVIDO\",\n};\nconst CONSUMIDOR_FINAL = 5;\n/** C26 and G2: exento, consumidor final and no alcanzado. */\nconst VAT_CONTAINED_RECEIVERS = new Set([4, 5, 15]);\nconst MONOTRIBUTO_RECEIVERS = new Set([6, 13, 16]);\n\nconst DOCUMENT_LABELS: Record<number, string> = {\n 80: \"CUIT\",\n 86: \"CUIL\",\n 87: \"CDI\",\n 94: \"Pasaporte\",\n 96: \"DNI\",\n};\nconst UNIDENTIFIED_DOCUMENT = 99;\n\n/** G3: precedes the codes of the observations ARCA returned with the CAE. */\nconst ARCA_OBSERVATIONS_LABEL = \"Observaciones de ARCA:\";\n\n/** G1: RG 1415, art. 15, inc. a), as replaced by RG 5003, art. 20. */\nexport const MONOTRIBUTO_CREDIT_LEGEND =\n \"El crédito fiscal discriminado en el presente comprobante, sólo podrá ser computado a efectos del Régimen de Sostenimiento e Inclusión Fiscal para Pequeños Contribuyentes de la Ley Nº 27.618\";\n\n/** ARCA tributo ids read as national indirect taxes: Impuestos nacionales and Impuestos internos. */\nconst NATIONAL_INDIRECT_TAX_IDS = new Set([1, 4]);\nconst TAX_NAMES: Record<number, string> = {\n 1: \"Impuestos nacionales\",\n 2: \"Impuestos provinciales\",\n 3: \"Impuestos municipales\",\n 4: \"Impuestos internos\",\n 5: \"Ingresos brutos\",\n 6: \"Percepción de IVA\",\n 7: \"Percepción de ingresos brutos\",\n 8: \"Percepciones por impuestos municipales\",\n 9: \"Otras percepciones\",\n 13: \"Percepción de IVA a no categorizado\",\n 99: \"Otros tributos\",\n};\n\n/** RG 5762 replaced class M by class A with retention legend on this date. */\nconst RETENTION_LEGEND_FROM = \"2025-12-01\";\n\nconst TITLES = {\n invoice: \"FACTURA\",\n debit_note: \"NOTA DE DÉBITO\",\n credit_note: \"NOTA DE CRÉDITO\",\n} as const;\n\n/**\n * Derives what a printed class A, B or C voucher must show from the\n * authorized voucher, the items it was issued from and the issuer's profile.\n * Pure. It throws `ArcaInputError` when a required datum is missing, when the\n * items do not add up to the authorized money, or for a voucher it does not\n * render: FCE, and class M vouchers issued before 2025-12-01.\n */\nexport function buildVoucherDocument(\n input: VoucherDocumentInput\n): VoucherDocument {\n const { voucher, issuer } = input;\n const info = describeVoucherType(voucher.voucherType);\n if (info.family === \"fce\") {\n invalid(\n \"voucher.voucherType\",\n \"a class A, B or C invoice or note: FCE vouchers are not rendered yet\"\n );\n }\n if (\n info.family === \"retention_legend\" &&\n voucher.date < RETENTION_LEGEND_FROM\n ) {\n invalid(\n \"voucher.voucherType\",\n \"a voucher issued from 2025-12-01: types 51 to 53 were class M before RG 5762\"\n );\n }\n const voucherClass = voucher.voucherClass;\n assertIssuerMatchesClass(issuer.condition, voucherClass);\n if (voucher.qr === undefined) {\n invalid(\"voucher.qr\", \"the QR every printed voucher carries\");\n }\n const taxId = digits(issuer.taxId);\n if (\n taxId.length !== 11 ||\n (voucher.qrPayload !== undefined &&\n String(voucher.qrPayload.cuit) !== taxId)\n ) {\n invalid(\"issuer.taxId\", \"the 11-digit CUIT the voucher was issued under\");\n }\n const lines = documentLines(input, voucherClass);\n const header = voucher.header;\n const receiver = documentReceiver(input, header);\n return {\n voucherClass,\n voucherType: voucher.voucherType,\n code: String(voucher.voucherType).padStart(3, \"0\"),\n ...letterLegend(info.family, voucherClass, issuer.paymentToInformedCbu),\n title: TITLES[info.kind],\n number: `${String(voucher.salesPoint).padStart(5, \"0\")}-${String(voucher.number).padStart(8, \"0\")}`,\n issueDate: voucher.date,\n issuer: {\n ...(issuer.tradeName\n ? { tradeName: required(issuer.tradeName, \"issuer.tradeName\") }\n : {}),\n legalName: required(issuer.legalName, \"issuer.legalName\"),\n address: required(issuer.address, \"issuer.address\"),\n taxId,\n conditionLegend: ISSUER_LEGENDS[issuer.condition],\n grossIncome: required(issuer.grossIncome, \"issuer.grossIncome\"),\n ...activitiesStart(issuer.activitiesStartDate),\n },\n receiver,\n saleConditions: required(input.saleConditions, \"saleConditions\"),\n remitos: (input.remitos ?? []).map((remito, index) =>\n required(remito, `remitos[${index}]`)\n ),\n ...(header.serviceStartDate && header.serviceEndDate\n ? {\n servicePeriod: {\n from: header.serviceStartDate,\n to: header.serviceEndDate,\n },\n }\n : {}),\n ...(header.paymentDueDate ? { paymentDueDate: header.paymentDueDate } : {}),\n currency: {\n id: header.currencyId,\n ...(header.currencyId !== \"PES\" && header.exchangeRate !== undefined\n ? { exchangeRate: header.exchangeRate }\n : {}),\n },\n lines: lines.lines,\n totals: {\n subtotal: lines.subtotal,\n exempt: voucher.totals.exempt,\n untaxed: voucher.totals.untaxed,\n vatRates: voucherClass === \"A\" ? voucher.totals.vatRates : [],\n otherTaxes: voucher.totals.taxes.map((tax) => ({\n id: tax.id,\n description: tax.description ?? TAX_NAMES[tax.id] ?? \"Otros tributos\",\n amount: tax.amount,\n })),\n adjustment: lines.adjustment,\n total: voucher.totals.total,\n },\n ...(voucherClass === \"B\" &&\n VAT_CONTAINED_RECEIVERS.has(header.receiverVatConditionId)\n ? {\n transparency: {\n vatContained: voucher.totals.vat,\n otherNationalIndirectTaxes: voucher.totals.taxes\n .filter((tax) => NATIONAL_INDIRECT_TAX_IDS.has(tax.id))\n .reduce((sum, tax) => sum + tax.amount, 0),\n },\n }\n : {}),\n authorization: {\n kind: \"CAE\",\n code: voucher.cae,\n dueDate: voucher.caeExpiry,\n },\n qr: voucher.qr,\n legends: legends(input, voucherClass),\n };\n}\n\nfunction letterLegend(\n family: string,\n voucherClass: \"A\" | \"B\" | \"C\",\n paymentToInformedCbu: boolean | undefined\n): Pick<VoucherDocument, \"letterLegend\"> {\n if (family === \"retention_legend\") {\n return { letterLegend: \"OPERACIÓN SUJETA A RETENCIÓN\" };\n }\n return voucherClass === \"A\" && paymentToInformedCbu === true\n ? { letterLegend: \"PAGO EN CBU INFORMADA\" }\n : {};\n}\n\nfunction legends(\n input: VoucherDocumentInput,\n voucherClass: \"A\" | \"B\" | \"C\"\n): VoucherDocument[\"legends\"] {\n if (voucherClass !== \"A\") {\n return [];\n }\n const found: VoucherDocument[\"legends\"] = [];\n if (MONOTRIBUTO_RECEIVERS.has(input.voucher.header.receiverVatConditionId)) {\n found.push({ rule: \"G1\", text: MONOTRIBUTO_CREDIT_LEGEND });\n }\n const codes = [\n ...new Set(\n (input.observations ?? [])\n .map((observation) => String(observation.code ?? \"\").trim())\n .filter((code) => code !== \"\")\n ),\n ];\n if (codes.length > 0) {\n found.push({\n rule: \"G3\",\n text: `${ARCA_OBSERVATIONS_LABEL} ${codes.join(\", \")}`,\n });\n }\n return found;\n}\n\nfunction assertIssuerMatchesClass(\n condition: PrintedIssuerCondition,\n voucherClass: \"A\" | \"B\" | \"C\"\n): void {\n if (!Object.hasOwn(ISSUER_LEGENDS, condition)) {\n invalid(\"issuer.condition\", Object.keys(ISSUER_LEGENDS).join(\", \"));\n }\n const vatRegistered = condition === \"responsable_inscripto\";\n if (vatRegistered !== (voucherClass !== \"C\")) {\n invalid(\n \"issuer.condition\",\n vatRegistered\n ? \"a condition that issues class C vouchers\"\n : \"responsable_inscripto, the only condition that issues class A and B vouchers\"\n );\n }\n}\n\nfunction documentReceiver(\n input: VoucherDocumentInput,\n header: IssuedVoucher[\"header\"]\n): VoucherDocument[\"receiver\"] {\n const condition = header.receiverVatConditionId;\n const conditionLegend = RECEIVER_LEGENDS[condition];\n if (conditionLegend === undefined) {\n invalid(\n \"voucher.header.receiverVatConditionId\",\n \"a receiver condition the SDK renders: 1, 4 to 10, 13, 15 or 16\"\n );\n }\n const name = input.receiver?.name?.trim();\n const address = input.receiver?.address?.trim();\n if (condition !== CONSUMIDOR_FINAL) {\n required(name, \"receiver.name\");\n required(address, \"receiver.address\");\n }\n const identified =\n header.documentType !== UNIDENTIFIED_DOCUMENT &&\n /[1-9]/.test(header.documentNumber);\n if (!identified && condition !== CONSUMIDOR_FINAL) {\n throw new ArcaInputError(\n \"Only a consumidor final may be unidentified on a printed voucher.\",\n {\n code: \"ARCA_INPUT_MISSING_FIELD\",\n field: \"voucher.header.documentNumber\",\n expected: \"the receiver's document (C13 to C17)\",\n }\n );\n }\n const label = DOCUMENT_LABELS[header.documentType];\n return {\n conditionLegend,\n ...(name ? { name } : {}),\n ...(address ? { address } : {}),\n ...(identified\n ? {\n document: {\n type: header.documentType,\n ...(label === undefined ? {} : { label }),\n number: header.documentNumber,\n },\n }\n : {}),\n };\n}\n\n/**\n * The items must describe the authorized money: the same net, exempt and\n * untaxed amounts and the same VAT bases. The printed lines then use the\n * per-item Half Even split, so they add up to the authorized header.\n */\nfunction documentLines(\n input: VoucherDocumentInput,\n voucherClass: \"A\" | \"B\" | \"C\"\n): { lines: VoucherDocumentLine[]; subtotal: number; adjustment: number } {\n const { items } = input;\n const totals = input.voucher.totals;\n if (!Array.isArray(items) || items.length === 0) {\n invalid(\"items\", \"the items the voucher was issued from\");\n }\n let computed: ReturnType<typeof calculateWsfeAmounts>;\n try {\n computed = calculateWsfeAmounts({\n voucherClass,\n items,\n total: totals.total - totals.otherTaxes,\n });\n } catch (error) {\n if (\n error instanceof ArcaInputError &&\n error.code === \"ARCA_INPUT_AMOUNT_MISMATCH\"\n ) {\n mismatch(\"total\");\n }\n throw error;\n }\n assertItemsMatchTotals(computed.data, totals, voucherClass);\n const settled =\n voucherClass === \"C\"\n ? undefined\n : settleVatItems({ voucherClass, items }, computed.amounts.vatAdjustment);\n const lines = items.map((item, index): VoucherDocumentLine => {\n const path = `items[${index}]`;\n const money = settled?.items[index];\n const amount =\n money === undefined\n ? (item.amount as number)\n : voucherClass === \"A\"\n ? money.amount - money.vat\n : money.amount;\n return {\n ...(item.code === undefined ? {} : { code: item.code }),\n description: required(item.description, `${path}.description`),\n ...lineQuantity(item, amount, path),\n ...(item.unit === undefined ? {} : { unit: item.unit }),\n ...(item.discount ? { discount: item.discount } : {}),\n amount,\n ...(voucherClass === \"A\" && money !== undefined\n ? { vatRate: money.rate }\n : {}),\n };\n });\n const sum = lines.reduce((total, line) => total + line.amount, 0);\n if (voucherClass === \"A\") {\n // The rows keep their computed VAT; an asserted total moves only the header.\n const rows = totals.vatRates.reduce((total, row) => total + row.amount, 0);\n return {\n lines,\n subtotal: totals.netTaxed,\n adjustment: totals.vat - rows,\n };\n }\n return { lines, subtotal: sum, adjustment: settled?.unabsorbed ?? 0 };\n}\n\nfunction assertItemsMatchTotals(\n data: ReturnType<typeof calculateWsfeAmounts>[\"data\"],\n totals: VoucherTotals,\n voucherClass: \"A\" | \"B\" | \"C\"\n): void {\n const minor = (value: number) =>\n Number(normalizeArcaAmountToMinorUnits(value, \"items\"));\n for (const [field, value, authorized] of [\n [\"netTaxed\", data.netAmount, totals.netTaxed],\n [\"exempt\", data.exemptAmount, totals.exempt],\n [\"untaxed\", data.nonTaxableAmount, totals.untaxed],\n [\"vat\", data.vatAmount, totals.vat],\n ] as const) {\n if (minor(value) !== authorized) {\n mismatch(field);\n }\n }\n if (voucherClass === \"C\") {\n return;\n }\n const bases = (rows: readonly { id: number; base: number }[]) =>\n rows\n .filter((row) => row.base !== 0)\n .map((row) => `${row.id}:${row.base}`)\n .sort()\n .join(\",\");\n const computedBases = (data.vatRates ?? []).map((row) => ({\n id: row.id,\n base: minor(row.baseAmount),\n }));\n if (bases(computedBases) !== bases(totals.vatRates)) {\n mismatch(\"vatRates\");\n }\n}\n\n/** C20 and C21: a line without quantity is one unit at its amount. */\nfunction lineQuantity(\n item: VatItem | AmountItem,\n amount: number,\n path: string\n): { quantity: number; unitPrice: string } {\n const discount = item.discount ?? 0;\n if (!(Number.isSafeInteger(discount) && discount >= 0)) {\n invalid(`${path}.discount`, \"a non-negative safe integer in minor units\");\n }\n if (item.quantity === undefined && item.unitPrice === undefined) {\n // The line amount is net of the discount: the unit price is not.\n return { quantity: 1, unitPrice: majorUnits(amount + discount) };\n }\n const { quantity, unitPrice } = item;\n if (\n !(typeof quantity === \"number\" && Number.isFinite(quantity) && quantity > 0)\n ) {\n invalid(`${path}.quantity`, \"a positive quantity, given with unitPrice\");\n }\n if (typeof unitPrice !== \"string\" || !/^\\d+(\\.\\d{1,6})?$/.test(unitPrice)) {\n invalid(\n `${path}.unitPrice`,\n \"a major-unit decimal string with at most six decimals, given with quantity\"\n );\n }\n const printed = Math.round(quantity * Number(unitPrice) * 100) - discount;\n if (Math.abs(printed - amount) > 1) {\n throw new ArcaInputError(\n `${path}: quantity × unitPrice − discount does not match the line amount.`,\n {\n code: \"ARCA_INPUT_AMOUNT_MISMATCH\",\n field: `${path}.unitPrice`,\n expected: `${amount} minor units, within one: without VAT on class A, with VAT on class B`,\n }\n );\n }\n return { quantity, unitPrice };\n}\n\nfunction activitiesStart(date: string | null): {\n activitiesStartDate?: string;\n} {\n if (date === null) {\n return {};\n }\n if (typeof date !== \"string\" || !/^\\d{4}-\\d{2}-\\d{2}$/.test(date)) {\n invalid(\n \"issuer.activitiesStartDate\",\n \"YYYY-MM-DD, or null for the exceptions of RG 1415, Anexo II, A, V 6\"\n );\n }\n return { activitiesStartDate: date };\n}\n\nfunction majorUnits(minor: number): string {\n const cents = String(minor).padStart(3, \"0\");\n return `${cents.slice(0, -2)}.${cents.slice(-2)}`;\n}\n\nfunction digits(value: string): string {\n return typeof value === \"string\" ? value.replace(/\\D/g, \"\") : \"\";\n}\n\nfunction required(value: string | undefined, field: string): string {\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new ArcaInputError(`${field} is required on a printed voucher.`, {\n code: \"ARCA_INPUT_MISSING_FIELD\",\n field,\n });\n }\n return value.trim();\n}\n\nfunction mismatch(field: string): never {\n throw new ArcaInputError(\"items do not add up to the authorized voucher.\", {\n code: \"ARCA_INPUT_AMOUNT_MISMATCH\",\n field: `items (${field})`,\n expected: \"the items the voucher was issued from\",\n });\n}\n\nfunction invalid(field: string, expected: string): never {\n throw new ArcaInputError(`${field} must be ${expected}.`, {\n code: \"ARCA_INPUT_INVALID_VALUE\",\n field,\n expected,\n });\n}\n","import { abortable } from \"../internal/abort\";\nimport { throwIfAborted } from \"./lock\";\nimport type { ArcaStore } from \"./types\";\n\n/** In-process store for tests; reservations do not survive a restart. */\nexport function createMemoryStore(): ArcaStore {\n const values = new Map<string, string>();\n const locks = new Map<string, Promise<void>>();\n return {\n get: (key) => Promise.resolve(values.get(key) ?? null),\n set(key, value) {\n values.set(key, value);\n return Promise.resolve();\n },\n add(key, value) {\n if (values.has(key)) {\n return Promise.resolve(false);\n }\n values.set(key, value);\n return Promise.resolve(true);\n },\n delete(key) {\n values.delete(key);\n return Promise.resolve();\n },\n async withLock(key, fn, { signal } = {}) {\n throwIfAborted(signal);\n const previous = locks.get(key) ?? Promise.resolve();\n let release: () => void = () => undefined;\n const current = new Promise<void>((resolve) => {\n release = resolve;\n });\n const queued = previous.catch(() => undefined).then(() => current);\n locks.set(key, queued);\n // An abort ends the wait early; the check below reports it.\n await abortable(\n previous.catch(() => undefined),\n signal\n ).catch(() => undefined);\n if (signal?.aborted) {\n // Hand the turn on, but keep this call's place until the holder\n // before it finishes: a caller arriving now must still wait for it.\n release();\n queued.then(() => {\n if (locks.get(key) === queued) {\n locks.delete(key);\n }\n });\n throwIfAborted(signal);\n }\n try {\n return await fn();\n } finally {\n release();\n if (locks.get(key) === queued) {\n locks.delete(key);\n }\n }\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaStore, storeCall } from \"./types\";\n\ntype Row = { key?: string; value?: string };\n/** Uses the caller's SQL client; provision the table before use. */\nexport function createPostgresStore({\n query,\n table = \"arca_store\",\n}: {\n query: (text: string, params: string[]) => Promise<Row[] | { rows: Row[] }>;\n table?: string;\n}): ArcaStore {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(table)) {\n throw new ArcaConfigurationError(\"Invalid ARCA store table identifier.\");\n }\n const name = `\"${table}\"`;\n const lease = Math.round(ARCA_LEASE_MS / 1000);\n const run = (text: string, params: string[]) =>\n storeCall(async () => {\n const result = await query(text, params);\n return Array.isArray(result) ? result : result.rows;\n });\n return {\n async get(key) {\n return (\n (await run(`SELECT value FROM ${name} WHERE key = $1`, [key]))[0]\n ?.value ?? null\n );\n },\n async set(key, value) {\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = now()`,\n [key, value]\n );\n },\n async add(key, value) {\n return (\n (\n await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, value]\n )\n ).length > 0\n );\n },\n async delete(key) {\n await run(`DELETE FROM ${name} WHERE key = $1`, [key]);\n },\n withLock(key, fn, options) {\n // A lease row, not an advisory lock: it survives a transaction-mode\n // pooler, where a session-scoped lock would be taken on another backend.\n return withLease(\n {\n async acquire(owner) {\n const taken = await run(\n `INSERT INTO ${name} (key, value) VALUES ($1, $2) ON CONFLICT DO NOTHING RETURNING key`,\n [key, owner]\n );\n if (taken.length > 0) {\n return true;\n }\n const expired = await run(\n `UPDATE ${name} SET value = $2, updated_at = now() WHERE key = $1 AND updated_at < now() - interval '${lease} seconds' RETURNING key`,\n [key, owner]\n );\n return expired.length > 0;\n },\n async renew(owner) {\n await run(\n `UPDATE ${name} SET updated_at = now() WHERE key = $1 AND value = $2`,\n [key, owner]\n );\n },\n async release(owner) {\n await run(`DELETE FROM ${name} WHERE key = $1 AND value = $2`, [\n key,\n owner,\n ]);\n },\n },\n fn,\n options\n );\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { type ArcaLockOptions, type ArcaStore, storeCall } from \"./types\";\n\ntype RedisClient = {\n get(key: string): Promise<unknown>;\n set(key: string, value: string): Promise<unknown>;\n call?(...args: string[]): Promise<unknown>;\n del?(key: string): Promise<unknown>;\n};\n/** Uses ioredis or Upstash without importing either driver. */\nexport function createRedisStore(\n client: RedisClient,\n options: { flavor?: \"ioredis\" | \"upstash\" } = {}\n): ArcaStore {\n const flavor =\n options.flavor ??\n (typeof client.call === \"function\" ? \"ioredis\" : \"upstash\");\n if (flavor === \"ioredis\" && !client.call) {\n throw new ArcaConfigurationError(\n \"ARCA Redis ioredis flavor requires client.call.\"\n );\n }\n // The public structural type accepts ioredis's overloaded set method.\n // Only the Upstash flavor invokes its options-object overload.\n const upstashSet = client.set as (\n key: string,\n value: string,\n options: { nx?: true; xx?: true; px?: number }\n ) => Promise<unknown>;\n const read = async (key: string) => {\n const value = await client.get(key);\n if (value === null || value === undefined) {\n return null;\n }\n // Upstash can deserialize stored JSON automatically.\n return typeof value === \"string\" ? value : JSON.stringify(value);\n };\n // A lease, so a crashed holder frees the key; a renewal keeps a live one.\n const lease = (key: string, owner: string, mode: \"nx\" | \"xx\") =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\n \"SET\",\n key,\n owner,\n mode.toUpperCase(),\n \"PX\",\n String(ARCA_LEASE_MS)\n )\n : await upstashSet.call(client, key, owner, {\n [mode]: true,\n px: ARCA_LEASE_MS,\n })) === \"OK\"\n );\n return {\n get: (key) => storeCall(() => read(key)),\n set: (key, value) =>\n storeCall(async () => {\n await client.set(key, value);\n }),\n add: (key, value) =>\n storeCall(\n async () =>\n (flavor === \"ioredis\"\n ? await client.call?.(\"SET\", key, value, \"NX\")\n : await upstashSet.call(client, key, value, { nx: true })) === \"OK\"\n ),\n ...(client.del\n ? {\n delete: (key: string) =>\n storeCall(async () => {\n await client.del?.(key);\n }),\n withLock: <T>(\n key: string,\n fn: () => Promise<T>,\n options?: ArcaLockOptions\n ) =>\n withLease(\n {\n acquire: (owner) => lease(key, owner, \"nx\"),\n renew: async (owner) => {\n // Check and set: only the holder extends its own lease.\n if ((await storeCall(() => read(key))) === owner) {\n await lease(key, owner, \"xx\");\n }\n },\n release: async (owner) => {\n await storeCall(async () => {\n if ((await read(key)) === owner) {\n await client.del?.(key);\n }\n });\n },\n },\n fn,\n options\n ),\n }\n : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBO,IAAM,uBAAuB;AAAA;AAAA,EAElC,MAAM;AAAA;AAAA,EAEN,iBAAiB;AAAA;AAAA,EAEjB,KAAK;AAAA;AAAA,EAEL,YAAY;AAAA;AAAA,EAEZ,mBACE;AAAA;AAAA,EAEF,cAAc;AAAA;AAAA,EAEd,4BAA4B;AAC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ACF;AAAA,IACJ,IACA,CAAC;AAAA,EACP;AACF;","names":["options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "facturas",
3
- "version": "0.22.1",
3
+ "version": "0.23.1",
4
4
  "description": "SDK de TypeScript para facturación electrónica con ARCA / AFIP: facturas, notas de crédito y débito, y Padrón con una sola API.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",