bkper-js 1.41.0 → 1.43.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/lib/index.d.ts +35 -3
- package/lib/model/Book.js +54 -4
- package/lib/service/transaction-service.js +22 -9
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -959,13 +959,45 @@ export declare class Book {
|
|
|
959
959
|
*/
|
|
960
960
|
round(value: Amount | number): Amount;
|
|
961
961
|
/**
|
|
962
|
-
*
|
|
962
|
+
* Batch create [[Transactions]] on the Book.
|
|
963
|
+
*
|
|
964
|
+
* @param transactions The transactions to be created
|
|
965
|
+
*
|
|
966
|
+
* @returns The created Transactions
|
|
963
967
|
*/
|
|
964
968
|
batchCreateTransactions(transactions: Transaction[]): Promise<Transaction[]>;
|
|
965
969
|
/**
|
|
966
|
-
*
|
|
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
|
+
*/
|
|
977
|
+
batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean): Promise<void>;
|
|
978
|
+
/**
|
|
979
|
+
* Batch check [[Transactions]] on the Book.
|
|
980
|
+
*
|
|
981
|
+
* @param transactions The transactions to be checked
|
|
982
|
+
*
|
|
983
|
+
*/
|
|
984
|
+
batchCheckTransactions(transactions: Transaction[]): Promise<void>;
|
|
985
|
+
/**
|
|
986
|
+
* Batch uncheck [[Transactions]] on the Book.
|
|
987
|
+
*
|
|
988
|
+
* @param transactions The transactions to be unchecked
|
|
989
|
+
*
|
|
990
|
+
*/
|
|
991
|
+
batchUncheckTransactions(transactions: Transaction[]): Promise<void>;
|
|
992
|
+
/**
|
|
993
|
+
* Batch trash [[Transactions]] on the Book.
|
|
994
|
+
*
|
|
995
|
+
* @param transactions The transactions to be trashed
|
|
996
|
+
*
|
|
997
|
+
* @param trashChecked True to also trash checked transactions
|
|
998
|
+
*
|
|
967
999
|
*/
|
|
968
|
-
batchTrashTransactions(transactions: Transaction[]): Promise<void>;
|
|
1000
|
+
batchTrashTransactions(transactions: Transaction[], trashChecked?: boolean): Promise<void>;
|
|
969
1001
|
/**
|
|
970
1002
|
* Replay [[Events]] on the Book, in batch.
|
|
971
1003
|
*/
|
package/lib/model/Book.js
CHANGED
|
@@ -406,7 +406,11 @@ export class Book {
|
|
|
406
406
|
return Utils.round(value, this.getFractionDigits());
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
|
-
*
|
|
409
|
+
* Batch create [[Transactions]] on the Book.
|
|
410
|
+
*
|
|
411
|
+
* @param transactions The transactions to be created
|
|
412
|
+
*
|
|
413
|
+
* @returns The created Transactions
|
|
410
414
|
*/
|
|
411
415
|
batchCreateTransactions(transactions) {
|
|
412
416
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -418,13 +422,59 @@ export class Book {
|
|
|
418
422
|
});
|
|
419
423
|
}
|
|
420
424
|
/**
|
|
421
|
-
*
|
|
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
|
+
*/
|
|
432
|
+
batchUpdateTransactions(transactions, updateChecked) {
|
|
433
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
434
|
+
let transactionsPayload = [];
|
|
435
|
+
transactions.forEach(tx => transactionsPayload.push(tx.json()));
|
|
436
|
+
yield TransactionService.updateTransactionsBatch(this.getId(), transactionsPayload, updateChecked);
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Batch check [[Transactions]] on the Book.
|
|
441
|
+
*
|
|
442
|
+
* @param transactions The transactions to be checked
|
|
443
|
+
*
|
|
444
|
+
*/
|
|
445
|
+
batchCheckTransactions(transactions) {
|
|
446
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
447
|
+
let transactionPayloads = [];
|
|
448
|
+
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
449
|
+
yield TransactionService.checkTransactionsBatch(this.getId(), transactionPayloads);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Batch uncheck [[Transactions]] on the Book.
|
|
454
|
+
*
|
|
455
|
+
* @param transactions The transactions to be unchecked
|
|
456
|
+
*
|
|
457
|
+
*/
|
|
458
|
+
batchUncheckTransactions(transactions) {
|
|
459
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
460
|
+
let transactionPayloads = [];
|
|
461
|
+
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
462
|
+
yield TransactionService.uncheckTransactionsBatch(this.getId(), transactionPayloads);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Batch trash [[Transactions]] on the Book.
|
|
467
|
+
*
|
|
468
|
+
* @param transactions The transactions to be trashed
|
|
469
|
+
*
|
|
470
|
+
* @param trashChecked True to also trash checked transactions
|
|
471
|
+
*
|
|
422
472
|
*/
|
|
423
|
-
batchTrashTransactions(transactions) {
|
|
473
|
+
batchTrashTransactions(transactions, trashChecked) {
|
|
424
474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
425
475
|
let transactionPayloads = [];
|
|
426
476
|
transactions.forEach(tx => transactionPayloads.push(tx.json()));
|
|
427
|
-
yield TransactionService.trashTransactionsBatch(this.getId(), transactionPayloads);
|
|
477
|
+
yield TransactionService.trashTransactionsBatch(this.getId(), transactionPayloads, trashChecked);
|
|
428
478
|
});
|
|
429
479
|
}
|
|
430
480
|
/**
|
|
@@ -28,16 +28,29 @@ export function createTransactionsBatch(bookId, transactions) {
|
|
|
28
28
|
return transactionList != null && transactionList.items != null ? transactionList.items : [];
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
export function
|
|
31
|
+
export function updateTransactionsBatch(bookId, transactions, updateChecked) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const payload = { items: transactions };
|
|
34
|
+
yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('PUT').setPayload(payload).addParam('updateChecked', updateChecked).fetch();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function checkTransactionsBatch(bookId, transactions) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const payload = { items: transactions };
|
|
40
|
+
yield new HttpBooksApiV5Request(`${bookId}/transactions/check/batch`).setMethod('PATCH').setPayload(payload).fetch();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function uncheckTransactionsBatch(bookId, transactions) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const payload = { items: transactions };
|
|
46
|
+
yield new HttpBooksApiV5Request(`${bookId}/transactions/uncheck/batch`).setMethod('PATCH').setPayload(payload).fetch();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function trashTransactionsBatch(bookId, transactions, trashChecked) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let transactionList = { items: transactions };
|
|
52
|
+
const payload = transactionList;
|
|
53
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/trash/batch`).setMethod('PATCH').setPayload(payload).addParam('trashChecked', trashChecked).fetch();
|
|
41
54
|
transactionList = yield response.data;
|
|
42
55
|
});
|
|
43
56
|
}
|