bkper-js 2.14.1 → 2.15.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/CHANGELOG.md CHANGED
@@ -9,6 +9,7 @@ See what's new and what has changed in bkper-js
9
9
  - Files attached to transactions are now created internally when transaction is persisted
10
10
  - Added `Transaction.removeFile`
11
11
  - Added `Book.countTransactions`
12
+ - Added `Book.remove`
12
13
 
13
14
  **September 2025**
14
15
 
package/lib/index.d.ts CHANGED
@@ -1909,6 +1909,14 @@ export declare class Book extends Resource<bkper.Book> {
1909
1909
  * @returns The updated Book object
1910
1910
  */
1911
1911
  update(): Promise<Book>;
1912
+ /**
1913
+ * Warning!
1914
+ *
1915
+ * Deletes this Book and all its data (transactions, accounts, groups). Book owner only.
1916
+ *
1917
+ * @returns This Book after deletion
1918
+ */
1919
+ remove(): Promise<Book>;
1912
1920
  /**
1913
1921
  * Create a [[BalancesReport]] based on query.
1914
1922
  *
@@ -3515,19 +3523,19 @@ export declare class Transaction extends Resource<bkper.Transaction> {
3515
3523
  /**
3516
3524
  * Sets the credit/origin [[Account]] of this Transaction. Same as from()
3517
3525
  *
3518
- * @param account - The Account object
3526
+ * @param account - The Account object, or null/undefined to clear
3519
3527
  *
3520
3528
  * @returns This Transaction, for chaining
3521
3529
  */
3522
- setCreditAccount(account: Account | bkper.Account): Transaction;
3530
+ setCreditAccount(account: Account | bkper.Account | null | undefined): Transaction;
3523
3531
  /**
3524
3532
  * Sets the credit/origin [[Account]] of this Transaction. Same as setCreditAccount()
3525
3533
  *
3526
- * @param account - The Account object
3534
+ * @param account - The Account object, or null/undefined to clear
3527
3535
  *
3528
3536
  * @returns This Transaction, for chaining
3529
3537
  */
3530
- from(account: Account | bkper.Account): Transaction;
3538
+ from(account: Account | bkper.Account | null | undefined): Transaction;
3531
3539
  /**
3532
3540
  * Gets the debit account associated with this Transaction. Same as destination account
3533
3541
  *
@@ -3543,19 +3551,19 @@ export declare class Transaction extends Resource<bkper.Transaction> {
3543
3551
  /**
3544
3552
  * Sets the debit/destination [[Account]] of this Transaction. Same as to()
3545
3553
  *
3546
- * @param account - The Account object
3554
+ * @param account - The Account object, or null/undefined to clear
3547
3555
  *
3548
3556
  * @returns This Transaction, for chaining
3549
3557
  */
3550
- setDebitAccount(account: Account | bkper.Account): Transaction;
3558
+ setDebitAccount(account: Account | bkper.Account | null | undefined): Transaction;
3551
3559
  /**
3552
3560
  * Sets the debit/destination [[Account]] of this Transaction. Same as setDebitAccount()
3553
3561
  *
3554
- * @param account - The Account object
3562
+ * @param account - The Account object, or null/undefined to clear
3555
3563
  *
3556
3564
  * @returns This Transaction, for chaining
3557
3565
  */
3558
- to(account: Account | bkper.Account): Transaction;
3566
+ to(account: Account | bkper.Account | null | undefined): Transaction;
3559
3567
  /**
3560
3568
  * Gets the amount of this Transaction.
3561
3569
  *
package/lib/model/Book.js CHANGED
@@ -1172,6 +1172,19 @@ export class Book extends Resource {
1172
1172
  return this;
1173
1173
  });
1174
1174
  }
1175
+ /**
1176
+ * Warning!
1177
+ *
1178
+ * Deletes this Book and all its data (transactions, accounts, groups). Book owner only.
1179
+ *
1180
+ * @returns This Book after deletion
1181
+ */
1182
+ remove() {
1183
+ return __awaiter(this, void 0, void 0, function* () {
1184
+ this.payload = yield BookService.deleteBook(this.getId(), this.getConfig());
1185
+ return this;
1186
+ });
1187
+ }
1175
1188
  /**
1176
1189
  * Create a [[BalancesReport]] based on query.
1177
1190
  *
@@ -431,18 +431,22 @@ export class Transaction extends Resource {
431
431
  /**
432
432
  * Sets the credit/origin [[Account]] of this Transaction. Same as from()
433
433
  *
434
- * @param account - The Account object
434
+ * @param account - The Account object, or null/undefined to clear
435
435
  *
436
436
  * @returns This Transaction, for chaining
437
437
  */
438
438
  setCreditAccount(account) {
439
+ if (account == null) {
440
+ this.payload.creditAccount = undefined;
441
+ return this;
442
+ }
439
443
  if (account instanceof Account) {
440
- if (account != null && account.getId() != null) {
444
+ if (account.getId() != null) {
441
445
  this.payload.creditAccount = account.json();
442
446
  }
443
447
  }
444
448
  else {
445
- if (account != null && account.id != null) {
449
+ if (account.id != null) {
446
450
  this.payload.creditAccount = account;
447
451
  }
448
452
  }
@@ -451,7 +455,7 @@ export class Transaction extends Resource {
451
455
  /**
452
456
  * Sets the credit/origin [[Account]] of this Transaction. Same as setCreditAccount()
453
457
  *
454
- * @param account - The Account object
458
+ * @param account - The Account object, or null/undefined to clear
455
459
  *
456
460
  * @returns This Transaction, for chaining
457
461
  */
@@ -490,18 +494,22 @@ export class Transaction extends Resource {
490
494
  /**
491
495
  * Sets the debit/destination [[Account]] of this Transaction. Same as to()
492
496
  *
493
- * @param account - The Account object
497
+ * @param account - The Account object, or null/undefined to clear
494
498
  *
495
499
  * @returns This Transaction, for chaining
496
500
  */
497
501
  setDebitAccount(account) {
502
+ if (account == null) {
503
+ this.payload.debitAccount = undefined;
504
+ return this;
505
+ }
498
506
  if (account instanceof Account) {
499
- if (account != null && account.getId() != null) {
507
+ if (account.getId() != null) {
500
508
  this.payload.debitAccount = { id: account.getId(), name: account.getName() };
501
509
  }
502
510
  }
503
511
  else {
504
- if (account != null && account.id != null) {
512
+ if (account.id != null) {
505
513
  this.payload.debitAccount = { id: account.id, name: account.name };
506
514
  }
507
515
  }
@@ -510,7 +518,7 @@ export class Transaction extends Resource {
510
518
  /**
511
519
  * Sets the debit/destination [[Account]] of this Transaction. Same as setDebitAccount()
512
520
  *
513
- * @param account - The Account object
521
+ * @param account - The Account object, or null/undefined to clear
514
522
  *
515
523
  * @returns This Transaction, for chaining
516
524
  */
@@ -74,4 +74,10 @@ export function copyBook(bookId, name, copyTransactions, fromDate, config) {
74
74
  return response.data;
75
75
  });
76
76
  }
77
+ export function deleteBook(bookId, config) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const response = yield new HttpBooksApiV5Request(`${bookId}`, config).setMethod('DELETE').fetch();
80
+ return response.data;
81
+ });
82
+ }
77
83
  //# sourceMappingURL=book-service.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.14.1",
3
+ "version": "2.15.1",
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
  "peerDependencies": {
38
- "@bkper/bkper-api-types": "^5.29.0"
38
+ "@bkper/bkper-api-types": "^5.30.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "big.js": "^6.0.3",