@scell/sdk 1.2.0 → 1.5.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 +0 -0
- package/README.md +61 -2
- package/dist/index.d.mts +2353 -236
- package/dist/index.d.ts +2353 -236
- package/dist/index.js +1308 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1308 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +3 -1
- package/src/errors.ts +0 -0
- package/src/index.ts +42 -2
- package/src/resources/api-keys.ts +0 -0
- package/src/resources/auth.ts +0 -0
- package/src/resources/balance.ts +0 -0
- package/src/resources/billing.ts +49 -0
- package/src/resources/companies.ts +0 -0
- package/src/resources/fiscal.ts +128 -0
- package/src/resources/invoices.ts +0 -0
- package/src/resources/signatures.ts +33 -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/resources/webhooks.ts +0 -0
- package/src/tenant-client.ts +105 -0
- package/src/types/api-keys.ts +0 -0
- package/src/types/auth.ts +0 -0
- package/src/types/balance.ts +0 -0
- package/src/types/billing.ts +73 -0
- package/src/types/common.ts +0 -0
- package/src/types/companies.ts +0 -0
- package/src/types/fiscal.ts +251 -0
- package/src/types/index.ts +103 -0
- package/src/types/invoices.ts +0 -0
- package/src/types/signatures.ts +0 -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 +0 -0
- package/src/utils/retry.ts +0 -0
- package/src/utils/webhook-verify.ts +0 -0
package/LICENSE
CHANGED
|
File without changes
|
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
|
|
@@ -336,6 +337,58 @@ const { signers_reminded } = await apiClient.signatures.remind(signatureId);
|
|
|
336
337
|
await apiClient.signatures.cancel(signatureId);
|
|
337
338
|
```
|
|
338
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
|
+
|
|
339
392
|
### Balance
|
|
340
393
|
|
|
341
394
|
```typescript
|
|
@@ -503,6 +556,12 @@ import type {
|
|
|
503
556
|
SignatureStatus,
|
|
504
557
|
CreateSignatureInput,
|
|
505
558
|
Signer,
|
|
559
|
+
// Tenant Credit Notes
|
|
560
|
+
TenantCreditNote,
|
|
561
|
+
TenantCreditNoteStatus,
|
|
562
|
+
TenantCreditNoteType,
|
|
563
|
+
CreateTenantCreditNoteInput,
|
|
564
|
+
RemainingCreditable,
|
|
506
565
|
// Webhooks
|
|
507
566
|
Webhook,
|
|
508
567
|
WebhookEvent,
|