facturas 0.12.4 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +41 -35
  2. package/dist/{chunk-YYDSBHMO.mjs → chunk-BPBTQDCO.mjs} +16 -173
  3. package/dist/chunk-BPBTQDCO.mjs.map +1 -0
  4. package/dist/{chunk-7V5S3ISG.mjs → chunk-KPWAQMR5.mjs} +766 -190
  5. package/dist/chunk-KPWAQMR5.mjs.map +1 -0
  6. package/dist/{chunk-GX5ERXT6.mjs → chunk-LQMNKQ2V.mjs} +1 -1
  7. package/dist/chunk-LQMNKQ2V.mjs.map +1 -0
  8. package/dist/{chunk-3EJINDBP.mjs → chunk-WN62NMUJ.mjs} +13 -13
  9. package/dist/chunk-WN62NMUJ.mjs.map +1 -0
  10. package/dist/cli.d.ts +5 -5
  11. package/dist/cli.mjs +4 -4
  12. package/dist/{client-tzfxAy7w.d.ts → client-bblLZeUb.d.ts} +83 -46
  13. package/dist/constants.d.ts +1 -1
  14. package/dist/constants.mjs +1 -1
  15. package/dist/errors.d.ts +2 -2
  16. package/dist/{fiscal-evidence-DXl_U1uz.d.ts → fiscal-evidence-DaCyGd5o.d.ts} +2 -2
  17. package/dist/{index-CT1ffEAL.d.ts → index-DAC3edtw.d.ts} +1 -1
  18. package/dist/index.d.ts +6 -7
  19. package/dist/index.mjs +9 -15
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/padron.d.ts +2 -2
  22. package/dist/{types-SdBQAflw.d.ts → types-Su7QwloQ.d.ts} +1 -1
  23. package/dist/types.d.ts +1 -1
  24. package/dist/wsfe.d.ts +255 -31
  25. package/dist/wsfe.mjs +1 -8
  26. package/dist/wsmtxca.d.ts +6 -6
  27. package/dist/wsmtxca.mjs +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunk-3EJINDBP.mjs.map +0 -1
  30. package/dist/chunk-7V5S3ISG.mjs.map +0 -1
  31. package/dist/chunk-GX5ERXT6.mjs.map +0 -1
  32. package/dist/chunk-YYDSBHMO.mjs.map +0 -1
  33. package/dist/chunk-ZZDL6I56.mjs +0 -169
  34. package/dist/chunk-ZZDL6I56.mjs.map +0 -1
  35. package/dist/decimal-CgWMOiAC.d.ts +0 -272
package/dist/index.mjs CHANGED
@@ -11,26 +11,22 @@ import {
11
11
  resolveArcaEnvironment,
12
12
  storeCall,
13
13
  withLease
14
- } from "./chunk-7V5S3ISG.mjs";
15
- import {
16
- createPadronService
17
- } from "./chunk-WVKVJTFG.mjs";
18
- import {
19
- buildFacturaB,
20
- buildFacturaC
21
- } from "./chunk-ZZDL6I56.mjs";
22
- import {
23
- createWsfeService
24
- } from "./chunk-YYDSBHMO.mjs";
14
+ } from "./chunk-KPWAQMR5.mjs";
25
15
  import {
26
16
  ARCA_FINAL_CONSUMER_IDENTIFICATION_THRESHOLD_MINOR_UNITS,
27
17
  ARCA_INVOICE_CLASS_BY_ISSUER,
28
18
  ARCA_ISSUER_CONDITION_IDS,
29
19
  ARCA_RECEIVER_CONDITION_IDS
30
- } from "./chunk-GX5ERXT6.mjs";
20
+ } from "./chunk-LQMNKQ2V.mjs";
21
+ import {
22
+ createPadronService
23
+ } from "./chunk-WVKVJTFG.mjs";
24
+ import {
25
+ createWsfeService
26
+ } from "./chunk-BPBTQDCO.mjs";
31
27
  import {
32
28
  createWsmtxcaService
33
- } from "./chunk-3EJINDBP.mjs";
29
+ } from "./chunk-WN62NMUJ.mjs";
34
30
  import "./chunk-PHXH34L6.mjs";
35
31
  import {
36
32
  ArcaAuthenticationError,
@@ -236,8 +232,6 @@ export {
236
232
  ArcaSoapFaultError,
237
233
  ArcaTransportError,
238
234
  assertArcaClientConfig,
239
- buildFacturaB,
240
- buildFacturaC,
241
235
  createArcaClient,
242
236
  createArcaClientConfigFromEnv,
243
237
  createFileStore,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/store/memory.ts","../src/store/postgres.ts","../src/store/redis.ts"],"sourcesContent":["import 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) {\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 await previous.catch(() => undefined);\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) {\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 key,\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 );\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { 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>(key: string, fn: () => Promise<T>) =>\n withLease(\n key,\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 ),\n }\n : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,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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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,MACF;AAAA,IACJ,IACA,CAAC;AAAA,EACP;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/store/memory.ts","../src/store/postgres.ts","../src/store/redis.ts"],"sourcesContent":["import 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) {\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 await previous.catch(() => undefined);\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) {\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 key,\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 );\n },\n };\n}\n","import { ArcaConfigurationError } from \"../errors\";\nimport { ARCA_LEASE_MS, withLease } from \"./lock\";\nimport { 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>(key: string, fn: () => Promise<T>) =>\n withLease(\n key,\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 ),\n }\n : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,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,QAAQ,QAAQ;AAAA,IACzB;AAAA,IACA,IAAI,KAAK,OAAO;AACd,UAAI,OAAO,IAAI,GAAG,GAAG;AACnB,eAAO,QAAQ,QAAQ,KAAK;AAAA,MAC9B;AACA,aAAO,IAAI,KAAK,KAAK;AACrB,aAAO,QAAQ,QAAQ,IAAI;AAAA,IAC7B;AAAA,IACA,OAAO,KAAK;AACV,aAAO,OAAO,GAAG;AACjB,aAAO,QAAQ,QAAQ;AAAA,IACzB;AAAA,IACA,MAAM,SAAS,KAAK,IAAI;AACtB,YAAM,WAAW,MAAM,IAAI,GAAG,KAAK,QAAQ,QAAQ;AACnD,UAAI,UAAsB,MAAM;AAChC,YAAM,UAAU,IAAI,QAAc,CAAC,YAAY;AAC7C,kBAAU;AAAA,MACZ,CAAC;AACD,YAAM,SAAS,SAAS,MAAM,MAAM,MAAS,EAAE,KAAK,MAAM,OAAO;AACjE,YAAM,IAAI,KAAK,MAAM;AACrB,YAAM,SAAS,MAAM,MAAM,MAAS;AACpC,UAAI;AACF,eAAO,MAAM,GAAG;AAAA,MAClB,UAAE;AACA,gBAAQ;AACR,YAAI,MAAM,IAAI,GAAG,MAAM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A,IACvC,KAAK,CAAC,KAAK,UACT,UAAU,YAAY;AACpB,YAAM,OAAO,IAAI,KAAK,KAAK;AAAA,IAC7B,CAAC;AAAA,IACH,KAAK,CAAC,KAAK,UACT;AAAA,MACE,aACG,WAAW,YACR,MAAM,OAAO,OAAO,OAAO,KAAK,OAAO,IAAI,IAC3C,MAAM,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,CAAI,KAAa,OACzB;AAAA,QACE;AAAA,QACA;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,MACF;AAAA,IACJ,IACA,CAAC;AAAA,EACP;AACF;","names":[]}
