bkper-js 2.15.0 → 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/lib/index.d.ts CHANGED
@@ -3523,19 +3523,19 @@ export declare class Transaction extends Resource<bkper.Transaction> {
3523
3523
  /**
3524
3524
  * Sets the credit/origin [[Account]] of this Transaction. Same as from()
3525
3525
  *
3526
- * @param account - The Account object
3526
+ * @param account - The Account object, or null/undefined to clear
3527
3527
  *
3528
3528
  * @returns This Transaction, for chaining
3529
3529
  */
3530
- setCreditAccount(account: Account | bkper.Account): Transaction;
3530
+ setCreditAccount(account: Account | bkper.Account | null | undefined): Transaction;
3531
3531
  /**
3532
3532
  * Sets the credit/origin [[Account]] of this Transaction. Same as setCreditAccount()
3533
3533
  *
3534
- * @param account - The Account object
3534
+ * @param account - The Account object, or null/undefined to clear
3535
3535
  *
3536
3536
  * @returns This Transaction, for chaining
3537
3537
  */
3538
- from(account: Account | bkper.Account): Transaction;
3538
+ from(account: Account | bkper.Account | null | undefined): Transaction;
3539
3539
  /**
3540
3540
  * Gets the debit account associated with this Transaction. Same as destination account
3541
3541
  *
@@ -3551,19 +3551,19 @@ export declare class Transaction extends Resource<bkper.Transaction> {
3551
3551
  /**
3552
3552
  * Sets the debit/destination [[Account]] of this Transaction. Same as to()
3553
3553
  *
3554
- * @param account - The Account object
3554
+ * @param account - The Account object, or null/undefined to clear
3555
3555
  *
3556
3556
  * @returns This Transaction, for chaining
3557
3557
  */
3558
- setDebitAccount(account: Account | bkper.Account): Transaction;
3558
+ setDebitAccount(account: Account | bkper.Account | null | undefined): Transaction;
3559
3559
  /**
3560
3560
  * Sets the debit/destination [[Account]] of this Transaction. Same as setDebitAccount()
3561
3561
  *
3562
- * @param account - The Account object
3562
+ * @param account - The Account object, or null/undefined to clear
3563
3563
  *
3564
3564
  * @returns This Transaction, for chaining
3565
3565
  */
3566
- to(account: Account | bkper.Account): Transaction;
3566
+ to(account: Account | bkper.Account | null | undefined): Transaction;
3567
3567
  /**
3568
3568
  * Gets the amount of this Transaction.
3569
3569
  *
@@ -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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper-js",
3
- "version": "2.15.0",
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",