bkper-js 1.43.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 +3 -1
- package/lib/model/Book.js +7 -3
- package/lib/service/transaction-service.js +8 -10
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -973,8 +973,10 @@ export declare class Book {
|
|
|
973
973
|
*
|
|
974
974
|
* @param updateChecked True to also update checked transactions
|
|
975
975
|
*
|
|
976
|
+
* @returns The updated draft Transactions
|
|
977
|
+
*
|
|
976
978
|
*/
|
|
977
|
-
batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean): Promise<
|
|
979
|
+
batchUpdateTransactions(transactions: Transaction[], updateChecked?: boolean): Promise<Transaction[]>;
|
|
978
980
|
/**
|
|
979
981
|
* Batch check [[Transactions]] on the Book.
|
|
980
982
|
*
|
package/lib/model/Book.js
CHANGED
|
@@ -428,12 +428,16 @@ export class Book {
|
|
|
428
428
|
*
|
|
429
429
|
* @param updateChecked True to also update checked transactions
|
|
430
430
|
*
|
|
431
|
+
* @returns The updated draft Transactions
|
|
432
|
+
*
|
|
431
433
|
*/
|
|
432
434
|
batchUpdateTransactions(transactions, updateChecked) {
|
|
433
435
|
return __awaiter(this, void 0, void 0, function* () {
|
|
434
|
-
let
|
|
435
|
-
transactions.forEach(tx =>
|
|
436
|
-
yield TransactionService.updateTransactionsBatch(this.getId(),
|
|
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;
|
|
437
441
|
});
|
|
438
442
|
}
|
|
439
443
|
/**
|
|
@@ -16,22 +16,20 @@ 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
|
-
var payload = transactionList;
|
|
23
|
-
let response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`)
|
|
24
|
-
.setMethod('POST')
|
|
25
|
-
.setPayload(payload)
|
|
26
|
-
.fetch();
|
|
19
|
+
let transactionList = { items: transactions };
|
|
20
|
+
const payload = transactionList;
|
|
21
|
+
const response = yield new HttpBooksApiV5Request(`${bookId}/transactions/batch`).setMethod('POST').setPayload(payload).fetch();
|
|
27
22
|
transactionList = yield response.data;
|
|
28
23
|
return transactionList != null && transactionList.items != null ? transactionList.items : [];
|
|
29
24
|
});
|
|
30
25
|
}
|
|
31
26
|
export function updateTransactionsBatch(bookId, transactions, updateChecked) {
|
|
32
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
|
|
34
|
-
|
|
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();
|
|
31
|
+
transactionList = yield response.data;
|
|
32
|
+
return transactionList != null && transactionList.items != null ? transactionList.items : [];
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
export function checkTransactionsBatch(bookId, transactions) {
|