orb-billing 5.38.0 → 5.41.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/LICENSE +1 -1
  3. package/README.md +4 -1
  4. package/index.d.mts +7 -4
  5. package/index.d.ts +7 -4
  6. package/index.d.ts.map +1 -1
  7. package/index.js +5 -0
  8. package/index.js.map +1 -1
  9. package/index.mjs +7 -2
  10. package/index.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/credit-blocks.d.ts +59 -0
  13. package/resources/credit-blocks.d.ts.map +1 -0
  14. package/resources/credit-blocks.js +38 -0
  15. package/resources/credit-blocks.js.map +1 -0
  16. package/resources/credit-blocks.mjs +34 -0
  17. package/resources/credit-blocks.mjs.map +1 -0
  18. package/resources/events/events.d.ts +1 -1
  19. package/resources/index.d.ts +3 -2
  20. package/resources/index.d.ts.map +1 -1
  21. package/resources/index.js +5 -1
  22. package/resources/index.js.map +1 -1
  23. package/resources/index.mjs +3 -2
  24. package/resources/index.mjs.map +1 -1
  25. package/resources/invoices.d.ts +439 -2
  26. package/resources/invoices.d.ts.map +1 -1
  27. package/resources/invoices.js +28 -1
  28. package/resources/invoices.js.map +1 -1
  29. package/resources/invoices.mjs +26 -0
  30. package/resources/invoices.mjs.map +1 -1
  31. package/resources/plans/index.d.ts +1 -0
  32. package/resources/plans/index.d.ts.map +1 -1
  33. package/resources/plans/index.js +4 -1
  34. package/resources/plans/index.js.map +1 -1
  35. package/resources/plans/index.mjs +1 -0
  36. package/resources/plans/index.mjs.map +1 -1
  37. package/resources/plans/migrations.d.ts +47 -0
  38. package/resources/plans/migrations.d.ts.map +1 -0
  39. package/resources/plans/migrations.js +36 -0
  40. package/resources/plans/migrations.js.map +1 -0
  41. package/resources/plans/migrations.mjs +31 -0
  42. package/resources/plans/migrations.mjs.map +1 -0
  43. package/resources/plans/plans.d.ts +4 -0
  44. package/resources/plans/plans.d.ts.map +1 -1
  45. package/resources/plans/plans.js +5 -0
  46. package/resources/plans/plans.js.map +1 -1
  47. package/resources/plans/plans.mjs +5 -0
  48. package/resources/plans/plans.mjs.map +1 -1
  49. package/resources/prices/prices.d.ts +6 -96
  50. package/resources/prices/prices.d.ts.map +1 -1
  51. package/resources/prices/prices.js.map +1 -1
  52. package/resources/prices/prices.mjs.map +1 -1
  53. package/resources/shared.d.ts +18 -288
  54. package/resources/shared.d.ts.map +1 -1
  55. package/resources/shared.js.map +1 -1
  56. package/resources/shared.mjs.map +1 -1
  57. package/resources/subscription-changes.d.ts +33 -1
  58. package/resources/subscription-changes.d.ts.map +1 -1
  59. package/resources/subscription-changes.js +15 -1
  60. package/resources/subscription-changes.js.map +1 -1
  61. package/resources/subscription-changes.mjs +13 -0
  62. package/resources/subscription-changes.mjs.map +1 -1
  63. package/resources/subscriptions.d.ts +6 -96
  64. package/resources/subscriptions.d.ts.map +1 -1
  65. package/resources/subscriptions.js.map +1 -1
  66. package/resources/subscriptions.mjs.map +1 -1
  67. package/src/index.ts +19 -0
  68. package/src/resources/credit-blocks.ts +81 -0
  69. package/src/resources/events/events.ts +1 -1
  70. package/src/resources/index.ts +7 -0
  71. package/src/resources/invoices.ts +602 -46
  72. package/src/resources/plans/index.ts +8 -0
  73. package/src/resources/plans/migrations.ts +105 -0
  74. package/src/resources/plans/plans.ts +21 -0
  75. package/src/resources/prices/prices.ts +6 -96
  76. package/src/resources/shared.ts +18 -288
  77. package/src/resources/subscription-changes.ts +64 -0
  78. package/src/resources/subscriptions.ts +6 -96
  79. package/src/version.ts +1 -1
  80. package/version.d.ts +1 -1
  81. package/version.js +1 -1
  82. package/version.mjs +1 -1
@@ -5,7 +5,7 @@ import { isRequestOptions } from '../core';
5
5
  import * as Core from '../core';
6
6
  import * as Shared from './shared';
7
7
  import { InvoicesPage } from './shared';
8
- import { type PageParams } from '../pagination';
8
+ import { Page, type PageParams } from '../pagination';
9
9
 
