@billkit-eu/sdk 0.3.0 → 0.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/CHANGELOG.md CHANGED
@@ -8,6 +8,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  Versioning is independent of the Python SDK; the two ship on their own cadence,
9
9
  so the numbers will diverge after this first release.
10
10
 
11
+ ## [0.4.0]
12
+
13
+ ### Added
14
+ - **`creditNotes`** — `retrieve`, `list`, `iter` and `retrievePdf`. A credit
15
+ note is the document that reverses an issued invoice; one is created for you
16
+ when a refund settles, so there is no `create` here. `list` takes
17
+ `invoice_id` to answer "was this sale credited, and by how much".
18
+ - **`invoices.void(id)`** — records that an invoice was never owed. It keeps
19
+ its number and stays readable; it just stops being a receivable.
20
+
21
+ A **paid** invoice is refused with a `ConflictError` whose `code` is
22
+ `"invoice_not_voidable"`. Once the money has moved, "never owed" is not
23
+ true — refund the payment instead, and a credit note is issued when the
24
+ refund settles. Voiding twice is a no-op.
25
+
11
26
  ## [0.3.0]
12
27
 
13
28
  ### Added
package/dist/index.cjs CHANGED
@@ -620,6 +620,46 @@ var Invoices = class extends BaseResource {
620
620
  iter(options = {}) {
621
621
  return paginate((p) => this.get("/v1/invoices", p), { pageSize: options.pageSize });
622
622
  }
623
+ /**
624
+ * Void an invoice: state that the sale was never owed.
625
+ *
626
+ * The invoice keeps its number and stays readable — a gapless series
627
+ * cannot lose a row — and stops being a receivable. Use it for an
628
+ * invoice that should not have been issued.
629
+ *
630
+ * A **paid** invoice is refused with a `ConflictError` whose `code` is
631
+ * `"invoice_not_voidable"`. That is deliberate rather than a
632
+ * limitation: once the money has moved, "never owed" is false, and the
633
+ * document that reverses a real sale is a credit note — refund the
634
+ * payment and one is issued when the refund settles.
635
+ *
636
+ * Idempotent: re-voiding an already-void invoice returns it unchanged.
637
+ */
638
+ void(id, params = {}) {
639
+ return this.post(`/v1/invoices/${id}/void`, params);
640
+ }
641
+ };
642
+ var CreditNotes = class extends BaseResource {
643
+ retrieve(id) {
644
+ return this.get(`/v1/credit_notes/${id}`);
645
+ }
646
+ /**
647
+ * Download the rendered credit note PDF as raw bytes. Same storage
648
+ * split as {@link Invoices.retrievePdf}: bytes inline or a followed
649
+ * `302`, and `501 rendering_pending` on a deployment with no renderer.
650
+ */
651
+ retrievePdf(id) {
652
+ return this.t.requestBinary({ method: "GET", path: `/v1/credit_notes/${id}/pdf` });
653
+ }
654
+ list(params = {}) {
655
+ return this.get("/v1/credit_notes", params);
656
+ }
657
+ iter(options = {}) {
658
+ return paginate((p) => this.get("/v1/credit_notes", p), {
659
+ pageSize: options.pageSize,
660
+ filters: { invoice_id: options.invoice_id, customer_id: options.customer_id }
661
+ });
662
+ }
623
663
  };
624
664
  var AuditLogs = class extends BaseResource {
625
665
  retrieve(id) {
@@ -797,7 +837,7 @@ function sleep(ms) {
797
837
  }
798
838
 
799
839
  // src/version.ts
800
- var VERSION = "0.3.0";
840
+ var VERSION = "0.4.0";
801
841
 
802
842
  // src/transport.ts
803
843
  var DEFAULT_BASE_URL = "https://api.billkit.eu";
@@ -1031,6 +1071,7 @@ var BillKit = class {
1031
1071
  coupons;
1032
1072
  taxRates;
1033
1073
  invoices;
1074
+ creditNotes;
1034
1075
  auditLogs;
1035
1076
  payments;
1036
1077
  billingPortalSessions;
@@ -1053,6 +1094,7 @@ var BillKit = class {
1053
1094
  this.coupons = new Coupons(transport);
1054
1095
  this.taxRates = new TaxRates(transport);
1055
1096
  this.invoices = new Invoices(transport);
1097
+ this.creditNotes = new CreditNotes(transport);
1056
1098
  this.auditLogs = new AuditLogs(transport);
1057
1099
  this.payments = new Payments(transport);
1058
1100
  this.billingPortalSessions = new BillingPortalSessions(transport);