arca-sdk 1.3.0 → 1.3.2

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.d.cts CHANGED
@@ -222,8 +222,7 @@ declare enum VatCondition {
222
222
  PROVEEDOR_DEL_EXTERIOR = 8,
223
223
  CLIENTE_DEL_EXTERIOR = 9,
224
224
  IVA_LIBERADO_LEY_19640 = 10,
225
- IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION = 11,
226
- MONOTRIBUTISTA_SOCIAL = 13
225
+ IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION = 11
227
226
  }
228
227
  /**
229
228
  * Datos del comprador
@@ -720,6 +719,8 @@ interface Taxpayer {
720
719
  isSocialMonotax: boolean;
721
720
  /** ¿Es exento de IVA? */
722
721
  isVATExempt: boolean;
722
+ /** Condición frente al IVA autocalculada (lista para WSFE/CAEA) */
723
+ vatCondition?: VatCondition;
723
724
  }
724
725
  /**
725
726
  * Respuesta del servicio de Padrón
package/dist/index.d.ts CHANGED
@@ -222,8 +222,7 @@ declare enum VatCondition {
222
222
  PROVEEDOR_DEL_EXTERIOR = 8,
223
223
  CLIENTE_DEL_EXTERIOR = 9,
224
224
  IVA_LIBERADO_LEY_19640 = 10,
225
- IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION = 11,
226
- MONOTRIBUTISTA_SOCIAL = 13
225
+ IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION = 11
227
226
  }
228
227
  /**
229
228
  * Datos del comprador
@@ -720,6 +719,8 @@ interface Taxpayer {
720
719
  isSocialMonotax: boolean;
721
720
  /** ¿Es exento de IVA? */
722
721
  isVATExempt: boolean;
722
+ /** Condición frente al IVA autocalculada (lista para WSFE/CAEA) */
723
+ vatCondition?: VatCondition;
723
724
  }
724
725
  /**
725
726
  * Respuesta del servicio de Padrón
package/dist/index.js CHANGED
@@ -338,6 +338,7 @@ async function callArcaApi(url, options) {
338
338
  }
339
339
 
340
340
  // src/auth/wsaa.ts
341
+ import { XMLParser as XMLParser2 } from "fast-xml-parser";
341
342
  var WsaaService = class {
342
343
  config;
343
344
  ticketManager;
@@ -439,13 +440,27 @@ var WsaaService = class {
439
440
  body: this.buildSoapRequest(cms),
440
441
  timeout: this.config.timeout
441
442
  });
443
+ const responseText = await response.text();
442
444
  if (!response.ok) {
445
+ let errorMessage = `Error HTTP al comunicarse con WSAA: ${response.status} ${response.statusText}`;
446
+ try {
447
+ const parser = new XMLParser2({
448
+ ignoreAttributes: false,
449
+ removeNSPrefix: true
450
+ });
451
+ const result = parser.parse(responseText);
452
+ const fault = result.Envelope?.Body?.Fault;
453
+ if (fault && fault.faultstring) {
454
+ errorMessage = `Error AFIP WSAA: ${fault.faultstring}`;
455
+ }
456
+ } catch (e) {
457
+ }
443
458
  throw new ArcaAuthError(
444
- `Error HTTP al comunicarse con WSAA: ${response.status} ${response.statusText}`,
445
- { status: response.status, statusText: response.statusText }
459
+ errorMessage,
460
+ { status: response.status, statusText: response.statusText, body: responseText }
446
461
  );
447
462
  }
448
- const responseXml = await response.text();
463
+ const responseXml = responseText;
449
464
  return parseWsaaResponse(responseXml);
450
465
  }
451
466
  /**
@@ -522,7 +537,6 @@ var VatCondition = /* @__PURE__ */ ((VatCondition2) => {
522
537
  VatCondition2[VatCondition2["CLIENTE_DEL_EXTERIOR"] = 9] = "CLIENTE_DEL_EXTERIOR";
523
538
  VatCondition2[VatCondition2["IVA_LIBERADO_LEY_19640"] = 10] = "IVA_LIBERADO_LEY_19640";
524
539
  VatCondition2[VatCondition2["IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION"] = 11] = "IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION";
525
- VatCondition2[VatCondition2["MONOTRIBUTISTA_SOCIAL"] = 13] = "MONOTRIBUTISTA_SOCIAL";
526
540
  return VatCondition2;
527
541
  })(VatCondition || {});
528
542
 
@@ -1347,7 +1361,7 @@ var WsfeService = class _WsfeService {
1347
1361
  };
1348
1362
 
1349
1363
  // src/services/padron.ts
1350
- import { XMLParser as XMLParser2 } from "fast-xml-parser";
1364
+ import { XMLParser as XMLParser3 } from "fast-xml-parser";
1351
1365
  var PadronService = class {
1352
1366
  wsaa;
1353
1367
  config;
@@ -1406,7 +1420,7 @@ var PadronService = class {
1406
1420
  * Parsea la respuesta XML de getPersona
1407
1421
  */
1408
1422
  parseResponse(xml) {
1409
- const parser = new XMLParser2({
1423
+ const parser = new XMLParser3({
1410
1424
  ignoreAttributes: false,
1411
1425
  removeNSPrefix: true
1412
1426
  });
@@ -1430,6 +1444,16 @@ var PadronService = class {
1430
1444
  if (!p) {
1431
1445
  return { error: "CUIT no encontrado" };
1432
1446
  }
1447
+ let vatCondition;
1448
+ if (this.hasTaxId(p, 30)) {
1449
+ vatCondition = 1 /* IVA_RESPONSABLE_INSCRIPTO */;
1450
+ } else if (this.hasTaxId(p, 32)) {
1451
+ vatCondition = 4 /* IVA_SUJETO_EXENTO */;
1452
+ } else if (this.hasTaxId(p, 20) || this.hasTaxId(p, 21) || this.hasTaxId(p, 22) || this.hasTaxId(p, 24)) {
1453
+ vatCondition = 6 /* RESPONSABLE_MONOTRIBUTO */;
1454
+ } else {
1455
+ vatCondition = 5 /* CONSUMIDOR_FINAL */;
1456
+ }
1433
1457
  const taxpayer = {
1434
1458
  taxId: Number(p.idPersona),
1435
1459
  personType: p.tipoPersona,
@@ -1443,12 +1467,13 @@ var PadronService = class {
1443
1467
  mainActivity: p.descripcionActividadPrincipal,
1444
1468
  isVATRegistered: this.hasTaxId(p, 30),
1445
1469
  // 30 = IVA
1446
- isMonotax: this.hasTaxId(p, 20) || this.hasTaxId(p, 24) || this.hasTaxId(p, 21),
1470
+ isMonotax: this.hasTaxId(p, 20) || this.hasTaxId(p, 24) || this.hasTaxId(p, 21) || this.hasTaxId(p, 22),
1447
1471
  // General o Social/Autónomo
1448
1472
  isSocialMonotax: this.hasTaxId(p, 24) || this.hasTaxId(p, 21),
1449
1473
  // 24 = Obra Social / Promovido, 21 = Autónomo
1450
- isVATExempt: this.hasTaxId(p, 32)
1474
+ isVATExempt: this.hasTaxId(p, 32),
1451
1475
  // 32 = IVA Exento
1476
+ vatCondition
1452
1477
  };
1453
1478
  return { taxpayer };
1454
1479
  }