bkper-js 2.29.4 → 2.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/lib/index.d.ts +17 -3
- package/lib/model/Book.js +53 -1
- package/lib/model/Enums.js +0 -2
- package/lib/service/account-service.js +14 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,20 +15,20 @@ It provides a set of classes and functions to interact with the Bkper API, inclu
|
|
|
15
15
|
|
|
16
16
|
### Add the package:
|
|
17
17
|
|
|
18
|
-
```
|
|
18
|
+
```bash tab="npm"
|
|
19
19
|
npm i -S bkper-js
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
yarn add bkper-js
|
|
22
|
+
```bash tab="bun"
|
|
23
|
+
bun add bkper-js
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
```bash tab="pnpm"
|
|
27
|
+
pnpm add bkper-js
|
|
30
28
|
```
|
|
31
|
-
|
|
29
|
+
|
|
30
|
+
```bash tab="yarn"
|
|
31
|
+
yarn add bkper-js
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Usage
|
package/lib/index.d.ts
CHANGED
|
@@ -1830,6 +1830,22 @@ export declare class Book extends ResourceProperty<bkper.Book> {
|
|
|
1830
1830
|
* @returns The created Accounts
|
|
1831
1831
|
*/
|
|
1832
1832
|
batchCreateAccounts(accounts: Account[]): Promise<Account[]>;
|
|
1833
|
+
/**
|
|
1834
|
+
* Update [[Accounts]] on the Book, in batch.
|
|
1835
|
+
*
|
|
1836
|
+
* @param accounts - The accounts to be updated
|
|
1837
|
+
*
|
|
1838
|
+
* @returns The updated Accounts
|
|
1839
|
+
*/
|
|
1840
|
+
batchUpdateAccounts(accounts: Account[]): Promise<Account[]>;
|
|
1841
|
+
/**
|
|
1842
|
+
* Delete [[Accounts]] on the Book, in batch.
|
|
1843
|
+
*
|
|
1844
|
+
* @param accounts - The accounts to be deleted
|
|
1845
|
+
*
|
|
1846
|
+
* @returns The deleted Accounts
|
|
1847
|
+
*/
|
|
1848
|
+
batchDeleteAccounts(accounts: Account[]): Promise<Account[]>;
|
|
1833
1849
|
/**
|
|
1834
1850
|
* Create [[Groups]] on the Book, in batch.
|
|
1835
1851
|
*
|
|
@@ -1839,7 +1855,7 @@ export declare class Book extends ResourceProperty<bkper.Book> {
|
|
|
1839
1855
|
*/
|
|
1840
1856
|
batchCreateGroups(groups: Group[]): Promise<Group[]>;
|
|
1841
1857
|
/**
|
|
1842
|
-
* Trigger
|
|
1858
|
+
* Trigger Balances Audit async process.
|
|
1843
1859
|
*/
|
|
1844
1860
|
audit(): void;
|
|
1845
1861
|
/**
|
|
@@ -3234,8 +3250,6 @@ export declare enum Periodicity {
|
|
|
3234
3250
|
/**
|
|
3235
3251
|
* Enum representing permissions of user in the Book
|
|
3236
3252
|
*
|
|
3237
|
-
* Learn more at [share article](https://help.bkper.com/en/articles/2569153-share-your-book-with-your-peers).
|
|
3238
|
-
*
|
|
3239
3253
|
* @public
|
|
3240
3254
|
*/
|
|
3241
3255
|
export declare enum Permission {
|
package/lib/model/Book.js
CHANGED
|
@@ -574,6 +574,58 @@ export class Book extends ResourceProperty {
|
|
|
574
574
|
return [];
|
|
575
575
|
});
|
|
576
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Update [[Accounts]] on the Book, in batch.
|
|
579
|
+
*
|
|
580
|
+
* @param accounts - The accounts to be updated
|
|
581
|
+
*
|
|
582
|
+
* @returns The updated Accounts
|
|
583
|
+
*/
|
|
584
|
+
batchUpdateAccounts(accounts) {
|
|
585
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
586
|
+
if (accounts.length > 0) {
|
|
587
|
+
const accountList = {
|
|
588
|
+
items: accounts.map(a => a.json()),
|
|
589
|
+
};
|
|
590
|
+
const payloads = yield AccountService.updateAccounts(this.getId(), accountList, this.getConfig());
|
|
591
|
+
const updatedAccounts = [];
|
|
592
|
+
for (const payload of payloads) {
|
|
593
|
+
const account = new Account(this, payload);
|
|
594
|
+
updatedAccounts.push(account);
|
|
595
|
+
this.setAccount(payload);
|
|
596
|
+
}
|
|
597
|
+
this.clearCache();
|
|
598
|
+
return updatedAccounts;
|
|
599
|
+
}
|
|
600
|
+
return [];
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Delete [[Accounts]] on the Book, in batch.
|
|
605
|
+
*
|
|
606
|
+
* @param accounts - The accounts to be deleted
|
|
607
|
+
*
|
|
608
|
+
* @returns The deleted Accounts
|
|
609
|
+
*/
|
|
610
|
+
batchDeleteAccounts(accounts) {
|
|
611
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
612
|
+
if (accounts.length > 0) {
|
|
613
|
+
const accountList = {
|
|
614
|
+
items: accounts.map(a => a.json()),
|
|
615
|
+
};
|
|
616
|
+
const payloads = yield AccountService.deleteAccounts(this.getId(), accountList, this.getConfig());
|
|
617
|
+
const deletedAccounts = [];
|
|
618
|
+
for (const payload of payloads) {
|
|
619
|
+
const account = new Account(this, payload);
|
|
620
|
+
deletedAccounts.push(account);
|
|
621
|
+
this.setAccount(payload, true);
|
|
622
|
+
}
|
|
623
|
+
this.clearCache();
|
|
624
|
+
return deletedAccounts;
|
|
625
|
+
}
|
|
626
|
+
return [];
|
|
627
|
+
});
|
|
628
|
+
}
|
|
577
629
|
/**
|
|
578
630
|
* Create [[Groups]] on the Book, in batch.
|
|
579
631
|
*
|
|
@@ -599,7 +651,7 @@ export class Book extends ResourceProperty {
|
|
|
599
651
|
});
|
|
600
652
|
}
|
|
601
653
|
/**
|
|
602
|
-
* Trigger
|
|
654
|
+
* Trigger Balances Audit async process.
|
|
603
655
|
*/
|
|
604
656
|
audit() {
|
|
605
657
|
BookService.audit(this.getId(), this.getConfig());
|
package/lib/model/Enums.js
CHANGED
|
@@ -28,12 +28,26 @@ export function updateAccount(bookId, account, config) {
|
|
|
28
28
|
return response.data;
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
+
export function updateAccounts(bookId, payload, config) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a;
|
|
34
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/accounts/batch`, config).setMethod('PUT').setPayload(payload).fetch();
|
|
35
|
+
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
31
38
|
export function deleteAccount(bookId, account, config) {
|
|
32
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
40
|
var response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${account.id}`, config).setMethod('DELETE').fetch();
|
|
34
41
|
return response.data;
|
|
35
42
|
});
|
|
36
43
|
}
|
|
44
|
+
export function deleteAccounts(bookId, payload, config) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
var _a;
|
|
47
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/accounts/delete/batch`, config).setMethod('POST').setPayload(payload).fetch();
|
|
48
|
+
return ((_a = response.data) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
37
51
|
export function getAccount(bookId, idOrName, config) {
|
|
38
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
53
|
let response = yield new HttpBooksApiV5Request(`${bookId}/accounts/${encodeURIComponent(idOrName)}`, config).setMethod('GET').fetch();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"description": "Javascript client for Bkper REST API",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@bkper/bkper-api-types": "^5.
|
|
38
|
+
"@bkper/bkper-api-types": "^5.38.0",
|
|
39
39
|
"big.js": "^6.0.3",
|
|
40
40
|
"dayjs": "^1.10.3",
|
|
41
41
|
"luxon": "^1.25.0",
|