@ramiidv/arca-fecred 0.1.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.
- package/LICENSE +21 -0
- package/README.md +351 -0
- package/dist/arca-fecred.d.ts +129 -0
- package/dist/arca-fecred.d.ts.map +1 -0
- package/dist/arca-fecred.js +365 -0
- package/dist/arca-fecred.js.map +1 -0
- package/dist/constants.d.ts +83 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +108 -0
- package/dist/constants.js.map +1 -0
- package/dist/fecred-client.d.ts +100 -0
- package/dist/fecred-client.d.ts.map +1 -0
- package/dist/fecred-client.js +194 -0
- package/dist/fecred-client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +26 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +161 -0
- package/dist/validation.js.map +1 -0
- package/llms.txt +173 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ramiidv
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# @ramiidv/arca-fecred
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@ramiidv/arca-fecred)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org)
|
|
6
|
+
|
|
7
|
+
SDK en TypeScript para el web service **WSFECRED** de **ARCA** (ex AFIP) -- Factura de Credito Electronica MiPyME (Ley 27440).
|
|
8
|
+
|
|
9
|
+
Gestiona el ciclo de vida completo de las FCE: consulta de obligados, cuentas corrientes, comprobantes, aceptacion, rechazo e informar cancelacion.
|
|
10
|
+
|
|
11
|
+
## Instalacion
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @ramiidv/arca-fecred
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Requisitos
|
|
18
|
+
|
|
19
|
+
- Node.js >= 18
|
|
20
|
+
- Certificado digital X.509 y clave privada de ARCA
|
|
21
|
+
- **Testing**: generalo desde [WSASS Homologacion](https://wsass-homo.afip.gob.ar/wsass/portal/main.aspx)
|
|
22
|
+
- **Produccion**: generalo desde [Administracion de Certificados Digitales](https://www.afip.gob.ar/ws/documentacion/certificados.asp) (requiere clave fiscal en [arca.gob.ar](https://arca.gob.ar))
|
|
23
|
+
|
|
24
|
+
## Uso rapido
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { readFileSync } from 'fs';
|
|
28
|
+
import { ArcaFecred, RolCtaCte, MotivoRechazo, FormaCancelacion } from '@ramiidv/arca-fecred';
|
|
29
|
+
|
|
30
|
+
const fecred = new ArcaFecred({
|
|
31
|
+
cert: readFileSync('./cert.pem', 'utf-8'),
|
|
32
|
+
key: readFileSync('./key.pem', 'utf-8'),
|
|
33
|
+
cuit: '20123456789',
|
|
34
|
+
production: false, // true para produccion
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Verificar si una CUIT esta obligada a recibir FCE
|
|
38
|
+
const obligado = await fecred.consultarMontoObligadoRecepcion('30712345678');
|
|
39
|
+
console.log(obligado.obligado); // true/false
|
|
40
|
+
|
|
41
|
+
// Consultar cuentas corrientes como receptor
|
|
42
|
+
const cuentas = await fecred.consultarCtasCtes({
|
|
43
|
+
rol: RolCtaCte.RECEPTOR,
|
|
44
|
+
fechaDesde: '2026-01-01',
|
|
45
|
+
fechaHasta: '2026-03-31',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
for (const cta of cuentas) {
|
|
49
|
+
console.log(`FCE #${cta.codCtaCte}: $${cta.importeTotal} - ${cta.estado}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Aceptar una FCE
|
|
53
|
+
const aceptar = await fecred.aceptarFECred(12345);
|
|
54
|
+
console.log(aceptar.resultado);
|
|
55
|
+
|
|
56
|
+
// Rechazar una FCE
|
|
57
|
+
const rechazar = await fecred.rechazarFECred(12345, MotivoRechazo.CBU_INCORRECTO);
|
|
58
|
+
console.log(rechazar.resultado);
|
|
59
|
+
|
|
60
|
+
// Informar que una FCE aceptada fue pagada
|
|
61
|
+
const cancelar = await fecred.informarFacturaAceptadaCancelada({
|
|
62
|
+
codCtaCte: 12345,
|
|
63
|
+
codFormaCancelacion: FormaCancelacion.TRANSFERENCIA,
|
|
64
|
+
});
|
|
65
|
+
console.log(cancelar.resultado);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Configuracion
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const fecred = new ArcaFecred({
|
|
72
|
+
cert: '...', // Certificado X.509 (PEM)
|
|
73
|
+
key: '...', // Clave privada (PEM)
|
|
74
|
+
cuit: '20123456789', // CUIT representada
|
|
75
|
+
production: false, // Default: false (testing/homologacion)
|
|
76
|
+
timeout: 30_000, // Default: 30000 (30 segundos)
|
|
77
|
+
retries: 1, // Default: 1 (reintentos en errores transitorios)
|
|
78
|
+
retryDelayMs: 1_000, // Default: 1000 (backoff exponencial: 1s, 2s, ...)
|
|
79
|
+
onEvent: (e) => { // Opcional: callback para logging/debugging
|
|
80
|
+
console.log(e.type, e);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Ejemplos
|
|
86
|
+
|
|
87
|
+
### Verificar obligacion de recepcion FCE
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const resultado = await fecred.consultarMontoObligadoRecepcion('30712345678');
|
|
91
|
+
|
|
92
|
+
if (resultado.obligado) {
|
|
93
|
+
console.log(`CUIT obligada a recibir FCE desde $${resultado.montoDesde}`);
|
|
94
|
+
} else {
|
|
95
|
+
console.log('CUIT no obligada a recibir FCE');
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Consultar cuentas corrientes
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// Como emisor (mis facturas FCE emitidas)
|
|
103
|
+
const misEmitidas = await fecred.consultarCtasCtes({
|
|
104
|
+
rol: RolCtaCte.EMISOR,
|
|
105
|
+
fechaDesde: '2026-01-01',
|
|
106
|
+
fechaHasta: '2026-03-31',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Como receptor (FCE que me enviaron)
|
|
110
|
+
const recibidas = await fecred.consultarCtasCtes({
|
|
111
|
+
rol: RolCtaCte.RECEPTOR,
|
|
112
|
+
cuitEmisor: '30712345678', // opcional: filtrar por emisor
|
|
113
|
+
fechaDesde: '2026-01-01',
|
|
114
|
+
fechaHasta: '2026-03-31',
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Consultar comprobantes FCE
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Buscar por CUIT emisor
|
|
122
|
+
const comprobantes = await fecred.consultarComprobantes({
|
|
123
|
+
cuitEmisor: '30712345678',
|
|
124
|
+
fechaDesde: '2026-01-01',
|
|
125
|
+
fechaHasta: '2026-03-31',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Buscar un comprobante especifico por codigo de cuenta corriente
|
|
129
|
+
const comprobante = await fecred.consultarComprobantes({
|
|
130
|
+
codCtaCte: 12345,
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Aceptar y luego informar cancelacion
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { FormaCancelacion } from '@ramiidv/arca-fecred';
|
|
138
|
+
|
|
139
|
+
// 1. Aceptar la FCE
|
|
140
|
+
await fecred.aceptarFECred(12345);
|
|
141
|
+
|
|
142
|
+
// 2. Luego de pagar, informar la cancelacion
|
|
143
|
+
await fecred.informarFacturaAceptadaCancelada({
|
|
144
|
+
codCtaCte: 12345,
|
|
145
|
+
codFormaCancelacion: FormaCancelacion.TRANSFERENCIA,
|
|
146
|
+
observaciones: 'Transferencia realizada el 2026-03-15',
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Rechazar una FCE
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { MotivoRechazo } from '@ramiidv/arca-fecred';
|
|
154
|
+
|
|
155
|
+
await fecred.rechazarFECred(12345, MotivoRechazo.OTROS);
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Consultar parametros disponibles
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Tipos de retencion
|
|
162
|
+
const retenciones = await fecred.consultarTiposRetenciones();
|
|
163
|
+
for (const r of retenciones) {
|
|
164
|
+
console.log(`${r.codTipoRetencion}: ${r.descTipoRetencion}`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Formas de cancelacion
|
|
168
|
+
const formas = await fecred.consultarTiposFormasCancelacion();
|
|
169
|
+
|
|
170
|
+
// Tipos de ajuste de operacion
|
|
171
|
+
const ajustes = await fecred.consultarTiposAjustesOperacion();
|
|
172
|
+
|
|
173
|
+
// Motivos de rechazo
|
|
174
|
+
const motivos = await fecred.consultarTiposMotivoRechazo();
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Health check
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
const status = await fecred.status();
|
|
181
|
+
console.log(status.appserver); // "OK"
|
|
182
|
+
console.log(status.dbserver); // "OK"
|
|
183
|
+
console.log(status.authserver); // "OK"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Retry automatico
|
|
187
|
+
|
|
188
|
+
El SDK reintenta automaticamente en errores transitorios (timeout, HTTP 5xx, errores de red). No reintenta en errores de negocio (4xx, errores de ARCA).
|
|
189
|
+
|
|
190
|
+
- **Default**: 1 reintento con backoff exponencial (1s, 2s, ...)
|
|
191
|
+
- **Configurable**: `retries: 0` para desactivar, `retries: 3` para mas intentos
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
const fecred = new ArcaFecred({
|
|
195
|
+
...config,
|
|
196
|
+
retries: 2, // 2 reintentos (3 intentos totales)
|
|
197
|
+
retryDelayMs: 2000, // empezar con 2s -> 4s -> 8s
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Eventos / Logging
|
|
202
|
+
|
|
203
|
+
El SDK emite eventos para debugging y monitoreo sin forzar un logger especifico.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
const fecred = new ArcaFecred({
|
|
207
|
+
...config,
|
|
208
|
+
onEvent: (e) => console.log(`[${e.type}]`, e),
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
| Evento | Cuando | Datos |
|
|
213
|
+
| --- | --- | --- |
|
|
214
|
+
| `auth:login` | Nuevo token obtenido | `service`, `durationMs` |
|
|
215
|
+
| `auth:cache-hit` | Token cacheado reutilizado | `service` |
|
|
216
|
+
| `request:start` | Antes de una llamada SOAP | `method`, `endpoint` |
|
|
217
|
+
| `request:end` | Llamada SOAP completada | `method`, `durationMs` |
|
|
218
|
+
| `request:retry` | Reintentando tras error | `method`, `attempt`, `error` |
|
|
219
|
+
| `request:error` | Llamada SOAP fallo | `method`, `error` |
|
|
220
|
+
|
|
221
|
+
## Manejo de errores
|
|
222
|
+
|
|
223
|
+
El SDK provee clases de error especificas para catch granular:
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import {
|
|
227
|
+
ArcaFecred,
|
|
228
|
+
ArcaAuthError,
|
|
229
|
+
ArcaServiceError,
|
|
230
|
+
ArcaSoapError,
|
|
231
|
+
} from '@ramiidv/arca-fecred';
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
const resultado = await fecred.aceptarFECred(12345);
|
|
235
|
+
} catch (e) {
|
|
236
|
+
if (e instanceof ArcaAuthError) {
|
|
237
|
+
// Error de autenticacion WSAA (certificado invalido, expirado, etc.)
|
|
238
|
+
console.error('Auth error:', e.message);
|
|
239
|
+
fecred.clearAuthCache(); // Limpiar cache e intentar de nuevo
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (e instanceof ArcaServiceError) {
|
|
243
|
+
// Error de negocio de WSFECRED (FCE no encontrada, estado invalido, etc.)
|
|
244
|
+
for (const err of e.errors) {
|
|
245
|
+
console.error(`[${err.code}] ${err.msg}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (e instanceof ArcaSoapError) {
|
|
250
|
+
// Error HTTP/SOAP (timeout, servidor caido, etc.)
|
|
251
|
+
console.error('HTTP status:', e.statusCode);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
| Clase | Cuando se lanza |
|
|
257
|
+
| --- | --- |
|
|
258
|
+
| `ArcaAuthError` | Falla en login WSAA, respuesta inesperada, token/sign invalidos |
|
|
259
|
+
| `ArcaServiceError` | Error devuelto por WSFECRED (FCE no encontrada, operacion invalida, etc.). Contiene `errors: { code, msg }[]` |
|
|
260
|
+
| `ArcaSoapError` | Error HTTP, timeout, SOAP Fault. Contiene `statusCode?: number` |
|
|
261
|
+
| `ArcaError` | Clase base para todos los errores del SDK |
|
|
262
|
+
|
|
263
|
+
## API
|
|
264
|
+
|
|
265
|
+
### `new ArcaFecred(config)`
|
|
266
|
+
|
|
267
|
+
| Parametro | Tipo | Default | Descripcion |
|
|
268
|
+
| --- | --- | --- | --- |
|
|
269
|
+
| `cert` | `string` | -- | Contenido del certificado X.509 (PEM) |
|
|
270
|
+
| `key` | `string` | -- | Contenido de la clave privada (PEM) |
|
|
271
|
+
| `cuit` | `string` | -- | CUIT de la entidad representada |
|
|
272
|
+
| `production` | `boolean` | `false` | Entorno de produccion |
|
|
273
|
+
| `timeout` | `number` | `30000` | Timeout HTTP en milisegundos |
|
|
274
|
+
| `retries` | `number` | `1` | Reintentos en errores transitorios |
|
|
275
|
+
| `retryDelayMs` | `number` | `1000` | Delay inicial entre reintentos (exponencial) |
|
|
276
|
+
| `onEvent` | `function` | -- | Callback para eventos del SDK |
|
|
277
|
+
|
|
278
|
+
### Consultas de operaciones
|
|
279
|
+
|
|
280
|
+
| Metodo | Descripcion |
|
|
281
|
+
| --- | --- |
|
|
282
|
+
| `consultarMontoObligadoRecepcion(cuit)` | Verifica si una CUIT esta obligada a recibir FCE |
|
|
283
|
+
| `consultarCtasCtes(params)` | Consulta cuentas corrientes de actividad FCE |
|
|
284
|
+
| `consultarComprobantes(params)` | Busca comprobantes FCE por filtros |
|
|
285
|
+
|
|
286
|
+
### Acciones sobre FCE
|
|
287
|
+
|
|
288
|
+
| Metodo | Descripcion |
|
|
289
|
+
| --- | --- |
|
|
290
|
+
| `aceptarFECred(codCtaCte)` | Acepta una FCE |
|
|
291
|
+
| `rechazarFECred(codCtaCte, codMotivoRechazo)` | Rechaza una FCE con motivo |
|
|
292
|
+
| `informarFacturaAceptadaCancelada(params)` | Informa que una FCE aceptada fue pagada/cancelada |
|
|
293
|
+
|
|
294
|
+
### Consultas de parametros
|
|
295
|
+
|
|
296
|
+
| Metodo | Descripcion |
|
|
297
|
+
| --- | --- |
|
|
298
|
+
| `consultarTiposRetenciones()` | Tipos de retenciones disponibles |
|
|
299
|
+
| `consultarTiposFormasCancelacion()` | Formas de cancelacion disponibles |
|
|
300
|
+
| `consultarTiposAjustesOperacion()` | Tipos de ajustes de operacion disponibles |
|
|
301
|
+
| `consultarTiposMotivoRechazo()` | Motivos de rechazo disponibles |
|
|
302
|
+
|
|
303
|
+
### Estado y utilidades
|
|
304
|
+
|
|
305
|
+
| Metodo | Descripcion |
|
|
306
|
+
| --- | --- |
|
|
307
|
+
| `status()` | Health check del servicio WSFECRED (no requiere autenticacion) |
|
|
308
|
+
| `clearAuthCache()` | Invalida el ticket de acceso cacheado |
|
|
309
|
+
|
|
310
|
+
### Acceso a clientes de bajo nivel
|
|
311
|
+
|
|
312
|
+
Para casos avanzados, se pueden usar los clientes individuales directamente:
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
const fecred = new ArcaFecred({ /* ... */ });
|
|
316
|
+
|
|
317
|
+
// Obtener ticket de acceso manualmente
|
|
318
|
+
const ticket = await fecred.wsaa.getAccessTicket('wsfecred');
|
|
319
|
+
|
|
320
|
+
const credenciales = {
|
|
321
|
+
Token: ticket.token,
|
|
322
|
+
Sign: ticket.sign,
|
|
323
|
+
Cuit: '20123456789',
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
// Llamar directamente al servicio
|
|
327
|
+
const rawResult = await fecred.fecred.consultarMontoObligadoRecepcion(
|
|
328
|
+
credenciales,
|
|
329
|
+
'30712345678',
|
|
330
|
+
);
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Enums disponibles
|
|
334
|
+
|
|
335
|
+
- `RolCtaCte` -- Rol en la cuenta corriente (EMISOR, RECEPTOR)
|
|
336
|
+
- `EstadoCtaCte` -- Estado de la cuenta corriente (PENDIENTE_ACEPTACION, ACEPTADA, RECHAZADA, CANCELADA, ANULADA)
|
|
337
|
+
- `MotivoRechazo` -- Motivos de rechazo (NOTA_CREDITO_DEBITO, CUIT_INCORRECTO, FECHA_INCORRECTA, CBU_INCORRECTO, OTROS)
|
|
338
|
+
- `FormaCancelacion` -- Formas de cancelacion (ACREDITACION_CUENTA, TRANSFERENCIA, CHEQUE, PAGO_ELECTRONICO, COMPENSACION, ENDOSO, OTRO)
|
|
339
|
+
- `TipoAjusteOperacion` -- Tipos de ajuste (NOTA_CREDITO, NOTA_DEBITO)
|
|
340
|
+
- `TipoRetencion` -- Tipos de retencion (GANANCIAS, IVA, SUSS, INGRESOS_BRUTOS, OTRAS)
|
|
341
|
+
|
|
342
|
+
## Entornos
|
|
343
|
+
|
|
344
|
+
| Entorno | WSAA | WSFECRED |
|
|
345
|
+
| --- | --- | --- |
|
|
346
|
+
| Testing | `wsaahomo.afip.gov.ar` | `fwshomo.afip.gob.ar` |
|
|
347
|
+
| Produccion | `wsaa.afip.gov.ar` | `serviciosjava.afip.gob.ar` |
|
|
348
|
+
|
|
349
|
+
## Licencia
|
|
350
|
+
|
|
351
|
+
MIT
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { WsaaClient } from '@ramiidv/arca-common';
|
|
2
|
+
import type { ServerStatus } from '@ramiidv/arca-common';
|
|
3
|
+
import { FecredClient } from './fecred-client.js';
|
|
4
|
+
import type { ArcaFecredConfig, MontoObligadoResult, CtaCte, ComprobanteFecred, ConsultarCtasCtesParams, ConsultarComprobantesParams, AceptarFecredResult, RechazarFecredResult, InformarCanceladaParams, InformarCanceladaResult, TipoRetencionItem, TipoFormaCancelacionItem, TipoAjusteOperacionItem, TipoMotivoRechazoItem } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Main orchestrator class for ARCA WSFECRED (Factura de Credito Electronica MiPyME).
|
|
7
|
+
*
|
|
8
|
+
* Provides high-level methods that handle WSAA authentication automatically
|
|
9
|
+
* and expose results from the WSFECRED web service for managing FCE
|
|
10
|
+
* (Electronic Credit Invoices) under Law 27440.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { ArcaFecred } from '@ramiidv/arca-fecred';
|
|
15
|
+
* import { readFileSync } from 'fs';
|
|
16
|
+
*
|
|
17
|
+
* const fecred = new ArcaFecred({
|
|
18
|
+
* cert: readFileSync('cert.pem', 'utf-8'),
|
|
19
|
+
* key: readFileSync('key.pem', 'utf-8'),
|
|
20
|
+
* cuit: '20123456789',
|
|
21
|
+
* production: false,
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // Check if a CUIT is obligated to receive FCE
|
|
25
|
+
* const obligado = await fecred.consultarMontoObligadoRecepcion('30712345678');
|
|
26
|
+
* console.log(obligado.obligado); // true/false
|
|
27
|
+
*
|
|
28
|
+
* // Query current accounts
|
|
29
|
+
* const cuentas = await fecred.consultarCtasCtes({
|
|
30
|
+
* rol: 'Receptor',
|
|
31
|
+
* fechaDesde: '2026-01-01',
|
|
32
|
+
* fechaHasta: '2026-03-31',
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class ArcaFecred {
|
|
37
|
+
/** Low-level WSAA client for direct access */
|
|
38
|
+
readonly wsaa: WsaaClient;
|
|
39
|
+
/** Low-level WSFECRED client for direct access */
|
|
40
|
+
readonly fecred: FecredClient;
|
|
41
|
+
private readonly cuit;
|
|
42
|
+
private readonly onEvent?;
|
|
43
|
+
constructor(config: ArcaFecredConfig);
|
|
44
|
+
/**
|
|
45
|
+
* Health check for the WSFECRED service.
|
|
46
|
+
* Does not require authentication.
|
|
47
|
+
*/
|
|
48
|
+
status(): Promise<ServerStatus>;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a CUIT is obligated to receive FCE (Factura de Credito Electronica).
|
|
51
|
+
* Authenticates automatically via WSAA.
|
|
52
|
+
*
|
|
53
|
+
* @param cuitConsultada - CUIT to check
|
|
54
|
+
* @returns Result indicating if the CUIT is obligated and the threshold amount
|
|
55
|
+
*/
|
|
56
|
+
consultarMontoObligadoRecepcion(cuitConsultada: string): Promise<MontoObligadoResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Query current accounts from FCE activity.
|
|
59
|
+
* Authenticates automatically via WSAA.
|
|
60
|
+
*
|
|
61
|
+
* @param params - Query filters (role, CUITs, date range)
|
|
62
|
+
* @returns Array of current account records
|
|
63
|
+
*/
|
|
64
|
+
consultarCtasCtes(params: ConsultarCtasCtesParams): Promise<CtaCte[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Search FCE invoices by filters.
|
|
67
|
+
* Authenticates automatically via WSAA.
|
|
68
|
+
*
|
|
69
|
+
* @param params - Query filters
|
|
70
|
+
* @returns Array of FCE invoice records
|
|
71
|
+
*/
|
|
72
|
+
consultarComprobantes(params: ConsultarComprobantesParams): Promise<ComprobanteFecred[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Accept an FCE (Factura de Credito Electronica).
|
|
75
|
+
* Authenticates automatically via WSAA.
|
|
76
|
+
*
|
|
77
|
+
* @param codCtaCte - Current account code of the FCE to accept
|
|
78
|
+
* @returns Result of the acceptance operation
|
|
79
|
+
*/
|
|
80
|
+
aceptarFECred(codCtaCte: number): Promise<AceptarFecredResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Reject an FCE (Factura de Credito Electronica).
|
|
83
|
+
* Authenticates automatically via WSAA.
|
|
84
|
+
*
|
|
85
|
+
* @param codCtaCte - Current account code of the FCE to reject
|
|
86
|
+
* @param codMotivoRechazo - Rejection reason code (use MotivoRechazo enum)
|
|
87
|
+
* @returns Result of the rejection operation
|
|
88
|
+
*/
|
|
89
|
+
rechazarFECred(codCtaCte: number, codMotivoRechazo: number): Promise<RechazarFecredResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Inform that an accepted FCE was paid/cancelled.
|
|
92
|
+
* Authenticates automatically via WSAA.
|
|
93
|
+
*
|
|
94
|
+
* @param params - Cancellation details (account code, payment method, optional observations)
|
|
95
|
+
* @returns Result of the cancellation notification
|
|
96
|
+
*/
|
|
97
|
+
informarFacturaAceptadaCancelada(params: InformarCanceladaParams): Promise<InformarCanceladaResult>;
|
|
98
|
+
/**
|
|
99
|
+
* Query available retention types.
|
|
100
|
+
* Authenticates automatically via WSAA.
|
|
101
|
+
*/
|
|
102
|
+
consultarTiposRetenciones(): Promise<TipoRetencionItem[]>;
|
|
103
|
+
/**
|
|
104
|
+
* Query available payment method types for cancelling accepted FCE.
|
|
105
|
+
* Authenticates automatically via WSAA.
|
|
106
|
+
*/
|
|
107
|
+
consultarTiposFormasCancelacion(): Promise<TipoFormaCancelacionItem[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Query available operation adjustment types.
|
|
110
|
+
* Authenticates automatically via WSAA.
|
|
111
|
+
*/
|
|
112
|
+
consultarTiposAjustesOperacion(): Promise<TipoAjusteOperacionItem[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Query available rejection reason types.
|
|
115
|
+
* Authenticates automatically via WSAA.
|
|
116
|
+
*/
|
|
117
|
+
consultarTiposMotivoRechazo(): Promise<TipoMotivoRechazoItem[]>;
|
|
118
|
+
/** Invalidate the cached WSAA access ticket for WSFECRED. */
|
|
119
|
+
clearAuthCache(): void;
|
|
120
|
+
private getAuth;
|
|
121
|
+
private parseCtaCte;
|
|
122
|
+
private parseComprobante;
|
|
123
|
+
/**
|
|
124
|
+
* Generic parser for parameter arrays from WSFECRED responses.
|
|
125
|
+
* Handles varying SOAP response structures (different key names, namespaces).
|
|
126
|
+
*/
|
|
127
|
+
private parseParamArray;
|
|
128
|
+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