bkper 2.4.0 → 2.5.2
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/lib/index.d.ts +11 -20
- package/lib/index.js +1 -2
- package/lib/model/Book.js +22 -0
- package/lib/model/Enums.js +1 -21
- package/lib/service/HttpApiRequest.js +9 -3
- package/lib/service/account-service.js +3 -23
- package/lib/service/group-service.js +6 -29
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -338,26 +338,6 @@ export declare class App {
|
|
|
338
338
|
|
|
339
339
|
|
|
340
340
|
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Enum that represents balance types.
|
|
345
|
-
*
|
|
346
|
-
* @public
|
|
347
|
-
*/
|
|
348
|
-
export declare enum BalanceType {
|
|
349
|
-
/**
|
|
350
|
-
* Total balance
|
|
351
|
-
*/
|
|
352
|
-
TOTAL = "TOTAL",
|
|
353
|
-
/**
|
|
354
|
-
* Period balance
|
|
355
|
-
*/
|
|
356
|
-
PERIOD = "PERIOD",
|
|
357
|
-
/**
|
|
358
|
-
* Cumulative balance
|
|
359
|
-
*/
|
|
360
|
-
CUMULATIVE = "CUMULATIVE"
|
|
361
341
|
}
|
|
362
342
|
|
|
363
343
|
/**
|
|
@@ -510,6 +490,17 @@ export declare class Book {
|
|
|
510
490
|
* @returns This Book, for chainning.
|
|
511
491
|
*/
|
|
512
492
|
setLockDate(lockDate: string): Book;
|
|
493
|
+
/**
|
|
494
|
+
* @returns The closing date of the Book in ISO format yyyy-MM-dd
|
|
495
|
+
*/
|
|
496
|
+
getClosingDate(): string;
|
|
497
|
+
/**
|
|
498
|
+
*
|
|
499
|
+
* Sets the closing date of the Book in ISO format yyyy-MM-dd.
|
|
500
|
+
*
|
|
501
|
+
* @returns This Book, for chainning.
|
|
502
|
+
*/
|
|
503
|
+
setClosingDate(closingDate: string): Book;
|
|
513
504
|
/**
|
|
514
505
|
* @returns The decimal separator of the Book
|
|
515
506
|
*/
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.Permission = exports.DecimalSeparator = exports.
|
|
10
|
+
exports.Permission = exports.DecimalSeparator = exports.AccountType = exports.Periodicity = exports.TransactionIterator = exports.Transaction = exports.Group = exports.File = exports.Collection = exports.Book = exports.Account = exports.Bkper = exports.Amount = exports.App = void 0;
|
|
11
11
|
var App_1 = require("./model/App");
|
|
12
12
|
Object.defineProperty(exports, "App", { enumerable: true, get: function () { return App_1.App; } });
|
|
13
13
|
var Amount_1 = require("./model/Amount");
|
|
@@ -31,7 +31,6 @@ Object.defineProperty(exports, "TransactionIterator", { enumerable: true, get: f
|
|
|
31
31
|
var Enums_1 = require("./model/Enums");
|
|
32
32
|
Object.defineProperty(exports, "Periodicity", { enumerable: true, get: function () { return Enums_1.Periodicity; } });
|
|
33
33
|
Object.defineProperty(exports, "AccountType", { enumerable: true, get: function () { return Enums_1.AccountType; } });
|
|
34
|
-
Object.defineProperty(exports, "BalanceType", { enumerable: true, get: function () { return Enums_1.BalanceType; } });
|
|
35
34
|
Object.defineProperty(exports, "DecimalSeparator", { enumerable: true, get: function () { return Enums_1.DecimalSeparator; } });
|
|
36
35
|
Object.defineProperty(exports, "Permission", { enumerable: true, get: function () { return Enums_1.Permission; } });
|
|
37
36
|
//# sourceMappingURL=index.js.map
|
package/lib/model/Book.js
CHANGED
|
@@ -206,6 +206,25 @@ class Book {
|
|
|
206
206
|
this.wrapped.lockDate = lockDate;
|
|
207
207
|
return this;
|
|
208
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* @returns The closing date of the Book in ISO format yyyy-MM-dd
|
|
211
|
+
*/
|
|
212
|
+
getClosingDate() {
|
|
213
|
+
return this.wrapped.closingDate;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
*
|
|
217
|
+
* Sets the closing date of the Book in ISO format yyyy-MM-dd.
|
|
218
|
+
*
|
|
219
|
+
* @returns This Book, for chainning.
|
|
220
|
+
*/
|
|
221
|
+
setClosingDate(closingDate) {
|
|
222
|
+
if (closingDate == null) {
|
|
223
|
+
closingDate = "1900-00-00";
|
|
224
|
+
}
|
|
225
|
+
this.wrapped.closingDate = closingDate;
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
209
228
|
/**
|
|
210
229
|
* @returns The decimal separator of the Book
|
|
211
230
|
*/
|
|
@@ -575,6 +594,9 @@ class Book {
|
|
|
575
594
|
getTransaction(id) {
|
|
576
595
|
return __awaiter(this, void 0, void 0, function* () {
|
|
577
596
|
let wrapped = yield TransactionService.getTransaction(this.getId(), id);
|
|
597
|
+
if (!wrapped) {
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
578
600
|
let transaction = Utils.wrapObject(new Transaction_1.Transaction(), wrapped);
|
|
579
601
|
this.configureTransaction_(transaction);
|
|
580
602
|
return transaction;
|
package/lib/model/Enums.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Month = exports.Period = exports.
|
|
3
|
+
exports.Month = exports.Period = exports.AccountType = exports.Permission = exports.DecimalSeparator = exports.Periodicity = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* The Periodicity of the query. It may depend on the level of granularity you write the range params.
|
|
6
6
|
*
|
|
@@ -95,26 +95,6 @@ var AccountType;
|
|
|
95
95
|
*/
|
|
96
96
|
AccountType["OUTGOING"] = "OUTGOING";
|
|
97
97
|
})(AccountType = exports.AccountType || (exports.AccountType = {}));
|
|
98
|
-
/**
|
|
99
|
-
* Enum that represents balance types.
|
|
100
|
-
*
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
|
-
var BalanceType;
|
|
104
|
-
(function (BalanceType) {
|
|
105
|
-
/**
|
|
106
|
-
* Total balance
|
|
107
|
-
*/
|
|
108
|
-
BalanceType["TOTAL"] = "TOTAL";
|
|
109
|
-
/**
|
|
110
|
-
* Period balance
|
|
111
|
-
*/
|
|
112
|
-
BalanceType["PERIOD"] = "PERIOD";
|
|
113
|
-
/**
|
|
114
|
-
* Cumulative balance
|
|
115
|
-
*/
|
|
116
|
-
BalanceType["CUMULATIVE"] = "CUMULATIVE";
|
|
117
|
-
})(BalanceType = exports.BalanceType || (exports.BalanceType = {}));
|
|
118
98
|
/**
|
|
119
99
|
* Enum that represents a period slice.
|
|
120
100
|
*
|
|
@@ -70,6 +70,7 @@ class HttpApiRequest {
|
|
|
70
70
|
return url;
|
|
71
71
|
}
|
|
72
72
|
fetch() {
|
|
73
|
+
var _a;
|
|
73
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
75
|
this.headers['Authorization'] = `Bearer ${yield getAccessToken()}`;
|
|
75
76
|
this.addParam('key', HttpApiRequest.API_KEY);
|
|
@@ -92,9 +93,14 @@ class HttpApiRequest {
|
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
catch (e) {
|
|
95
|
-
let error = e.response.data;
|
|
96
|
-
if (error
|
|
97
|
-
|
|
96
|
+
let error = (_a = e.response.data) === null || _a === void 0 ? void 0 : _a.error;
|
|
97
|
+
if (error) {
|
|
98
|
+
if (error.code == 404) {
|
|
99
|
+
return { data: null };
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw error.message;
|
|
103
|
+
}
|
|
98
104
|
}
|
|
99
105
|
else {
|
|
100
106
|
throw e.message;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getAccount = exports.
|
|
12
|
+
exports.getAccount = exports.deleteAccount = exports.updateAccount = exports.createAccount = void 0;
|
|
13
13
|
const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
14
14
|
function createAccount(bookId, account) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,30 +34,10 @@ function deleteAccount(bookId, account) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
exports.deleteAccount = deleteAccount;
|
|
37
|
-
function createAccounts(bookId, accounts) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
let accountList = {
|
|
40
|
-
items: accounts
|
|
41
|
-
};
|
|
42
|
-
var accountSaveBatchJSON = JSON.stringify(accountList);
|
|
43
|
-
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/batch`).setMethod('POST').setPayload(accountSaveBatchJSON).fetch();
|
|
44
|
-
var accountsPlain = yield response.data;
|
|
45
|
-
if (accountsPlain.items == null) {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
return accountsPlain;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
exports.createAccounts = createAccounts;
|
|
52
37
|
function getAccount(bookId, idOrName) {
|
|
53
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return response.data;
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
39
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
|
|
40
|
+
return response.data;
|
|
61
41
|
});
|
|
62
42
|
}
|
|
63
43
|
exports.getAccount = getAccount;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getAccounts = exports.getGroup = exports.getGroups = exports.getGroupsByAccountId = exports.
|
|
12
|
+
exports.getAccounts = exports.getGroup = exports.getGroups = exports.getGroupsByAccountId = exports.deleteGroup = exports.updateGroup = exports.createGroup = void 0;
|
|
13
13
|
const HttpApiRequest_1 = require("./HttpApiRequest");
|
|
14
14
|
function createGroup(bookId, group) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -34,29 +34,11 @@ function deleteGroup(bookId, group) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
exports.deleteGroup = deleteGroup;
|
|
37
|
-
function createGroups(bookId, groups) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
let groupList = {
|
|
40
|
-
items: groups
|
|
41
|
-
};
|
|
42
|
-
var groupsBatchJSON = JSON.stringify(groupList);
|
|
43
|
-
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/batch`).setMethod('POST').setPayload(groupsBatchJSON).fetch();
|
|
44
|
-
if (response == null) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
var groupsPlain = response.data;
|
|
48
|
-
if (groupsPlain.items == null) {
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
return groupsPlain.items;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
exports.createGroups = createGroups;
|
|
55
37
|
function getGroupsByAccountId(bookId, accountId) {
|
|
56
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
39
|
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/accounts/${accountId}/groups`).setMethod('GET').fetch();
|
|
58
40
|
var groupsPlain = response.data;
|
|
59
|
-
if (groupsPlain
|
|
41
|
+
if (!(groupsPlain === null || groupsPlain === void 0 ? void 0 : groupsPlain.items)) {
|
|
60
42
|
return [];
|
|
61
43
|
}
|
|
62
44
|
return groupsPlain.items;
|
|
@@ -67,7 +49,7 @@ function getGroups(bookId) {
|
|
|
67
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
50
|
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups`).setMethod('GET').fetch();
|
|
69
51
|
var groupsPlain = response.data;
|
|
70
|
-
if (groupsPlain
|
|
52
|
+
if (!(groupsPlain === null || groupsPlain === void 0 ? void 0 : groupsPlain.items)) {
|
|
71
53
|
return [];
|
|
72
54
|
}
|
|
73
55
|
return groupsPlain.items;
|
|
@@ -76,13 +58,8 @@ function getGroups(bookId) {
|
|
|
76
58
|
exports.getGroups = getGroups;
|
|
77
59
|
function getGroup(bookId, idOrName) {
|
|
78
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return response.data;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
61
|
+
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}`).setMethod('GET').fetch();
|
|
62
|
+
return response.data;
|
|
86
63
|
});
|
|
87
64
|
}
|
|
88
65
|
exports.getGroup = getGroup;
|
|
@@ -90,7 +67,7 @@ function getAccounts(bookId, idOrName) {
|
|
|
90
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
68
|
var response = yield new HttpApiRequest_1.HttpBooksApiV5Request(`${bookId}/groups/${encodeURIComponent(idOrName)}/accounts`).setMethod('GET').fetch();
|
|
92
69
|
var accountsPlain = response.data;
|
|
93
|
-
if (accountsPlain
|
|
70
|
+
if (!(accountsPlain === null || accountsPlain === void 0 ? void 0 : accountsPlain.items)) {
|
|
94
71
|
return [];
|
|
95
72
|
}
|
|
96
73
|
return accountsPlain.items;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Node.js client for Bkper REST API",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"open": "^7.3.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@bkper/bkper-api-types": "^5.
|
|
49
|
+
"@bkper/bkper-api-types": "^5.1.4",
|
|
50
50
|
"@microsoft/api-extractor": "^7.12.1",
|
|
51
51
|
"@types/big.js": "^6.0.2",
|
|
52
52
|
"@types/chai": "^4.2.14",
|