factuplan 0.10.0 → 0.15.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/dist/index.d.mts +287 -14
- package/dist/index.d.ts +287 -14
- package/dist/index.js +144 -2
- package/dist/index.mjs +140 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ interface PaginatedResponse<T> {
|
|
|
9
9
|
}
|
|
10
10
|
interface Customer {
|
|
11
11
|
id: string;
|
|
12
|
-
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER';
|
|
12
|
+
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER' | 'EXTERIOR';
|
|
13
13
|
identification: string;
|
|
14
14
|
legalName: string;
|
|
15
15
|
email?: string;
|
|
@@ -20,7 +20,7 @@ interface Customer {
|
|
|
20
20
|
updatedAt: string;
|
|
21
21
|
}
|
|
22
22
|
interface CreateCustomerInput {
|
|
23
|
-
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER';
|
|
23
|
+
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER' | 'EXTERIOR';
|
|
24
24
|
identification: string;
|
|
25
25
|
legalName: string;
|
|
26
26
|
email?: string;
|
|
@@ -85,7 +85,7 @@ interface ProductListParams {
|
|
|
85
85
|
search?: string;
|
|
86
86
|
}
|
|
87
87
|
interface InvoiceCustomer {
|
|
88
|
-
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER';
|
|
88
|
+
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER' | 'EXTERIOR';
|
|
89
89
|
identification: string;
|
|
90
90
|
legalName: string;
|
|
91
91
|
email?: string;
|
|
@@ -95,6 +95,8 @@ interface InvoiceCustomer {
|
|
|
95
95
|
}
|
|
96
96
|
interface InvoiceItem {
|
|
97
97
|
code: string;
|
|
98
|
+
/** Auxiliary code (SRI codigoAuxiliar). Optional — defaults to `code`. */
|
|
99
|
+
auxiliaryCode?: string;
|
|
98
100
|
description: string;
|
|
99
101
|
quantity: number;
|
|
100
102
|
unitPrice: number;
|
|
@@ -110,6 +112,16 @@ interface InvoicePayment {
|
|
|
110
112
|
term?: number;
|
|
111
113
|
timeUnit?: PaymentTimeUnit;
|
|
112
114
|
}
|
|
115
|
+
interface InvoiceRetencion {
|
|
116
|
+
/** SRI Tabla 22 code (1 digit). '2' = IVA presuntivo, '4' = combustibles/renta */
|
|
117
|
+
codigo: string;
|
|
118
|
+
/** SRI Tabla 23 percentage code (1–3 digits) */
|
|
119
|
+
codigoPorcentaje: string;
|
|
120
|
+
/** Retention rate (e.g. 0.20) */
|
|
121
|
+
tarifa: number;
|
|
122
|
+
/** Retained amount (e.g. 0.13) */
|
|
123
|
+
valor: number;
|
|
124
|
+
}
|
|
113
125
|
interface CreateInvoiceInput {
|
|
114
126
|
/** UUID of the emission point. Optional if using establishment + emissionPoint codes, or if the taxpayer has a single active emission point. */
|
|
115
127
|
emissionPointId?: string;
|
|
@@ -127,6 +139,11 @@ interface CreateInvoiceInput {
|
|
|
127
139
|
* @default true
|
|
128
140
|
*/
|
|
129
141
|
sendEmail?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* In-invoice withholdings. Applies to petroleum product distributors (Tabla 22 code 4)
|
|
144
|
+
* and presumptive IVA retention for newspaper/magazine editors and distributors (code 2).
|
|
145
|
+
*/
|
|
146
|
+
retenciones?: InvoiceRetencion[];
|
|
130
147
|
}
|
|
131
148
|
interface ImportByAccessKeyInput {
|
|
132
149
|
/** 49-digit SRI access key (claveAcceso) of an already-authorized invoice */
|
|
@@ -139,6 +156,34 @@ interface Invoice {
|
|
|
139
156
|
status: string;
|
|
140
157
|
total: number | string;
|
|
141
158
|
}
|
|
159
|
+
interface InvoiceListParams {
|
|
160
|
+
/** Filter by customer RUC or cédula */
|
|
161
|
+
ruc?: string;
|
|
162
|
+
/** Filter by invoice status: DRAFT | PENDING | PROCESSING | AUTHORIZED | REJECTED | VOIDED */
|
|
163
|
+
status?: string;
|
|
164
|
+
/** Start date (ISO 8601, e.g. "2025-01-01") */
|
|
165
|
+
dateFrom?: string;
|
|
166
|
+
/** End date (ISO 8601, e.g. "2025-12-31") */
|
|
167
|
+
dateTo?: string;
|
|
168
|
+
/** Page number (default: 1) */
|
|
169
|
+
page?: number;
|
|
170
|
+
/** Results per page (default: 20, max: 100) */
|
|
171
|
+
limit?: number;
|
|
172
|
+
}
|
|
173
|
+
interface InvoiceListItem {
|
|
174
|
+
id: string;
|
|
175
|
+
accessKey: string;
|
|
176
|
+
sequential: string;
|
|
177
|
+
status: string;
|
|
178
|
+
total: number | string;
|
|
179
|
+
issueDate: string;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
customer: {
|
|
182
|
+
identification: string;
|
|
183
|
+
identificationType: string;
|
|
184
|
+
legalName: string;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
142
187
|
interface InvoiceStatus {
|
|
143
188
|
id: string;
|
|
144
189
|
status: string;
|
|
@@ -155,6 +200,177 @@ interface DownloadUrlResponse {
|
|
|
155
200
|
*/
|
|
156
201
|
previewUrl?: string;
|
|
157
202
|
}
|
|
203
|
+
interface DebitNoteListParams {
|
|
204
|
+
/** Filter by customer RUC or cédula */
|
|
205
|
+
ruc?: string;
|
|
206
|
+
/** Filter by status: DRAFT | PENDING | PROCESSING | AUTHORIZED | REJECTED | VOIDED */
|
|
207
|
+
status?: string;
|
|
208
|
+
/** Start date (ISO 8601, e.g. "2025-01-01") */
|
|
209
|
+
dateFrom?: string;
|
|
210
|
+
/** End date (ISO 8601, e.g. "2025-12-31") */
|
|
211
|
+
dateTo?: string;
|
|
212
|
+
/** Page number (default: 1) */
|
|
213
|
+
page?: number;
|
|
214
|
+
/** Results per page (default: 20, max: 100) */
|
|
215
|
+
limit?: number;
|
|
216
|
+
}
|
|
217
|
+
interface DebitNoteListItem {
|
|
218
|
+
id: string;
|
|
219
|
+
accessKey: string;
|
|
220
|
+
sequential: string;
|
|
221
|
+
status: string;
|
|
222
|
+
total: number | string;
|
|
223
|
+
issueDate: string;
|
|
224
|
+
createdAt: string;
|
|
225
|
+
customer: {
|
|
226
|
+
identification: string;
|
|
227
|
+
identificationType: string;
|
|
228
|
+
legalName: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
interface DebitNoteReason {
|
|
232
|
+
/** Description of the charge or adjustment */
|
|
233
|
+
description: string;
|
|
234
|
+
/** Amount of this charge */
|
|
235
|
+
amount: number;
|
|
236
|
+
/**
|
|
237
|
+
* Tax type for this charge.
|
|
238
|
+
* `IVA` = IVA at the current rate · `IVA_0` = IVA 0% · `NO_TAX` = not taxable ·
|
|
239
|
+
* `ICE` = ICE · `IRBPNR` = IRBPNR · `IVA_EXEMPT` = exempt from IVA
|
|
240
|
+
*/
|
|
241
|
+
taxType: 'IVA' | 'IVA_0' | 'NO_TAX' | 'ICE' | 'IRBPNR' | 'IVA_EXEMPT';
|
|
242
|
+
}
|
|
243
|
+
interface CreateDebitNoteInput {
|
|
244
|
+
/** 49-digit SRI access key (claveAcceso) of the original authorized invoice */
|
|
245
|
+
invoiceAccessKey: string;
|
|
246
|
+
/** Reasons / charges for the debit note (at least one required) */
|
|
247
|
+
reasons: DebitNoteReason[];
|
|
248
|
+
additionalInfo?: Record<string, string>;
|
|
249
|
+
/** UUID of the emission point. Optional if taxpayer has a single active emission point. */
|
|
250
|
+
emissionPointId?: string;
|
|
251
|
+
/** SRI establishment code (e.g. "001"). Must be used together with emissionPoint. */
|
|
252
|
+
establishment?: string;
|
|
253
|
+
/** SRI emission point code (e.g. "001"). Must be used together with establishment. */
|
|
254
|
+
emissionPoint?: string;
|
|
255
|
+
}
|
|
256
|
+
interface DebitNote {
|
|
257
|
+
id: string;
|
|
258
|
+
accessKey: string;
|
|
259
|
+
sequential: string;
|
|
260
|
+
status: string;
|
|
261
|
+
total: number | string;
|
|
262
|
+
}
|
|
263
|
+
interface CreditNoteListParams {
|
|
264
|
+
/** Filter by customer RUC or cédula */
|
|
265
|
+
ruc?: string;
|
|
266
|
+
/** Filter by status: DRAFT | PENDING | PROCESSING | AUTHORIZED | REJECTED | VOIDED */
|
|
267
|
+
status?: string;
|
|
268
|
+
/** Start date (ISO 8601, e.g. "2025-01-01") */
|
|
269
|
+
dateFrom?: string;
|
|
270
|
+
/** End date (ISO 8601, e.g. "2025-12-31") */
|
|
271
|
+
dateTo?: string;
|
|
272
|
+
/** Page number (default: 1) */
|
|
273
|
+
page?: number;
|
|
274
|
+
/** Results per page (default: 20, max: 100) */
|
|
275
|
+
limit?: number;
|
|
276
|
+
}
|
|
277
|
+
interface CreditNoteListItem {
|
|
278
|
+
id: string;
|
|
279
|
+
accessKey: string;
|
|
280
|
+
sequential: string;
|
|
281
|
+
status: string;
|
|
282
|
+
total: number | string;
|
|
283
|
+
issueDate: string;
|
|
284
|
+
createdAt: string;
|
|
285
|
+
customer: {
|
|
286
|
+
identification: string;
|
|
287
|
+
identificationType: string;
|
|
288
|
+
legalName: string;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
interface CreateCreditNoteInput {
|
|
292
|
+
/** 49-digit SRI access key (claveAcceso) of the original authorized invoice */
|
|
293
|
+
invoiceAccessKey: string;
|
|
294
|
+
/** Reason for the credit note */
|
|
295
|
+
reason: string;
|
|
296
|
+
items: InvoiceItem[];
|
|
297
|
+
payments?: InvoicePayment[];
|
|
298
|
+
additionalInfo?: Record<string, string>;
|
|
299
|
+
/** UUID of the emission point. Optional if taxpayer has a single active emission point. */
|
|
300
|
+
emissionPointId?: string;
|
|
301
|
+
/** SRI establishment code (e.g. "001"). Must be used together with emissionPoint. */
|
|
302
|
+
establishment?: string;
|
|
303
|
+
/** SRI emission point code (e.g. "001"). Must be used together with establishment. */
|
|
304
|
+
emissionPoint?: string;
|
|
305
|
+
}
|
|
306
|
+
interface CreditNote {
|
|
307
|
+
id: string;
|
|
308
|
+
accessKey: string;
|
|
309
|
+
sequential: string;
|
|
310
|
+
status: string;
|
|
311
|
+
total: number | string;
|
|
312
|
+
}
|
|
313
|
+
interface WithholdingTaxInput {
|
|
314
|
+
/** Tax type: RENTA (income) | IVA (VAT) | ISD (foreign exchange) */
|
|
315
|
+
taxType: 'RENTA' | 'IVA' | 'ISD';
|
|
316
|
+
/** SRI rate code (codigoPorcentaje), e.g. "303" */
|
|
317
|
+
taxRateCode: string;
|
|
318
|
+
/** Tax rate percentage (0–100), e.g. 10 */
|
|
319
|
+
taxRate: number;
|
|
320
|
+
/** Tax base amount (baseImponible), must be > 0 */
|
|
321
|
+
taxBase: number;
|
|
322
|
+
/** Fiscal period MM/YYYY (defaults to current month) */
|
|
323
|
+
fiscalPeriod?: string;
|
|
324
|
+
}
|
|
325
|
+
interface CreateWithholdingInput {
|
|
326
|
+
/** 49-digit SRI access key (claveAcceso) of the original authorized invoice */
|
|
327
|
+
invoiceAccessKey: string;
|
|
328
|
+
/** Withholding tax lines (at least one required) */
|
|
329
|
+
taxes: WithholdingTaxInput[];
|
|
330
|
+
additionalInfo?: Record<string, string>;
|
|
331
|
+
/** UUID of the emission point. Optional if taxpayer has a single active emission point. */
|
|
332
|
+
emissionPointId?: string;
|
|
333
|
+
/** SRI establishment code (e.g. "001"). Must be used together with emissionPoint. */
|
|
334
|
+
establishment?: string;
|
|
335
|
+
/** SRI emission point code (e.g. "001"). Must be used together with establishment. */
|
|
336
|
+
emissionPoint?: string;
|
|
337
|
+
}
|
|
338
|
+
interface WithholdingListParams {
|
|
339
|
+
/** Filter by customer RUC or cédula */
|
|
340
|
+
ruc?: string;
|
|
341
|
+
/** Filter by status */
|
|
342
|
+
status?: string;
|
|
343
|
+
/** Start date (ISO 8601) */
|
|
344
|
+
dateFrom?: string;
|
|
345
|
+
/** End date (ISO 8601) */
|
|
346
|
+
dateTo?: string;
|
|
347
|
+
/** Page number (default: 1) */
|
|
348
|
+
page?: number;
|
|
349
|
+
/** Results per page (default: 20, max: 100) */
|
|
350
|
+
limit?: number;
|
|
351
|
+
}
|
|
352
|
+
interface WithholdingListItem {
|
|
353
|
+
id: string;
|
|
354
|
+
accessKey: string;
|
|
355
|
+
sequential: string;
|
|
356
|
+
status: string;
|
|
357
|
+
total: number | string;
|
|
358
|
+
issueDate: string;
|
|
359
|
+
createdAt: string;
|
|
360
|
+
customer: {
|
|
361
|
+
identification: string;
|
|
362
|
+
identificationType: string;
|
|
363
|
+
legalName: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
interface Withholding {
|
|
367
|
+
id: string;
|
|
368
|
+
accessKey: string;
|
|
369
|
+
sequential: string;
|
|
370
|
+
status: string;
|
|
371
|
+
totalWithheld: number | string;
|
|
372
|
+
invoiceId: string;
|
|
373
|
+
}
|
|
158
374
|
interface SignAndAuthorizeInput {
|
|
159
375
|
/** Unsigned XML string */
|
|
160
376
|
xml: string;
|
|
@@ -235,6 +451,18 @@ interface UpdateSequentialResponse {
|
|
|
235
451
|
invoiceSequential: number;
|
|
236
452
|
updatedAt: string;
|
|
237
453
|
}
|
|
454
|
+
interface UpdateCreditNoteSequentialResponse {
|
|
455
|
+
branchCode: string;
|
|
456
|
+
emissionCode: string;
|
|
457
|
+
creditNoteSequential: number;
|
|
458
|
+
updatedAt: string;
|
|
459
|
+
}
|
|
460
|
+
interface UpdateDebitNoteSequentialResponse {
|
|
461
|
+
branchCode: string;
|
|
462
|
+
emissionCode: string;
|
|
463
|
+
debitNoteSequential: number;
|
|
464
|
+
updatedAt: string;
|
|
465
|
+
}
|
|
238
466
|
interface CertificateUploadResponse {
|
|
239
467
|
hasCertificate: boolean;
|
|
240
468
|
isExpired?: boolean;
|
|
@@ -282,10 +510,10 @@ interface QueryExternalByAccessKeyResponse {
|
|
|
282
510
|
xmlBase64: string;
|
|
283
511
|
}
|
|
284
512
|
|
|
285
|
-
type Requester$
|
|
513
|
+
type Requester$7 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
286
514
|
declare class CertificatesResource {
|
|
287
515
|
private request;
|
|
288
|
-
constructor(request: Requester$
|
|
516
|
+
constructor(request: Requester$7);
|
|
289
517
|
/**
|
|
290
518
|
* Get the certificate status for the current taxpayer (requires x-taxpayer-ruc header).
|
|
291
519
|
*/
|
|
@@ -302,10 +530,24 @@ declare class CertificatesResource {
|
|
|
302
530
|
upload(file: Uint8Array | Blob, password: string): Promise<CertificateUploadResponse>;
|
|
303
531
|
}
|
|
304
532
|
|
|
305
|
-
type Requester$
|
|
533
|
+
type Requester$6 = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
534
|
+
declare class CreditNotesResource {
|
|
535
|
+
private request;
|
|
536
|
+
constructor(request: Requester$6);
|
|
537
|
+
list(params?: CreditNoteListParams): Promise<PaginatedResponse<CreditNoteListItem>>;
|
|
538
|
+
create(input: CreateCreditNoteInput): Promise<CreditNote>;
|
|
539
|
+
get(id: string): Promise<Record<string, unknown>>;
|
|
540
|
+
getStatus(id: string): Promise<InvoiceStatus>;
|
|
541
|
+
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
542
|
+
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
543
|
+
void(id: string, reason: string): Promise<VoidInvoiceResponse>;
|
|
544
|
+
updateSequential(branchCode: string, emissionCode: string, creditNoteSequential: number): Promise<UpdateCreditNoteSequentialResponse>;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
type Requester$5 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
306
548
|
declare class CustomersResource {
|
|
307
549
|
private request;
|
|
308
|
-
constructor(request: Requester$
|
|
550
|
+
constructor(request: Requester$5);
|
|
309
551
|
create(input: CreateCustomerInput): Promise<Customer>;
|
|
310
552
|
list(params?: CustomerListParams): Promise<PaginatedResponse<Customer>>;
|
|
311
553
|
get(id: string): Promise<Customer>;
|
|
@@ -313,10 +555,25 @@ declare class CustomersResource {
|
|
|
313
555
|
delete(id: string): Promise<void>;
|
|
314
556
|
}
|
|
315
557
|
|
|
316
|
-
type Requester$
|
|
558
|
+
type Requester$4 = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
559
|
+
declare class DebitNotesResource {
|
|
560
|
+
private request;
|
|
561
|
+
constructor(request: Requester$4);
|
|
562
|
+
list(params?: DebitNoteListParams): Promise<PaginatedResponse<DebitNoteListItem>>;
|
|
563
|
+
create(input: CreateDebitNoteInput): Promise<DebitNote>;
|
|
564
|
+
get(id: string): Promise<Record<string, unknown>>;
|
|
565
|
+
getStatus(id: string): Promise<InvoiceStatus>;
|
|
566
|
+
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
567
|
+
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
568
|
+
void(id: string, reason: string): Promise<VoidInvoiceResponse>;
|
|
569
|
+
updateSequential(branchCode: string, emissionCode: string, debitNoteSequential: number): Promise<UpdateDebitNoteSequentialResponse>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
type Requester$3 = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
317
573
|
declare class InvoicesResource {
|
|
318
574
|
private request;
|
|
319
|
-
constructor(request: Requester$
|
|
575
|
+
constructor(request: Requester$3);
|
|
576
|
+
list(params?: InvoiceListParams): Promise<PaginatedResponse<InvoiceListItem>>;
|
|
320
577
|
create(input: CreateInvoiceInput): Promise<Invoice>;
|
|
321
578
|
signAndAuthorize(input: SignAndAuthorizeInput): Promise<SignAndAuthorizeResponse>;
|
|
322
579
|
signOnly(input: SignOnlyInput): Promise<SignOnlyResponse>;
|
|
@@ -332,10 +589,10 @@ declare class InvoicesResource {
|
|
|
332
589
|
updateSequential(branchCode: string, emissionCode: string, invoiceSequential: number): Promise<UpdateSequentialResponse>;
|
|
333
590
|
}
|
|
334
591
|
|
|
335
|
-
type Requester$
|
|
592
|
+
type Requester$2 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
336
593
|
declare class ProductsResource {
|
|
337
594
|
private request;
|
|
338
|
-
constructor(request: Requester$
|
|
595
|
+
constructor(request: Requester$2);
|
|
339
596
|
create(input: CreateProductInput): Promise<Product>;
|
|
340
597
|
list(params?: ProductListParams): Promise<PaginatedResponse<Product>>;
|
|
341
598
|
get(id: string): Promise<Product>;
|
|
@@ -343,10 +600,10 @@ declare class ProductsResource {
|
|
|
343
600
|
delete(id: string): Promise<void>;
|
|
344
601
|
}
|
|
345
602
|
|
|
346
|
-
type Requester = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
603
|
+
type Requester$1 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
347
604
|
declare class WebhooksResource {
|
|
348
605
|
private readonly request;
|
|
349
|
-
constructor(requester: Requester);
|
|
606
|
+
constructor(requester: Requester$1);
|
|
350
607
|
/**
|
|
351
608
|
* Verify that a receipt (document) exists in the API.
|
|
352
609
|
* This is a second layer of verification beyond signature checking.
|
|
@@ -357,16 +614,32 @@ declare class WebhooksResource {
|
|
|
357
614
|
verifyReceipt(receiptId: string): Promise<Record<string, unknown> | null>;
|
|
358
615
|
}
|
|
359
616
|
|
|
617
|
+
type Requester = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
618
|
+
declare class WithholdingsResource {
|
|
619
|
+
private request;
|
|
620
|
+
constructor(request: Requester);
|
|
621
|
+
create(input: CreateWithholdingInput): Promise<Withholding>;
|
|
622
|
+
list(params?: WithholdingListParams): Promise<PaginatedResponse<WithholdingListItem>>;
|
|
623
|
+
get(id: string): Promise<Record<string, unknown>>;
|
|
624
|
+
getStatus(id: string): Promise<InvoiceStatus>;
|
|
625
|
+
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
626
|
+
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
627
|
+
void(id: string, reason: string): Promise<VoidInvoiceResponse>;
|
|
628
|
+
}
|
|
629
|
+
|
|
360
630
|
declare class Factuplan {
|
|
361
631
|
private readonly apiKey;
|
|
362
632
|
private readonly baseUrl;
|
|
363
633
|
private readonly timeout;
|
|
364
634
|
private readonly options;
|
|
365
635
|
readonly certificates: CertificatesResource;
|
|
636
|
+
readonly creditNotes: CreditNotesResource;
|
|
637
|
+
readonly debitNotes: DebitNotesResource;
|
|
366
638
|
readonly customers: CustomersResource;
|
|
367
639
|
readonly products: ProductsResource;
|
|
368
640
|
readonly invoices: InvoicesResource;
|
|
369
641
|
readonly webhooks: WebhooksResource;
|
|
642
|
+
readonly withholdings: WithholdingsResource;
|
|
370
643
|
static readonly webhooks: typeof WebhooksResource;
|
|
371
644
|
constructor(apiKey: string, options?: FactuplanOptions);
|
|
372
645
|
usage(): Promise<UsageResponse>;
|
|
@@ -386,4 +659,4 @@ declare class RateLimitError extends FactuplanError {
|
|
|
386
659
|
constructor(message?: string);
|
|
387
660
|
}
|
|
388
661
|
|
|
389
|
-
export { AuthenticationError, type CertificateStatus, type CertificateUploadResponse, CertificatesResource, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, type QueryExternalByAccessKeyInput, type QueryExternalByAccessKeyResponse, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UpdateSequentialResponse, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type VoidInvoiceResponse, type WebhookEvent, type WebhookReceiptData };
|
|
662
|
+
export { AuthenticationError, type CertificateStatus, type CertificateUploadResponse, CertificatesResource, type CreateCreditNoteInput, type CreateCustomerInput, type CreateDebitNoteInput, type CreateInvoiceInput, type CreateProductInput, type CreateWithholdingInput, type CreditNote, type CreditNoteListItem, type CreditNoteListParams, CreditNotesResource, type Customer, type CustomerListParams, type DebitNote, type DebitNoteListItem, type DebitNoteListParams, type DebitNoteReason, DebitNotesResource, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceListItem, type InvoiceListParams, type InvoiceRetencion, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, type QueryExternalByAccessKeyInput, type QueryExternalByAccessKeyResponse, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCreditNoteSequentialResponse, type UpdateCustomerInput, type UpdateDebitNoteSequentialResponse, type UpdateProductInput, type UpdateSequentialResponse, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type VoidInvoiceResponse, type WebhookEvent, type WebhookReceiptData, type Withholding, type WithholdingListItem, type WithholdingListParams, type WithholdingTaxInput, WithholdingsResource };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface PaginatedResponse<T> {
|
|
|
9
9
|
}
|
|
10
10
|
interface Customer {
|
|
11
11
|
id: string;
|
|
12
|
-
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER';
|
|
12
|
+
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER' | 'EXTERIOR';
|
|
13
13
|
identification: string;
|
|
14
14
|
legalName: string;
|
|
15
15
|
email?: string;
|
|
@@ -20,7 +20,7 @@ interface Customer {
|
|
|
20
20
|
updatedAt: string;
|
|
21
21
|
}
|
|
22
22
|
interface CreateCustomerInput {
|
|
23
|
-
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER';
|
|
23
|
+
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER' | 'EXTERIOR';
|
|
24
24
|
identification: string;
|
|
25
25
|
legalName: string;
|
|
26
26
|
email?: string;
|
|
@@ -85,7 +85,7 @@ interface ProductListParams {
|
|
|
85
85
|
search?: string;
|
|
86
86
|
}
|
|
87
87
|
interface InvoiceCustomer {
|
|
88
|
-
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER';
|
|
88
|
+
identificationType: 'RUC' | 'CEDULA' | 'PASSPORT' | 'FINAL_CONSUMER' | 'EXTERIOR';
|
|
89
89
|
identification: string;
|
|
90
90
|
legalName: string;
|
|
91
91
|
email?: string;
|
|
@@ -95,6 +95,8 @@ interface InvoiceCustomer {
|
|
|
95
95
|
}
|
|
96
96
|
interface InvoiceItem {
|
|
97
97
|
code: string;
|
|
98
|
+
/** Auxiliary code (SRI codigoAuxiliar). Optional — defaults to `code`. */
|
|
99
|
+
auxiliaryCode?: string;
|
|
98
100
|
description: string;
|
|
99
101
|
quantity: number;
|
|
100
102
|
unitPrice: number;
|
|
@@ -110,6 +112,16 @@ interface InvoicePayment {
|
|
|
110
112
|
term?: number;
|
|
111
113
|
timeUnit?: PaymentTimeUnit;
|
|
112
114
|
}
|
|
115
|
+
interface InvoiceRetencion {
|
|
116
|
+
/** SRI Tabla 22 code (1 digit). '2' = IVA presuntivo, '4' = combustibles/renta */
|
|
117
|
+
codigo: string;
|
|
118
|
+
/** SRI Tabla 23 percentage code (1–3 digits) */
|
|
119
|
+
codigoPorcentaje: string;
|
|
120
|
+
/** Retention rate (e.g. 0.20) */
|
|
121
|
+
tarifa: number;
|
|
122
|
+
/** Retained amount (e.g. 0.13) */
|
|
123
|
+
valor: number;
|
|
124
|
+
}
|
|
113
125
|
interface CreateInvoiceInput {
|
|
114
126
|
/** UUID of the emission point. Optional if using establishment + emissionPoint codes, or if the taxpayer has a single active emission point. */
|
|
115
127
|
emissionPointId?: string;
|
|
@@ -127,6 +139,11 @@ interface CreateInvoiceInput {
|
|
|
127
139
|
* @default true
|
|
128
140
|
*/
|
|
129
141
|
sendEmail?: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* In-invoice withholdings. Applies to petroleum product distributors (Tabla 22 code 4)
|
|
144
|
+
* and presumptive IVA retention for newspaper/magazine editors and distributors (code 2).
|
|
145
|
+
*/
|
|
146
|
+
retenciones?: InvoiceRetencion[];
|
|
130
147
|
}
|
|
131
148
|
interface ImportByAccessKeyInput {
|
|
132
149
|
/** 49-digit SRI access key (claveAcceso) of an already-authorized invoice */
|
|
@@ -139,6 +156,34 @@ interface Invoice {
|
|
|
139
156
|
status: string;
|
|
140
157
|
total: number | string;
|
|
141
158
|
}
|
|
159
|
+
interface InvoiceListParams {
|
|
160
|
+
/** Filter by customer RUC or cédula */
|
|
161
|
+
ruc?: string;
|
|
162
|
+
/** Filter by invoice status: DRAFT | PENDING | PROCESSING | AUTHORIZED | REJECTED | VOIDED */
|
|
163
|
+
status?: string;
|
|
164
|
+
/** Start date (ISO 8601, e.g. "2025-01-01") */
|
|
165
|
+
dateFrom?: string;
|
|
166
|
+
/** End date (ISO 8601, e.g. "2025-12-31") */
|
|
167
|
+
dateTo?: string;
|
|
168
|
+
/** Page number (default: 1) */
|
|
169
|
+
page?: number;
|
|
170
|
+
/** Results per page (default: 20, max: 100) */
|
|
171
|
+
limit?: number;
|
|
172
|
+
}
|
|
173
|
+
interface InvoiceListItem {
|
|
174
|
+
id: string;
|
|
175
|
+
accessKey: string;
|
|
176
|
+
sequential: string;
|
|
177
|
+
status: string;
|
|
178
|
+
total: number | string;
|
|
179
|
+
issueDate: string;
|
|
180
|
+
createdAt: string;
|
|
181
|
+
customer: {
|
|
182
|
+
identification: string;
|
|
183
|
+
identificationType: string;
|
|
184
|
+
legalName: string;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
142
187
|
interface InvoiceStatus {
|
|
143
188
|
id: string;
|
|
144
189
|
status: string;
|
|
@@ -155,6 +200,177 @@ interface DownloadUrlResponse {
|
|
|
155
200
|
*/
|
|
156
201
|
previewUrl?: string;
|
|
157
202
|
}
|
|
203
|
+
interface DebitNoteListParams {
|
|
204
|
+
/** Filter by customer RUC or cédula */
|
|
205
|
+
ruc?: string;
|
|
206
|
+
/** Filter by status: DRAFT | PENDING | PROCESSING | AUTHORIZED | REJECTED | VOIDED */
|
|
207
|
+
status?: string;
|
|
208
|
+
/** Start date (ISO 8601, e.g. "2025-01-01") */
|
|
209
|
+
dateFrom?: string;
|
|
210
|
+
/** End date (ISO 8601, e.g. "2025-12-31") */
|
|
211
|
+
dateTo?: string;
|
|
212
|
+
/** Page number (default: 1) */
|
|
213
|
+
page?: number;
|
|
214
|
+
/** Results per page (default: 20, max: 100) */
|
|
215
|
+
limit?: number;
|
|
216
|
+
}
|
|
217
|
+
interface DebitNoteListItem {
|
|
218
|
+
id: string;
|
|
219
|
+
accessKey: string;
|
|
220
|
+
sequential: string;
|
|
221
|
+
status: string;
|
|
222
|
+
total: number | string;
|
|
223
|
+
issueDate: string;
|
|
224
|
+
createdAt: string;
|
|
225
|
+
customer: {
|
|
226
|
+
identification: string;
|
|
227
|
+
identificationType: string;
|
|
228
|
+
legalName: string;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
interface DebitNoteReason {
|
|
232
|
+
/** Description of the charge or adjustment */
|
|
233
|
+
description: string;
|
|
234
|
+
/** Amount of this charge */
|
|
235
|
+
amount: number;
|
|
236
|
+
/**
|
|
237
|
+
* Tax type for this charge.
|
|
238
|
+
* `IVA` = IVA at the current rate · `IVA_0` = IVA 0% · `NO_TAX` = not taxable ·
|
|
239
|
+
* `ICE` = ICE · `IRBPNR` = IRBPNR · `IVA_EXEMPT` = exempt from IVA
|
|
240
|
+
*/
|
|
241
|
+
taxType: 'IVA' | 'IVA_0' | 'NO_TAX' | 'ICE' | 'IRBPNR' | 'IVA_EXEMPT';
|
|
242
|
+
}
|
|
243
|
+
interface CreateDebitNoteInput {
|
|
244
|
+
/** 49-digit SRI access key (claveAcceso) of the original authorized invoice */
|
|
245
|
+
invoiceAccessKey: string;
|
|
246
|
+
/** Reasons / charges for the debit note (at least one required) */
|
|
247
|
+
reasons: DebitNoteReason[];
|
|
248
|
+
additionalInfo?: Record<string, string>;
|
|
249
|
+
/** UUID of the emission point. Optional if taxpayer has a single active emission point. */
|
|
250
|
+
emissionPointId?: string;
|
|
251
|
+
/** SRI establishment code (e.g. "001"). Must be used together with emissionPoint. */
|
|
252
|
+
establishment?: string;
|
|
253
|
+
/** SRI emission point code (e.g. "001"). Must be used together with establishment. */
|
|
254
|
+
emissionPoint?: string;
|
|
255
|
+
}
|
|
256
|
+
interface DebitNote {
|
|
257
|
+
id: string;
|
|
258
|
+
accessKey: string;
|
|
259
|
+
sequential: string;
|
|
260
|
+
status: string;
|
|
261
|
+
total: number | string;
|
|
262
|
+
}
|
|
263
|
+
interface CreditNoteListParams {
|
|
264
|
+
/** Filter by customer RUC or cédula */
|
|
265
|
+
ruc?: string;
|
|
266
|
+
/** Filter by status: DRAFT | PENDING | PROCESSING | AUTHORIZED | REJECTED | VOIDED */
|
|
267
|
+
status?: string;
|
|
268
|
+
/** Start date (ISO 8601, e.g. "2025-01-01") */
|
|
269
|
+
dateFrom?: string;
|
|
270
|
+
/** End date (ISO 8601, e.g. "2025-12-31") */
|
|
271
|
+
dateTo?: string;
|
|
272
|
+
/** Page number (default: 1) */
|
|
273
|
+
page?: number;
|
|
274
|
+
/** Results per page (default: 20, max: 100) */
|
|
275
|
+
limit?: number;
|
|
276
|
+
}
|
|
277
|
+
interface CreditNoteListItem {
|
|
278
|
+
id: string;
|
|
279
|
+
accessKey: string;
|
|
280
|
+
sequential: string;
|
|
281
|
+
status: string;
|
|
282
|
+
total: number | string;
|
|
283
|
+
issueDate: string;
|
|
284
|
+
createdAt: string;
|
|
285
|
+
customer: {
|
|
286
|
+
identification: string;
|
|
287
|
+
identificationType: string;
|
|
288
|
+
legalName: string;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
interface CreateCreditNoteInput {
|
|
292
|
+
/** 49-digit SRI access key (claveAcceso) of the original authorized invoice */
|
|
293
|
+
invoiceAccessKey: string;
|
|
294
|
+
/** Reason for the credit note */
|
|
295
|
+
reason: string;
|
|
296
|
+
items: InvoiceItem[];
|
|
297
|
+
payments?: InvoicePayment[];
|
|
298
|
+
additionalInfo?: Record<string, string>;
|
|
299
|
+
/** UUID of the emission point. Optional if taxpayer has a single active emission point. */
|
|
300
|
+
emissionPointId?: string;
|
|
301
|
+
/** SRI establishment code (e.g. "001"). Must be used together with emissionPoint. */
|
|
302
|
+
establishment?: string;
|
|
303
|
+
/** SRI emission point code (e.g. "001"). Must be used together with establishment. */
|
|
304
|
+
emissionPoint?: string;
|
|
305
|
+
}
|
|
306
|
+
interface CreditNote {
|
|
307
|
+
id: string;
|
|
308
|
+
accessKey: string;
|
|
309
|
+
sequential: string;
|
|
310
|
+
status: string;
|
|
311
|
+
total: number | string;
|
|
312
|
+
}
|
|
313
|
+
interface WithholdingTaxInput {
|
|
314
|
+
/** Tax type: RENTA (income) | IVA (VAT) | ISD (foreign exchange) */
|
|
315
|
+
taxType: 'RENTA' | 'IVA' | 'ISD';
|
|
316
|
+
/** SRI rate code (codigoPorcentaje), e.g. "303" */
|
|
317
|
+
taxRateCode: string;
|
|
318
|
+
/** Tax rate percentage (0–100), e.g. 10 */
|
|
319
|
+
taxRate: number;
|
|
320
|
+
/** Tax base amount (baseImponible), must be > 0 */
|
|
321
|
+
taxBase: number;
|
|
322
|
+
/** Fiscal period MM/YYYY (defaults to current month) */
|
|
323
|
+
fiscalPeriod?: string;
|
|
324
|
+
}
|
|
325
|
+
interface CreateWithholdingInput {
|
|
326
|
+
/** 49-digit SRI access key (claveAcceso) of the original authorized invoice */
|
|
327
|
+
invoiceAccessKey: string;
|
|
328
|
+
/** Withholding tax lines (at least one required) */
|
|
329
|
+
taxes: WithholdingTaxInput[];
|
|
330
|
+
additionalInfo?: Record<string, string>;
|
|
331
|
+
/** UUID of the emission point. Optional if taxpayer has a single active emission point. */
|
|
332
|
+
emissionPointId?: string;
|
|
333
|
+
/** SRI establishment code (e.g. "001"). Must be used together with emissionPoint. */
|
|
334
|
+
establishment?: string;
|
|
335
|
+
/** SRI emission point code (e.g. "001"). Must be used together with establishment. */
|
|
336
|
+
emissionPoint?: string;
|
|
337
|
+
}
|
|
338
|
+
interface WithholdingListParams {
|
|
339
|
+
/** Filter by customer RUC or cédula */
|
|
340
|
+
ruc?: string;
|
|
341
|
+
/** Filter by status */
|
|
342
|
+
status?: string;
|
|
343
|
+
/** Start date (ISO 8601) */
|
|
344
|
+
dateFrom?: string;
|
|
345
|
+
/** End date (ISO 8601) */
|
|
346
|
+
dateTo?: string;
|
|
347
|
+
/** Page number (default: 1) */
|
|
348
|
+
page?: number;
|
|
349
|
+
/** Results per page (default: 20, max: 100) */
|
|
350
|
+
limit?: number;
|
|
351
|
+
}
|
|
352
|
+
interface WithholdingListItem {
|
|
353
|
+
id: string;
|
|
354
|
+
accessKey: string;
|
|
355
|
+
sequential: string;
|
|
356
|
+
status: string;
|
|
357
|
+
total: number | string;
|
|
358
|
+
issueDate: string;
|
|
359
|
+
createdAt: string;
|
|
360
|
+
customer: {
|
|
361
|
+
identification: string;
|
|
362
|
+
identificationType: string;
|
|
363
|
+
legalName: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
interface Withholding {
|
|
367
|
+
id: string;
|
|
368
|
+
accessKey: string;
|
|
369
|
+
sequential: string;
|
|
370
|
+
status: string;
|
|
371
|
+
totalWithheld: number | string;
|
|
372
|
+
invoiceId: string;
|
|
373
|
+
}
|
|
158
374
|
interface SignAndAuthorizeInput {
|
|
159
375
|
/** Unsigned XML string */
|
|
160
376
|
xml: string;
|
|
@@ -235,6 +451,18 @@ interface UpdateSequentialResponse {
|
|
|
235
451
|
invoiceSequential: number;
|
|
236
452
|
updatedAt: string;
|
|
237
453
|
}
|
|
454
|
+
interface UpdateCreditNoteSequentialResponse {
|
|
455
|
+
branchCode: string;
|
|
456
|
+
emissionCode: string;
|
|
457
|
+
creditNoteSequential: number;
|
|
458
|
+
updatedAt: string;
|
|
459
|
+
}
|
|
460
|
+
interface UpdateDebitNoteSequentialResponse {
|
|
461
|
+
branchCode: string;
|
|
462
|
+
emissionCode: string;
|
|
463
|
+
debitNoteSequential: number;
|
|
464
|
+
updatedAt: string;
|
|
465
|
+
}
|
|
238
466
|
interface CertificateUploadResponse {
|
|
239
467
|
hasCertificate: boolean;
|
|
240
468
|
isExpired?: boolean;
|
|
@@ -282,10 +510,10 @@ interface QueryExternalByAccessKeyResponse {
|
|
|
282
510
|
xmlBase64: string;
|
|
283
511
|
}
|
|
284
512
|
|
|
285
|
-
type Requester$
|
|
513
|
+
type Requester$7 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
286
514
|
declare class CertificatesResource {
|
|
287
515
|
private request;
|
|
288
|
-
constructor(request: Requester$
|
|
516
|
+
constructor(request: Requester$7);
|
|
289
517
|
/**
|
|
290
518
|
* Get the certificate status for the current taxpayer (requires x-taxpayer-ruc header).
|
|
291
519
|
*/
|
|
@@ -302,10 +530,24 @@ declare class CertificatesResource {
|
|
|
302
530
|
upload(file: Uint8Array | Blob, password: string): Promise<CertificateUploadResponse>;
|
|
303
531
|
}
|
|
304
532
|
|
|
305
|
-
type Requester$
|
|
533
|
+
type Requester$6 = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
534
|
+
declare class CreditNotesResource {
|
|
535
|
+
private request;
|
|
536
|
+
constructor(request: Requester$6);
|
|
537
|
+
list(params?: CreditNoteListParams): Promise<PaginatedResponse<CreditNoteListItem>>;
|
|
538
|
+
create(input: CreateCreditNoteInput): Promise<CreditNote>;
|
|
539
|
+
get(id: string): Promise<Record<string, unknown>>;
|
|
540
|
+
getStatus(id: string): Promise<InvoiceStatus>;
|
|
541
|
+
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
542
|
+
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
543
|
+
void(id: string, reason: string): Promise<VoidInvoiceResponse>;
|
|
544
|
+
updateSequential(branchCode: string, emissionCode: string, creditNoteSequential: number): Promise<UpdateCreditNoteSequentialResponse>;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
type Requester$5 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
306
548
|
declare class CustomersResource {
|
|
307
549
|
private request;
|
|
308
|
-
constructor(request: Requester$
|
|
550
|
+
constructor(request: Requester$5);
|
|
309
551
|
create(input: CreateCustomerInput): Promise<Customer>;
|
|
310
552
|
list(params?: CustomerListParams): Promise<PaginatedResponse<Customer>>;
|
|
311
553
|
get(id: string): Promise<Customer>;
|
|
@@ -313,10 +555,25 @@ declare class CustomersResource {
|
|
|
313
555
|
delete(id: string): Promise<void>;
|
|
314
556
|
}
|
|
315
557
|
|
|
316
|
-
type Requester$
|
|
558
|
+
type Requester$4 = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
559
|
+
declare class DebitNotesResource {
|
|
560
|
+
private request;
|
|
561
|
+
constructor(request: Requester$4);
|
|
562
|
+
list(params?: DebitNoteListParams): Promise<PaginatedResponse<DebitNoteListItem>>;
|
|
563
|
+
create(input: CreateDebitNoteInput): Promise<DebitNote>;
|
|
564
|
+
get(id: string): Promise<Record<string, unknown>>;
|
|
565
|
+
getStatus(id: string): Promise<InvoiceStatus>;
|
|
566
|
+
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
567
|
+
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
568
|
+
void(id: string, reason: string): Promise<VoidInvoiceResponse>;
|
|
569
|
+
updateSequential(branchCode: string, emissionCode: string, debitNoteSequential: number): Promise<UpdateDebitNoteSequentialResponse>;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
type Requester$3 = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
317
573
|
declare class InvoicesResource {
|
|
318
574
|
private request;
|
|
319
|
-
constructor(request: Requester$
|
|
575
|
+
constructor(request: Requester$3);
|
|
576
|
+
list(params?: InvoiceListParams): Promise<PaginatedResponse<InvoiceListItem>>;
|
|
320
577
|
create(input: CreateInvoiceInput): Promise<Invoice>;
|
|
321
578
|
signAndAuthorize(input: SignAndAuthorizeInput): Promise<SignAndAuthorizeResponse>;
|
|
322
579
|
signOnly(input: SignOnlyInput): Promise<SignOnlyResponse>;
|
|
@@ -332,10 +589,10 @@ declare class InvoicesResource {
|
|
|
332
589
|
updateSequential(branchCode: string, emissionCode: string, invoiceSequential: number): Promise<UpdateSequentialResponse>;
|
|
333
590
|
}
|
|
334
591
|
|
|
335
|
-
type Requester$
|
|
592
|
+
type Requester$2 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
336
593
|
declare class ProductsResource {
|
|
337
594
|
private request;
|
|
338
|
-
constructor(request: Requester$
|
|
595
|
+
constructor(request: Requester$2);
|
|
339
596
|
create(input: CreateProductInput): Promise<Product>;
|
|
340
597
|
list(params?: ProductListParams): Promise<PaginatedResponse<Product>>;
|
|
341
598
|
get(id: string): Promise<Product>;
|
|
@@ -343,10 +600,10 @@ declare class ProductsResource {
|
|
|
343
600
|
delete(id: string): Promise<void>;
|
|
344
601
|
}
|
|
345
602
|
|
|
346
|
-
type Requester = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
603
|
+
type Requester$1 = (method: string, path: string, body?: unknown, params?: Record<string, string | number | undefined>) => Promise<unknown>;
|
|
347
604
|
declare class WebhooksResource {
|
|
348
605
|
private readonly request;
|
|
349
|
-
constructor(requester: Requester);
|
|
606
|
+
constructor(requester: Requester$1);
|
|
350
607
|
/**
|
|
351
608
|
* Verify that a receipt (document) exists in the API.
|
|
352
609
|
* This is a second layer of verification beyond signature checking.
|
|
@@ -357,16 +614,32 @@ declare class WebhooksResource {
|
|
|
357
614
|
verifyReceipt(receiptId: string): Promise<Record<string, unknown> | null>;
|
|
358
615
|
}
|
|
359
616
|
|
|
617
|
+
type Requester = (method: string, path: string, body?: unknown) => Promise<unknown>;
|
|
618
|
+
declare class WithholdingsResource {
|
|
619
|
+
private request;
|
|
620
|
+
constructor(request: Requester);
|
|
621
|
+
create(input: CreateWithholdingInput): Promise<Withholding>;
|
|
622
|
+
list(params?: WithholdingListParams): Promise<PaginatedResponse<WithholdingListItem>>;
|
|
623
|
+
get(id: string): Promise<Record<string, unknown>>;
|
|
624
|
+
getStatus(id: string): Promise<InvoiceStatus>;
|
|
625
|
+
downloadXml(id: string): Promise<DownloadUrlResponse>;
|
|
626
|
+
downloadPdf(id: string): Promise<DownloadUrlResponse>;
|
|
627
|
+
void(id: string, reason: string): Promise<VoidInvoiceResponse>;
|
|
628
|
+
}
|
|
629
|
+
|
|
360
630
|
declare class Factuplan {
|
|
361
631
|
private readonly apiKey;
|
|
362
632
|
private readonly baseUrl;
|
|
363
633
|
private readonly timeout;
|
|
364
634
|
private readonly options;
|
|
365
635
|
readonly certificates: CertificatesResource;
|
|
636
|
+
readonly creditNotes: CreditNotesResource;
|
|
637
|
+
readonly debitNotes: DebitNotesResource;
|
|
366
638
|
readonly customers: CustomersResource;
|
|
367
639
|
readonly products: ProductsResource;
|
|
368
640
|
readonly invoices: InvoicesResource;
|
|
369
641
|
readonly webhooks: WebhooksResource;
|
|
642
|
+
readonly withholdings: WithholdingsResource;
|
|
370
643
|
static readonly webhooks: typeof WebhooksResource;
|
|
371
644
|
constructor(apiKey: string, options?: FactuplanOptions);
|
|
372
645
|
usage(): Promise<UsageResponse>;
|
|
@@ -386,4 +659,4 @@ declare class RateLimitError extends FactuplanError {
|
|
|
386
659
|
constructor(message?: string);
|
|
387
660
|
}
|
|
388
661
|
|
|
389
|
-
export { AuthenticationError, type CertificateStatus, type CertificateUploadResponse, CertificatesResource, type CreateCustomerInput, type CreateInvoiceInput, type CreateProductInput, type Customer, type CustomerListParams, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, type QueryExternalByAccessKeyInput, type QueryExternalByAccessKeyResponse, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCustomerInput, type UpdateProductInput, type UpdateSequentialResponse, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type VoidInvoiceResponse, type WebhookEvent, type WebhookReceiptData };
|
|
662
|
+
export { AuthenticationError, type CertificateStatus, type CertificateUploadResponse, CertificatesResource, type CreateCreditNoteInput, type CreateCustomerInput, type CreateDebitNoteInput, type CreateInvoiceInput, type CreateProductInput, type CreateWithholdingInput, type CreditNote, type CreditNoteListItem, type CreditNoteListParams, CreditNotesResource, type Customer, type CustomerListParams, type DebitNote, type DebitNoteListItem, type DebitNoteListParams, type DebitNoteReason, DebitNotesResource, type DownloadUrlResponse, Factuplan, FactuplanError, type FactuplanOptions, type ImportByAccessKeyInput, type Invoice, type InvoiceCustomer, type InvoiceItem, type InvoiceListItem, type InvoiceListParams, type InvoiceRetencion, type InvoiceStatus, type PaginatedResponse, type Product, type ProductListParams, type QueryExternalByAccessKeyInput, type QueryExternalByAccessKeyResponse, RateLimitError, type SignAndAuthorizeInput, type SignAndAuthorizeResponse, type SignOnlyInput, type SignOnlyResponse, type UpdateCreditNoteSequentialResponse, type UpdateCustomerInput, type UpdateDebitNoteSequentialResponse, type UpdateProductInput, type UpdateSequentialResponse, type UsageResponse, type ValidateXmlInput, type ValidateXmlResponse, type VerifyResponse, type VoidInvoiceResponse, type WebhookEvent, type WebhookReceiptData, type Withholding, type WithholdingListItem, type WithholdingListParams, type WithholdingTaxInput, WithholdingsResource };
|
package/dist/index.js
CHANGED
|
@@ -22,9 +22,12 @@ var index_exports = {};
|
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AuthenticationError: () => AuthenticationError,
|
|
24
24
|
CertificatesResource: () => CertificatesResource,
|
|
25
|
+
CreditNotesResource: () => CreditNotesResource,
|
|
26
|
+
DebitNotesResource: () => DebitNotesResource,
|
|
25
27
|
Factuplan: () => Factuplan,
|
|
26
28
|
FactuplanError: () => FactuplanError,
|
|
27
|
-
RateLimitError: () => RateLimitError
|
|
29
|
+
RateLimitError: () => RateLimitError,
|
|
30
|
+
WithholdingsResource: () => WithholdingsResource
|
|
28
31
|
});
|
|
29
32
|
module.exports = __toCommonJS(index_exports);
|
|
30
33
|
|
|
@@ -80,6 +83,49 @@ var CertificatesResource = class {
|
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
|
|
86
|
+
// src/resources/credit-notes.ts
|
|
87
|
+
var CreditNotesResource = class {
|
|
88
|
+
constructor(request) {
|
|
89
|
+
this.request = request;
|
|
90
|
+
}
|
|
91
|
+
async list(params) {
|
|
92
|
+
const query = new URLSearchParams();
|
|
93
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
94
|
+
if (params?.status) query.set("status", params.status);
|
|
95
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
96
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
97
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
98
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
99
|
+
const qs = query.toString();
|
|
100
|
+
return this.request("GET", `/developer/credit-notes${qs ? `?${qs}` : ""}`);
|
|
101
|
+
}
|
|
102
|
+
async create(input) {
|
|
103
|
+
return this.request("POST", "/developer/credit-notes", input);
|
|
104
|
+
}
|
|
105
|
+
async get(id) {
|
|
106
|
+
return this.request("GET", `/developer/receipts/${id}`);
|
|
107
|
+
}
|
|
108
|
+
async getStatus(id) {
|
|
109
|
+
return this.request("GET", `/developer/receipts/${id}/status`);
|
|
110
|
+
}
|
|
111
|
+
async downloadXml(id) {
|
|
112
|
+
return this.request("GET", `/developer/receipts/${id}/xml`);
|
|
113
|
+
}
|
|
114
|
+
async downloadPdf(id) {
|
|
115
|
+
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
116
|
+
}
|
|
117
|
+
async void(id, reason) {
|
|
118
|
+
return this.request("POST", `/developer/receipts/${id}/void`, { reason });
|
|
119
|
+
}
|
|
120
|
+
async updateSequential(branchCode, emissionCode, creditNoteSequential) {
|
|
121
|
+
return this.request(
|
|
122
|
+
"PATCH",
|
|
123
|
+
"/developer/credit-notes/sequential",
|
|
124
|
+
{ branchCode, emissionCode, creditNoteSequential }
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
83
129
|
// src/resources/customers.ts
|
|
84
130
|
var CustomersResource = class {
|
|
85
131
|
constructor(request) {
|
|
@@ -102,11 +148,65 @@ var CustomersResource = class {
|
|
|
102
148
|
}
|
|
103
149
|
};
|
|
104
150
|
|
|
151
|
+
// src/resources/debit-notes.ts
|
|
152
|
+
var DebitNotesResource = class {
|
|
153
|
+
constructor(request) {
|
|
154
|
+
this.request = request;
|
|
155
|
+
}
|
|
156
|
+
async list(params) {
|
|
157
|
+
const query = new URLSearchParams();
|
|
158
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
159
|
+
if (params?.status) query.set("status", params.status);
|
|
160
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
161
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
162
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
163
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
164
|
+
const qs = query.toString();
|
|
165
|
+
return this.request("GET", `/developer/debit-notes${qs ? `?${qs}` : ""}`);
|
|
166
|
+
}
|
|
167
|
+
async create(input) {
|
|
168
|
+
return this.request("POST", "/developer/debit-notes", input);
|
|
169
|
+
}
|
|
170
|
+
async get(id) {
|
|
171
|
+
return this.request("GET", `/developer/receipts/${id}`);
|
|
172
|
+
}
|
|
173
|
+
async getStatus(id) {
|
|
174
|
+
return this.request("GET", `/developer/receipts/${id}/status`);
|
|
175
|
+
}
|
|
176
|
+
async downloadXml(id) {
|
|
177
|
+
return this.request("GET", `/developer/receipts/${id}/xml`);
|
|
178
|
+
}
|
|
179
|
+
async downloadPdf(id) {
|
|
180
|
+
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
181
|
+
}
|
|
182
|
+
async void(id, reason) {
|
|
183
|
+
return this.request("POST", `/developer/receipts/${id}/void`, { reason });
|
|
184
|
+
}
|
|
185
|
+
async updateSequential(branchCode, emissionCode, debitNoteSequential) {
|
|
186
|
+
return this.request(
|
|
187
|
+
"PATCH",
|
|
188
|
+
"/developer/debit-notes/sequential",
|
|
189
|
+
{ branchCode, emissionCode, debitNoteSequential }
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
105
194
|
// src/resources/invoices.ts
|
|
106
195
|
var InvoicesResource = class {
|
|
107
196
|
constructor(request) {
|
|
108
197
|
this.request = request;
|
|
109
198
|
}
|
|
199
|
+
async list(params) {
|
|
200
|
+
const query = new URLSearchParams();
|
|
201
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
202
|
+
if (params?.status) query.set("status", params.status);
|
|
203
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
204
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
205
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
206
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
207
|
+
const qs = query.toString();
|
|
208
|
+
return this.request("GET", `/developer/invoices${qs ? `?${qs}` : ""}`);
|
|
209
|
+
}
|
|
110
210
|
async create(input) {
|
|
111
211
|
return this.request("POST", "/developer/invoices", input);
|
|
112
212
|
}
|
|
@@ -204,6 +304,42 @@ var WebhooksResource = class {
|
|
|
204
304
|
}
|
|
205
305
|
};
|
|
206
306
|
|
|
307
|
+
// src/resources/withholdings.ts
|
|
308
|
+
var WithholdingsResource = class {
|
|
309
|
+
constructor(request) {
|
|
310
|
+
this.request = request;
|
|
311
|
+
}
|
|
312
|
+
async create(input) {
|
|
313
|
+
return this.request("POST", "/developer/withholdings", input);
|
|
314
|
+
}
|
|
315
|
+
async list(params) {
|
|
316
|
+
const query = new URLSearchParams();
|
|
317
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
318
|
+
if (params?.status) query.set("status", params.status);
|
|
319
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
320
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
321
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
322
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
323
|
+
const qs = query.toString();
|
|
324
|
+
return this.request("GET", `/developer/withholdings${qs ? `?${qs}` : ""}`);
|
|
325
|
+
}
|
|
326
|
+
async get(id) {
|
|
327
|
+
return this.request("GET", `/developer/receipts/${id}`);
|
|
328
|
+
}
|
|
329
|
+
async getStatus(id) {
|
|
330
|
+
return this.request("GET", `/developer/receipts/${id}/status`);
|
|
331
|
+
}
|
|
332
|
+
async downloadXml(id) {
|
|
333
|
+
return this.request("GET", `/developer/receipts/${id}/xml`);
|
|
334
|
+
}
|
|
335
|
+
async downloadPdf(id) {
|
|
336
|
+
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
337
|
+
}
|
|
338
|
+
async void(id, reason) {
|
|
339
|
+
return this.request("POST", `/developer/receipts/${id}/void`, { reason });
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
207
343
|
// src/client.ts
|
|
208
344
|
var DEFAULT_BASE_URL = "https://api-rest.factuplan.com.ec/v1";
|
|
209
345
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -216,10 +352,13 @@ var Factuplan = class {
|
|
|
216
352
|
this.timeout = options?.timeout ?? DEFAULT_TIMEOUT;
|
|
217
353
|
const requester = this.request.bind(this);
|
|
218
354
|
this.certificates = new CertificatesResource(requester);
|
|
355
|
+
this.creditNotes = new CreditNotesResource(requester);
|
|
356
|
+
this.debitNotes = new DebitNotesResource(requester);
|
|
219
357
|
this.customers = new CustomersResource(requester);
|
|
220
358
|
this.products = new ProductsResource(requester);
|
|
221
359
|
this.invoices = new InvoicesResource(requester);
|
|
222
360
|
this.webhooks = new WebhooksResource(requester);
|
|
361
|
+
this.withholdings = new WithholdingsResource(requester);
|
|
223
362
|
}
|
|
224
363
|
async usage() {
|
|
225
364
|
return this.request("GET", "/developer/usage");
|
|
@@ -289,7 +428,10 @@ Factuplan.webhooks = WebhooksResource;
|
|
|
289
428
|
0 && (module.exports = {
|
|
290
429
|
AuthenticationError,
|
|
291
430
|
CertificatesResource,
|
|
431
|
+
CreditNotesResource,
|
|
432
|
+
DebitNotesResource,
|
|
292
433
|
Factuplan,
|
|
293
434
|
FactuplanError,
|
|
294
|
-
RateLimitError
|
|
435
|
+
RateLimitError,
|
|
436
|
+
WithholdingsResource
|
|
295
437
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -50,6 +50,49 @@ var CertificatesResource = class {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
// src/resources/credit-notes.ts
|
|
54
|
+
var CreditNotesResource = class {
|
|
55
|
+
constructor(request) {
|
|
56
|
+
this.request = request;
|
|
57
|
+
}
|
|
58
|
+
async list(params) {
|
|
59
|
+
const query = new URLSearchParams();
|
|
60
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
61
|
+
if (params?.status) query.set("status", params.status);
|
|
62
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
63
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
64
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
65
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
66
|
+
const qs = query.toString();
|
|
67
|
+
return this.request("GET", `/developer/credit-notes${qs ? `?${qs}` : ""}`);
|
|
68
|
+
}
|
|
69
|
+
async create(input) {
|
|
70
|
+
return this.request("POST", "/developer/credit-notes", input);
|
|
71
|
+
}
|
|
72
|
+
async get(id) {
|
|
73
|
+
return this.request("GET", `/developer/receipts/${id}`);
|
|
74
|
+
}
|
|
75
|
+
async getStatus(id) {
|
|
76
|
+
return this.request("GET", `/developer/receipts/${id}/status`);
|
|
77
|
+
}
|
|
78
|
+
async downloadXml(id) {
|
|
79
|
+
return this.request("GET", `/developer/receipts/${id}/xml`);
|
|
80
|
+
}
|
|
81
|
+
async downloadPdf(id) {
|
|
82
|
+
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
83
|
+
}
|
|
84
|
+
async void(id, reason) {
|
|
85
|
+
return this.request("POST", `/developer/receipts/${id}/void`, { reason });
|
|
86
|
+
}
|
|
87
|
+
async updateSequential(branchCode, emissionCode, creditNoteSequential) {
|
|
88
|
+
return this.request(
|
|
89
|
+
"PATCH",
|
|
90
|
+
"/developer/credit-notes/sequential",
|
|
91
|
+
{ branchCode, emissionCode, creditNoteSequential }
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
53
96
|
// src/resources/customers.ts
|
|
54
97
|
var CustomersResource = class {
|
|
55
98
|
constructor(request) {
|
|
@@ -72,11 +115,65 @@ var CustomersResource = class {
|
|
|
72
115
|
}
|
|
73
116
|
};
|
|
74
117
|
|
|
118
|
+
// src/resources/debit-notes.ts
|
|
119
|
+
var DebitNotesResource = class {
|
|
120
|
+
constructor(request) {
|
|
121
|
+
this.request = request;
|
|
122
|
+
}
|
|
123
|
+
async list(params) {
|
|
124
|
+
const query = new URLSearchParams();
|
|
125
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
126
|
+
if (params?.status) query.set("status", params.status);
|
|
127
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
128
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
129
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
130
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
131
|
+
const qs = query.toString();
|
|
132
|
+
return this.request("GET", `/developer/debit-notes${qs ? `?${qs}` : ""}`);
|
|
133
|
+
}
|
|
134
|
+
async create(input) {
|
|
135
|
+
return this.request("POST", "/developer/debit-notes", input);
|
|
136
|
+
}
|
|
137
|
+
async get(id) {
|
|
138
|
+
return this.request("GET", `/developer/receipts/${id}`);
|
|
139
|
+
}
|
|
140
|
+
async getStatus(id) {
|
|
141
|
+
return this.request("GET", `/developer/receipts/${id}/status`);
|
|
142
|
+
}
|
|
143
|
+
async downloadXml(id) {
|
|
144
|
+
return this.request("GET", `/developer/receipts/${id}/xml`);
|
|
145
|
+
}
|
|
146
|
+
async downloadPdf(id) {
|
|
147
|
+
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
148
|
+
}
|
|
149
|
+
async void(id, reason) {
|
|
150
|
+
return this.request("POST", `/developer/receipts/${id}/void`, { reason });
|
|
151
|
+
}
|
|
152
|
+
async updateSequential(branchCode, emissionCode, debitNoteSequential) {
|
|
153
|
+
return this.request(
|
|
154
|
+
"PATCH",
|
|
155
|
+
"/developer/debit-notes/sequential",
|
|
156
|
+
{ branchCode, emissionCode, debitNoteSequential }
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
75
161
|
// src/resources/invoices.ts
|
|
76
162
|
var InvoicesResource = class {
|
|
77
163
|
constructor(request) {
|
|
78
164
|
this.request = request;
|
|
79
165
|
}
|
|
166
|
+
async list(params) {
|
|
167
|
+
const query = new URLSearchParams();
|
|
168
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
169
|
+
if (params?.status) query.set("status", params.status);
|
|
170
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
171
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
172
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
173
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
174
|
+
const qs = query.toString();
|
|
175
|
+
return this.request("GET", `/developer/invoices${qs ? `?${qs}` : ""}`);
|
|
176
|
+
}
|
|
80
177
|
async create(input) {
|
|
81
178
|
return this.request("POST", "/developer/invoices", input);
|
|
82
179
|
}
|
|
@@ -174,6 +271,42 @@ var WebhooksResource = class {
|
|
|
174
271
|
}
|
|
175
272
|
};
|
|
176
273
|
|
|
274
|
+
// src/resources/withholdings.ts
|
|
275
|
+
var WithholdingsResource = class {
|
|
276
|
+
constructor(request) {
|
|
277
|
+
this.request = request;
|
|
278
|
+
}
|
|
279
|
+
async create(input) {
|
|
280
|
+
return this.request("POST", "/developer/withholdings", input);
|
|
281
|
+
}
|
|
282
|
+
async list(params) {
|
|
283
|
+
const query = new URLSearchParams();
|
|
284
|
+
if (params?.ruc) query.set("ruc", params.ruc);
|
|
285
|
+
if (params?.status) query.set("status", params.status);
|
|
286
|
+
if (params?.dateFrom) query.set("dateFrom", params.dateFrom);
|
|
287
|
+
if (params?.dateTo) query.set("dateTo", params.dateTo);
|
|
288
|
+
if (params?.page != null) query.set("page", String(params.page));
|
|
289
|
+
if (params?.limit != null) query.set("limit", String(params.limit));
|
|
290
|
+
const qs = query.toString();
|
|
291
|
+
return this.request("GET", `/developer/withholdings${qs ? `?${qs}` : ""}`);
|
|
292
|
+
}
|
|
293
|
+
async get(id) {
|
|
294
|
+
return this.request("GET", `/developer/receipts/${id}`);
|
|
295
|
+
}
|
|
296
|
+
async getStatus(id) {
|
|
297
|
+
return this.request("GET", `/developer/receipts/${id}/status`);
|
|
298
|
+
}
|
|
299
|
+
async downloadXml(id) {
|
|
300
|
+
return this.request("GET", `/developer/receipts/${id}/xml`);
|
|
301
|
+
}
|
|
302
|
+
async downloadPdf(id) {
|
|
303
|
+
return this.request("GET", `/developer/receipts/${id}/pdf`);
|
|
304
|
+
}
|
|
305
|
+
async void(id, reason) {
|
|
306
|
+
return this.request("POST", `/developer/receipts/${id}/void`, { reason });
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
177
310
|
// src/client.ts
|
|
178
311
|
var DEFAULT_BASE_URL = "https://api-rest.factuplan.com.ec/v1";
|
|
179
312
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -186,10 +319,13 @@ var Factuplan = class {
|
|
|
186
319
|
this.timeout = options?.timeout ?? DEFAULT_TIMEOUT;
|
|
187
320
|
const requester = this.request.bind(this);
|
|
188
321
|
this.certificates = new CertificatesResource(requester);
|
|
322
|
+
this.creditNotes = new CreditNotesResource(requester);
|
|
323
|
+
this.debitNotes = new DebitNotesResource(requester);
|
|
189
324
|
this.customers = new CustomersResource(requester);
|
|
190
325
|
this.products = new ProductsResource(requester);
|
|
191
326
|
this.invoices = new InvoicesResource(requester);
|
|
192
327
|
this.webhooks = new WebhooksResource(requester);
|
|
328
|
+
this.withholdings = new WithholdingsResource(requester);
|
|
193
329
|
}
|
|
194
330
|
async usage() {
|
|
195
331
|
return this.request("GET", "/developer/usage");
|
|
@@ -258,7 +394,10 @@ Factuplan.webhooks = WebhooksResource;
|
|
|
258
394
|
export {
|
|
259
395
|
AuthenticationError,
|
|
260
396
|
CertificatesResource,
|
|
397
|
+
CreditNotesResource,
|
|
398
|
+
DebitNotesResource,
|
|
261
399
|
Factuplan,
|
|
262
400
|
FactuplanError,
|
|
263
|
-
RateLimitError
|
|
401
|
+
RateLimitError,
|
|
402
|
+
WithholdingsResource
|
|
264
403
|
};
|
package/package.json
CHANGED