package/dist/padron.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as ArcaClientConfig } from './types-SdBQAflw.js';
2
- import { W as WsaaAuthModule, S as SoapTransport } from './index-CT1ffEAL.js';
1
+ import { a as ArcaClientConfig } from './types-Su7QwloQ.js';
2
+ import { W as WsaaAuthModule, S as SoapTransport } from './index-DAC3edtw.js';
3
3
 
4
4
  /** Result of a taxpayer lookup via Padron A5. */
5
5
  type PadronTaxpayerResult = {
@@ -64,7 +64,7 @@ type ArcaAuthOptions = {
64
64
  forceRefresh?: boolean;
65
65
  representedTaxId?: ArcaRepresentedTaxId;
66
66
  /** Aborts login, submission and consultation with the caller's deadline. */
67
- signal?: AbortSignal;
67
+ abortSignal?: AbortSignal;
68
68
  };
69
69
  type ArcaSoapExecutionOptions<TBody> = {
70
70
  service: ArcaServiceName;
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
1
- export { g as ArcaAuthCredentials, f as ArcaAuthOptions, A as ArcaClientConfig, h as ArcaEnvironment, k as ArcaLogLevel, l as ArcaLoggerConfig, m as ArcaPadronServiceName, n as ArcaRepresentedTaxId, b as ArcaServiceName, o as ArcaServiceTarget, e as ArcaWsaaServiceId, p as ArcaWsaaSessionKey, j as ArcaWsaaSessionStore } from './types-SdBQAflw.js';
1
+ export { g as ArcaAuthCredentials, f as ArcaAuthOptions, A as ArcaClientConfig, h as ArcaEnvironment, k as ArcaLogLevel, l as ArcaLoggerConfig, m as ArcaPadronServiceName, n as ArcaRepresentedTaxId, b as ArcaServiceName, o as ArcaServiceTarget, e as ArcaWsaaServiceId, p as ArcaWsaaSessionKey, j as ArcaWsaaSessionStore } from './types-Su7QwloQ.js';
package/dist/wsfe.d.ts CHANGED
@@ -1,45 +1,269 @@
1
- import { i as WsfeDateInput, S as SupportedVatRate, s as WsfeVoucherInput } from './decimal-CgWMOiAC.js';
2
- export { C as CreateWsfeServiceOptions, W as WsfeActivity, a as WsfeActivityType, b as WsfeAssociatedPeriod, c as WsfeAssociatedVoucher, d as WsfeAuthorizationOutcome, e as WsfeAuthorizeVoucherInput, f as WsfeBuyer, g as WsfeCatalogEntry, h as WsfeCurrencyType, j as WsfeOptionalField, k as WsfeQuotation, l as WsfeReceiverVatCondition, m as WsfeSalesPoint, n as WsfeServerStatus, o as WsfeService, p as WsfeTax, q as WsfeVatRate, r as WsfeVoucherInfo, t as WsfeVoucherLookupResult, u as createWsfeService } from './decimal-CgWMOiAC.js';
3
- import './types-SdBQAflw.js';
4
- import './index-CT1ffEAL.js';
5
- import './fiscal-evidence-DXl_U1uz.js';
1
+ import { a as ArcaClientConfig } from './types-Su7QwloQ.js';
2
+ import { W as WsaaAuthModule, S as SoapTransport } from './index-DAC3edtw.js';
3
+ import { e as ArcaAuthorizationOutcome, t as ArcaVoucherLookupResult } from './fiscal-evidence-DaCyGd5o.js';
6
4
 
7
- type WsfeBuilderCurrencyInput = {
8
- currency?: "ARS";
9
- exchangeRate?: never;
10
- sameCurrencyForeignCancellation?: never;
11
- } | {
12
- currency: "USD";
13
- exchangeRate: string;
14
- sameCurrencyForeignCancellation?: false;
15
- } | {
16
- currency: "USD";
17
- exchangeRate?: never;
18
- sameCurrencyForeignCancellation: true;
19
- };
20
- type WsfeBuilderVatRate = SupportedVatRate;
21
- type WsfeInvoiceBuilderBaseInput = {
5
+ /** Accepted public date inputs for WSFE request fields. */
6
+ type WsfeDateInput = `${number}${number}${number}${number}-${number}${number}-${number}${number}` | `${number}${number}${number}${number}${number}${number}${number}${number}`;
7
+ /** An associated voucher referenced by a WSFE invoice request. */
8
+ type WsfeAssociatedVoucher = {
9
+ type: number;
22
10
  salesPoint: number;
11
+ number: number;
12
+ taxId?: string;
13
+ voucherDate?: WsfeDateInput;
14
+ };
15
+ /** An associated period used by WSFE credit/debit notes without associated vouchers. */
16
+ type WsfeAssociatedPeriod = {
17
+ startDate: WsfeDateInput;
18
+ endDate: WsfeDateInput;
19
+ };
20
+ /** A tax (tributo) item in a WSFE invoice request. */
21
+ type WsfeTax = {
22
+ id: number;
23
+ description?: string;
24
+ baseAmount: number;
25
+ rate: number;
26
+ amount: number;
27
+ };
28
+ /** A VAT rate (alícuota IVA) item in a WSFE invoice request. */
29
+ type WsfeVatRate = {
30
+ id: number;
31
+ baseAmount: number;
32
+ amount: number;
33
+ };
34
+ /** An optional field (campo opcional) in a WSFE invoice request. */
35
+ type WsfeOptionalField = {
36
+ id: string;
37
+ value: string;
38
+ };
39
+ /** A buyer (comprador) in a WSFE invoice request. */
40
+ type WsfeBuyer = {
41
+ documentType: number;
42
+ documentNumber: number;
43
+ percentage: number;
44
+ };
45
+ /** An activity associated with a WSFE invoice request. */
46
+ type WsfeActivity = {
47
+ id: number;
48
+ };
49
+ /** Input data for authorizing a WSFE voucher. */
50
+ type WsfeVoucherInput = {
51
+ salesPoint: number;
52
+ voucherType: number;
23
53
  concept: number;
24
54
  documentType: number;
25
55
  documentNumber: number;
26
56
  receiverVatConditionId: number;
27
57
  voucherDate: WsfeDateInput;
58
+ totalAmount: number;
59
+ nonTaxableAmount: number;
60
+ netAmount: number;
61
+ exemptAmount: number;
62
+ taxAmount: number;
63
+ vatAmount: number;
64
+ currencyId: string;
65
+ exchangeRate?: number | string;
66
+ sameCurrencyForeignCancellation?: "S" | "N";
28
67
  serviceStartDate?: WsfeDateInput;
29
68
  serviceEndDate?: WsfeDateInput;
30
69
  paymentDueDate?: WsfeDateInput;
70
+ associatedVouchers?: WsfeAssociatedVoucher[];
71
+ associatedPeriod?: WsfeAssociatedPeriod;
72
+ taxes?: WsfeTax[];
73
+ vatRates?: WsfeVatRate[];
74
+ optionalFields?: WsfeOptionalField[];
75
+ buyers?: WsfeBuyer[];
76
+ activities?: WsfeActivity[];
31
77
  };
32
- type BuildFacturaBInput = WsfeInvoiceBuilderBaseInput & WsfeBuilderCurrencyInput & {
33
- /** Positive integer currency minor units forming the taxable base. */
34
- taxableAmount: number;
35
- vatRate: WsfeBuilderVatRate;
78
+ /** Input for authorizing a WSFE voucher with an explicit voucher number. */
79
+ type WsfeAuthorizeVoucherInput = {
80
+ representedTaxId?: number | string;
81
+ data: WsfeVoucherInput;
82
+ voucherNumber: number;
83
+ forceRefresh?: boolean;
84
+ /** Aborts login, submission and consultation with the caller's deadline. */
85
+ abortSignal?: AbortSignal;
36
86
  };
37
- type BuildFacturaCInput = WsfeInvoiceBuilderBaseInput & WsfeBuilderCurrencyInput & {
38
- amount: number;
87
+ /** Structured evidence from one exact WSFE authorization attempt. */
88
+ type WsfeAuthorizationOutcome = ArcaAuthorizationOutcome<"wsfe">;
89
+ /** A point-of-sale entry returned by {@link WsfeService.getSalesPoints}. */
90
+ type WsfeSalesPoint = {
91
+ number: number;
92
+ emissionType?: string;
93
+ blocked?: string;
94
+ deletedSince?: string;
95
+ };
96
+ /** Voucher details returned by {@link WsfeService.getVoucherInfo}. */
97
+ type WsfeVoucherInfo = {
98
+ voucherNumber: number;
99
+ voucherDate?: string;
100
+ salesPoint?: number;
101
+ voucherType?: number;
102
+ concept?: number;
103
+ documentType?: number;
104
+ documentNumber?: string;
105
+ receiverVatConditionId?: number;
106
+ totalAmount?: number;
107
+ nonTaxableAmount?: number;
108
+ netAmount?: number;
109
+ exemptAmount?: number;
110
+ taxAmount?: number;
111
+ vatAmount?: number;
112
+ currencyId?: string;
113
+ exchangeRate?: number;
114
+ result?: string;
115
+ cae?: string;
116
+ caeExpiry?: string;
117
+ vatRates?: WsfeVatRate[];
118
+ serviceStartDate?: string;
119
+ serviceEndDate?: string;
120
+ paymentDueDate?: string;
121
+ taxes?: WsfeTax[];
122
+ associatedVouchers?: WsfeAssociatedVoucher[];
123
+ associatedPeriod?: WsfeAssociatedPeriod;
124
+ optionalFields?: WsfeOptionalField[];
125
+ buyers?: WsfeBuyer[];
126
+ activities?: WsfeActivity[];
127
+ sameCurrencyForeignCancellation?: "S" | "N";
128
+ raw: Record<string, unknown>;
129
+ };
130
+ /** Typed exact-voucher consultation result for WSFE. */
131
+ type WsfeVoucherLookupResult = ArcaVoucherLookupResult<WsfeVoucherInfo, "wsfe">;
132
+ type WsfeCatalogEntry = {
133
+ id: number;
134
+ description: string;
135
+ };
136
+ type WsfeActivityType = WsfeCatalogEntry & {
137
+ order: number;
138
+ };
139
+ type WsfeReceiverVatCondition = WsfeCatalogEntry & {
140
+ voucherClass: string;
141
+ };
142
+ type WsfeCurrencyType = {
143
+ id: string;
144
+ description: string;
145
+ validFrom: string;
146
+ validTo: string;
147
+ };
148
+ type WsfeServerStatus = {
149
+ appServer: string;
150
+ dbServer: string;
151
+ authServer: string;
152
+ };
153
+ type WsfeQuotation = {
154
+ currencyId: string;
155
+ rate: number;
156
+ date: string;
157
+ };
158
+ /** WSFE electronic invoicing service. */
159
+ type WsfeService = {
160
+ /**
161
+ * Issues one exact voucher: a single FECAESolicitar for the caller-owned
162
+ * `voucherNumber`, without transport retries, returning structured evidence
163
+ * (`authorized`, `rejected` or `indeterminate`) instead of throwing.
164
+ */
165
+ issue(input: WsfeAuthorizeVoucherInput): Promise<WsfeAuthorizationOutcome>;
166
+ /** Returns the next available voucher number for the given sales point and type. */
167
+ getNextVoucherNumber(input: {
168
+ representedTaxId?: number | string;
169
+ salesPoint: number;
170
+ voucherType: number;
171
+ forceRefresh?: boolean;
172
+ abortSignal?: AbortSignal;
173
+ }): Promise<number>;
174
+ /**
175
+ * @deprecated Use `getNextVoucherNumber()` instead.
176
+ * Returns the next available voucher number, not the last authorized one.
177
+ */
178
+ getLastVoucher(input: {
179
+ representedTaxId?: number | string;
180
+ salesPoint: number;
181
+ voucherType: number;
182
+ forceRefresh?: boolean;
183
+ }): Promise<number>;
184
+ /** Lists all configured points of sale for the taxpayer. */
185
+ getSalesPoints(input: {
186
+ representedTaxId?: number | string;
187
+ forceRefresh?: boolean;
188
+ }): Promise<WsfeSalesPoint[]>;
189
+ /** Lists voucher types accepted by WSFE. */
190
+ getVoucherTypes(input: {
191
+ representedTaxId?: number | string;
192
+ forceRefresh?: boolean;
193
+ }): Promise<WsfeCatalogEntry[]>;
194
+ /** Lists document types accepted by WSFE. */
195
+ getDocumentTypes(input: {
196
+ representedTaxId?: number | string;
197
+ forceRefresh?: boolean;
198
+ }): Promise<WsfeCatalogEntry[]>;
199
+ /** Lists concept types accepted by WSFE. */
200
+ getConceptTypes(input: {
201
+ representedTaxId?: number | string;
202
+ forceRefresh?: boolean;
203
+ }): Promise<WsfeCatalogEntry[]>;
204
+ /** Lists live ARCA currency identifiers such as PES and DOL, not ISO codes. */
205
+ getCurrencyTypes(input: {
206
+ representedTaxId?: number | string;
207
+ forceRefresh?: boolean;
208
+ }): Promise<WsfeCurrencyType[]>;
209
+ /** Lists VAT rates accepted by WSFE. */
210
+ getVatRates(input: {
211
+ representedTaxId?: number | string;
212
+ forceRefresh?: boolean;
213
+ }): Promise<WsfeCatalogEntry[]>;
214
+ /** Lists tax types accepted by WSFE. */
215
+ getTaxTypes(input: {
216
+ representedTaxId?: number | string;
217
+ forceRefresh?: boolean;
218
+ }): Promise<WsfeCatalogEntry[]>;
219
+ /** Lists optional field types accepted by WSFE. */
220
+ getOptionalTypes(input: {
221
+ representedTaxId?: number | string;
222
+ forceRefresh?: boolean;
223
+ }): Promise<WsfeCatalogEntry[]>;
224
+ /** Lists activities enabled for the taxpayer. */
225
+ getActivities(input: {
226
+ representedTaxId?: number | string;
227
+ forceRefresh?: boolean;
228
+ }): Promise<WsfeActivityType[]>;
229
+ /** Lists receiver VAT condition values accepted by WSFE. */
230
+ getReceiverVatConditions(input: {
231
+ representedTaxId?: number | string;
232
+ voucherClass?: string;
233
+ forceRefresh?: boolean;
234
+ }): Promise<WsfeReceiverVatCondition[]>;
235
+ /** Reports WSFE backend status without requiring taxpayer authorization. */
236
+ getServerStatus(): Promise<WsfeServerStatus>;
237
+ /** Returns the exchange rate for a given currency. */
238
+ getQuotation(input: {
239
+ currencyId: string;
240
+ representedTaxId?: number | string;
241
+ forceRefresh?: boolean;
242
+ }): Promise<WsfeQuotation>;
243
+ /** Retrieves details for a specific voucher. Returns `null` if not found. */
244
+ getVoucherInfo(input: {
245
+ representedTaxId?: number | string;
246
+ number: number;
247
+ salesPoint: number;
248
+ voucherType: number;
249
+ forceRefresh?: boolean;
250
+ }): Promise<WsfeVoucherInfo | null>;
251
+ /** Consults one exact voucher and normalizes WSFE error 602 to `not_found`. */
252
+ lookupVoucher(input: {
253
+ representedTaxId?: number | string;
254
+ number: number;
255
+ salesPoint: number;
256
+ voucherType: number;
257
+ forceRefresh?: boolean;
258
+ abortSignal?: AbortSignal;
259
+ }): Promise<WsfeVoucherLookupResult>;
260
+ };
261
+ type CreateWsfeServiceOptions = {
262
+ config: ArcaClientConfig;
263
+ auth: WsaaAuthModule;
264
+ soap: SoapTransport;
39
265
  };
40
- /** Builds a narrow Factura B exact WSFE input from integer currency minor units. */
41
- declare function buildFacturaB(input: BuildFacturaBInput): WsfeVoucherInput;
42
- /** Builds a narrow Factura C exact WSFE input from integer currency minor units. */
43
- declare function buildFacturaC(input: BuildFacturaCInput): WsfeVoucherInput;
266
+ /** Creates a WSFE service instance wired with authentication and SOAP transport. */
267
+ declare function createWsfeService(options: CreateWsfeServiceOptions): WsfeService;
44
268
 
45
- export { type BuildFacturaBInput, type BuildFacturaCInput, type WsfeBuilderCurrencyInput, type WsfeBuilderVatRate, WsfeDateInput, WsfeVoucherInput, buildFacturaB, buildFacturaC };
269
+ export { type CreateWsfeServiceOptions, type WsfeActivity, type WsfeActivityType, type WsfeAssociatedPeriod, type WsfeAssociatedVoucher, type WsfeAuthorizationOutcome, type WsfeAuthorizeVoucherInput, type WsfeBuyer, type WsfeCatalogEntry, type WsfeCurrencyType, type WsfeDateInput, type WsfeOptionalField, type WsfeQuotation, type WsfeReceiverVatCondition, type WsfeSalesPoint, type WsfeServerStatus, type WsfeService, type WsfeTax, type WsfeVatRate, type WsfeVoucherInfo, type WsfeVoucherInput, type WsfeVoucherLookupResult, createWsfeService };
package/dist/wsfe.mjs CHANGED
@@ -1,16 +1,9 @@
1
- import {
2
- buildFacturaB,
3
- buildFacturaC
4
- } from "./chunk-ZZDL6I56.mjs";
5
1
  import {
6
2
  createWsfeService
7
- } from "./chunk-YYDSBHMO.mjs";
8
- import "./chunk-GX5ERXT6.mjs";
3
+ } from "./chunk-BPBTQDCO.mjs";
9
4
  import "./chunk-PHXH34L6.mjs";
10
5
  import "./chunk-BYEP3ABS.mjs";
11
6
  export {
12
- buildFacturaB,
13
- buildFacturaC,
14
7
  createWsfeService
15
8
  };
16
9
  //# sourceMappingURL=wsfe.mjs.map
package/dist/wsmtxca.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { n as ArcaRepresentedTaxId, a as ArcaClientConfig } from './types-SdBQAflw.js';
2
- import { W as WsaaAuthModule, S as SoapTransport } from './index-CT1ffEAL.js';
3
- import { A as ArcaAuthorizationOutcome, a as ArcaVoucherLookupResult } from './fiscal-evidence-DXl_U1uz.js';
1
+ import { n as ArcaRepresentedTaxId, a as ArcaClientConfig } from './types-Su7QwloQ.js';
2
+ import { W as WsaaAuthModule, S as SoapTransport } from './index-DAC3edtw.js';
3
+ import { e as ArcaAuthorizationOutcome, t as ArcaVoucherLookupResult } from './fiscal-evidence-DaCyGd5o.js';
4
4
 
5
5
  /** Input data for one WSMTXCA voucher authorization. */
6
6
  type WsmtxcaAuthorizeVoucherInput = {
@@ -8,7 +8,7 @@ type WsmtxcaAuthorizeVoucherInput = {
8
8
  data: Record<string, unknown>;
9
9
  forceRefresh?: boolean;
10
10
  /** Aborts login, submission and consultation with the caller's deadline. */
11
- signal?: AbortSignal;
11
+ abortSignal?: AbortSignal;
12
12
  };
13
13
  /** Structured evidence from one exact WSMTXCA authorization attempt. */
14
14
  type WsmtxcaAuthorizationOutcome = ArcaAuthorizationOutcome<"wsmtxca">;
@@ -73,7 +73,7 @@ type WsmtxcaService = {
73
73
  voucherType: number;
74
74
  salesPoint: number;
75
75
  forceRefresh?: boolean;
76
- signal?: AbortSignal;
76
+ abortSignal?: AbortSignal;
77
77
  }): Promise<WsmtxcaLastAuthorizedVoucherResult>;
78
78
  /** Returns the points of sale enabled for WSMTXCA. */
79
79
  getSalesPoints(input: {
@@ -87,7 +87,7 @@ type WsmtxcaService = {
87
87
  salesPoint: number;
88
88
  voucherNumber: number;
89
89
  forceRefresh?: boolean;
90
- signal?: AbortSignal;
90
+ abortSignal?: AbortSignal;
91
91
  }): Promise<WsmtxcaVoucherLookupOutcome>;
92
92
  /** Retrieves details for a specific voucher. */
93
93
  getVoucher(input: {
package/dist/wsmtxca.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createWsmtxcaService
3
- } from "./chunk-3EJINDBP.mjs";
3
+ } from "./chunk-WN62NMUJ.mjs";
4
4
  import "./chunk-PHXH34L6.mjs";
5
5
  import "./chunk-BYEP3ABS.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "facturas",
3
- "version": "0.12.4",
3
+ "version": "0.13.0",
4
4
  "description": "Node.js client for ARCA services including WSFE, WSMTXCA, and padron lookups.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/wsmtxca.ts"],"sourcesContent":["import {\n ArcaInputError,\n ArcaInvalidSoapResponseError,\n ArcaServiceError,\n ArcaSoapFaultError,\n ArcaTransportError,\n} from \"../errors\";\nimport {\n classifyArcaAuthenticationError,\n classifyArcaAuthenticationIssues,\n createArcaAuthenticationEvidence,\n executeWithAuthenticationRecovery,\n} from \"../internal/authentication\";\nimport type { ArcaClientConfig, ArcaRepresentedTaxId } from \"../internal/types\";\nimport type { SoapTransport } from \"../soap\";\nimport type { WsaaAuthModule } from \"../wsaa\";\nimport type {\n ArcaAuthorizationIndeterminateReason,\n ArcaAuthorizationOutcome,\n ArcaFiscalIssue,\n ArcaVoucherLookupResult,\n} from \"./fiscal-evidence\";\n\n/** Input data for one WSMTXCA voucher authorization. */\nexport type WsmtxcaAuthorizeVoucherInput = {\n representedTaxId?: ArcaRepresentedTaxId;\n data: Record<string, unknown>;\n forceRefresh?: boolean;\n /** Aborts login, submission and consultation with the caller's deadline. */\n signal?: AbortSignal;\n};\n\n/** Structured evidence from one exact WSMTXCA authorization attempt. */\nexport type WsmtxcaAuthorizationOutcome = ArcaAuthorizationOutcome<\"wsmtxca\">;\n\n/** Result of querying the last authorized voucher number. */\nexport type WsmtxcaLastAuthorizedVoucherResult = {\n voucherNumber: number;\n raw: Record<string, unknown>;\n};\n\n/** A point of sale enabled for WSMTXCA. */\nexport type WsmtxcaSalesPoint = {\n number: number;\n blocked: boolean;\n deletedAt?: string;\n};\n\n/** Result of querying WSMTXCA points of sale. */\nexport type WsmtxcaSalesPointsResult = {\n salesPoints: WsmtxcaSalesPoint[];\n raw: Record<string, unknown>;\n};\n\n/** Typed provider fields used to match one exact WSMTXCA voucher. */\nexport type WsmtxcaVoucherInfo = {\n voucherNumber?: number;\n invoiceDate?: string;\n salesPoint?: number;\n voucherType?: number;\n concept?: number;\n documentType?: number;\n documentNumber?: string;\n receiverVatConditionId?: number;\n totalAmount?: number;\n subtotalAmount?: number;\n taxableAmount?: number;\n nonTaxableAmount?: number;\n exemptAmount?: number;\n taxAmount?: number;\n vatAmount?: number;\n currencyId?: string;\n exchangeRate?: number;\n cae?: string;\n caeExpiry?: string;\n raw: Record<string, unknown>;\n};\n\n/** Typed exact-voucher consultation result for WSMTXCA. */\nexport type WsmtxcaVoucherLookupOutcome = ArcaVoucherLookupResult<\n WsmtxcaVoucherInfo,\n \"wsmtxca\"\n>;\n\n/** Result of looking up a specific WSMTXCA voucher. */\nexport type WsmtxcaVoucherLookupResult = {\n invoiceDate: string;\n voucher: Record<string, unknown>;\n messages: string[];\n raw: Record<string, unknown>;\n};\n\n/** WSMTXCA electronic invoicing service (Factura de Crédito Electrónica). */\nexport type WsmtxcaService = {\n /**\n * Issues one exact voucher: a single autorizarComprobante without transport\n * retries, returning structured evidence instead of throwing.\n */\n issue(\n input: WsmtxcaAuthorizeVoucherInput\n ): Promise<WsmtxcaAuthorizationOutcome>;\n /** Returns the last authorized voucher number for the given sales point and type. */\n getLastAuthorizedVoucher(input: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n }): Promise<WsmtxcaLastAuthorizedVoucherResult>;\n /** Returns the points of sale enabled for WSMTXCA. */\n getSalesPoints(input: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceRefresh?: boolean;\n }): Promise<WsmtxcaSalesPointsResult>;\n /** Consults one exact voucher and normalizes WSMTXCA error 1503 to `not_found`. */\n lookupVoucher(input: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n voucherNumber: number;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n }): Promise<WsmtxcaVoucherLookupOutcome>;\n /** Retrieves details for a specific voucher. */\n getVoucher(input: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n voucherNumber: number;\n forceRefresh?: boolean;\n }): Promise<WsmtxcaVoucherLookupResult>;\n};\n\nexport type CreateWsmtxcaServiceOptions = {\n config: ArcaClientConfig;\n auth: WsaaAuthModule;\n soap: SoapTransport;\n};\n\n/** Creates a WSMTXCA service instance wired with authentication and SOAP transport. */\nexport function createWsmtxcaService(\n options: CreateWsmtxcaServiceOptions\n): WsmtxcaService {\n async function executeWsmtxcaAuthenticatedOperation(\n operation: WsmtxcaOperation,\n input: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n },\n body: Record<string, unknown> = {},\n retries?: number\n ) {\n const auth = await options.auth.login(\"wsmtxca\", {\n representedTaxId: input.representedTaxId,\n forceRefresh: input.forceRefresh,\n signal: input.signal,\n });\n const response = await options.soap.execute<\n Record<string, unknown>,\n Record<string, unknown>\n >({\n service: \"wsmtxca\",\n operation,\n ...(retries === undefined ? {} : { retries }),\n signal: input.signal,\n bodyElementName: `${operation}Request`,\n bodyElementNamespaceMode: \"prefix\",\n body: {\n // WSMTXCA request types use an XML sequence with authentication first.\n authRequest: createWsmtxcaAuth(\n input.representedTaxId ?? options.config.taxId,\n auth.token,\n auth.sign\n ),\n ...body,\n },\n });\n\n return unwrapWsmtxcaOperationResponse(response.result, operation);\n }\n\n async function executeWsmtxcaAuthorization({\n representedTaxId,\n data,\n forceRefresh,\n signal,\n }: WsmtxcaAuthorizeVoucherInput): Promise<{\n outcome: WsmtxcaAuthorizationOutcome;\n error?: unknown;\n }> {\n if (Object.hasOwn(data, \"authRequest\")) {\n throw new ArcaInputError(\n 'WSMTXCA authorization data cannot include the reserved top-level field \"authRequest\".',\n {\n code: \"ARCA_INPUT_RESERVED_FIELD\",\n field: \"data.authRequest\",\n expected: \"omitted because facturas manages authentication fields\",\n }\n );\n }\n\n try {\n const raw = await executeWsmtxcaAuthenticatedOperation(\n \"autorizarComprobante\",\n { representedTaxId, forceRefresh, signal },\n data,\n 0\n );\n return { outcome: classifyWsmtxcaAuthorization(raw) };\n } catch (error) {\n return {\n outcome: createWsmtxcaIndeterminateOutcome(error),\n error,\n };\n }\n }\n\n async function issue(\n input: WsmtxcaAuthorizeVoucherInput\n ): Promise<WsmtxcaAuthorizationOutcome> {\n return (await executeWsmtxcaAuthorization(input)).outcome;\n }\n\n function getLastAuthorizedVoucher({\n representedTaxId,\n voucherType,\n salesPoint,\n forceRefresh,\n signal,\n }: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n }): Promise<WsmtxcaLastAuthorizedVoucherResult> {\n return executeWithAuthenticationRecovery({\n service: \"wsmtxca\",\n operation: \"consultarUltimoComprobanteAutorizado\",\n forceRefresh,\n execute: (attemptForceRefresh) =>\n getLastAuthorizedVoucherOnce({\n representedTaxId,\n voucherType,\n salesPoint,\n forceRefresh: attemptForceRefresh,\n signal,\n }),\n });\n }\n\n async function getLastAuthorizedVoucherOnce({\n representedTaxId,\n voucherType,\n salesPoint,\n forceRefresh,\n signal,\n }: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n }): Promise<WsmtxcaLastAuthorizedVoucherResult> {\n const operation = \"consultarUltimoComprobanteAutorizado\";\n const raw = await executeWsmtxcaAuthenticatedOperation(\n operation,\n { representedTaxId, forceRefresh, signal },\n {\n consultaUltimoComprobanteAutorizadoRequest: {\n codigoTipoComprobante: voucherType,\n numeroPuntoVenta: salesPoint,\n },\n }\n );\n const errors = extractWsmtxcaIssues(raw, operation, \"error\");\n\n if (errors.length > 0 && errors.every((issue) => issue.code === \"1502\")) {\n return { voucherNumber: 0, raw };\n }\n if (errors.length > 0) {\n throw createWsmtxcaServiceError(operation, errors);\n }\n\n return {\n voucherNumber: parseWsmtxcaVoucherNumber(\n raw.numeroComprobante ?? raw.cbteNro ?? raw.nroComprobante,\n \"WSMTXCA did not return the last authorized voucher number\",\n true\n ),\n raw,\n };\n }\n\n function getSalesPoints({\n representedTaxId,\n forceRefresh,\n }: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceRefresh?: boolean;\n }): Promise<WsmtxcaSalesPointsResult> {\n return executeWithAuthenticationRecovery({\n service: \"wsmtxca\",\n operation: \"consultarPuntosVenta\",\n forceRefresh,\n execute: (attemptForceRefresh) =>\n getSalesPointsOnce({\n representedTaxId,\n forceRefresh: attemptForceRefresh,\n }),\n });\n }\n\n async function getSalesPointsOnce({\n representedTaxId,\n forceRefresh,\n }: {\n representedTaxId?: ArcaRepresentedTaxId;\n forceRefresh?: boolean;\n }): Promise<WsmtxcaSalesPointsResult> {\n const operation = \"consultarPuntosVenta\";\n const raw = await executeWsmtxcaAuthenticatedOperation(operation, {\n representedTaxId,\n forceRefresh,\n });\n throwForWsmtxcaOperationErrors(operation, raw);\n const rawSalesPoints = toRecord(raw.arrayPuntosVenta)?.puntoVenta;\n const entries = Array.isArray(rawSalesPoints)\n ? rawSalesPoints\n : rawSalesPoints\n ? [rawSalesPoints]\n : [];\n const salesPoints = entries.flatMap((entry) => {\n const record = toRecord(entry);\n const number = parseOptionalPositiveInteger(record?.numeroPuntoVenta);\n if (number === undefined) {\n return [];\n }\n const deletedAt = normalizeWsmtxcaResponseDate(record?.fechaBaja);\n return [\n {\n number,\n blocked: String(record?.bloqueado ?? \"N\").toUpperCase() === \"S\",\n ...(deletedAt === undefined ? {} : { deletedAt }),\n },\n ];\n });\n\n return { salesPoints, raw };\n }\n\n function lookupVoucher({\n representedTaxId,\n voucherType,\n salesPoint,\n voucherNumber,\n forceRefresh,\n signal,\n }: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n voucherNumber: number;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n }): Promise<WsmtxcaVoucherLookupOutcome> {\n return executeWithAuthenticationRecovery({\n service: \"wsmtxca\",\n operation: \"consultarComprobante\",\n forceRefresh,\n execute: (attemptForceRefresh) =>\n lookupVoucherOnce({\n representedTaxId,\n voucherType,\n salesPoint,\n voucherNumber,\n forceRefresh: attemptForceRefresh,\n signal,\n }),\n });\n }\n\n async function lookupVoucherOnce({\n representedTaxId,\n voucherType,\n salesPoint,\n voucherNumber,\n forceRefresh,\n signal,\n }: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n voucherNumber: number;\n forceRefresh?: boolean;\n signal?: AbortSignal;\n }): Promise<WsmtxcaVoucherLookupOutcome> {\n const operation = \"consultarComprobante\";\n const raw = await executeWsmtxcaAuthenticatedOperation(\n operation,\n { representedTaxId, forceRefresh, signal },\n {\n consultaComprobanteRequest: {\n codigoTipoComprobante: voucherType,\n numeroPuntoVenta: salesPoint,\n numeroComprobante: voucherNumber,\n },\n }\n );\n const errors = extractWsmtxcaIssues(raw, operation, \"error\");\n const observations = extractWsmtxcaIssues(raw, operation, \"observation\");\n\n if (errors.length > 0 && errors.every((issue) => issue.code === \"1503\")) {\n return {\n kind: \"not_found\",\n service: \"wsmtxca\",\n operation,\n errors,\n observations,\n raw,\n };\n }\n if (errors.length > 0) {\n throw createWsmtxcaServiceError(operation, errors);\n }\n\n const voucher = extractWsmtxcaVoucherPayload(raw);\n if (voucher === raw && !toRecord(raw.comprobante)) {\n throw new ArcaServiceError(\n \"WSMTXCA did not return the voucher issue date\",\n {\n service: \"wsmtxca\",\n operation,\n issues: observations,\n }\n );\n }\n\n return {\n kind: \"found\",\n service: \"wsmtxca\",\n operation,\n voucher: mapWsmtxcaVoucherInfo(voucher),\n observations,\n raw,\n };\n }\n\n async function getVoucher(input: {\n representedTaxId?: ArcaRepresentedTaxId;\n voucherType: number;\n salesPoint: number;\n voucherNumber: number;\n forceRefresh?: boolean;\n }): Promise<WsmtxcaVoucherLookupResult> {\n const lookup = await lookupVoucher(input);\n if (lookup.kind === \"not_found\") {\n throw createWsmtxcaServiceError(lookup.operation, lookup.errors);\n }\n\n const invoiceDate = lookup.voucher.invoiceDate;\n if (!invoiceDate) {\n throw new ArcaServiceError(\n formatWsmtxcaIssues(lookup.observations)[0] ??\n \"WSMTXCA did not return the voucher issue date\",\n {\n service: \"wsmtxca\",\n operation: lookup.operation,\n issues: lookup.observations,\n }\n );\n }\n\n return {\n invoiceDate,\n voucher: lookup.voucher.raw,\n messages: formatWsmtxcaIssues(lookup.observations),\n raw: lookup.raw,\n };\n }\n\n return {\n issue,\n getLastAuthorizedVoucher,\n getSalesPoints,\n lookupVoucher,\n getVoucher,\n };\n}\n\nfunction createWsmtxcaAuth(\n representedTaxId: number | string,\n token: string,\n sign: string\n) {\n return {\n token,\n sign,\n cuitRepresentada: Number.parseInt(String(representedTaxId), 10),\n };\n}\n\nfunction toRecord(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined;\n}\n\ntype WsmtxcaOperation =\n | \"autorizarComprobante\"\n | \"consultarUltimoComprobanteAutorizado\"\n | \"consultarPuntosVenta\"\n | \"consultarComprobante\";\n\nfunction unwrapWsmtxcaOperationResponse(\n response: unknown,\n operation: WsmtxcaOperation\n) {\n const responseRecord = toRecord(response) ?? {};\n\n if (operation === \"autorizarComprobante\") {\n return (\n toRecord(responseRecord.autorizarComprobanteResponse) ??\n toRecord(responseRecord.autorizarComprobanteResult) ??\n toRecord(responseRecord.comprobanteCAEResponse) ??\n toRecord(responseRecord.comprobanteCAEReponse) ??\n responseRecord\n );\n }\n\n if (operation === \"consultarComprobante\") {\n return (\n toRecord(responseRecord.consultarComprobanteResponse) ??\n toRecord(responseRecord.consultaComprobanteResponse) ??\n toRecord(responseRecord.consultarComprobanteResult) ??\n responseRecord\n );\n }\n\n if (operation === \"consultarPuntosVenta\") {\n return (\n toRecord(responseRecord.consultarPuntosVentaResponse) ??\n toRecord(responseRecord.consultarPuntosVentaResult) ??\n responseRecord\n );\n }\n\n return (\n toRecord(responseRecord.consultarUltimoComprobanteAutorizadoResponse) ??\n toRecord(responseRecord.consultaUltimoComprobanteAutorizadoResponse) ??\n toRecord(responseRecord.consultarUltimoComprobanteAutorizadoResult) ??\n responseRecord\n );\n}\n\nfunction extractWsmtxcaAuthorizationPayload(raw: Record<string, unknown>) {\n return (\n toRecord(raw.comprobanteResponse) ??\n toRecord(raw.comprobanteCAEResponse) ??\n toRecord(raw.comprobanteCAEReponse) ??\n raw\n );\n}\n\nfunction extractWsmtxcaVoucherPayload(raw: Record<string, unknown>) {\n return (\n toRecord(raw.comprobanteResponse) ??\n toRecord(raw.comprobante) ??\n toRecord(raw.cmp) ??\n raw\n );\n}\n\nfunction classifyWsmtxcaAuthorization(\n raw: Record<string, unknown>\n): WsmtxcaAuthorizationOutcome {\n const operation = \"autorizarComprobante\";\n const payload = extractWsmtxcaAuthorizationPayload(raw);\n const result = normalizeWsmtxcaResult(raw.resultado ?? payload.resultado);\n const cae = normalizeWsmtxcaString(\n payload.CAE ?? payload.codigoAutorizacion ?? raw.codigoAutorizacion\n );\n const caeExpiry = normalizeWsmtxcaResponseDate(\n payload.fechaVencimientoCAE ??\n payload.fechaVencimiento ??\n raw.fechaVencimiento\n );\n const voucherNumber = parseOptionalPositiveInteger(\n payload.numeroComprobante ?? raw.numeroComprobante\n );\n const errors = extractWsmtxcaIssues(raw, operation, \"error\");\n const observations = extractWsmtxcaIssues(raw, operation, \"observation\");\n const base = {\n service: \"wsmtxca\" as const,\n operation,\n results: createWsmtxcaResults(result),\n errors,\n observations,\n raw,\n };\n\n const authenticationOutcome = createWsmtxcaAuthenticationOutcome({\n base,\n result,\n cae,\n voucherNumber,\n });\n if (authenticationOutcome) {\n return authenticationOutcome;\n }\n\n if (\n (result === \"A\" || result === \"O\") &&\n cae &&\n voucherNumber !== undefined &&\n errors.length === 0\n ) {\n return {\n ...base,\n kind: \"authorized\",\n result,\n resultLevel: \"operation\",\n cae,\n ...(caeExpiry === undefined ? {} : { caeExpiry }),\n voucherNumber,\n };\n }\n\n if (result === \"R\" && !cae && errors.length > 0) {\n return {\n ...base,\n kind: \"rejected\",\n result: \"R\",\n resultLevel: \"operation\",\n };\n }\n\n const outcome: WsmtxcaAuthorizationOutcome = {\n ...base,\n kind: \"indeterminate\",\n reason:\n (result === \"R\" && Boolean(cae)) ||\n ((result === \"A\" || result === \"O\") && Boolean(errors.length))\n ? \"contradictory_response\"\n : \"incomplete_response\",\n ...(result === undefined ? {} : { result }),\n ...(result === undefined ? {} : { resultLevel: \"operation\" }),\n };\n assignWsmtxcaValue(outcome, \"cae\", cae);\n assignWsmtxcaValue(outcome, \"caeExpiry\", caeExpiry);\n assignWsmtxcaValue(outcome, \"voucherNumber\", voucherNumber);\n return outcome;\n}\n\nfunction createWsmtxcaAuthenticationOutcome({\n base,\n result,\n cae,\n voucherNumber,\n}: {\n base: {\n service: \"wsmtxca\";\n operation: string;\n results: ReturnType<typeof createWsmtxcaResults>;\n errors: ArcaFiscalIssue[];\n observations: ArcaFiscalIssue[];\n raw: Record<string, unknown>;\n };\n result?: string;\n cae?: string;\n voucherNumber?: number;\n}): WsmtxcaAuthorizationOutcome | undefined {\n const authenticationError = classifyArcaAuthenticationIssues(base.errors, {\n service: base.service,\n operation: base.operation,\n });\n if (\n !authenticationError ||\n result === \"A\" ||\n result === \"O\" ||\n cae ||\n voucherNumber !== undefined\n ) {\n return undefined;\n }\n\n return {\n ...base,\n kind: \"indeterminate\",\n reason: \"authentication_rejected\",\n authentication: createArcaAuthenticationEvidence(authenticationError),\n ...(result === undefined ? {} : { result }),\n ...(result === undefined ? {} : { resultLevel: \"operation\" }),\n };\n}\n\nfunction createWsmtxcaIndeterminateOutcome(\n error: unknown\n): WsmtxcaAuthorizationOutcome {\n const authenticationError = classifyArcaAuthenticationError(error, {\n service: \"wsmtxca\",\n operation: \"autorizarComprobante\",\n });\n return {\n kind: \"indeterminate\",\n service: \"wsmtxca\",\n operation: \"autorizarComprobante\",\n results: {},\n reason: authenticationError\n ? \"authentication_rejected\"\n : getWsmtxcaIndeterminateReason(error),\n ...(authenticationError\n ? {\n authentication: createArcaAuthenticationEvidence(authenticationError),\n }\n : {}),\n errors: [],\n observations: [],\n };\n}\n\nfunction getWsmtxcaIndeterminateReason(\n error: unknown\n): ArcaAuthorizationIndeterminateReason {\n if (error instanceof ArcaTransportError) {\n return \"transport_error\";\n }\n if (error instanceof ArcaSoapFaultError) {\n return \"soap_fault\";\n }\n if (error instanceof ArcaInvalidSoapResponseError) {\n return \"invalid_response\";\n }\n return \"unexpected_error\";\n}\n\nfunction createWsmtxcaResults(operationResult?: string) {\n const results: { operation?: string } = {};\n assignWsmtxcaValue(results, \"operation\", operationResult);\n return results;\n}\n\nfunction createWsmtxcaServiceError(\n operation: string,\n issues: ArcaFiscalIssue[]\n) {\n const authenticationError = classifyArcaAuthenticationIssues(issues, {\n service: \"wsmtxca\",\n operation,\n });\n if (authenticationError) {\n return authenticationError;\n }\n\n const firstIssue = issues[0];\n return new ArcaServiceError(\n formatWsmtxcaIssues(issues).join(\" | \") ||\n \"WSMTXCA returned a service error\",\n {\n service: \"wsmtxca\",\n operation,\n ...(firstIssue?.code === undefined\n ? {}\n : { serviceCode: firstIssue.code }),\n issues,\n }\n );\n}\n\nfunction throwForWsmtxcaOperationErrors(\n operation: string,\n raw: Record<string, unknown>\n): void {\n const errors = extractWsmtxcaIssues(raw, operation, \"error\");\n if (errors.length > 0) {\n throw createWsmtxcaServiceError(operation, errors);\n }\n}\n\nfunction extractWsmtxcaIssues(\n raw: Record<string, unknown>,\n operation: string,\n source: \"error\" | \"observation\"\n): ArcaFiscalIssue[] {\n const container = toRecord(\n source === \"error\" ? raw.arrayErrores : raw.arrayObservaciones\n );\n return normalizeWsmtxcaIssueEntries(container?.codigoDescripcion).map(\n (entry) => ({\n service: \"wsmtxca\",\n operation,\n source,\n category:\n source === \"observation\"\n ? \"observation\"\n : operation === \"autorizarComprobante\"\n ? \"business\"\n : \"unknown\",\n ...(entry.code === undefined ? {} : { code: entry.code }),\n message: entry.message,\n ...(operation === \"autorizarComprobante\"\n ? { resultLevel: \"operation\" as const }\n : {}),\n })\n );\n}\n\nfunction normalizeWsmtxcaIssueEntries(value: unknown) {\n const entries = Array.isArray(value) ? value : value ? [value] : [];\n return entries.map((entry) => {\n const record = toRecord(entry) ?? {};\n const code = record.codigo;\n const description = record.descripcion;\n return {\n ...(code === undefined || code === null ? {} : { code: String(code) }),\n message:\n description === undefined || description === null\n ? \"Unknown WSMTXCA issue\"\n : String(description),\n };\n });\n}\n\nfunction formatWsmtxcaIssues(issues: ArcaFiscalIssue[]): string[] {\n return issues.map((issue) => {\n const prefix = issue.source === \"error\" ? \"Error\" : \"Obs\";\n return `${prefix}${issue.code ? ` ${issue.code}` : \"\"}: ${issue.message}`;\n });\n}\n\nfunction mapWsmtxcaVoucherInfo(\n raw: Record<string, unknown>\n): WsmtxcaVoucherInfo {\n const voucher: WsmtxcaVoucherInfo = { raw };\n const invoiceDate = normalizeWsmtxcaResponseDate(\n raw.fechaEmision ?? raw.fecha ?? raw.CbteFch\n );\n const cae = normalizeWsmtxcaString(raw.codigoAutorizacion ?? raw.CAE);\n const caeExpiry = normalizeWsmtxcaResponseDate(\n raw.fechaVencimiento ?? raw.fechaVencimientoCAE\n );\n const vatAmount = sumWsmtxcaVatAmounts(raw.arraySubtotalesIVA);\n\n assignWsmtxcaValue(\n voucher,\n \"voucherNumber\",\n parseOptionalPositiveInteger(raw.numeroComprobante)\n );\n assignWsmtxcaValue(voucher, \"invoiceDate\", invoiceDate);\n assignWsmtxcaValue(\n voucher,\n \"salesPoint\",\n parseOptionalPositiveInteger(raw.numeroPuntoVenta)\n );\n assignWsmtxcaValue(\n voucher,\n \"voucherType\",\n parseOptionalPositiveInteger(raw.codigoTipoComprobante)\n );\n assignWsmtxcaValue(\n voucher,\n \"concept\",\n parseOptionalNumber(raw.codigoConcepto)\n );\n assignWsmtxcaValue(\n voucher,\n \"documentType\",\n parseOptionalNumber(raw.codigoTipoDocumento)\n );\n assignWsmtxcaValue(\n voucher,\n \"documentNumber\",\n normalizeWsmtxcaString(raw.numeroDocumento)\n );\n assignWsmtxcaValue(\n voucher,\n \"receiverVatConditionId\",\n parseOptionalNumber(raw.condicionIVAReceptor)\n );\n assignWsmtxcaValue(\n voucher,\n \"totalAmount\",\n parseOptionalNumber(raw.importeTotal)\n );\n assignWsmtxcaValue(\n voucher,\n \"subtotalAmount\",\n parseOptionalNumber(raw.importeSubtotal)\n );\n assignWsmtxcaValue(\n voucher,\n \"taxableAmount\",\n parseOptionalNumber(raw.importeGravado)\n );\n assignWsmtxcaValue(\n voucher,\n \"nonTaxableAmount\",\n parseOptionalNumber(raw.importeNoGravado)\n );\n assignWsmtxcaValue(\n voucher,\n \"exemptAmount\",\n parseOptionalNumber(raw.importeExento)\n );\n // A voucher issued without tributes carries neither the amount nor the\n // detail, and its tribute amount is zero.\n assignWsmtxcaValue(\n voucher,\n \"taxAmount\",\n parseOptionalNumber(raw.importeOtrosTributos) ??\n (raw.arrayOtrosTributos === undefined ? 0 : undefined)\n );\n assignWsmtxcaValue(voucher, \"vatAmount\", vatAmount);\n assignWsmtxcaValue(\n voucher,\n \"currencyId\",\n normalizeWsmtxcaString(raw.codigoMoneda)\n );\n assignWsmtxcaValue(\n voucher,\n \"exchangeRate\",\n parseOptionalNumber(raw.cotizacionMoneda)\n );\n assignWsmtxcaValue(voucher, \"cae\", cae);\n assignWsmtxcaValue(voucher, \"caeExpiry\", caeExpiry);\n\n return voucher;\n}\n\nfunction sumWsmtxcaVatAmounts(value: unknown): number | undefined {\n const subtotals = toRecord(value)?.subtotalIVA;\n const entries = Array.isArray(subtotals)\n ? subtotals\n : subtotals\n ? [subtotals]\n : [];\n const amounts = entries\n .map((entry) => parseOptionalNumber(toRecord(entry)?.importe))\n .filter((amount): amount is number => amount !== undefined);\n return amounts.length > 0\n ? amounts.reduce((total, amount) => total + amount, 0)\n : undefined;\n}\n\nfunction parseWsmtxcaVoucherNumber(\n value: unknown,\n message: string,\n allowZero = false\n) {\n const parsed = Number.parseInt(String(value ?? \"\"), 10);\n if (!Number.isFinite(parsed) || (allowZero ? parsed < 0 : parsed <= 0)) {\n throw new ArcaServiceError(message, {\n service: \"wsmtxca\",\n });\n }\n return parsed;\n}\n\nfunction parseOptionalPositiveInteger(value: unknown): number | undefined {\n const parsed = Number.parseInt(String(value ?? \"\"), 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n}\n\nfunction parseOptionalNumber(value: unknown): number | undefined {\n if (value === undefined || value === null || value === \"\") {\n return undefined;\n }\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\nfunction normalizeWsmtxcaResult(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return undefined;\n }\n const normalized = value.trim().toUpperCase();\n return normalized || undefined;\n}\n\nfunction normalizeWsmtxcaString(value: unknown): string | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n const normalized = String(value).trim();\n return normalized || undefined;\n}\n\nfunction assignWsmtxcaValue<TTarget, TKey extends keyof TTarget>(\n target: TTarget,\n key: TKey,\n value: TTarget[TKey] | undefined\n) {\n if (value !== undefined) {\n target[key] = value;\n }\n}\n\nfunction normalizeWsmtxcaResponseDate(value: unknown): string | undefined {\n if (typeof value === \"number\" && Number.isInteger(value)) {\n return formatCompactDateToIso(value);\n }\n\n if (typeof value !== \"string\") {\n return undefined;\n }\n\n const trimmed = value.trim();\n if (!trimmed) {\n return undefined;\n }\n\n if (/^\\d{8}$/.test(trimmed)) {\n return formatCompactDateToIso(Number.parseInt(trimmed, 10));\n }\n\n if (/^\\d{4}-\\d{2}-\\d{2}/.test(trimmed)) {\n return trimmed.slice(0, 10);\n }\n\n return undefined;\n}\n\nfunction formatCompactDateToIso(dateValue?: number | null): string | undefined {\n if (!dateValue) {\n return undefined;\n }\n\n const raw = String(dateValue);\n if (raw.length !== 8) {\n return undefined;\n }\n\n return `${raw.slice(0, 4)}-${raw.slice(4, 6)}-${raw.slice(6, 8)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA4IO,SAAS,qBACd,SACgB;AAChB,iBAAe,qCACb,WACA,OAKA,OAAgC,CAAC,GACjC,SACA;AACA,UAAM,OAAO,MAAM,QAAQ,KAAK,MAAM,WAAW;AAAA,MAC/C,kBAAkB,MAAM;AAAA,MACxB,cAAc,MAAM;AAAA,MACpB,QAAQ,MAAM;AAAA,IAChB,CAAC;AACD,UAAM,WAAW,MAAM,QAAQ,KAAK,QAGlC;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA,GAAI,YAAY,SAAY,CAAC,IAAI,EAAE,QAAQ;AAAA,MAC3C,QAAQ,MAAM;AAAA,MACd,iBAAiB,GAAG,SAAS;AAAA,MAC7B,0BAA0B;AAAA,MAC1B,MAAM;AAAA;AAAA,QAEJ,aAAa;AAAA,UACX,MAAM,oBAAoB,QAAQ,OAAO;AAAA,UACzC,KAAK;AAAA,UACL,KAAK;AAAA,QACP;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF,CAAC;AAED,WAAO,+BAA+B,SAAS,QAAQ,SAAS;AAAA,EAClE;AAEA,iBAAe,4BAA4B;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAGG;AACD,QAAI,OAAO,OAAO,MAAM,aAAa,GAAG;AACtC,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,OAAO;AAAA,UACP,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAEA,QAAI;AACF,YAAM,MAAM,MAAM;AAAA,QAChB;AAAA,QACA,EAAE,kBAAkB,cAAc,OAAO;AAAA,QACzC;AAAA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