bkper-js 1.42.0 → 1.43.1
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 +14 -1
- package/lib/model/Book.js +23 -2
- package/lib/service/transaction-service.js +16 -17
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -966,6 +966,17 @@ export declare class Book {
|
|
|
966
966
|
* @returns The created Transactions
|
|
967
967
|
*/
|
|
968
968
|
batchCreateTransactions(transactions: Transaction[]): Promise<Transaction[]>;
|
|
969
|
+
/**
|
|
970
|
+
* Batch update [[Transactions]] on the Book.
|
|
971
|
+
*
|
|
972
|
+
* @param transactions The transactions to be updated
|
|
973
|
+
*
|
|
974
|
+
* @param updateChecked True to also update checked transactions
|
|
975
|
+
*
|
|
976
|
+
* @returns The updated draft Transactions
|
|
977
|
+
*
|
|
978
|
+
*/
|
|
979
|
+
batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean): Promise<Transaction[]>;
|
|
969
980
|
/**
|
|
970
981
|
* Batch check [[Transactions]] on the Book.
|
|
971
982
|
*
|
|
@@ -985,8 +996,10 @@ export declare class Book {
|
|
|
985
996
|
*
|
|
986
997
|
* @param transactions The transactions to be trashed
|
|
987
998
|
*
|
|
999
|
+
* @param trashChecked True to also trash checked transactions
|
|
1000
|
+
*
|
|
988
1001
|
*/
|
|
989
|
-
batchTrashTransactions(transactions: Transaction[]): Promise<void>;
|
|
1002
|
+
batchTrashTransactions(transactions: Transaction[], trashChecked?: boolean): Promise<void>;
|
|
990
1003
|
/**
|
|
991
1004
|
* Replay [[Events]] on the Book, in batch.
|
|
992
1005
|
*/
|
package/lib/model/Book.js
CHANGED
|
@@ -421,6 +421,25 @@ export class Book {
|
|
|
421
421
|
return transactions;
|
|
422
422
|
});
|
|
423
423
|
}
|
|
424
|
+
/**
|
|
425
|
+
* Batch update [[Transactions]] on the Book.
|
|
426
|
+
*
|
|
427
|
+
* @param transactions The transactions to be updated
|
|
428
|
+
*
|
|
429
|
+
* @param updateChecked True to also update checked transactions
|
|
430
|
+
*
|
|
431
|
+
* @returns The updated draft Transactions
|
|
432
|
+
*
|
|
433
|
+
*/
|
|
434
|
+
batchUpdateTransactions(transactions, updateChecked) {
|
|
435
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
436
|
+
let transactionPayloads = [];
|
|
437
|
+
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
438
|
+
transactionPayloads = yield TransactionService.updateTransactionsBatch(this.getId(), transactionPayloads, updateChecked);
|
|
439
|
+
transactions = transactionPayloads.map(tx => new Transaction(this, tx));
|
|
440
|
+
return transactions;
|
|
441
|
+
});
|
|
442
|
+
}
|
|
424
443
|
/**
|
|
425
444
|
* Batch check [[Transactions]] on the Book.
|
|
426
445
|
*
|
|
@@ -452,12 +471,14 @@ export class Book {
|
|
|
452
471
|
*
|
|
453
472
|
* @param transactions The transactions to be trashed
|
|
454
473
|
*
|
|
474
|
+
* @param trashChecked True to also trash checked transactions
|
|
475
|
+
*
|
|
455
476
|
*/
|
|
456
|
-
batchTrashTransactions(transactions) {
|
|
477
|
+
batchTrashTransactions(transactions, trashChecked) {
|
|
457
478
|
return __awaiter(this, void 0, void 0, function* () {
|
|
458
479
|
let transactionPayloads = [];
|
|
459
480
|
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
460
|
-
yield TransactionService.trashTransactionsBatch(this.getId(), transactionPayloads);
|
|
481
|
+
yield TransactionService.trashTransactionsBatch(this.getId(), transactionPayloads, trashChecked);
|
|
461
482
|
});
|
|
462
483
|
}
|
|
463
484
|
/**
|
|
@@ -16,14 +16,18 @@ export function createTransaction(bookId, transaction) {
|
|
|
16
16
|
}
|
|
17
17
|
export function createTransactionsBatch(bookId, transactions) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
let transactionList = {
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
let transactionList = { items: transactions };
|
|
20
|
+
const payload = transactionList;
|
|
21
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('POST').setPayload(payload).fetch();
|
|
22
|
+
transactionList = yield response.data;
|
|
23
|
+
return transactionList != null && transactionList.items != null ? transactionList.items : [];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function updateTransactionsBatch(bookId, transactions, updateChecked) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
let transactionList = { items: transactions };
|
|
29
|
+
const payload = transactionList;
|
|
30
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('PUT').setPayload(payload).addParam('updateChecked', updateChecked).fetch();
|
|
27
31
|
transactionList = yield response.data;
|
|
28
32
|
return transactionList != null && transactionList.items != null ? transactionList.items : [];
|
|
29
33
|
});
|
|
@@ -40,16 +44,11 @@ export function uncheckTransactionsBatch(bookId, transactions) {
|
|
|
40
44
|
yield new HttpBooksApiV5Request(`${bookId}/transactions/uncheck/batch`).setMethod('PATCH').setPayload(payload).fetch();
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
|
-
export function trashTransactionsBatch(bookId, transactions) {
|
|
47
|
+
export function trashTransactionsBatch(bookId, transactions, trashChecked) {
|
|
44
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
let transactionList = {
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
var payload = transactionList;
|
|
49
|
-
let response = yield new HttpBooksApiV5Request(`${bookId}/transactions/trash/batch`)
|
|
50
|
-
.setMethod('PATCH')
|
|
51
|
-
.setPayload(payload)
|
|
52
|
-
.fetch();
|
|
49
|
+
let transactionList = { items: transactions };
|
|
50
|
+
const payload = transactionList;
|
|
51
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/trash/batch`).setMethod('PATCH').setPayload(payload).addParam('trashChecked', trashChecked).fetch();
|
|
53
52
|
transactionList = yield response.data;
|
|
54
53
|
});
|
|
55
54
|
}
|