10
10
  export class Invoices extends APIResource {
11
11
  /**
@@ -62,6 +62,24 @@ export class Invoices extends APIResource {
62
62
  return this._client.getAPIList('/invoices', InvoicesPage, { query, ...options });
63
63
  }
64
64
 
65
+ /**
66
+ * This endpoint deletes an invoice line item from a draft invoice.
67
+ *
68
+ * This endpoint only allows deletion of one-off line items (not subscription-based
69
+ * line items). The invoice must be in a draft status for this operation to
70
+ * succeed.
71
+ */
72
+ deleteLineItem(
73
+ invoiceId: string,
74
+ lineItemId: string,
75
+ options?: Core.RequestOptions,
76
+ ): Core.APIPromise<void> {
77
+ return this._client.delete(`/invoices/${invoiceId}/invoice_line_items/${lineItemId}`, {
78
+ ...options,
79
+ headers: { Accept: '*/*', ...options?.headers },
80
+ });
81
+ }
82
+
65
83
  /**
66
84
  * This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an
67
85
  * identifier.
@@ -107,6 +125,44 @@ export class Invoices extends APIResource {
107
125
  return this._client.post(`/invoices/${invoiceId}/issue`, { body, ...options });
108
126
  }
109
127
 
128
+ /**
129
+ * This is a lighter-weight endpoint that returns a list of all
130
+ * [`Invoice`](/core-concepts#invoice) summaries for an account in a list format.
131
+ *
132
+ * These invoice summaries do not include line item details, minimums, maximums,
133
+ * and discounts, making this endpoint more efficient.
134
+ *
135
+ * The list of invoices is ordered starting from the most recently issued invoice
136
+ * date. The response also includes
137
+ * [`pagination_metadata`](/api-reference/pagination), which lets the caller
138
+ * retrieve the next page of results if they exist.
139
+ *
140
+ * By default, this only returns invoices that are `issued`, `paid`, or `synced`.
141
+ *
142
+ * When fetching any `draft` invoices, this returns the last-computed invoice
143
+ * values for each draft invoice, which may not always be up-to-date since Orb
144
+ * regularly refreshes invoices asynchronously.
145
+ */
146
+ listSummary(
147
+ query?: InvoiceListSummaryParams,
148
+ options?: Core.RequestOptions,
149
+ ): Core.PagePromise<InvoiceListSummaryResponsesPage, InvoiceListSummaryResponse>;
150
+ listSummary(
151
+ options?: Core.RequestOptions,
152
+ ): Core.PagePromise<InvoiceListSummaryResponsesPage, InvoiceListSummaryResponse>;
153
+ listSummary(
154
+ query: InvoiceListSummaryParams | Core.RequestOptions = {},
155
+ options?: Core.RequestOptions,
156
+ ): Core.PagePromise<InvoiceListSummaryResponsesPage, InvoiceListSummaryResponse> {
157
+ if (isRequestOptions(query)) {
158
+ return this.listSummary({}, query);
159
+ }
160
+ return this._client.getAPIList('/invoices/summary', InvoiceListSummaryResponsesPage, {
161
+ query,
162
+ ...options,
163
+ });
164
+ }
165
+
110
166
  /**
111
167
  * This endpoint allows an invoice's status to be set to the `paid` status. This
112
168
  * can only be done to invoices that are in the `issued` or `synced` status.
@@ -145,6 +201,8 @@ export class Invoices extends APIResource {
145
201
  }
146
202
  }
147
203
 
204
+ export class InvoiceListSummaryResponsesPage extends Page<InvoiceListSummaryResponse> {}
205
+
148
206
  export interface InvoiceFetchUpcomingResponse {
149
207
  id: string;
150
208
 
@@ -730,82 +788,533 @@ export namespace InvoiceFetchUpcomingResponse {
730
788
  }
731
789
  }
732
790
 
733
- export interface InvoiceCreateParams {
791
+ /**
792
+ * #InvoiceApiResourceWithoutLineItems
793
+ */
794
+ export interface InvoiceListSummaryResponse {
795
+ id: string;
796
+
734
797
  /**
735
- * An ISO 4217 currency string. Must be the same as the customer's currency if it
736
- * is set.
798
+ * This is the final amount required to be charged to the customer and reflects the
799
+ * application of the customer balance to the `total` of the invoice.
737
800
  */
738
- currency: string;
801
+ amount_due: string;
802
+
803
+ auto_collection: InvoiceListSummaryResponse.AutoCollection;
804
+
805
+ billing_address: Shared.Address | null;
739
806
 
740
807
  /**
741
- * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is
742
- * set to the current time in the customer's timezone.
808
+ * The creation time of the resource in Orb.
743
809
  */
744
- invoice_date: string;
745
-
746
- line_items: Array<InvoiceCreateParams.LineItem>;
810
+ created_at: string;
747
811
 
748
812
  /**
749
- * The id of the `Customer` to create this invoice for. One of `customer_id` and
750
- * `external_customer_id` are required.
813
+ * A list of credit notes associated with the invoice
751
814
  */
752
- customer_id?: string | null;
815
+ credit_notes: Array<InvoiceListSummaryResponse.CreditNote>;
753
816
 
754
817
  /**
755
- * An optional discount to attach to the invoice.
818
+ * An ISO 4217 currency string or `credits`
756
819
  */
757
- discount?: Shared.Discount | null;
820
+ currency: string;
821
+
822
+ customer: Shared.CustomerMinified;
823
+
824
+ customer_balance_transactions: Array<InvoiceListSummaryResponse.CustomerBalanceTransaction>;
758
825
 
759
826
  /**
760
- * An optional custom due date for the invoice. If not set, the due date will be
761
- * calculated based on the `net_terms` value.
827
+ * Tax IDs are commonly required to be displayed on customer invoices, which are
828
+ * added to the headers of invoices.
829
+ *
830
+ * ### Supported Tax ID Countries and Types
831
+ *
832
+ * | Country | Type | Description |
833
+ * | ---------------------- | ------------ | ------------------------------------------------------------------------------------------------------- |
834
+ * | Albania | `al_tin` | Albania Tax Identification Number |
835
+ * | Andorra | `ad_nrt` | Andorran NRT Number |
836
+ * | Angola | `ao_tin` | Angola Tax Identification Number |
837
+ * | Argentina | `ar_cuit` | Argentinian Tax ID Number |
838
+ * | Armenia | `am_tin` | Armenia Tax Identification Number |
839
+ * | Aruba | `aw_tin` | Aruba Tax Identification Number |
840
+ * | Australia | `au_abn` | Australian Business Number (AU ABN) |
841
+ * | Australia | `au_arn` | Australian Taxation Office Reference Number |
842
+ * | Austria | `eu_vat` | European VAT Number |
843
+ * | Azerbaijan | `az_tin` | Azerbaijan Tax Identification Number |
844
+ * | Bahamas | `bs_tin` | Bahamas Tax Identification Number |
845
+ * | Bahrain | `bh_vat` | Bahraini VAT Number |
846
+ * | Bangladesh | `bd_bin` | Bangladesh Business Identification Number |
847
+ * | Barbados | `bb_tin` | Barbados Tax Identification Number |
848
+ * | Belarus | `by_tin` | Belarus TIN Number |
849
+ * | Belgium | `eu_vat` | European VAT Number |
850
+ * | Benin | `bj_ifu` | Benin Tax Identification Number (Identifiant Fiscal Unique) |
851
+ * | Bolivia | `bo_tin` | Bolivian Tax ID |
852
+ * | Bosnia and Herzegovina | `ba_tin` | Bosnia and Herzegovina Tax Identification Number |
853
+ * | Brazil | `br_cnpj` | Brazilian CNPJ Number |
854
+ * | Brazil | `br_cpf` | Brazilian CPF Number |
855
+ * | Bulgaria | `bg_uic` | Bulgaria Unified Identification Code |
856
+ * | Bulgaria | `eu_vat` | European VAT Number |
857
+ * | Burkina Faso | `bf_ifu` | Burkina Faso Tax Identification Number (Numéro d'Identifiant Fiscal Unique) |
858
+ * | Cambodia | `kh_tin` | Cambodia Tax Identification Number |
859
+ * | Cameroon | `cm_niu` | Cameroon Tax Identification Number (Numéro d'Identifiant fiscal Unique) |
860
+ * | Canada | `ca_bn` | Canadian BN |
861
+ * | Canada | `ca_gst_hst` | Canadian GST/HST Number |
862
+ * | Canada | `ca_pst_bc` | Canadian PST Number (British Columbia) |
863
+ * | Canada | `ca_pst_mb` | Canadian PST Number (Manitoba) |
864
+ * | Canada | `ca_pst_sk` | Canadian PST Number (Saskatchewan) |
865
+ * | Canada | `ca_qst` | Canadian QST Number (Québec) |
866
+ * | Cape Verde | `cv_nif` | Cape Verde Tax Identification Number (Número de Identificação Fiscal) |
867
+ * | Chile | `cl_tin` | Chilean TIN |
868
+ * | China | `cn_tin` | Chinese Tax ID |
869
+ * | Colombia | `co_nit` | Colombian NIT Number |
870
+ * | Congo-Kinshasa | `cd_nif` | Congo (DR) Tax Identification Number (Número de Identificação Fiscal) |
871
+ * | Costa Rica | `cr_tin` | Costa Rican Tax ID |
872
+ * | Croatia | `eu_vat` | European VAT Number |
873
+ * | Croatia | `hr_oib` | Croatian Personal Identification Number (OIB) |
874
+ * | Cyprus | `eu_vat` | European VAT Number |
875
+ * | Czech Republic | `eu_vat` | European VAT Number |
876
+ * | Denmark | `eu_vat` | European VAT Number |
877
+ * | Dominican Republic | `do_rcn` | Dominican RCN Number |
878
+ * | Ecuador | `ec_ruc` | Ecuadorian RUC Number |
879
+ * | Egypt | `eg_tin` | Egyptian Tax Identification Number |
880
+ * | El Salvador | `sv_nit` | El Salvadorian NIT Number |
881
+ * | Estonia | `eu_vat` | European VAT Number |
882
+ * | Ethiopia | `et_tin` | Ethiopia Tax Identification Number |
883
+ * | European Union | `eu_oss_vat` | European One Stop Shop VAT Number for non-Union scheme |
884
+ * | Finland | `eu_vat` | European VAT Number |
885
+ * | France | `eu_vat` | European VAT Number |
886
+ * | Georgia | `ge_vat` | Georgian VAT |
887
+ * | Germany | `de_stn` | German Tax Number (Steuernummer) |
888
+ * | Germany | `eu_vat` | European VAT Number |
889
+ * | Greece | `eu_vat` | European VAT Number |
890
+ * | Guinea | `gn_nif` | Guinea Tax Identification Number (Número de Identificação Fiscal) |
891
+ * | Hong Kong | `hk_br` | Hong Kong BR Number |
892
+ * | Hungary | `eu_vat` | European VAT Number |
893
+ * | Hungary | `hu_tin` | Hungary Tax Number (adószám) |
894
+ * | Iceland | `is_vat` | Icelandic VAT |
895
+ * | India | `in_gst` | Indian GST Number |
896
+ * | Indonesia | `id_npwp` | Indonesian NPWP Number |
897
+ * | Ireland | `eu_vat` | European VAT Number |
898
+ * | Israel | `il_vat` | Israel VAT |
899
+ * | Italy | `eu_vat` | European VAT Number |
900
+ * | Japan | `jp_cn` | Japanese Corporate Number (_Hōjin Bangō_) |
901
+ * | Japan | `jp_rn` | Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_) |
902
+ * | Japan | `jp_trn` | Japanese Tax Registration Number (_Tōroku Bangō_) |
903
+ * | Kazakhstan | `kz_bin` | Kazakhstani Business Identification Number |
904
+ * | Kenya | `ke_pin` | Kenya Revenue Authority Personal Identification Number |
905
+ * | Kyrgyzstan | `kg_tin` | Kyrgyzstan Tax Identification Number |
906
+ * | Laos | `la_tin` | Laos Tax Identification Number |
907
+ * | Latvia | `eu_vat` | European VAT Number |
908
+ * | Liechtenstein | `li_uid` | Liechtensteinian UID Number |
909
+ * | Liechtenstein | `li_vat` | Liechtenstein VAT Number |
910
+ * | Lithuania | `eu_vat` | European VAT Number |
911
+ * | Luxembourg | `eu_vat` | European VAT Number |
912
+ * | Malaysia | `my_frp` | Malaysian FRP Number |
913
+ * | Malaysia | `my_itn` | Malaysian ITN |
914
+ * | Malaysia | `my_sst` | Malaysian SST Number |
915
+ * | Malta | `eu_vat` | European VAT Number |
916
+ * | Mauritania | `mr_nif` | Mauritania Tax Identification Number (Número de Identificação Fiscal) |
917
+ * | Mexico | `mx_rfc` | Mexican RFC Number |
918
+ * | Moldova | `md_vat` | Moldova VAT Number |
919
+ * | Montenegro | `me_pib` | Montenegro PIB Number |
920
+ * | Morocco | `ma_vat` | Morocco VAT Number |
921
+ * | Nepal | `np_pan` | Nepal PAN Number |
922
+ * | Netherlands | `eu_vat` | European VAT Number |
923
+ * | New Zealand | `nz_gst` | New Zealand GST Number |
924
+ * | Nigeria | `ng_tin` | Nigerian Tax Identification Number |
925
+ * | North Macedonia | `mk_vat` | North Macedonia VAT Number |
926
+ * | Northern Ireland | `eu_vat` | Northern Ireland VAT Number |
927
+ * | Norway | `no_vat` | Norwegian VAT Number |
928
+ * | Norway | `no_voec` | Norwegian VAT on e-commerce Number |
929
+ * | Oman | `om_vat` | Omani VAT Number |
930
+ * | Peru | `pe_ruc` | Peruvian RUC Number |
931
+ * | Philippines | `ph_tin` | Philippines Tax Identification Number |
932
+ * | Poland | `eu_vat` | European VAT Number |
933
+ * | Portugal | `eu_vat` | European VAT Number |
934
+ * | Romania | `eu_vat` | European VAT Number |
935
+ * | Romania | `ro_tin` | Romanian Tax ID Number |
936
+ * | Russia | `ru_inn` | Russian INN |
937
+ * | Russia | `ru_kpp` | Russian KPP |
938
+ * | Saudi Arabia | `sa_vat` | Saudi Arabia VAT |
939
+ * | Senegal | `sn_ninea` | Senegal NINEA Number |
940
+ * | Serbia | `rs_pib` | Serbian PIB Number |
941
+ * | Singapore | `sg_gst` | Singaporean GST |
942
+ * | Singapore | `sg_uen` | Singaporean UEN |
943
+ * | Slovakia | `eu_vat` | European VAT Number |
944
+ * | Slovenia | `eu_vat` | European VAT Number |
945
+ * | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) |
946
+ * | South Africa | `za_vat` | South African VAT Number |
947
+ * | South Korea | `kr_brn` | Korean BRN |
948
+ * | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF Number) |
949
+ * | Spain | `eu_vat` | European VAT Number |
950
+ * | Suriname | `sr_fin` | Suriname FIN Number |
951
+ * | Sweden | `eu_vat` | European VAT Number |
952
+ * | Switzerland | `ch_uid` | Switzerland UID Number |
953
+ * | Switzerland | `ch_vat` | Switzerland VAT Number |
954
+ * | Taiwan | `tw_vat` | Taiwanese VAT |
955
+ * | Tajikistan | `tj_tin` | Tajikistan Tax Identification Number |
956
+ * | Tanzania | `tz_vat` | Tanzania VAT Number |
957
+ * | Thailand | `th_vat` | Thai VAT |
958
+ * | Turkey | `tr_tin` | Turkish Tax Identification Number |
959
+ * | Uganda | `ug_tin` | Uganda Tax Identification Number |
960
+ * | Ukraine | `ua_vat` | Ukrainian VAT |
961
+ * | United Arab Emirates | `ae_trn` | United Arab Emirates TRN |
962
+ * | United Kingdom | `gb_vat` | United Kingdom VAT Number |
963
+ * | United States | `us_ein` | United States EIN |
964
+ * | Uruguay | `uy_ruc` | Uruguayan RUC Number |
965
+ * | Uzbekistan | `uz_tin` | Uzbekistan TIN Number |
966
+ * | Uzbekistan | `uz_vat` | Uzbekistan VAT Number |
967
+ * | Venezuela | `ve_rif` | Venezuelan RIF Number |
968
+ * | Vietnam | `vn_tin` | Vietnamese Tax ID Number |
969
+ * | Zambia | `zm_tin` | Zambia Tax Identification Number |
970
+ * | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number |
762
971
  */
763
- due_date?: (string & {}) | (string & {}) | null;
972
+ customer_tax_id: Shared.CustomerTaxID | null;
764
973
 
765
974
  /**
766
- * The `external_customer_id` of the `Customer` to create this invoice for. One of
767
- * `customer_id` and `external_customer_id` are required.
975
+ * When the invoice payment is due. The due date is null if the invoice is not yet
976
+ * finalized.
768
977
  */
769
- external_customer_id?: string | null;
978
+ due_date: string | null;
770
979
 
771
980
  /**
772
- * An optional memo to attach to the invoice. If no memo is provided, we will
773
- * attach the default memo
981
+ * If the invoice has a status of `draft`, this will be the time that the invoice
982
+ * will be eligible to be issued, otherwise it will be `null`. If `auto-issue` is
983
+ * true, the invoice will automatically begin issuing at this time.
774
984
  */
775
- memo?: string | null;
985
+ eligible_to_issue_at: string | null;
776
986
 
777
987
  /**
778
- * User-specified key/value pairs for the resource. Individual keys can be removed
779
- * by setting the value to `null`, and the entire metadata mapping can be cleared
780
- * by setting `metadata` to `null`.
988
+ * A URL for the customer-facing invoice portal. This URL expires 30 days after the
989
+ * invoice's due date, or 60 days after being re-generated through the UI.
781
990
  */
782
- metadata?: { [key: string]: string | null } | null;
991
+ hosted_invoice_url: string | null;
783
992
 
784
993
  /**
785
- * The net terms determines the due date of the invoice. Due date is calculated
786
- * based on the invoice or issuance date, depending on the account's configured due
787
- * date calculation method. A value of '0' here represents that the invoice is due
788
- * on issue, whereas a value of '30' represents that the customer has 30 days to
789
- * pay the invoice. Do not set this field if you want to set a custom due date.
994
+ * The scheduled date of the invoice
790
995
  */
791
- net_terms?: number | null;
996
+ invoice_date: string;
792
997
 
793
998
  /**
794
- * When true, this invoice will be submitted for issuance upon creation. When
795
- * false, the resulting invoice will require manual review to issue. Defaulted to
796
- * false.
999
+ * Automatically generated invoice number to help track and reconcile invoices.
1000
+ * Invoice numbers have a prefix such as `RFOBWG`. These can be sequential per
1001
+ * account or customer.
797
1002
  */
798
- will_auto_issue?: boolean;
799
- }
1003
+ invoice_number: string;
800
1004
 
801
- export namespace InvoiceCreateParams {
802
- export interface LineItem {
803
- /**
804
- * A date string to specify the line item's end date in the customer's timezone.
805
- */
806
- end_date: string;
1005
+ /**
1006
+ * The link to download the PDF representation of the `Invoice`.
1007
+ */
1008
+ invoice_pdf: string | null;
807
1009
 
808
- item_id: string;
1010
+ invoice_source: 'subscription' | 'partial' | 'one_off';
1011
+
1012
+ /**
1013
+ * If the invoice failed to issue, this will be the last time it failed to issue
1014
+ * (even if it is now in a different state.)
1015
+ */
1016
+ issue_failed_at: string | null;
1017
+
1018
+ /**
1019
+ * If the invoice has been issued, this will be the time it transitioned to
1020
+ * `issued` (even if it is now in a different state.)
1021
+ */
1022
+ issued_at: string | null;
1023
+
1024
+ /**
1025
+ * Free-form text which is available on the invoice PDF and the Orb invoice portal.
1026
+ */
1027
+ memo: string | null;
1028
+
1029
+ /**
1030
+ * User specified key-value pairs for the resource. If not present, this defaults
1031
+ * to an empty dictionary. Individual keys can be removed by setting the value to
1032
+ * `null`, and the entire metadata mapping can be cleared by setting `metadata` to
1033
+ * `null`.
1034
+ */
1035
+ metadata: { [key: string]: string };
1036
+
1037
+ /**
1038
+ * If the invoice has a status of `paid`, this gives a timestamp when the invoice
1039
+ * was paid.
1040
+ */
1041
+ paid_at: string | null;
1042
+
1043
+ /**
1044
+ * A list of payment attempts associated with the invoice
1045
+ */
1046
+ payment_attempts: Array<InvoiceListSummaryResponse.PaymentAttempt>;
1047
+
1048
+ /**
1049
+ * If payment was attempted on this invoice but failed, this will be the time of
1050
+ * the most recent attempt.
1051
+ */
1052
+ payment_failed_at: string | null;
1053
+
1054
+ /**
1055
+ * If payment was attempted on this invoice, this will be the start time of the
1056
+ * most recent attempt. This field is especially useful for delayed-notification
1057
+ * payment mechanisms (like bank transfers), where payment can take 3 days or more.
1058
+ */
1059
+ payment_started_at: string | null;
1060
+
1061
+ /**
1062
+ * If the invoice is in draft, this timestamp will reflect when the invoice is
1063
+ * scheduled to be issued.
1064
+ */
1065
+ scheduled_issue_at: string | null;
1066
+
1067
+ shipping_address: Shared.Address | null;
1068
+
1069
+ status: 'issued' | 'paid' | 'synced' | 'void' | 'draft';
1070
+
1071
+ subscription: Shared.SubscriptionMinified | null;
1072
+
1073
+ /**
1074
+ * If the invoice failed to sync, this will be the last time an external invoicing
1075
+ * provider sync was attempted. This field will always be `null` for invoices using
1076
+ * Orb Invoicing.
1077
+ */
1078
+ sync_failed_at: string | null;
1079
+
1080
+ /**
1081
+ * The total after any minimums and discounts have been applied.
1082
+ */
1083
+ total: string;
1084
+
1085
+ /**
1086
+ * If the invoice has a status of `void`, this gives a timestamp when the invoice
1087
+ * was voided.
1088
+ */
1089
+ voided_at: string | null;
1090
+
1091
+ /**
1092
+ * This is true if the invoice will be automatically issued in the future, and
1093
+ * false otherwise.
1094
+ */
1095
+ will_auto_issue: boolean;
1096
+ }
1097
+
1098
+ export namespace InvoiceListSummaryResponse {
1099
+ export interface AutoCollection {
1100
+ /**
1101
+ * True only if auto-collection is enabled for this invoice.
1102
+ */
1103
+ enabled: boolean | null;
1104
+
1105
+ /**
1106
+ * If the invoice is scheduled for auto-collection, this field will reflect when
1107
+ * the next attempt will occur. If dunning has been exhausted, or auto-collection
1108
+ * is not enabled for this invoice, this field will be `null`.
1109
+ */
1110
+ next_attempt_at: string | null;
1111
+
1112
+ /**
1113
+ * Number of auto-collection payment attempts.
1114
+ */
1115
+ num_attempts: number | null;
1116
+
1117
+ /**
1118
+ * If Orb has ever attempted payment auto-collection for this invoice, this field
1119
+ * will reflect when that attempt occurred. In conjunction with `next_attempt_at`,
1120
+ * this can be used to tell whether the invoice is currently in dunning (that is,
1121
+ * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or
1122
+ * if dunning has been exhausted (`previously_attempted_at` is non-null, but
1123
+ * `next_attempt_time` is null).
1124
+ */
1125
+ previously_attempted_at: string | null;
1126
+ }
1127
+
1128
+ export interface CreditNote {
1129
+ id: string;
1130
+
1131
+ credit_note_number: string;
1132
+
1133
+ /**
1134
+ * An optional memo supplied on the credit note.
1135
+ */
1136
+ memo: string | null;
1137
+
1138
+ reason: string;
1139
+
1140
+ total: string;
1141
+
1142
+ type: string;
1143
+
1144
+ /**
1145
+ * If the credit note has a status of `void`, this gives a timestamp when the
1146
+ * credit note was voided.
1147
+ */
1148
+ voided_at: string | null;
1149
+ }
1150
+
1151
+ export interface CustomerBalanceTransaction {
1152
+ /**
1153
+ * A unique id for this transaction.
1154
+ */
1155
+ id: string;
1156
+
1157
+ action:
1158
+ | 'applied_to_invoice'
1159
+ | 'manual_adjustment'
1160
+ | 'prorated_refund'
1161
+ | 'revert_prorated_refund'
1162
+ | 'return_from_voiding'
1163
+ | 'credit_note_applied'
1164
+ | 'credit_note_voided'
1165
+ | 'overpayment_refund'
1166
+ | 'external_payment'
1167
+ | 'small_invoice_carryover';
1168
+
1169
+ /**
1170
+ * The value of the amount changed in the transaction.
1171
+ */
1172
+ amount: string;
1173
+
1174
+ /**
1175
+ * The creation time of this transaction.
1176
+ */
1177
+ created_at: string;
1178
+
1179
+ credit_note: Shared.CreditNoteTiny | null;
1180
+
1181
+ /**
1182
+ * An optional description provided for manual customer balance adjustments.
1183
+ */
1184
+ description: string | null;
1185
+
1186
+ /**
1187
+ * The new value of the customer's balance prior to the transaction, in the
1188
+ * customer's currency.
1189
+ */
1190
+ ending_balance: string;
1191
+
1192
+ invoice: Shared.InvoiceTiny | null;
1193
+
1194
+ /**
1195
+ * The original value of the customer's balance prior to the transaction, in the
1196
+ * customer's currency.
1197
+ */
1198
+ starting_balance: string;
1199
+
1200
+ type: 'increment' | 'decrement';
1201
+ }
1202
+
1203
+ export interface PaymentAttempt {
1204
+ /**
1205
+ * The ID of the payment attempt.
1206
+ */
1207
+ id: string;
1208
+
1209
+ /**
1210
+ * The amount of the payment attempt.
1211
+ */
1212
+ amount: string;
1213
+
1214
+ /**
1215
+ * The time at which the payment attempt was created.
1216
+ */
1217
+ created_at: string;
1218
+
1219
+ /**
1220
+ * The payment provider that attempted to collect the payment.
1221
+ */
1222
+ payment_provider: 'stripe' | null;
1223
+
1224
+ /**
1225
+ * The ID of the payment attempt in the payment provider.
1226
+ */
1227
+ payment_provider_id: string | null;
1228
+
1229
+ /**
1230
+ * URL to the downloadable PDF version of the receipt. This field will be `null`
1231
+ * for payment attempts that did not succeed.
1232
+ */
1233
+ receipt_pdf: string | null;
1234
+
1235
+ /**
1236
+ * Whether the payment attempt succeeded.
1237
+ */
1238
+ succeeded: boolean;
1239
+ }
1240
+ }
1241
+
1242
+ export interface InvoiceCreateParams {
1243
+ /**
1244
+ * An ISO 4217 currency string. Must be the same as the customer's currency if it
1245
+ * is set.
1246
+ */
1247
+ currency: string;
1248
+
1249
+ /**
1250
+ * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is
1251
+ * set to the current time in the customer's timezone.
1252
+ */
1253
+ invoice_date: string;
1254
+
1255
+ line_items: Array<InvoiceCreateParams.LineItem>;
1256
+
1257
+ /**
1258
+ * The id of the `Customer` to create this invoice for. One of `customer_id` and
1259
+ * `external_customer_id` are required.
1260
+ */
1261
+ customer_id?: string | null;
1262
+
1263
+ /**
1264
+ * An optional discount to attach to the invoice.
1265
+ */
1266
+ discount?: Shared.Discount | null;
1267
+
1268
+ /**
1269
+ * An optional custom due date for the invoice. If not set, the due date will be
1270
+ * calculated based on the `net_terms` value.
1271
+ */
1272
+ due_date?: (string & {}) | (string & {}) | null;
1273
+
1274
+ /**
1275
+ * The `external_customer_id` of the `Customer` to create this invoice for. One of
1276
+ * `customer_id` and `external_customer_id` are required.
1277
+ */
1278
+ external_customer_id?: string | null;
1279
+
1280
+ /**
1281
+ * An optional memo to attach to the invoice. If no memo is provided, we will
1282
+ * attach the default memo
1283
+ */
1284
+ memo?: string | null;
1285
+
1286
+ /**
1287
+ * User-specified key/value pairs for the resource. Individual keys can be removed
1288
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
1289
+ * by setting `metadata` to `null`.
1290
+ */
1291
+ metadata?: { [key: string]: string | null } | null;
1292
+
1293
+ /**
1294
+ * The net terms determines the due date of the invoice. Due date is calculated
1295
+ * based on the invoice or issuance date, depending on the account's configured due
1296
+ * date calculation method. A value of '0' here represents that the invoice is due
1297
+ * on issue, whereas a value of '30' represents that the customer has 30 days to
1298
+ * pay the invoice. Do not set this field if you want to set a custom due date.
1299
+ */
1300
+ net_terms?: number | null;
1301
+
1302
+ /**
1303
+ * When true, this invoice will be submitted for issuance upon creation. When
1304
+ * false, the resulting invoice will require manual review to issue. Defaulted to
1305
+ * false.
1306
+ */
1307
+ will_auto_issue?: boolean;
1308
+ }
1309
+
1310
+ export namespace InvoiceCreateParams {
1311
+ export interface LineItem {
1312
+ /**
1313
+ * A date string to specify the line item's end date in the customer's timezone.
1314
+ */
1315
+ end_date: string;
1316
+
1317
+ item_id: string;
809
1318
 
810
1319
  model_type: 'unit';
811
1320
 
@@ -917,6 +1426,48 @@ export interface InvoiceIssueParams {
917
1426
  synchronous?: boolean;
918
1427
  }
919
1428
 
1429
+ export interface InvoiceListSummaryParams extends PageParams {
1430
+ amount?: string | null;
1431
+
1432
+ 'amount[gt]'?: string | null;
1433
+
1434
+ 'amount[lt]'?: string | null;
1435
+
1436
+ customer_id?: string | null;
1437
+
1438
+ date_type?: 'due_date' | 'invoice_date' | null;
1439
+
1440
+ due_date?: string | null;
1441
+
1442
+ /**
1443
+ * Filters invoices by their due dates within a specific time range in the past.
1444
+ * Specify the range as a number followed by 'd' (days) or 'm' (months). For
1445
+ * example, '7d' filters invoices due in the last 7 days, and '2m' filters those
1446
+ * due in the last 2 months.
1447
+ */
1448
+ due_date_window?: string | null;
1449
+
1450
+ 'due_date[gt]'?: string | null;
1451
+
1452
+ 'due_date[lt]'?: string | null;
1453
+
1454
+ external_customer_id?: string | null;
1455
+
1456
+ 'invoice_date[gt]'?: string | null;
1457
+
1458
+ 'invoice_date[gte]'?: string | null;
1459
+
1460
+ 'invoice_date[lt]'?: string | null;
1461
+
1462
+ 'invoice_date[lte]'?: string | null;
1463
+
1464
+ is_recurring?: boolean | null;
1465
+
1466
+ status?: Array<'draft' | 'issued' | 'paid' | 'synced' | 'void'> | null;
1467
+
1468
+ subscription_id?: string | null;
1469
+ }
1470
+
920
1471
  export interface InvoiceMarkPaidParams {
921
1472
  /**
922
1473
  * A date string to specify the date of the payment.
@@ -934,14 +1485,19 @@ export interface InvoiceMarkPaidParams {
934
1485
  notes?: string | null;
935
1486
  }
936
1487
 
1488
+ Invoices.InvoiceListSummaryResponsesPage = InvoiceListSummaryResponsesPage;
1489
+
937
1490
  export declare namespace Invoices {
938
1491
  export {
939
1492
  type InvoiceFetchUpcomingResponse as InvoiceFetchUpcomingResponse,
1493
+ type InvoiceListSummaryResponse as InvoiceListSummaryResponse,
1494
+ InvoiceListSummaryResponsesPage as InvoiceListSummaryResponsesPage,
940
1495
  type InvoiceCreateParams as InvoiceCreateParams,
941
1496
  type InvoiceUpdateParams as InvoiceUpdateParams,
942
1497
  type InvoiceListParams as InvoiceListParams,
943
1498
  type InvoiceFetchUpcomingParams as InvoiceFetchUpcomingParams,
944
1499
  type InvoiceIssueParams as InvoiceIssueParams,
1500
+ type InvoiceListSummaryParams as InvoiceListSummaryParams,
945
1501
  type InvoiceMarkPaidParams as InvoiceMarkPaidParams,
946
1502
  };
947
1503
  }