@scell/sdk 1.2.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 CHANGED
@@ -202,8 +202,9 @@ const apiClient = new ScellApiClient(apiKey, {
202
202
  });
203
203
 
204
204
  // Resources
205
- apiClient.invoices // Create, download, convert invoices
206
- apiClient.signatures // Create, download, remind, cancel 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,