moneybirdjs 1.0.17 → 1.0.19

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
@@ -14,6 +14,7 @@ A wrapper for the Moneybird API
14
14
  - Purchase Invoices
15
15
  - Receipts
16
16
  - Typeless documents
17
+ - Downloads
17
18
  - External Sales Invoices*
18
19
  - Financial Accounts
19
20
  - Financial Mutations
@@ -1,6 +1,6 @@
1
1
  import { RequestHandler } from "./RequestHandler";
2
2
  import { Administration, Contact, ContactPerson, ExternalSalesInvoice, FinancialMutation, LedgerAccount, PurchaseInvoice, Receipt, SalesInvoice } from "../struct";
3
- import { AddAdditionalChargeOptions, AddAttachmentOptions, AddContactOptions, AddContactPersonOptions, AddLedgerAccountOptions, AddNoteOptions, AddPaymentOptions, APIAdditionalCharge, APIAdministration, APIBalanceSheetReport, APICashFlowReport, APIContact, APIContactPerson, APICreditorsReport, APICustomField, APIDebtorsAgingReport, APIDebtorsReport, APIDocument, APIDocumentStyle, APIExpensesByContactReport, APIExpensesByProjectReport, APIFinancialAccount, APIFinancialMutation, APIGeneralLedgerReport, APILedgerAccount, APINote, APIPayment, APIPaymentsMandate, APIProfitLossReport, APIReportAsset, APIReportJournalEntry, APIRevenueByContactReport, APIRevenueByProjectReport, APISalesInvoice, APISubscriptionsReport, APITaxRate, APITaxReport, APIUser, APIVerifications, APIWorkflow, CashFlowReportOptions, ContactFilterOptions, ContactListIdsOptions, ContactSearchOptions, Document, DocumentAddOptions, DocumentEntityType, DocumentSearchOptions, DocumentUpdateOptions, EntityType, Filter, FinancialMutationLinkBookingOptions, FinancialMutationUnlinkBookingOptions, Identifier, JournalEntriesReportOptions, PagedAgingReportOptions, PagedReportOptions, ProfitLossReportOptions, ReportOptions, RequestPaymentsMandateEmailOptions, RequestPaymentsMandateOptions, SendSalesInvoiceOptions, TaxRateSearchOptions, UpdateContactOptions, UpdateContactPersonOptions, UpdateLedgerAccountOptions, UserSearchOptions } from "../types";
3
+ import { AddAdditionalChargeOptions, AddAttachmentOptions, AddContactOptions, AddContactPersonOptions, AddLedgerAccountOptions, AddNoteOptions, AddPaymentOptions, APIAdditionalCharge, APIAdministration, APIBalanceSheetReport, APICashFlowReport, APIContact, APIContactPerson, APICreditorsAgingReport, APICreditorsReport, APICustomField, APIDebtorsAgingReport, APIDebtorsReport, APIDocument, APIDocumentStyle, APIDownload, APIExpensesByContactReport, APIExpensesByProjectReport, APIFinancialAccount, APIFinancialMutation, APIGeneralLedgerReport, APILedgerAccount, APINote, APIPayment, APIPaymentsMandate, APIProfitLossReport, APIReportAsset, APIReportJournalEntry, APIRevenueByContactReport, APIRevenueByProjectReport, APISalesInvoice, APISubscriptionsReport, APITaxRate, APITaxReport, APIUser, APIVerifications, APIWorkflow, CashFlowReportOptions, ContactFilterOptions, ContactListIdsOptions, ContactSearchOptions, Document, DocumentAddOptions, DocumentEntityType, DocumentSearchOptions, DocumentUpdateOptions, DownloadFilterOptions, EntityType, Filter, FinancialMutationLinkBookingOptions, FinancialMutationUnlinkBookingOptions, Identifier, JournalEntriesReportOptions, PagedAgingReportOptions, PagedReportOptions, ProfitLossReportOptions, ReportOptions, RequestPaymentsMandateEmailOptions, RequestPaymentsMandateOptions, SendSalesInvoiceOptions, TaxRateSearchOptions, UpdateContactOptions, UpdateContactPersonOptions, UpdateLedgerAccountOptions, UserSearchOptions } from "../types";
4
4
  export declare class RESTManager {
5
5
  requestHandler: RequestHandler;
6
6
  constructor(apiToken: string);
@@ -46,12 +46,12 @@ export declare class RESTManager {
46
46
  * Returns all information about a contact person.
47
47
  * @see https://developer.moneybird.com/api/contacts#get-contact-person
48
48
  */
49
- getContactPerson(contact: Contact, contactPersonId: string): Promise<import("../types").Response<APIContactPerson>>;
49
+ getContactPerson(contact: Contact, contactPersonId: Identifier): Promise<import("../types").Response<APIContactPerson>>;
50
50
  /**
51
51
  * Deletes a contact person.
52
52
  * @see https://developer.moneybird.com/api/contacts#delete-a-contact-person
53
53
  */
54
- deleteContactPerson(contact: Contact, contactPersonId: string): Promise<import("../types").Response<void>>;
54
+ deleteContactPerson(contact: Contact, contactPersonId: Identifier): Promise<import("../types").Response<void>>;
55
55
  /**
56
56
  * When updating a contact, you only need to provide the information you want to change. Attributes you don't provide in the request will not be updated.
57
57
  * @see https://developer.moneybird.com/api/contacts#update-a-contact-person
@@ -110,7 +110,7 @@ export declare class RESTManager {
110
110
  * Deletes a contact.
111
111
  * @see https://developer.moneybird.com/api/contacts#delete-a-contact
112
112
  */
113
- deleteContact(administration: Administration, contactId: string): Promise<import("../types").Response<void>>;
113
+ deleteContact(administration: Administration, contactId: Identifier): Promise<import("../types").Response<void>>;
114
114
  /**
115
115
  * When updating a contact, you only need to provide the information you want to change. Attributes you don't provide in the request will not be updated. Optional attributes can be removed by setting them to an empty string value.
116
116
  * @see https://developer.moneybird.com/api/contacts#update-a-contact
@@ -148,8 +148,23 @@ export declare class RESTManager {
148
148
  * @see https://developer.moneybird.com/api/custom-fields#list-all-custom-fields
149
149
  */
150
150
  getCustomFields(administration: Administration): Promise<import("../types").Response<APICustomField[]>>;
151
- /** */
151
+ /**
152
+ * Returns a list of all document styles.
153
+ * @see https://developer.moneybird.com/api/document-styles#list-all-document-styles
154
+ */
152
155
  getDocumentStyles(administration: Administration): Promise<import("../types").Response<APIDocumentStyle[]>>;
156
+ /**
157
+ * Downloads the actual file. The user must have the appropriate permissions to access the download based on its type.
158
+ * @see https://developer.moneybird.com/api/downloads#download-a-file
159
+ */
160
+ downloadFile(administration: Administration, id: Identifier): Promise<import("../types").Response<Buffer<ArrayBufferLike>>>;
161
+ /**
162
+ * Returns a paginated list of all downloads in the administration.
163
+ *
164
+ * Only downloads that the authenticated user has permission to access will be returned, based on the download type and the user's permissions within the administration.
165
+ * @see https://developer.moneybird.com/api/downloads#list-all-downloads
166
+ */
167
+ getDownloads(administration: Administration, options?: DownloadFilterOptions): Promise<import("../types").Response<APIDownload[]>>;
153
168
  /** */
154
169
  listDocumentsByIds<T extends APIDocument>(administration: Administration, documentType: DocumentEntityType, ids: Array<string>): Promise<import("../types").Response<T[]>>;
155
170
  getDocuments<T extends APIDocument>(administration: Administration, documentType: DocumentEntityType, urlOptions: DocumentSearchOptions): Promise<import("../types").Response<T[]>>;
@@ -202,6 +217,11 @@ export declare class RESTManager {
202
217
  * @see https://developer.moneybird.com/api/reports#creditors-report
203
218
  */
204
219
  getCreditorsReport(administration: Administration, options?: PagedReportOptions): Promise<import("../types").Response<APICreditorsReport>>;
220
+ /**
221
+ * Returns a creditors aging report for the specified administration.
222
+ * @see https://developer.moneybird.com/api/reports#creditors-aging-report
223
+ */
224
+ getCreditorsAgingReport(administration: Administration, options?: PagedAgingReportOptions): Promise<import("../types").Response<APICreditorsAgingReport>>;
205
225
  /**
206
226
  * Returns a debtors report for the specified administration.
207
227
  * @see https://developer.moneybird.com/api/reports#debtors-report
@@ -247,10 +247,34 @@ class RESTManager {
247
247
  return this.requestHandler.request(`${administration.id}/custom_fields${Constants_1.format}`, { method: "GET" });
248
248
  }
249
249
  //#endregion Custom Fields
250
- /** */
250
+ //#region Document Styles
251
+ /**
252
+ * Returns a list of all document styles.
253
+ * @see https://developer.moneybird.com/api/document-styles#list-all-document-styles
254
+ */
251
255
  getDocumentStyles(administration) {
252
256
  return this.requestHandler.request(`${administration.id}/document_styles${Constants_1.format}`, { method: "GET" });
253
257
  }
258
+ //#endregion Document Styles
259
+ //#region Downloads
260
+ /**
261
+ * Downloads the actual file. The user must have the appropriate permissions to access the download based on its type.
262
+ * @see https://developer.moneybird.com/api/downloads#download-a-file
263
+ */
264
+ downloadFile(administration, id) {
265
+ return this.requestHandler.request(`${administration.id}/downloads/${id}/download${Constants_1.format}`, { method: "POST" });
266
+ }
267
+ /**
268
+ * Returns a paginated list of all downloads in the administration.
269
+ *
270
+ * Only downloads that the authenticated user has permission to access will be returned, based on the download type and the user's permissions within the administration.
271
+ * @see https://developer.moneybird.com/api/downloads#list-all-downloads
272
+ */
273
+ getDownloads(administration, options) {
274
+ const query = options === undefined ? '' : Util_1.Util.queryString(options);
275
+ return this.requestHandler.request(`${administration.id}/downloads${Constants_1.format}${query}`, { method: "GET" });
276
+ }
277
+ //#endregion Downloads
254
278
  //#region Document
255
279
  /** */
256
280
  listDocumentsByIds(administration, documentType, ids) {
@@ -411,6 +435,14 @@ class RESTManager {
411
435
  const query = options === undefined ? "" : Util_1.Util.queryString(options);
412
436
  return this.requestHandler.request(`${administration.id}/reports/creditors${Constants_1.format}${query}`, { method: "GET" });
413
437
  }
438
+ /**
439
+ * Returns a creditors aging report for the specified administration.
440
+ * @see https://developer.moneybird.com/api/reports#creditors-aging-report
441
+ */
442
+ getCreditorsAgingReport(administration, options) {
443
+ const query = options === undefined ? "" : Util_1.Util.queryString(options);
444
+ return this.requestHandler.request(`${administration.id}/reports/creditors_aging${Constants_1.format}${query}`, { method: "GET" });
445
+ }
414
446
  /**
415
447
  * Returns a debtors report for the specified administration.
416
448
  * @see https://developer.moneybird.com/api/reports#debtors-report
@@ -1,7 +1,6 @@
1
1
  import { RequestOptions, Response } from "../types";
2
2
  export declare class RequestHandler {
3
3
  #private;
4
- rejectIfNotValid: boolean;
5
4
  rateLimit: number;
6
5
  constructor(apiToken: string);
7
6
  request<T>(path: string, options: RequestOptions): Promise<Response<T>>;
@@ -49,7 +49,6 @@ exports.RequestHandler = void 0;
49
49
  const Constants = __importStar(require("../util/Constants"));
50
50
  class RequestHandler {
51
51
  constructor(apiToken) {
52
- this.rejectIfNotValid = true;
53
52
  this.rateLimit = 10;
54
53
  _RequestHandler_apiToken.set(this, void 0);
55
54
  __classPrivateFieldSet(this, _RequestHandler_apiToken, apiToken, "f");
@@ -58,87 +57,83 @@ class RequestHandler {
58
57
  return this.exec(path, options);
59
58
  }
60
59
  async exec(path, options, retries = 0) {
60
+ let contentType = 'application/json';
61
+ if (options.additionalHeaders?.["content-type"]) {
62
+ contentType = options.additionalHeaders["content-type"];
63
+ delete options.additionalHeaders["content-type"];
64
+ }
65
+ const headers = {
66
+ 'Authorization': `Bearer ${__classPrivateFieldGet(this, _RequestHandler_apiToken, "f")}`,
67
+ 'Content-Type': contentType,
68
+ ...options.additionalHeaders
69
+ };
70
+ let res;
61
71
  try {
62
- let contentType = 'application/json';
63
- if (options.additionalHeaders?.["content-type"]) {
64
- contentType = options.additionalHeaders["content-type"];
65
- delete options.additionalHeaders["content-type"];
66
- }
67
- const headers = {
68
- 'Authorization': `Bearer ${__classPrivateFieldGet(this, _RequestHandler_apiToken, "f")}`,
69
- 'Content-Type': contentType,
70
- ...options.additionalHeaders
71
- };
72
- const res = await fetch(`${Constants.APIBaseURL}${path}`, {
72
+ res = await fetch(`${Constants.APIBaseURL}${path}`, {
73
73
  method: options.method, headers: headers,
74
- body: options.method !== 'GET' ? options.body : undefined
74
+ body: options.method !== 'GET' ? options.body : undefined,
75
75
  });
76
- if (res.status >= 500 && retries < this.rateLimit) {
77
- return this.exec(path, options, ++retries);
78
- }
79
- if (res.status === 429) {
80
- const retryAfter = parseInt(res.headers.get('Retry-After'));
81
- const rateLimitRemaining = parseInt(res.headers.get('RateLimit-Remaining'));
82
- //const rateLimitLimit = parseInt(res.headers.get('RateLimit-Limit')!)
83
- const rateLimitReset = parseInt(res.headers.get('RateLimit-Reset'));
84
- const timeoutMS = (1 + (rateLimitRemaining < 10 ? rateLimitReset : retryAfter)) * 1000 - Date.now();
85
- await new Promise((resolve) => {
86
- setTimeout(resolve, timeoutMS);
87
- });
88
- return this.exec(path, options, ++retries);
89
- }
90
- if (res.status === 204)
91
- return {
92
- data: {},
93
- status: 204,
94
- maxAge: 0,
95
- path,
96
- ok: true
97
- };
98
- let data = null;
99
- if (res.body != null) {
100
- data = res.body;
101
- const chunks = [];
102
- const reader = data.getReader();
103
- while (true) {
104
- const { value, done } = await reader.read();
105
- if (value !== undefined)
106
- chunks.push(value);
107
- if (done)
108
- break;
109
- }
110
- const buffer = Buffer.concat(chunks);
111
- try {
112
- data = JSON.parse(buffer.toString());
113
- }
114
- catch (e) {
115
- const contentDisposition = res.headers?.get('content-disposition');
116
- if (contentDisposition?.startsWith('attachment') || contentDisposition?.startsWith('inline;')) {
117
- data = buffer;
118
- }
119
- else
120
- data = buffer.toString();
121
- }
122
- }
123
- const isOk = res.status === 200 || res.status === 201;
124
- return { data: data, status: res.status, maxAge: 0, path, ok: isOk };
125
- //https://developer.moneybird.com/#responses
126
76
  }
127
77
  catch (e) {
128
78
  // fetch error timeout and rate-limit not reached yet -> Try again
129
79
  if (e instanceof Error && e.message === 'fetch failed' && retries < this.rateLimit) {
130
80
  return this.exec(path, options, ++retries);
131
81
  }
132
- if (this.rejectIfNotValid)
133
- throw e;
82
+ throw e;
83
+ }
84
+ if (res.status >= 500 && retries < this.rateLimit)
85
+ return this.exec(path, options, ++retries);
86
+ if (res.status === 429) {
87
+ const retryAfter = parseInt(res.headers.get('Retry-After'));
88
+ const rateLimitRemaining = parseInt(res.headers.get('RateLimit-Remaining'));
89
+ //const rateLimitLimit = parseInt(res.headers.get('RateLimit-Limit')!)
90
+ const rateLimitReset = parseInt(res.headers.get('RateLimit-Reset'));
91
+ const timeoutMS = (1 + (rateLimitRemaining < 5 ? rateLimitReset : retryAfter)) * 1000 - Date.now();
92
+ await new Promise((resolve) => {
93
+ setTimeout(resolve, timeoutMS);
94
+ });
95
+ return this.exec(path, options, ++retries);
96
+ }
97
+ if (res.status === 204)
134
98
  return {
135
- data: { message: e.message },
99
+ data: {},
100
+ status: 204,
136
101
  maxAge: 0,
137
- status: 500,
138
- path,
139
- ok: false
102
+ path
140
103
  };
104
+ let data = null;
105
+ if (res.body != null) {
106
+ data = res.body;
107
+ const chunks = [];
108
+ const reader = data.getReader();
109
+ while (true) {
110
+ const { value, done } = await reader.read();
111
+ if (value !== undefined)
112
+ chunks.push(value);
113
+ if (done)
114
+ break;
115
+ }
116
+ const buffer = Buffer.concat(chunks);
117
+ try {
118
+ data = JSON.parse(buffer.toString());
119
+ }
120
+ catch (e) {
121
+ const contentDisposition = res.headers?.get('content-disposition');
122
+ if (contentDisposition?.startsWith('attachment') || contentDisposition?.startsWith('inline;')) {
123
+ data = buffer;
124
+ }
125
+ else
126
+ data = buffer.toString();
127
+ }
128
+ }
129
+ const isOk = res.status === 200 || res.status === 201;
130
+ if (!isOk) {
131
+ if (typeof data === 'object')
132
+ throw new Error(JSON.stringify(data));
133
+ throw new Error(res.statusText);
141
134
  }
135
+ return { data: data, status: res.status, maxAge: 0, path };
136
+ //TODO: https://developer.moneybird.com/#responses
142
137
  }
143
138
  }
144
139
  exports.RequestHandler = RequestHandler;
@@ -1,6 +1,6 @@
1
1
  import { Client } from "../client/Client";
2
- import { AssetsReport, BalanceSheetReport, CashFlowReport, Contact, CreditorsReport, CustomField, DebtorsAgingReport, DebtorsReport, DocumentStyle, ExpensesByContactReport, ExpensesByProjectReport, ExternalSalesInvoice, FinancialAccount, FinancialMutation, GeneralDocument, GeneralLedgerReport, JournalDocument, JournalEntriesReport, LedgerAccount, Payment, ProfitLossReport, PurchaseInvoice, Receipt, RevenueByContactReport, RevenueByProjectReport, SalesInvoice, SubscriptionsReport, TaxRate, TaxReport, TypelessDocument, User, Verifications, Workflow } from ".";
3
- import { AddContactOptions, AddExternalSalesInvoiceOptions, AddGeneralDocumentOptions, AddJournalDocumentOptions, AddLedgerAccountOptions, AddPurchaseInvoiceOptions, AddReceiptOptions, AddSalesInvoiceOptions, AddTypelessDocumentOptions, APIAdministration, CashFlowReportOptions, ContactFilterOptions, ContactListIdsOptions, ContactSearchOptions, EntityType, ExternalSalesInvoiceSearchOptions, Filter, GeneralDocumentSearchOptions, Identifier, JournalDocumentSearchOptions, JournalEntriesReportOptions, PagedAgingReportOptions, PagedReportOptions, ProfitLossReportOptions, PurchaseInvoiceSearchOptions, ReceiptSearchOptions, ReportOptions, SalesInvoiceSearchOptions, TaxRateSearchOptions, TypelessDocumentSearchOptions, UserSearchOptions } from "../types";
2
+ import { AssetsReport, BalanceSheetReport, CashFlowReport, Contact, CreditorsAgingReport, CreditorsReport, CustomField, DebtorsAgingReport, DebtorsReport, DocumentStyle, Download, ExpensesByContactReport, ExpensesByProjectReport, ExternalSalesInvoice, FinancialAccount, FinancialMutation, GeneralDocument, GeneralLedgerReport, JournalDocument, JournalEntriesReport, LedgerAccount, Payment, ProfitLossReport, PurchaseInvoice, Receipt, RevenueByContactReport, RevenueByProjectReport, SalesInvoice, SubscriptionsReport, TaxRate, TaxReport, TypelessDocument, User, Verifications, Workflow } from ".";
3
+ import { AccessType, AddContactOptions, AddExternalSalesInvoiceOptions, AddGeneralDocumentOptions, AddJournalDocumentOptions, AddLedgerAccountOptions, AddPurchaseInvoiceOptions, AddReceiptOptions, AddSalesInvoiceOptions, AddTypelessDocumentOptions, APIAdministration, CashFlowReportOptions, ContactFilterOptions, ContactListIdsOptions, ContactSearchOptions, DownloadFilterOptions, EntityType, ExternalSalesInvoiceSearchOptions, Filter, GeneralDocumentSearchOptions, Identifier, JournalDocumentSearchOptions, JournalEntriesReportOptions, PagedAgingReportOptions, PagedReportOptions, ProfitLossReportOptions, PurchaseInvoiceSearchOptions, ReceiptSearchOptions, ReportOptions, SalesInvoiceSearchOptions, TaxRateSearchOptions, TypelessDocumentSearchOptions, UserSearchOptions } from "../types";
4
4
  /** Administrations are the top level entities in Moneybird. */
5
5
  export declare class Administration {
6
6
  client: Client;
@@ -15,9 +15,11 @@ export declare class Administration {
15
15
  /** The time zone of the administration */
16
16
  time_zone: string;
17
17
  /** The type of access the user has to this administration */
18
- access: string;
18
+ access: AccessType;
19
19
  suspended: boolean;
20
20
  period_locked_until?: Date;
21
+ /** Start of the year in which the administration recorded its first bookkeeping data, based on journal entries. */
22
+ period_start_date: Date;
21
23
  constructor(client: Client, data: APIAdministration);
22
24
  /** Returns all entities of {@link entityType} in the administration. The list contains the id and the version of the entity. Check if the version of the entity is newer than the version you have stored locally. */
23
25
  listIdsAndVersions(entityType: EntityType, filter?: Filter): Promise<{
@@ -57,7 +59,7 @@ export declare class Administration {
57
59
  * Deletes a contact.
58
60
  * @see https://developer.moneybird.com/api/contacts#delete-a-contact
59
61
  */
60
- deleteContact(contactId: string): Promise<void>;
62
+ deleteContact(contactId: Identifier): Promise<void>;
61
63
  /**
62
64
  * Returns a paginated list of contacts in the administration.
63
65
  *
@@ -90,8 +92,19 @@ export declare class Administration {
90
92
  * @see https://developer.moneybird.com/api/custom-fields#list-all-custom-fields
91
93
  */
92
94
  getCustomFields(): Promise<CustomField[]>;
93
- /** */
95
+ /**
96
+ * Returns a list of all document styles.
97
+ * @see https://developer.moneybird.com/api/document-styles#list-all-document-styles
98
+ */
94
99
  getDocumentStyles(): Promise<DocumentStyle[]>;
100
+ /**
101
+ * Returns a paginated list of all downloads in the administration.
102
+ *
103
+ * Only downloads that the authenticated user has permission to access will be returned, based on the download type and the user's permissions within the administration.
104
+ * @see https://developer.moneybird.com/api/downloads#list-all-downloads
105
+ */
106
+ getDownloads(options?: DownloadFilterOptions): Promise<Download[]>;
107
+ /** */
95
108
  listGeneralDocumentsByIds(ids: Array<string>): Promise<GeneralDocument[]>;
96
109
  getGeneralDocuments(options?: GeneralDocumentSearchOptions): Promise<GeneralDocument[]>;
97
110
  getGeneralDocument(generalDocumentId: string): Promise<GeneralDocument>;
@@ -158,6 +171,11 @@ export declare class Administration {
158
171
  * @see https://developer.moneybird.com/api/reports#creditors-report
159
172
  */
160
173
  getCreditorsReport(options?: PagedReportOptions): Promise<CreditorsReport>;
174
+ /**
175
+ * Returns a creditors aging report for the specified administration.
176
+ * @see https://developer.moneybird.com/api/reports#creditors-aging-report
177
+ */
178
+ getCreditorsAgingReport(options?: PagedAgingReportOptions): Promise<CreditorsAgingReport>;
161
179
  /**
162
180
  * Returns a debtors report for the specified administration.
163
181
  * @see https://developer.moneybird.com/api/reports#debtors-report
@@ -16,6 +16,7 @@ class Administration {
16
16
  this.suspended = data.suspended;
17
17
  if (data.period_locked_until)
18
18
  this.period_locked_until = new Date(data.period_locked_until);
19
+ this.period_start_date = new Date(data.period_start_date);
19
20
  }
20
21
  /** Returns all entities of {@link entityType} in the administration. The list contains the id and the version of the entity. Check if the version of the entity is newer than the version you have stored locally. */
21
22
  async listIdsAndVersions(entityType, filter) {
@@ -115,12 +116,29 @@ class Administration {
115
116
  }
116
117
  //#endregion Custom Fields
117
118
  // TODO: Customer contact portal
118
- /** */
119
+ //#region Document Styles
120
+ /**
121
+ * Returns a list of all document styles.
122
+ * @see https://developer.moneybird.com/api/document-styles#list-all-document-styles
123
+ */
119
124
  async getDocumentStyles() {
120
125
  const { data } = await this.client.rest.getDocumentStyles(this);
121
126
  return data.map((entry) => new _1.DocumentStyle(this, entry));
122
127
  }
123
- // TODO: Downloads
128
+ //#endregion Document Styles
129
+ //#region Downloads
130
+ /**
131
+ * Returns a paginated list of all downloads in the administration.
132
+ *
133
+ * Only downloads that the authenticated user has permission to access will be returned, based on the download type and the user's permissions within the administration.
134
+ * @see https://developer.moneybird.com/api/downloads#list-all-downloads
135
+ */
136
+ async getDownloads(options) {
137
+ const { data } = await this.client.rest.getDownloads(this, options);
138
+ return data.map((entry) => new _1.Download(this, entry));
139
+ }
140
+ //#endregion Downloads
141
+ /** */
124
142
  async listGeneralDocumentsByIds(ids) {
125
143
  const { data } = await this.client.rest.listDocumentsByIds(this, 'generalDocument', ids);
126
144
  return data.map((entry) => new _1.GeneralDocument(this, entry));
@@ -318,6 +336,14 @@ class Administration {
318
336
  const { data } = await this.client.rest.getCreditorsReport(this, options);
319
337
  return new _1.CreditorsReport(data);
320
338
  }
339
+ /**
340
+ * Returns a creditors aging report for the specified administration.
341
+ * @see https://developer.moneybird.com/api/reports#creditors-aging-report
342
+ */
343
+ async getCreditorsAgingReport(options) {
344
+ const { data } = await this.client.rest.getCreditorsAgingReport(this, options);
345
+ return new _1.CreditorsAgingReport(data);
346
+ }
321
347
  /**
322
348
  * Returns a debtors report for the specified administration.
323
349
  * @see https://developer.moneybird.com/api/reports#debtors-report
@@ -1,7 +1,8 @@
1
- import { APICashFlowReport, LedgerAccountData } from "../types";
1
+ import { ReportLedgerAccount } from ".";
2
+ import { APICashFlowReport } from "../types";
2
3
  export declare class CashFlowReport {
3
- cash_received_by_ledger_account: LedgerAccountData;
4
- cash_paid_by_ledger_account: LedgerAccountData;
4
+ cash_received_by_ledger_account: ReportLedgerAccount[];
5
+ cash_paid_by_ledger_account: ReportLedgerAccount[];
5
6
  opening_balance: number;
6
7
  closing_balance: number;
7
8
  constructor(data: APICashFlowReport);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CashFlowReport = void 0;
4
+ const _1 = require(".");
4
5
  class CashFlowReport {
5
6
  constructor(data) {
6
- this.cash_received_by_ledger_account = Object.fromEntries(Object.entries(data.cash_received_by_ledger_account).map(([k, v]) => [k, parseFloat(v)]));
7
- this.cash_paid_by_ledger_account = Object.fromEntries(Object.entries(data.cash_paid_by_ledger_account).map(([k, v]) => [k, parseFloat(v)]));
7
+ this.cash_received_by_ledger_account = data.cash_received_by_ledger_account.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
8
+ this.cash_paid_by_ledger_account = data.cash_paid_by_ledger_account.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
8
9
  this.opening_balance = parseFloat(data.opening_balance);
9
10
  this.closing_balance = parseFloat(data.closing_balance);
10
11
  }
@@ -59,12 +59,12 @@ export declare class Contact {
59
59
  * Returns all information about a contact person.
60
60
  * @see https://developer.moneybird.com/api/contacts#get-contact-person
61
61
  */
62
- getContactPerson(contactPersonId: string): Promise<ContactPerson>;
62
+ getContactPerson(contactPersonId: Identifier): Promise<ContactPerson>;
63
63
  /**
64
64
  * Deletes a contact person.
65
65
  * @see https://developer.moneybird.com/api/contacts#delete-a-contact-person
66
66
  */
67
- deleteContactPerson(contactPersonId: string): Promise<void>;
67
+ deleteContactPerson(contactPersonId: Identifier): Promise<void>;
68
68
  /**
69
69
  * Creating a new contact person in the administration requires at least a `contact_person` hash including `firstname` and `lastname`.
70
70
  * @see https://developer.moneybird.com/api/contacts#create-a-new-contact-person
@@ -0,0 +1,6 @@
1
+ import { ReportAgingContact } from ".";
2
+ import { APICreditorsAgingReport } from "../types";
3
+ export declare class CreditorsAgingReport {
4
+ creditors: ReportAgingContact[];
5
+ constructor(data: APICreditorsAgingReport);
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreditorsAgingReport = void 0;
4
+ const _1 = require(".");
5
+ class CreditorsAgingReport {
6
+ constructor(data) {
7
+ this.creditors = data.creditors.map(creditor => new _1.ReportAgingContact(creditor));
8
+ }
9
+ }
10
+ exports.CreditorsAgingReport = CreditorsAgingReport;
@@ -1,20 +1,21 @@
1
1
  import { Administration } from ".";
2
- import { APIDocumentField, APIDocumentStyle } from "../types";
2
+ import { AddressPosition, APIDocumentField, APIDocumentStyle, Identifier, LogoPosition, PaperSize } from "../types";
3
+ /** Document styles are used to define the layout of documents, like invoices and estimates. You can have multiple document styles for different purposes. */
3
4
  export declare class DocumentStyle {
4
5
  administration: Administration;
5
- id: string;
6
- administration_id: string;
6
+ id: Identifier;
7
+ administration_id: Identifier;
7
8
  name: string;
8
- identity_id: string;
9
+ identity_id: Identifier;
9
10
  default: boolean;
10
11
  logo_hash: string;
11
12
  logo_container_full_width: boolean;
12
13
  logo_display_width: number;
13
- logo_position: string;
14
+ logo_position: LogoPosition;
14
15
  background_hash: string;
15
- paper_size: string;
16
- address_position: string;
17
- font_size: 9 | 10 | 11 | 12;
16
+ paper_size: PaperSize;
17
+ address_position: AddressPosition;
18
+ font_size: number;
18
19
  font_family: string;
19
20
  print_on_stationery: boolean;
20
21
  custom_css: string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocumentStyle = void 0;
4
+ /** Document styles are used to define the layout of documents, like invoices and estimates. You can have multiple document styles for different purposes. */
4
5
  class DocumentStyle {
5
6
  constructor(administration, data) {
6
7
  this.administration = administration;
@@ -0,0 +1,22 @@
1
+ import { Administration } from ".";
2
+ import { APIDownload, DownloadType, Identifier } from "../types";
3
+ /** Downloads are files that have been generated as exports from your administration. These can be CSV exports of contacts, sales invoices, time entries, or various financial reports. */
4
+ export declare class Download {
5
+ administration: Administration;
6
+ id: Identifier;
7
+ user_id?: Identifier;
8
+ download_type: DownloadType;
9
+ filename: string;
10
+ content_type: string;
11
+ failed: boolean;
12
+ downloaded: boolean;
13
+ created_at: Date;
14
+ updated_at: Date;
15
+ private data;
16
+ constructor(administration: Administration, data: APIDownload);
17
+ /**
18
+ * Downloads this file
19
+ * @see https://developer.moneybird.com/api/downloads#download-a-file
20
+ */
21
+ download(): Promise<Buffer<ArrayBufferLike>>;
22
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Download = void 0;
4
+ /** Downloads are files that have been generated as exports from your administration. These can be CSV exports of contacts, sales invoices, time entries, or various financial reports. */
5
+ class Download {
6
+ constructor(administration, data) {
7
+ this.administration = administration;
8
+ this.data = null;
9
+ this.id = data.id;
10
+ if (data.user_id)
11
+ this.user_id = data.user_id;
12
+ this.download_type = data.download_type;
13
+ this.filename = data.filename;
14
+ this.content_type = data.content_type;
15
+ this.failed = data.failed;
16
+ this.downloaded = data.downloaded;
17
+ this.created_at = new Date(data.created_at);
18
+ this.updated_at = new Date(data.updated_at);
19
+ }
20
+ /**
21
+ * Downloads this file
22
+ * @see https://developer.moneybird.com/api/downloads#download-a-file
23
+ */
24
+ async download() {
25
+ if (this.data == null)
26
+ this.data = (await this.administration.client.rest.downloadFile(this.administration, this.id)).data;
27
+ return this.data;
28
+ }
29
+ }
30
+ exports.Download = Download;
@@ -1,10 +1,9 @@
1
- import { APIGeneralLedgerReport, GeneralLedgerReportGroupedData, LedgerAccountData } from "../types";
1
+ import { ReportLedgerAccount } from ".";
2
+ import { APIGeneralLedgerReport } from "../types";
2
3
  export declare class GeneralLedgerReport {
3
- start_balance: LedgerAccountData;
4
- debit_sums: LedgerAccountData;
5
- credit_sums: LedgerAccountData;
6
- final_balance: LedgerAccountData;
7
- private _groupedByLedger?;
4
+ start_balance: ReportLedgerAccount[];
5
+ debit_sums: ReportLedgerAccount[];
6
+ credit_sums: ReportLedgerAccount[];
7
+ final_balance: ReportLedgerAccount[];
8
8
  constructor(data: APIGeneralLedgerReport);
9
- groupByLedger(): GeneralLedgerReportGroupedData;
10
9
  }
@@ -1,27 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GeneralLedgerReport = void 0;
4
+ const _1 = require(".");
4
5
  class GeneralLedgerReport {
5
6
  constructor(data) {
6
- this.start_balance = Object.fromEntries(Object.entries(data.start_balance).map(([k, v]) => [k, parseFloat(v)]));
7
- this.debit_sums = Object.fromEntries(Object.entries(data.debit_sums).map(([k, v]) => [k, parseFloat(v)]));
8
- this.credit_sums = Object.fromEntries(Object.entries(data.credit_sums).map(([k, v]) => [k, parseFloat(v)]));
9
- this.final_balance = Object.fromEntries(Object.entries(data.final_balance).map(([k, v]) => [k, parseFloat(v)]));
10
- }
11
- groupByLedger() {
12
- if (this._groupedByLedger !== undefined)
13
- return this._groupedByLedger;
14
- const keys = [...Object.keys(this.start_balance), ...Object.keys(this.debit_sums), ...Object.keys(this.credit_sums), ...Object.keys(this.final_balance)];
15
- this._groupedByLedger = Object.fromEntries(keys.map(k => {
16
- const ledgerId = k;
17
- return [k, {
18
- start_balance: this.start_balance[ledgerId] ?? 0,
19
- debit_sums: this.debit_sums[ledgerId] ?? 0,
20
- credit_sums: this.credit_sums[ledgerId] ?? 0,
21
- final_balance: this.final_balance[ledgerId] ?? 0
22
- }];
23
- }));
24
- return this._groupedByLedger;
7
+ this.start_balance = data.start_balance.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
8
+ this.debit_sums = data.debit_sums.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
9
+ this.credit_sums = data.credit_sums.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
10
+ this.final_balance = data.final_balance.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
25
11
  }
26
12
  }
27
13
  exports.GeneralLedgerReport = GeneralLedgerReport;
@@ -1,9 +1,10 @@
1
- import { APIProfitLossReport, LedgerAccountData } from "../types";
1
+ import { ReportLedgerAccount } from ".";
2
+ import { APIProfitLossReport } from "../types";
2
3
  export declare class ProfitLossReport {
3
- revenue_by_ledger_account: LedgerAccountData;
4
- direct_costs_by_ledger_account: LedgerAccountData;
5
- expenses_by_ledger_account: LedgerAccountData;
6
- other_income_expenses_by_ledger_account: LedgerAccountData;
4
+ revenue_by_ledger_account: ReportLedgerAccount[];
5
+ direct_costs_by_ledger_account: ReportLedgerAccount[];
6
+ expenses_by_ledger_account: ReportLedgerAccount[];
7
+ other_income_expenses_by_ledger_account: ReportLedgerAccount[];
7
8
  gross_profit: number;
8
9
  operating_profit: number;
9
10
  net_profit: number;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProfitLossReport = void 0;
4
+ const _1 = require(".");
4
5
  class ProfitLossReport {
5
6
  constructor(data) {
6
- this.revenue_by_ledger_account = Object.fromEntries(Object.entries(data.revenue_by_ledger_account).map(([k, v]) => [k, parseFloat(v)]));
7
- this.direct_costs_by_ledger_account = Object.fromEntries(Object.entries(data.direct_costs_by_ledger_account).map(([k, v]) => [k, parseFloat(v)]));
8
- this.expenses_by_ledger_account = Object.fromEntries(Object.entries(data.expenses_by_ledger_account).map(([k, v]) => [k, parseFloat(v)]));
9
- this.other_income_expenses_by_ledger_account = Object.fromEntries(Object.entries(data.other_income_expenses_by_ledger_account).map(([k, v]) => [k, parseFloat(v)]));
7
+ this.revenue_by_ledger_account = data.revenue_by_ledger_account.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
8
+ this.direct_costs_by_ledger_account = data.direct_costs_by_ledger_account.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
9
+ this.expenses_by_ledger_account = data.expenses_by_ledger_account.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
10
+ this.other_income_expenses_by_ledger_account = data.other_income_expenses_by_ledger_account.ledger_accounts.map(data => new _1.ReportLedgerAccount(data));
10
11
  this.gross_profit = parseFloat(data.gross_profit);
11
12
  this.operating_profit = parseFloat(data.operating_profit);
12
13
  this.net_profit = parseFloat(data.net_profit);
@@ -0,0 +1,6 @@
1
+ import { APIReportLedgerAccount, Identifier } from "../types";
2
+ export declare class ReportLedgerAccount {
3
+ ledger_account_id: Identifier;
4
+ value: number;
5
+ constructor(data: APIReportLedgerAccount);
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReportLedgerAccount = void 0;
4
+ class ReportLedgerAccount {
5
+ constructor(data) {
6
+ this.ledger_account_id = data.ledger_account_id;
7
+ this.value = parseFloat(data.value);
8
+ }
9
+ }
10
+ exports.ReportLedgerAccount = ReportLedgerAccount;
@@ -11,11 +11,13 @@ export * from './CustomField';
11
11
  export * from './Contact';
12
12
  export * from './ContactCustomField';
13
13
  export * from './ContactPerson';
14
+ export * from './CreditorsAgingReport';
14
15
  export * from './CreditorsReport';
15
16
  export * from './DebtorsAgingReport';
16
17
  export * from './DebtorsReport';
17
18
  export * from './DocumentDetail';
18
19
  export * from './DocumentStyle';
20
+ export * from './Download';
19
21
  export * from './Event';
20
22
  export * from './ExpensesByContactReport';
21
23
  export * from './ExpensesByProjectReport';
@@ -39,6 +41,7 @@ export * from './ReportAgingBucket';
39
41
  export * from './ReportAgingContact';
40
42
  export * from './ReportAsset';
41
43
  export * from './ReportJournalEntry';
44
+ export * from './ReportLedgerAccount';
42
45
  export * from './ReportProject';
43
46
  export * from './ReportTaxRate';
44
47
  export * from './RevenueByContactReport';
@@ -27,11 +27,13 @@ __exportStar(require("./CustomField"), exports);
27
27
  __exportStar(require("./Contact"), exports);
28
28
  __exportStar(require("./ContactCustomField"), exports);
29
29
  __exportStar(require("./ContactPerson"), exports);
30
+ __exportStar(require("./CreditorsAgingReport"), exports);
30
31
  __exportStar(require("./CreditorsReport"), exports);
31
32
  __exportStar(require("./DebtorsAgingReport"), exports);
32
33
  __exportStar(require("./DebtorsReport"), exports);
33
34
  __exportStar(require("./DocumentDetail"), exports);
34
35
  __exportStar(require("./DocumentStyle"), exports);
36
+ __exportStar(require("./Download"), exports);
35
37
  __exportStar(require("./Event"), exports);
36
38
  __exportStar(require("./ExpensesByContactReport"), exports);
37
39
  __exportStar(require("./ExpensesByProjectReport"), exports);
@@ -55,6 +57,7 @@ __exportStar(require("./ReportAgingBucket"), exports);
55
57
  __exportStar(require("./ReportAgingContact"), exports);
56
58
  __exportStar(require("./ReportAsset"), exports);
57
59
  __exportStar(require("./ReportJournalEntry"), exports);
60
+ __exportStar(require("./ReportLedgerAccount"), exports);
58
61
  __exportStar(require("./ReportProject"), exports);
59
62
  __exportStar(require("./ReportTaxRate"), exports);
60
63
  __exportStar(require("./RevenueByContactReport"), exports);
@@ -1,4 +1,5 @@
1
- import { CreditCardType, CustomFieldSource, DeliveryMethod, Identifier, NoteEntityType, Period, SepaSequenceType, SiIdentifierType, ToDoType } from "./lib";
1
+ import { AccessType, CreditCardType, CustomFieldSource, DeliveryMethod, DownloadType, Identifier, NoteEntityType, Period, SepaSequenceType, SiIdentifierType, ToDoType } from "./lib";
2
+ import { AddressPosition, LogoPosition, PaperSize } from "./lib_documentStyle";
2
3
  export interface APIAdministration {
3
4
  id: Identifier;
4
5
  name: string;
@@ -11,9 +12,11 @@ export interface APIAdministration {
11
12
  /** The time zone of the administration */
12
13
  time_zone: string;
13
14
  /** The type of access the user has to this administration */
14
- access: string;
15
+ access: AccessType;
15
16
  suspended: boolean;
16
17
  period_locked_until: string | null;
18
+ /** Start of the year in which the administration recorded its first bookkeeping data, based on journal entries. */
19
+ period_start_date: string;
17
20
  }
18
21
  export interface APICustomField {
19
22
  id: Identifier;
@@ -147,19 +150,19 @@ export interface APIAdditionalCharge {
147
150
  description: string;
148
151
  }
149
152
  export interface APIDocumentStyle {
150
- id: string;
151
- administration_id: string;
153
+ id: Identifier;
154
+ administration_id: Identifier;
152
155
  name: string;
153
- identity_id: string;
156
+ identity_id: Identifier;
154
157
  default: boolean;
155
158
  logo_hash: string;
156
159
  logo_container_full_width: boolean;
157
160
  logo_display_width: number;
158
- logo_position: string;
161
+ logo_position: LogoPosition;
159
162
  background_hash: string;
160
- paper_size: string;
161
- address_position: string;
162
- font_size: 9 | 10 | 11 | 12;
163
+ paper_size: PaperSize;
164
+ address_position: AddressPosition;
165
+ font_size: number;
163
166
  font_family: string;
164
167
  print_on_stationery: boolean;
165
168
  custom_css: string;
@@ -178,6 +181,17 @@ export interface APIDocumentField {
178
181
  bold?: boolean;
179
182
  italic?: boolean;
180
183
  }
184
+ export interface APIDownload {
185
+ id: Identifier;
186
+ user_id: Identifier | null;
187
+ download_type: DownloadType;
188
+ filename: string;
189
+ content_type: string;
190
+ failed: boolean;
191
+ downloaded: boolean;
192
+ created_at: string;
193
+ updated_at: string;
194
+ }
181
195
  export type APIDocument = APIGeneralDocument | APIJournalDocument | APIPurchaseInvoice | APIReceipt | APITypelessDocument | APIExternalSalesInvoice | APISalesInvoice;
182
196
  export interface APIGeneralDocument {
183
197
  id: string;
@@ -795,15 +809,22 @@ export interface APIBalanceSheetLedgerAccount {
795
809
  children?: APIBalanceSheetLedgerAccount[];
796
810
  }
797
811
  export interface APICashFlowReport {
798
- cash_received_by_ledger_account: APILedgerAccountData;
799
- cash_paid_by_ledger_account: APILedgerAccountData;
812
+ cash_received_by_ledger_account: {
813
+ ledger_accounts: APIReportLedgerAccount[];
814
+ };
815
+ cash_paid_by_ledger_account: {
816
+ ledger_accounts: APIReportLedgerAccount[];
817
+ };
800
818
  opening_balance: string;
801
819
  closing_balance: string;
802
820
  }
803
- /** Data grouped by ledger account */
804
- export type APILedgerAccountData = {
805
- [l: Identifier]: string;
821
+ export type APIReportLedgerAccount = {
822
+ ledger_account_id: Identifier;
823
+ value: string;
806
824
  };
825
+ export interface APICreditorsAgingReport {
826
+ creditors: APIReportAgingContact[];
827
+ }
807
828
  export interface APICreditorsReport {
808
829
  creditors: APIReportContact[];
809
830
  }
@@ -836,10 +857,18 @@ export interface APIReportProject {
836
857
  amount: string;
837
858
  }
838
859
  export interface APIGeneralLedgerReport {
839
- debit_sums: APILedgerAccountData;
840
- credit_sums: APILedgerAccountData;
841
- start_balance: APILedgerAccountData;
842
- final_balance: APILedgerAccountData;
860
+ debit_sums: {
861
+ ledger_accounts: APIReportLedgerAccount[];
862
+ };
863
+ credit_sums: {
864
+ ledger_accounts: APIReportLedgerAccount[];
865
+ };
866
+ start_balance: {
867
+ ledger_accounts: APIReportLedgerAccount[];
868
+ };
869
+ final_balance: {
870
+ ledger_accounts: APIReportLedgerAccount[];
871
+ };
843
872
  }
844
873
  export interface APIReportJournalEntry {
845
874
  /** Unique identifier for the journal entry */
@@ -866,10 +895,18 @@ export interface APIReportJournalEntry {
866
895
  description: string;
867
896
  }
868
897
  export interface APIProfitLossReport {
869
- revenue_by_ledger_account: APILedgerAccountData;
870
- direct_costs_by_ledger_account: APILedgerAccountData;
871
- expenses_by_ledger_account: APILedgerAccountData;
872
- other_income_expenses_by_ledger_account: APILedgerAccountData;
898
+ revenue_by_ledger_account: {
899
+ ledger_accounts: APIReportLedgerAccount[];
900
+ };
901
+ direct_costs_by_ledger_account: {
902
+ ledger_accounts: APIReportLedgerAccount[];
903
+ };
904
+ expenses_by_ledger_account: {
905
+ ledger_accounts: APIReportLedgerAccount[];
906
+ };
907
+ other_income_expenses_by_ledger_account: {
908
+ ledger_accounts: APIReportLedgerAccount[];
909
+ };
873
910
  gross_profit: string;
874
911
  operating_profit: string;
875
912
  net_profit: string;
@@ -4,6 +4,8 @@ import { APILedgerAccountAllowedDocumentTypes, APILedgerAccountType } from "./ap
4
4
  export * from "./lib_contact";
5
5
  export * from "./lib_customField";
6
6
  export * from "./lib_documents";
7
+ export * from "./lib_documentStyle";
8
+ export * from "./lib_download";
7
9
  export * from "./lib_financialMutation";
8
10
  export * from "./lib_note";
9
11
  export * from "./lib_reports";
@@ -41,9 +43,10 @@ export type Identifier = `${number}`;
41
43
  * @default this_month
42
44
  */
43
45
  export type Period = `${number}..${number}` | `${number}` | 'this_month' | 'prev_month' | 'next_month' | 'this_quarter' | 'prev_quarter' | 'next_quarter' | 'this_year' | 'prev_year' | 'next_year';
46
+ export type AccessType = 'accountant_company' | 'user';
44
47
  export type BookingType = 'SalesInvoice' | 'Document' | 'LedgerAccount' | 'PaymentTransactionBatch' | 'PurchaseTransaction' | 'NewPurchaseInvoice' | 'NewReceipt' | 'PaymentTransaction' | 'PurchaseTransactionBatch' | 'ExternalSalesInvoice' | 'Payment' | 'VatDocument';
45
48
  export type RequestOptions = {
46
- method: 'GET' | 'DELETE' | 'PATCH';
49
+ method: 'GET' | 'DELETE' | 'PATCH' | 'POST';
47
50
  body?: undefined;
48
51
  additionalHeaders?: {
49
52
  'content-type'?: string;
@@ -62,7 +65,6 @@ export interface Response<T> {
62
65
  status: number;
63
66
  maxAge: 0;
64
67
  path: string;
65
- ok: boolean;
66
68
  }
67
69
  /** The filter argument allows you to filter on the list. Filters are a combination of keys and values. The most common filter method will be period: period:'this_month'. Filtering works the same as in the web application, for more advanced examples, change the filtering in the web application and learn from the resulting URI. */
68
70
  export interface Filter {
@@ -70,6 +72,7 @@ export interface Filter {
70
72
  }
71
73
  export interface PagedOptions {
72
74
  page?: number;
75
+ /** min: 1, max: 100 */
73
76
  per_page?: number;
74
77
  }
75
78
  export interface AddAttachmentOptions {
package/dist/types/lib.js CHANGED
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./lib_contact"), exports);
18
18
  __exportStar(require("./lib_customField"), exports);
19
19
  __exportStar(require("./lib_documents"), exports);
20
+ __exportStar(require("./lib_documentStyle"), exports);
21
+ __exportStar(require("./lib_download"), exports);
20
22
  __exportStar(require("./lib_financialMutation"), exports);
21
23
  __exportStar(require("./lib_note"), exports);
22
24
  __exportStar(require("./lib_reports"), exports);
@@ -0,0 +1,3 @@
1
+ export type AddressPosition = 'left' | 'right';
2
+ export type LogoPosition = 'left' | 'center' | 'right';
3
+ export type PaperSize = 'A4' | 'letter';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { PagedOptions } from "./lib";
2
+ export type DownloadType = 'auditfile' | 'brugstaat' | 'export_bank_statement' | 'export_contacts' | 'export_documents' | 'export_ledger_account_report' | 'export_sales_invoices' | string;
3
+ export interface DownloadFilterOptions extends PagedOptions {
4
+ /**
5
+ * Filter downloads by type. Common download types include:
6
+ * - `auditfile`
7
+ * - `brugstaat`
8
+ * - `export_ledger_account_report`
9
+ *
10
+ * Check the `download_type` field in the response to see all available types.
11
+ */
12
+ download_type?: DownloadType;
13
+ downloaded?: boolean;
14
+ failed?: boolean;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,6 @@
1
1
  import { Identifier, PagedOptions, Period } from "./lib";
2
2
  import { APILedgerAccountType } from "./api";
3
3
  /** Data grouped by {@link LedgerAccount.id} */
4
- export type LedgerAccountData = {
5
- [l: Identifier]: number;
6
- };
7
- /** Data grouped by {@link LedgerAccount.id} */
8
4
  export type GeneralLedgerReportGroupedData = {
9
5
  [l: Identifier]: {
10
6
  start_balance: number;
package/package.json CHANGED
@@ -5,9 +5,9 @@
5
5
  },
6
6
  "description": "A wrapper for the Moneybird API",
7
7
  "devDependencies": {
8
- "@types/node": "^25.0.3",
8
+ "@types/node": "^25.6.0",
9
9
  "gen-esm-wrapper": "^1.1.3",
10
- "rimraf": "^6.1.2",
10
+ "rimraf": "^6.1.3",
11
11
  "typescript": "^5.9.3"
12
12
  },
13
13
  "exports": {
@@ -28,5 +28,5 @@
28
28
  "test": "npm run prepare && node test/index.js"
29
29
  },
30
30
  "types": "dist/types/index.d.ts",
31
- "version": "1.0.17"
31
+ "version": "1.0.19"
32
32
  }