moneybirdjs 1.0.18 → 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/dist/rest/RESTManager.d.ts +6 -1
- package/dist/rest/RESTManager.js +8 -0
- package/dist/rest/RequestHandler.d.ts +0 -1
- package/dist/rest/RequestHandler.js +63 -68
- package/dist/struct/Administration.d.ts +10 -3
- package/dist/struct/Administration.js +9 -0
- package/dist/struct/CashFlowReport.d.ts +4 -3
- package/dist/struct/CashFlowReport.js +3 -2
- package/dist/struct/CreditorsAgingReport.d.ts +6 -0
- package/dist/struct/CreditorsAgingReport.js +10 -0
- package/dist/struct/GeneralLedgerReport.d.ts +6 -7
- package/dist/struct/GeneralLedgerReport.js +5 -19
- package/dist/struct/ProfitLossReport.d.ts +6 -5
- package/dist/struct/ProfitLossReport.js +5 -4
- package/dist/struct/ReportLedgerAccount.d.ts +6 -0
- package/dist/struct/ReportLedgerAccount.js +10 -0
- package/dist/struct/index.d.ts +2 -0
- package/dist/struct/index.js +2 -0
- package/dist/types/api.d.ts +40 -15
- package/dist/types/lib.d.ts +1 -1
- package/dist/types/lib_reports.d.ts +0 -4
- package/package.json +3 -3
|
@@ -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, 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";
|
|
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);
|
|
@@ -217,6 +217,11 @@ export declare class RESTManager {
|
|
|
217
217
|
* @see https://developer.moneybird.com/api/reports#creditors-report
|
|
218
218
|
*/
|
|
219
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>>;
|
|
220
225
|
/**
|
|
221
226
|
* Returns a debtors report for the specified administration.
|
|
222
227
|
* @see https://developer.moneybird.com/api/reports#debtors-report
|
package/dist/rest/RESTManager.js
CHANGED
|
@@ -435,6 +435,14 @@ class RESTManager {
|
|
|
435
435
|
const query = options === undefined ? "" : Util_1.Util.queryString(options);
|
|
436
436
|
return this.requestHandler.request(`${administration.id}/reports/creditors${Constants_1.format}${query}`, { method: "GET" });
|
|
437
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
|
+
}
|
|
438
446
|
/**
|
|
439
447
|
* Returns a debtors report for the specified administration.
|
|
440
448
|
* @see https://developer.moneybird.com/api/reports#debtors-report
|
|
@@ -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
|
-
|
|
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
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
|
-
|
|
133
|
-
|
|
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: {
|
|
99
|
+
data: {},
|
|
100
|
+
status: 204,
|
|
136
101
|
maxAge: 0,
|
|
137
|
-
|
|
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, 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 { 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";
|
|
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:
|
|
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<{
|
|
@@ -169,6 +171,11 @@ export declare class Administration {
|
|
|
169
171
|
* @see https://developer.moneybird.com/api/reports#creditors-report
|
|
170
172
|
*/
|
|
171
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>;
|
|
172
179
|
/**
|
|
173
180
|
* Returns a debtors report for the specified administration.
|
|
174
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) {
|
|
@@ -335,6 +336,14 @@ class Administration {
|
|
|
335
336
|
const { data } = await this.client.rest.getCreditorsReport(this, options);
|
|
336
337
|
return new _1.CreditorsReport(data);
|
|
337
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
|
+
}
|
|
338
347
|
/**
|
|
339
348
|
* Returns a debtors report for the specified administration.
|
|
340
349
|
* @see https://developer.moneybird.com/api/reports#debtors-report
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReportLedgerAccount } from ".";
|
|
2
|
+
import { APICashFlowReport } from "../types";
|
|
2
3
|
export declare class CashFlowReport {
|
|
3
|
-
cash_received_by_ledger_account:
|
|
4
|
-
cash_paid_by_ledger_account:
|
|
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 =
|
|
7
|
-
this.cash_paid_by_ledger_account =
|
|
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
|
}
|
|
@@ -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,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReportLedgerAccount } from ".";
|
|
2
|
+
import { APIGeneralLedgerReport } from "../types";
|
|
2
3
|
export declare class GeneralLedgerReport {
|
|
3
|
-
start_balance:
|
|
4
|
-
debit_sums:
|
|
5
|
-
credit_sums:
|
|
6
|
-
final_balance:
|
|
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 =
|
|
7
|
-
this.debit_sums =
|
|
8
|
-
this.credit_sums =
|
|
9
|
-
this.final_balance =
|
|
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 {
|
|
1
|
+
import { ReportLedgerAccount } from ".";
|
|
2
|
+
import { APIProfitLossReport } from "../types";
|
|
2
3
|
export declare class ProfitLossReport {
|
|
3
|
-
revenue_by_ledger_account:
|
|
4
|
-
direct_costs_by_ledger_account:
|
|
5
|
-
expenses_by_ledger_account:
|
|
6
|
-
other_income_expenses_by_ledger_account:
|
|
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 =
|
|
7
|
-
this.direct_costs_by_ledger_account =
|
|
8
|
-
this.expenses_by_ledger_account =
|
|
9
|
-
this.other_income_expenses_by_ledger_account =
|
|
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,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;
|
package/dist/struct/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ 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';
|
|
@@ -40,6 +41,7 @@ export * from './ReportAgingBucket';
|
|
|
40
41
|
export * from './ReportAgingContact';
|
|
41
42
|
export * from './ReportAsset';
|
|
42
43
|
export * from './ReportJournalEntry';
|
|
44
|
+
export * from './ReportLedgerAccount';
|
|
43
45
|
export * from './ReportProject';
|
|
44
46
|
export * from './ReportTaxRate';
|
|
45
47
|
export * from './RevenueByContactReport';
|
package/dist/struct/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __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);
|
|
@@ -56,6 +57,7 @@ __exportStar(require("./ReportAgingBucket"), exports);
|
|
|
56
57
|
__exportStar(require("./ReportAgingContact"), exports);
|
|
57
58
|
__exportStar(require("./ReportAsset"), exports);
|
|
58
59
|
__exportStar(require("./ReportJournalEntry"), exports);
|
|
60
|
+
__exportStar(require("./ReportLedgerAccount"), exports);
|
|
59
61
|
__exportStar(require("./ReportProject"), exports);
|
|
60
62
|
__exportStar(require("./ReportTaxRate"), exports);
|
|
61
63
|
__exportStar(require("./RevenueByContactReport"), exports);
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CreditCardType, CustomFieldSource, DeliveryMethod, DownloadType, Identifier, NoteEntityType, Period, SepaSequenceType, SiIdentifierType, ToDoType } from "./lib";
|
|
1
|
+
import { AccessType, CreditCardType, CustomFieldSource, DeliveryMethod, DownloadType, Identifier, NoteEntityType, Period, SepaSequenceType, SiIdentifierType, ToDoType } from "./lib";
|
|
2
2
|
import { AddressPosition, LogoPosition, PaperSize } from "./lib_documentStyle";
|
|
3
3
|
export interface APIAdministration {
|
|
4
4
|
id: Identifier;
|
|
@@ -12,9 +12,11 @@ export interface APIAdministration {
|
|
|
12
12
|
/** The time zone of the administration */
|
|
13
13
|
time_zone: string;
|
|
14
14
|
/** The type of access the user has to this administration */
|
|
15
|
-
access:
|
|
15
|
+
access: AccessType;
|
|
16
16
|
suspended: boolean;
|
|
17
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;
|
|
18
20
|
}
|
|
19
21
|
export interface APICustomField {
|
|
20
22
|
id: Identifier;
|
|
@@ -807,15 +809,22 @@ export interface APIBalanceSheetLedgerAccount {
|
|
|
807
809
|
children?: APIBalanceSheetLedgerAccount[];
|
|
808
810
|
}
|
|
809
811
|
export interface APICashFlowReport {
|
|
810
|
-
cash_received_by_ledger_account:
|
|
811
|
-
|
|
812
|
+
cash_received_by_ledger_account: {
|
|
813
|
+
ledger_accounts: APIReportLedgerAccount[];
|
|
814
|
+
};
|
|
815
|
+
cash_paid_by_ledger_account: {
|
|
816
|
+
ledger_accounts: APIReportLedgerAccount[];
|
|
817
|
+
};
|
|
812
818
|
opening_balance: string;
|
|
813
819
|
closing_balance: string;
|
|
814
820
|
}
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
821
|
+
export type APIReportLedgerAccount = {
|
|
822
|
+
ledger_account_id: Identifier;
|
|
823
|
+
value: string;
|
|
818
824
|
};
|
|
825
|
+
export interface APICreditorsAgingReport {
|
|
826
|
+
creditors: APIReportAgingContact[];
|
|
827
|
+
}
|
|
819
828
|
export interface APICreditorsReport {
|
|
820
829
|
creditors: APIReportContact[];
|
|
821
830
|
}
|
|
@@ -848,10 +857,18 @@ export interface APIReportProject {
|
|
|
848
857
|
amount: string;
|
|
849
858
|
}
|
|
850
859
|
export interface APIGeneralLedgerReport {
|
|
851
|
-
debit_sums:
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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
|
+
};
|
|
855
872
|
}
|
|
856
873
|
export interface APIReportJournalEntry {
|
|
857
874
|
/** Unique identifier for the journal entry */
|
|
@@ -878,10 +895,18 @@ export interface APIReportJournalEntry {
|
|
|
878
895
|
description: string;
|
|
879
896
|
}
|
|
880
897
|
export interface APIProfitLossReport {
|
|
881
|
-
revenue_by_ledger_account:
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
+
};
|
|
885
910
|
gross_profit: string;
|
|
886
911
|
operating_profit: string;
|
|
887
912
|
net_profit: string;
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export type Identifier = `${number}`;
|
|
|
43
43
|
* @default this_month
|
|
44
44
|
*/
|
|
45
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';
|
|
46
47
|
export type BookingType = 'SalesInvoice' | 'Document' | 'LedgerAccount' | 'PaymentTransactionBatch' | 'PurchaseTransaction' | 'NewPurchaseInvoice' | 'NewReceipt' | 'PaymentTransaction' | 'PurchaseTransactionBatch' | 'ExternalSalesInvoice' | 'Payment' | 'VatDocument';
|
|
47
48
|
export type RequestOptions = {
|
|
48
49
|
method: 'GET' | 'DELETE' | 'PATCH' | 'POST';
|
|
@@ -64,7 +65,6 @@ export interface Response<T> {
|
|
|
64
65
|
status: number;
|
|
65
66
|
maxAge: 0;
|
|
66
67
|
path: string;
|
|
67
|
-
ok: boolean;
|
|
68
68
|
}
|
|
69
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. */
|
|
70
70
|
export interface Filter {
|
|
@@ -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.
|
|
8
|
+
"@types/node": "^25.6.0",
|
|
9
9
|
"gen-esm-wrapper": "^1.1.3",
|
|
10
|
-
"rimraf": "^6.1.
|
|
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.
|
|
31
|
+
"version": "1.0.19"
|
|
32
32
|
}
|