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/README.md +5 -0
- package/dist/index.cjs +33 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -314,6 +314,11 @@ Con la eliminación total de la Factura Clase "M", ARCA instruyó el uso de Fact
|
|
|
314
314
|
* **Pago en CBU Informada:**
|
|
315
315
|
De igual modo, si te corresponde emitir con la leyenda de obligatoriedad de CBU, se adjunta el opcional correspondiente declarando tu cuenta bancaria asociada.
|
|
316
316
|
|
|
317
|
+
### 🤝 Monotributo Social y Regímenes Especiales
|
|
318
|
+
Para el Web Service de Facturación Electrónica (WSFE), la AFIP exige que todo contribuyente bajo el régimen de Monotributo (sea estándar, social o promovido) se declare bajo la Condición de IVA de **Responsable Monotributo (Código 6)**. El Código de IVA 13 (Monotributista Social) suele ser rechazado en producción.
|
|
319
|
+
|
|
320
|
+
Por esta razón, el SDK detecta automáticamente si el contribuyente tiene activos los impuestos de recaudación de monotributo (impuestos 20, 21, 22 o 24) en su perfil y mapea de forma segura su propiedad `vatCondition` al Código 6, previniendo errores de autorización de AFIP ("Computador no autorizado") de forma automática.
|
|
321
|
+
|
|
317
322
|
---
|
|
318
323
|
|
|
319
324
|
### Manejo de errores
|
package/dist/index.cjs
CHANGED
|
@@ -386,6 +386,7 @@ async function callArcaApi(url, options) {
|
|
|
386
386
|
}
|
|
387
387
|
|
|
388
388
|
// src/auth/wsaa.ts
|
|
389
|
+
var import_fast_xml_parser2 = require("fast-xml-parser");
|
|
389
390
|
var WsaaService = class {
|
|
390
391
|
config;
|
|
391
392
|
ticketManager;
|
|
@@ -487,13 +488,27 @@ var WsaaService = class {
|
|
|
487
488
|
body: this.buildSoapRequest(cms),
|
|
488
489
|
timeout: this.config.timeout
|
|
489
490
|
});
|
|
491
|
+
const responseText = await response.text();
|
|
490
492
|
if (!response.ok) {
|
|
493
|
+
let errorMessage = `Error HTTP al comunicarse con WSAA: ${response.status} ${response.statusText}`;
|
|
494
|
+
try {
|
|
495
|
+
const parser = new import_fast_xml_parser2.XMLParser({
|
|
496
|
+
ignoreAttributes: false,
|
|
497
|
+
removeNSPrefix: true
|
|
498
|
+
});
|
|
499
|
+
const result = parser.parse(responseText);
|
|
500
|
+
const fault = result.Envelope?.Body?.Fault;
|
|
501
|
+
if (fault && fault.faultstring) {
|
|
502
|
+
errorMessage = `Error AFIP WSAA: ${fault.faultstring}`;
|
|
503
|
+
}
|
|
504
|
+
} catch (e) {
|
|
505
|
+
}
|
|
491
506
|
throw new ArcaAuthError(
|
|
492
|
-
|
|
493
|
-
{ status: response.status, statusText: response.statusText }
|
|
507
|
+
errorMessage,
|
|
508
|
+
{ status: response.status, statusText: response.statusText, body: responseText }
|
|
494
509
|
);
|
|
495
510
|
}
|
|
496
|
-
const responseXml =
|
|
511
|
+
const responseXml = responseText;
|
|
497
512
|
return parseWsaaResponse(responseXml);
|
|
498
513
|
}
|
|
499
514
|
/**
|
|
@@ -570,7 +585,6 @@ var VatCondition = /* @__PURE__ */ ((VatCondition2) => {
|
|
|
570
585
|
VatCondition2[VatCondition2["CLIENTE_DEL_EXTERIOR"] = 9] = "CLIENTE_DEL_EXTERIOR";
|
|
571
586
|
VatCondition2[VatCondition2["IVA_LIBERADO_LEY_19640"] = 10] = "IVA_LIBERADO_LEY_19640";
|
|
572
587
|
VatCondition2[VatCondition2["IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION"] = 11] = "IVA_RESPONSABLE_INSCRIPTO_AGENTE_PERCEPCION";
|
|
573
|
-
VatCondition2[VatCondition2["MONOTRIBUTISTA_SOCIAL"] = 13] = "MONOTRIBUTISTA_SOCIAL";
|
|
574
588
|
return VatCondition2;
|
|
575
589
|
})(VatCondition || {});
|
|
576
590
|
|
|
@@ -1395,7 +1409,7 @@ var WsfeService = class _WsfeService {
|
|
|
1395
1409
|
};
|
|
1396
1410
|
|
|
1397
1411
|
// src/services/padron.ts
|
|
1398
|
-
var
|
|
1412
|
+
var import_fast_xml_parser3 = require("fast-xml-parser");
|
|
1399
1413
|
var PadronService = class {
|
|
1400
1414
|
wsaa;
|
|
1401
1415
|
config;
|
|
@@ -1454,7 +1468,7 @@ var PadronService = class {
|
|
|
1454
1468
|
* Parsea la respuesta XML de getPersona
|
|
1455
1469
|
*/
|
|
1456
1470
|
parseResponse(xml) {
|
|
1457
|
-
const parser = new
|
|
1471
|
+
const parser = new import_fast_xml_parser3.XMLParser({
|
|
1458
1472
|
ignoreAttributes: false,
|
|
1459
1473
|
removeNSPrefix: true
|
|
1460
1474
|
});
|
|
@@ -1478,6 +1492,16 @@ var PadronService = class {
|
|
|
1478
1492
|
if (!p) {
|
|
1479
1493
|
return { error: "CUIT no encontrado" };
|
|
1480
1494
|
}
|
|
1495
|
+
let vatCondition;
|
|
1496
|
+
if (this.hasTaxId(p, 30)) {
|
|
1497
|
+
vatCondition = 1 /* IVA_RESPONSABLE_INSCRIPTO */;
|
|
1498
|
+
} else if (this.hasTaxId(p, 32)) {
|
|
1499
|
+
vatCondition = 4 /* IVA_SUJETO_EXENTO */;
|
|
1500
|
+
} else if (this.hasTaxId(p, 20) || this.hasTaxId(p, 21) || this.hasTaxId(p, 22) || this.hasTaxId(p, 24)) {
|
|
1501
|
+
vatCondition = 6 /* RESPONSABLE_MONOTRIBUTO */;
|
|
1502
|
+
} else {
|
|
1503
|
+
vatCondition = 5 /* CONSUMIDOR_FINAL */;
|
|
1504
|
+
}
|
|
1481
1505
|
const taxpayer = {
|
|
1482
1506
|
taxId: Number(p.idPersona),
|
|
1483
1507
|
personType: p.tipoPersona,
|
|
@@ -1491,12 +1515,13 @@ var PadronService = class {
|
|
|
1491
1515
|
mainActivity: p.descripcionActividadPrincipal,
|
|
1492
1516
|
isVATRegistered: this.hasTaxId(p, 30),
|
|
1493
1517
|
// 30 = IVA
|
|
1494
|
-
isMonotax: this.hasTaxId(p, 20) || this.hasTaxId(p, 24) || this.hasTaxId(p, 21),
|
|
1518
|
+
isMonotax: this.hasTaxId(p, 20) || this.hasTaxId(p, 24) || this.hasTaxId(p, 21) || this.hasTaxId(p, 22),
|
|
1495
1519
|
// General o Social/Autónomo
|
|
1496
1520
|
isSocialMonotax: this.hasTaxId(p, 24) || this.hasTaxId(p, 21),
|
|
1497
1521
|
// 24 = Obra Social / Promovido, 21 = Autónomo
|
|
1498
|
-
isVATExempt: this.hasTaxId(p, 32)
|
|
1522
|
+
isVATExempt: this.hasTaxId(p, 32),
|
|
1499
1523
|
// 32 = IVA Exento
|
|
1524
|
+
vatCondition
|
|
1500
1525
|
};
|
|
1501
1526
|
return { taxpayer };
|
|
1502
1527
|
}
|