@scell/sdk 1.0.0 → 1.4.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/README.md +134 -5
- package/dist/index.d.mts +2502 -170
- package/dist/index.d.ts +2502 -170
- package/dist/index.js +1497 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1497 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +79 -1
- package/src/index.ts +17 -1
- package/src/resources/billing.ts +49 -0
- package/src/resources/fiscal.ts +128 -0
- package/src/resources/invoices.ts +217 -0
- package/src/resources/stats.ts +29 -0
- package/src/resources/sub-tenants.ts +41 -0
- package/src/resources/tenant-credit-notes.ts +301 -0
- package/src/resources/tenant-direct-credit-notes.ts +360 -0
- package/src/resources/tenant-direct-invoices.ts +424 -0
- package/src/resources/tenant-incoming-invoices.ts +429 -0
- package/src/tenant-client.ts +105 -0
- package/src/types/billing.ts +73 -0
- package/src/types/fiscal.ts +251 -0
- package/src/types/index.ts +112 -0
- package/src/types/invoices.ts +91 -0
- package/src/types/stats.ts +37 -0
- package/src/types/sub-tenants.ts +57 -0
- package/src/types/tenant-credit-notes.ts +128 -0
- package/src/types/tenant-invoices.ts +390 -0
- package/src/types/tenant-profile.ts +51 -0
- package/src/types/webhooks.ts +30 -1
package/README.md
CHANGED
|
@@ -202,8 +202,9 @@ const apiClient = new ScellApiClient(apiKey, {
|
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
// Resources
|
|
205
|
-
apiClient.invoices
|
|
206
|
-
apiClient.signatures
|
|
205
|
+
apiClient.invoices // Create, download, convert invoices
|
|
206
|
+
apiClient.signatures // Create, download, remind, cancel signatures
|
|
207
|
+
apiClient.tenantCreditNotes // Create, send, download tenant credit notes
|
|
207
208
|
```
|
|
208
209
|
|
|
209
210
|
### Companies
|
|
@@ -259,6 +260,57 @@ const { data: trail, integrity_valid } = await apiClient.invoices.auditTrail(inv
|
|
|
259
260
|
await apiClient.invoices.convert({ invoice_id: invoiceId, target_format: 'ubl' });
|
|
260
261
|
```
|
|
261
262
|
|
|
263
|
+
### Incoming Invoices (Supplier Invoices)
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
// List incoming invoices
|
|
267
|
+
const { data: incoming, meta } = await apiClient.invoices.incoming({
|
|
268
|
+
status: 'pending',
|
|
269
|
+
seller_siret: '12345678901234',
|
|
270
|
+
from: '2024-01-01',
|
|
271
|
+
min_amount: 100,
|
|
272
|
+
per_page: 50,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
console.log(`Found ${meta.total} incoming invoices`);
|
|
276
|
+
|
|
277
|
+
// Accept an incoming invoice
|
|
278
|
+
const { data: accepted } = await apiClient.invoices.accept(invoiceId, {
|
|
279
|
+
payment_date: '2024-02-15',
|
|
280
|
+
note: 'Approved by accounting department',
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// Reject an incoming invoice
|
|
284
|
+
const { data: rejected } = await apiClient.invoices.reject(invoiceId, {
|
|
285
|
+
reason: 'Invoice amount does not match purchase order #PO-2024-001',
|
|
286
|
+
reason_code: 'incorrect_amount',
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Dispute an incoming invoice
|
|
290
|
+
const { data: disputed } = await apiClient.invoices.dispute(invoiceId, {
|
|
291
|
+
reason: 'Billed amount exceeds agreed price by 50 EUR',
|
|
292
|
+
dispute_type: 'amount_dispute',
|
|
293
|
+
expected_amount: 950.00,
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
// Mark an invoice as paid (mandatory in French e-invoicing lifecycle)
|
|
297
|
+
const { data: paidInvoice } = await apiClient.invoices.markPaid(invoiceId, {
|
|
298
|
+
payment_reference: 'VIR-2026-0124',
|
|
299
|
+
paid_at: '2026-01-24T10:30:00Z',
|
|
300
|
+
note: 'Payment received via bank transfer',
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
// Download invoice file as PDF (Factur-X with embedded XML)
|
|
304
|
+
const pdfBuffer = await apiClient.invoices.downloadFile(invoiceId);
|
|
305
|
+
// In Node.js:
|
|
306
|
+
import { writeFileSync } from 'fs';
|
|
307
|
+
writeFileSync('invoice.pdf', Buffer.from(pdfBuffer));
|
|
308
|
+
|
|
309
|
+
// Download XML version (UBL/CII standalone)
|
|
310
|
+
const xmlBuffer = await apiClient.invoices.downloadFile(invoiceId, 'xml');
|
|
311
|
+
writeFileSync('invoice.xml', Buffer.from(xmlBuffer));
|
|
312
|
+
```
|
|
313
|
+
|
|
262
314
|
### Signatures
|
|
263
315
|
|
|
264
316
|
```typescript
|
|
@@ -285,6 +337,58 @@ const { signers_reminded } = await apiClient.signatures.remind(signatureId);
|
|
|
285
337
|
await apiClient.signatures.cancel(signatureId);
|
|
286
338
|
```
|
|
287
339
|
|
|
340
|
+
### Tenant Credit Notes
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
// List credit notes for a sub-tenant
|
|
344
|
+
const { data, meta } = await apiClient.tenantCreditNotes.list('sub-tenant-uuid', {
|
|
345
|
+
status: 'sent',
|
|
346
|
+
date_from: '2024-01-01',
|
|
347
|
+
per_page: 50,
|
|
348
|
+
});
|
|
349
|
+
console.log(`Found ${meta.total} credit notes`);
|
|
350
|
+
|
|
351
|
+
// Check remaining creditable amount for an invoice
|
|
352
|
+
const remaining = await apiClient.tenantCreditNotes.remainingCreditable('invoice-uuid');
|
|
353
|
+
console.log('Remaining to credit:', remaining.remaining_total);
|
|
354
|
+
remaining.lines.forEach(line => {
|
|
355
|
+
console.log(`${line.description}: ${line.remaining_quantity} items remaining`);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
// Create a partial credit note
|
|
359
|
+
const { data: creditNote } = await apiClient.tenantCreditNotes.create('sub-tenant-uuid', {
|
|
360
|
+
invoice_id: 'invoice-uuid',
|
|
361
|
+
reason: 'Product returned - damaged item',
|
|
362
|
+
type: 'partial',
|
|
363
|
+
items: [
|
|
364
|
+
{ invoice_line_id: 'line-uuid-1', quantity: 2 }
|
|
365
|
+
]
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Create a total credit note
|
|
369
|
+
const { data: totalCreditNote } = await apiClient.tenantCreditNotes.create('sub-tenant-uuid', {
|
|
370
|
+
invoice_id: 'invoice-uuid',
|
|
371
|
+
reason: 'Order cancelled',
|
|
372
|
+
type: 'total'
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
// Get credit note details
|
|
376
|
+
const { data: details } = await apiClient.tenantCreditNotes.get('credit-note-uuid');
|
|
377
|
+
console.log('Credit note number:', details.credit_note_number);
|
|
378
|
+
|
|
379
|
+
// Send a credit note (changes status from draft to sent)
|
|
380
|
+
const { data: sent } = await apiClient.tenantCreditNotes.send('credit-note-uuid');
|
|
381
|
+
|
|
382
|
+
// Download credit note as PDF
|
|
383
|
+
const pdfBuffer = await apiClient.tenantCreditNotes.download('credit-note-uuid');
|
|
384
|
+
// In Node.js:
|
|
385
|
+
import { writeFileSync } from 'fs';
|
|
386
|
+
writeFileSync('credit-note.pdf', Buffer.from(pdfBuffer));
|
|
387
|
+
|
|
388
|
+
// Delete a draft credit note
|
|
389
|
+
await apiClient.tenantCreditNotes.delete('credit-note-uuid');
|
|
390
|
+
```
|
|
391
|
+
|
|
288
392
|
### Balance
|
|
289
393
|
|
|
290
394
|
```typescript
|
|
@@ -412,6 +516,12 @@ const result = await withRetry(
|
|
|
412
516
|
| `invoice.accepted` | Invoice accepted |
|
|
413
517
|
| `invoice.rejected` | Invoice rejected |
|
|
414
518
|
| `invoice.error` | Invoice processing error |
|
|
519
|
+
| `invoice.incoming.received` | Incoming invoice received from supplier |
|
|
520
|
+
| `invoice.incoming.validated` | Incoming invoice validated |
|
|
521
|
+
| `invoice.incoming.accepted` | Incoming invoice accepted |
|
|
522
|
+
| `invoice.incoming.rejected` | Incoming invoice rejected |
|
|
523
|
+
| `invoice.incoming.disputed` | Incoming invoice disputed |
|
|
524
|
+
| `invoice.incoming.paid` | Incoming invoice marked as paid |
|
|
415
525
|
| `signature.created` | Signature request created |
|
|
416
526
|
| `signature.waiting` | Waiting for signers |
|
|
417
527
|
| `signature.signed` | A signer has signed |
|
|
@@ -431,17 +541,36 @@ import type {
|
|
|
431
541
|
Invoice,
|
|
432
542
|
InvoiceStatus,
|
|
433
543
|
InvoiceDirection,
|
|
544
|
+
InvoiceFileFormat,
|
|
434
545
|
CreateInvoiceInput,
|
|
546
|
+
// Incoming invoices
|
|
547
|
+
IncomingInvoiceParams,
|
|
548
|
+
AcceptInvoiceInput,
|
|
549
|
+
RejectInvoiceInput,
|
|
550
|
+
DisputeInvoiceInput,
|
|
551
|
+
MarkPaidInput,
|
|
552
|
+
RejectionCode,
|
|
553
|
+
DisputeType,
|
|
554
|
+
// Signatures
|
|
435
555
|
Signature,
|
|
436
556
|
SignatureStatus,
|
|
437
557
|
CreateSignatureInput,
|
|
438
558
|
Signer,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
559
|
+
// Tenant Credit Notes
|
|
560
|
+
TenantCreditNote,
|
|
561
|
+
TenantCreditNoteStatus,
|
|
562
|
+
TenantCreditNoteType,
|
|
563
|
+
CreateTenantCreditNoteInput,
|
|
564
|
+
RemainingCreditable,
|
|
565
|
+
// Webhooks
|
|
442
566
|
Webhook,
|
|
443
567
|
WebhookEvent,
|
|
444
568
|
WebhookPayload,
|
|
569
|
+
InvoiceIncomingPaidPayload,
|
|
570
|
+
// Other
|
|
571
|
+
Company,
|
|
572
|
+
Balance,
|
|
573
|
+
Transaction,
|
|
445
574
|
} from '@scell/sdk';
|
|
446
575
|
```
|
|
447
576
|
|