bkper-js 1.0.0 → 1.1.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/model/File.js CHANGED
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.File = void 0;
36
- const FileService = __importStar(require("../service/file-service"));
10
+ import * as FileService from '../service/file-service.js';
37
11
  /**
38
12
  *
39
13
  * This class defines a File uploaded to a [[Book]].
@@ -42,7 +16,18 @@ const FileService = __importStar(require("../service/file-service"));
42
16
  *
43
17
  * @public
44
18
  */
45
- class File {
19
+ export class File {
20
+ constructor(book, json) {
21
+ this.book = book;
22
+ this.wrapped = json || {};
23
+ }
24
+ /**
25
+ *
26
+ * @returns The wrapped plain json object
27
+ */
28
+ json() {
29
+ return this.wrapped;
30
+ }
46
31
  /**
47
32
  * Gets the File id
48
33
  */
@@ -86,8 +71,9 @@ class File {
86
71
  */
87
72
  getContent() {
88
73
  return __awaiter(this, void 0, void 0, function* () {
89
- if (this.getId() != null && (this.wrapped == null || this.wrapped.content == null)) {
90
- this.wrapped = yield FileService.getFile(this.book.getId(), this.getId());
74
+ const id = this.getId();
75
+ if (this.getId() != null && (this.wrapped == null || this.wrapped.content == null) && this.book && id) {
76
+ this.wrapped = yield FileService.getFile(this.book.getId(), id);
91
77
  }
92
78
  return this.wrapped.content;
93
79
  });
@@ -119,10 +105,11 @@ class File {
119
105
  */
120
106
  create() {
121
107
  return __awaiter(this, void 0, void 0, function* () {
122
- this.wrapped = yield FileService.createFile(this.book.getId(), this.wrapped);
108
+ if (this.book) {
109
+ this.wrapped = yield FileService.createFile(this.book.getId(), this.wrapped);
110
+ }
123
111
  return this;
124
112
  });
125
113
  }
126
114
  }
127
- exports.File = File;
128
115
  //# sourceMappingURL=File.js.map
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,12 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.Group = void 0;
36
- const GroupService = __importStar(require("../service/group-service"));
37
- const utils_1 = require("../utils");
38
- const Account_1 = require("./Account");
39
- const Utils = __importStar(require("../utils"));
10
+ import * as GroupService from '../service/group-service.js';
11
+ import { normalizeText } from "../utils.js";
12
+ import { Account } from './Account.js';
40
13
  /**
41
14
  * This class defines a Group of [[Accounts]].
42
15
  *
@@ -46,7 +19,11 @@ const Utils = __importStar(require("../utils"));
46
19
  *
47
20
  * @public
48
21
  */
49
- class Group {
22
+ export class Group {
23
+ constructor(book, json) {
24
+ this.book = book;
25
+ this.wrapped = json || {};
26
+ }
50
27
  /**
51
28
  *
52
29
  * @returns The wrapped plain json object
@@ -69,7 +46,7 @@ class Group {
69
46
  return yield this.book.getGroup(this.wrapped.parent.id);
70
47
  }
71
48
  else {
72
- return null;
49
+ return undefined;
73
50
  }
74
51
  });
75
52
  }
@@ -83,7 +60,7 @@ class Group {
83
60
  this.wrapped.parent = { id: group.getId(), name: group.getName(), normalizedName: group.getNormalizedName() };
84
61
  }
85
62
  else {
86
- this.wrapped.parent = null;
63
+ this.wrapped.parent = undefined;
87
64
  }
88
65
  return this;
89
66
  }
@@ -110,7 +87,7 @@ class Group {
110
87
  return this.wrapped.normalizedName;
111
88
  }
112
89
  else {
113
- return (0, utils_1.normalizeText)(this.getName());
90
+ return normalizeText(this.getName());
114
91
  }
115
92
  }
116
93
  /**
@@ -122,10 +99,7 @@ class Group {
122
99
  if (!accountsPlain) {
123
100
  return [];
124
101
  }
125
- let accounts = Utils.wrapObjects(new Account_1.Account(), accountsPlain);
126
- for (const account of accounts) {
127
- account.book = this.book;
128
- }
102
+ let accounts = accountsPlain.map(acc => new Account(this.book, acc));
129
103
  return accounts;
130
104
  });
131
105
  }
@@ -171,7 +145,7 @@ class Group {
171
145
  return value;
172
146
  }
173
147
  }
174
- return null;
148
+ return undefined;
175
149
  }
176
150
  /**
177
151
  * Sets a custom property in the Group.
@@ -186,6 +160,9 @@ class Group {
186
160
  if (this.wrapped.properties == null) {
187
161
  this.wrapped.properties = {};
188
162
  }
163
+ if (!value) {
164
+ value = '';
165
+ }
189
166
  this.wrapped.properties[key] = value;
190
167
  return this;
191
168
  }
@@ -244,5 +221,4 @@ class Group {
244
221
  });
245
222
  }
246
223
  }
247
- exports.Group = Group;
248
224
  //# sourceMappingURL=Group.js.map
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Integration = void 0;
4
1
  /**
5
2
  * This class defines a Integration from an [[User]] to an external service.
6
3
  *
7
4
  * @public
8
5
  */
9
- class Integration {
6
+ export class Integration {
10
7
  constructor(json) {
11
- this.wrapped = json;
8
+ this.wrapped = json || {};
12
9
  }
13
10
  /**
14
11
  * Gets the wrapped plain json object of the Integration.
@@ -76,7 +73,7 @@ class Integration {
76
73
  return value;
77
74
  }
78
75
  }
79
- return null;
76
+ return undefined;
80
77
  }
81
78
  /**
82
79
  * Sets a custom property in the Integration.
@@ -93,6 +90,9 @@ class Integration {
93
90
  if (this.wrapped.properties == null) {
94
91
  this.wrapped.properties = {};
95
92
  }
93
+ if (!value) {
94
+ value = '';
95
+ }
96
96
  this.wrapped.properties[key] = value;
97
97
  return this;
98
98
  }
@@ -108,5 +108,4 @@ class Integration {
108
108
  return this;
109
109
  }
110
110
  }
111
- exports.Integration = Integration;
112
111
  //# sourceMappingURL=Integration.js.map
@@ -1,27 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,13 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
8
  });
33
9
  };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.Transaction = void 0;
36
- const File_1 = require("./File");
37
- const Account_1 = require("./Account");
38
- const TransactionService = __importStar(require("../service/transaction-service"));
39
- const Utils = __importStar(require("../utils"));
40
- const Amount_1 = require("./Amount");
10
+ import { File } from "./File.js";
11
+ import { Account } from "./Account.js";
12
+ import * as TransactionService from '../service/transaction-service.js';
13
+ import * as Utils from '../utils.js';
14
+ import { Amount } from './Amount.js';
41
15
  /**
42
16
  *
43
17
  * This class defines a Transaction between [credit and debit](http://en.wikipedia.org/wiki/Debits_and_credits) [[Accounts]].
@@ -46,7 +20,11 @@ const Amount_1 = require("./Amount");
46
20
  *
47
21
  * @public
48
22
  */
49
- class Transaction {
23
+ export class Transaction {
24
+ constructor(book, json) {
25
+ this.book = book;
26
+ this.wrapped = json || {};
27
+ }
50
28
  /**
51
29
  *
52
30
  * @returns The wrapped plain json object
@@ -72,7 +50,7 @@ class Transaction {
72
50
  * @returns The remote ids of the Transaction.
73
51
  */
74
52
  getRemoteIds() {
75
- return this.wrapped.remoteIds;
53
+ return this.wrapped.remoteIds || [];
76
54
  }
77
55
  /**
78
56
  * Add a remote id to the Transaction.
@@ -123,13 +101,13 @@ class Transaction {
123
101
  * @returns All #hashtags used on the transaction.
124
102
  */
125
103
  getTags() {
126
- return this.wrapped.tags;
104
+ return this.wrapped.tags || [];
127
105
  }
128
106
  /**
129
107
  * @returns All urls of the transaction.
130
108
  */
131
109
  getUrls() {
132
- return this.wrapped.urls;
110
+ return this.wrapped.urls || [];
133
111
  }
134
112
  /**
135
113
  * Sets the Transaction urls. Url starts with https://
@@ -139,7 +117,7 @@ class Transaction {
139
117
  * @returns This Transaction, for chainning.
140
118
  */
141
119
  setUrls(urls) {
142
- this.wrapped.urls = null;
120
+ this.wrapped.urls = undefined;
143
121
  if (urls) {
144
122
  urls.forEach(url => {
145
123
  this.addUrl(url);
@@ -168,12 +146,7 @@ class Transaction {
168
146
  */
169
147
  getFiles() {
170
148
  if (this.wrapped.files && this.wrapped.files.length > 0) {
171
- const files = Utils.wrapObjects(new File_1.File(), this.wrapped.files);
172
- if (files != null) {
173
- for (const file of files) {
174
- file.book = this.book;
175
- }
176
- }
149
+ const files = this.wrapped.files.map(file => new File(this.book, file));
177
150
  return files;
178
151
  }
179
152
  else {
@@ -196,11 +169,10 @@ class Transaction {
196
169
  this.wrapped.files = [];
197
170
  }
198
171
  //Make sure file is already created
199
- if (file.getId() == null || file.book.getId() != this.book.getId()) {
200
- file.book = this.book;
172
+ if (file.getId() == null) {
201
173
  file = yield file.create();
202
174
  }
203
- this.wrapped.files.push(file.wrapped);
175
+ this.wrapped.files.push(file.json());
204
176
  return this;
205
177
  });
206
178
  }
@@ -246,7 +218,7 @@ class Transaction {
246
218
  return value;
247
219
  }
248
220
  }
249
- return null;
221
+ return undefined;
250
222
  }
251
223
  /**
252
224
  * Gets the custom properties keys stored in this Transaction.
@@ -279,6 +251,9 @@ class Transaction {
279
251
  if (this.wrapped.properties == null) {
280
252
  this.wrapped.properties = {};
281
253
  }
254
+ if (!value) {
255
+ value = '';
256
+ }
282
257
  this.wrapped.properties[key] = value;
283
258
  return this;
284
259
  }
@@ -300,7 +275,7 @@ class Transaction {
300
275
  getCreditAccount() {
301
276
  return __awaiter(this, void 0, void 0, function* () {
302
277
  if (!this.wrapped.creditAccount) {
303
- return null;
278
+ return undefined;
304
279
  }
305
280
  return yield this.book.getAccount(this.wrapped.creditAccount.id);
306
281
  });
@@ -310,8 +285,9 @@ class Transaction {
310
285
  */
311
286
  getCreditAccountName() {
312
287
  return __awaiter(this, void 0, void 0, function* () {
288
+ var _a;
313
289
  if ((yield this.getCreditAccount()) != null) {
314
- return (yield this.getCreditAccount()).getName();
290
+ return (_a = (yield this.getCreditAccount())) === null || _a === void 0 ? void 0 : _a.getName();
315
291
  }
316
292
  else {
317
293
  return "";
@@ -327,7 +303,7 @@ class Transaction {
327
303
  * @returns This Transaction, for chainning.
328
304
  */
329
305
  setCreditAccount(account) {
330
- if (account instanceof Account_1.Account) {
306
+ if (account instanceof Account) {
331
307
  if (account != null && account.getId() != null) {
332
308
  this.wrapped.creditAccount = account.json();
333
309
  }
@@ -358,7 +334,7 @@ class Transaction {
358
334
  getDebitAccount() {
359
335
  return __awaiter(this, void 0, void 0, function* () {
360
336
  if (!this.wrapped.debitAccount) {
361
- return null;
337
+ return undefined;
362
338
  }
363
339
  return yield this.book.getAccount(this.wrapped.debitAccount.id);
364
340
  });
@@ -368,8 +344,9 @@ class Transaction {
368
344
  */
369
345
  getDebitAccountName() {
370
346
  return __awaiter(this, void 0, void 0, function* () {
347
+ var _a;
371
348
  if ((yield this.getDebitAccount()) != null) {
372
- return (yield this.getDebitAccount()).getName();
349
+ return (_a = (yield this.getDebitAccount())) === null || _a === void 0 ? void 0 : _a.getName();
373
350
  }
374
351
  else {
375
352
  return "";
@@ -385,7 +362,7 @@ class Transaction {
385
362
  * @returns This Transaction, for chainning.
386
363
  */
387
364
  setDebitAccount(account) {
388
- if (account instanceof Account_1.Account) {
365
+ if (account instanceof Account) {
389
366
  if (account != null && account.getId() != null) {
390
367
  this.wrapped.debitAccount = account.json();
391
368
  }
@@ -413,7 +390,7 @@ class Transaction {
413
390
  * @returns The amount of the transaction.
414
391
  */
415
392
  getAmount() {
416
- return this.wrapped.amount != null && this.wrapped.amount.trim() != '' ? new Amount_1.Amount(this.wrapped.amount) : null;
393
+ return this.wrapped.amount != null && this.wrapped.amount.trim() != '' ? new Amount(this.wrapped.amount) : undefined;
417
394
  }
418
395
  /**
419
396
  *
@@ -427,9 +404,9 @@ class Transaction {
427
404
  this.wrapped.amount = amount.toString();
428
405
  return this;
429
406
  }
430
- amount = new Amount_1.Amount(amount);
407
+ amount = new Amount(amount);
431
408
  if (amount.eq(0)) {
432
- this.wrapped.amount = null;
409
+ this.wrapped.amount = undefined;
433
410
  return this;
434
411
  }
435
412
  this.wrapped.amount = amount.abs().toString();
@@ -443,10 +420,10 @@ class Transaction {
443
420
  getCreditAmount(account) {
444
421
  return __awaiter(this, void 0, void 0, function* () {
445
422
  let accountObject = yield this.getAccount_(account);
446
- if (this.isCredit(accountObject)) {
423
+ if (yield this.isCredit(accountObject)) {
447
424
  return this.getAmount();
448
425
  }
449
- return null;
426
+ return undefined;
450
427
  });
451
428
  }
452
429
  /**
@@ -457,10 +434,10 @@ class Transaction {
457
434
  getDebitAmount(account) {
458
435
  return __awaiter(this, void 0, void 0, function* () {
459
436
  let accountObject = yield this.getAccount_(account);
460
- if (this.isDebit(accountObject)) {
437
+ if (yield this.isDebit(accountObject)) {
461
438
  return this.getAmount();
462
439
  }
463
- return null;
440
+ return undefined;
464
441
  });
465
442
  }
466
443
  /**
@@ -471,13 +448,13 @@ class Transaction {
471
448
  getOtherAccount(account) {
472
449
  return __awaiter(this, void 0, void 0, function* () {
473
450
  let accountObject = yield this.getAccount_(account);
474
- if (this.isCredit(accountObject)) {
451
+ if (yield this.isCredit(accountObject)) {
475
452
  return yield this.getDebitAccount();
476
453
  }
477
- if (this.isDebit(accountObject)) {
454
+ if (yield this.isDebit(accountObject)) {
478
455
  return yield this.getCreditAccount();
479
456
  }
480
- return null;
457
+ return undefined;
481
458
  });
482
459
  }
483
460
  /**
@@ -505,7 +482,8 @@ class Transaction {
505
482
  */
506
483
  isCredit(account) {
507
484
  return __awaiter(this, void 0, void 0, function* () {
508
- return (yield this.getCreditAccount()) != null && account != null && (yield this.getCreditAccount()).getNormalizedName() == account.getNormalizedName();
485
+ var _a;
486
+ return (yield this.getCreditAccount()) != null && account != null && ((_a = (yield this.getCreditAccount())) === null || _a === void 0 ? void 0 : _a.getNormalizedName()) == account.getNormalizedName();
509
487
  });
510
488
  }
511
489
  /**
@@ -516,13 +494,14 @@ class Transaction {
516
494
  */
517
495
  isDebit(account) {
518
496
  return __awaiter(this, void 0, void 0, function* () {
519
- return (yield this.getDebitAccount()) != null && account != null && (yield this.getDebitAccount()).getNormalizedName() == account.getNormalizedName();
497
+ var _a;
498
+ return (yield this.getDebitAccount()) != null && account != null && ((_a = (yield this.getDebitAccount())) === null || _a === void 0 ? void 0 : _a.getNormalizedName()) == account.getNormalizedName();
520
499
  });
521
500
  }
522
501
  /** @internal */
523
502
  getAccount_(account) {
524
503
  return __awaiter(this, void 0, void 0, function* () {
525
- if (account == null || account instanceof Account_1.Account) {
504
+ if (account == null || account instanceof Account) {
526
505
  return account;
527
506
  }
528
507
  return yield this.book.getAccount(account);
@@ -609,11 +588,11 @@ class Transaction {
609
588
  //EVOLVED BALANCES
610
589
  /** @internal */
611
590
  getCaEvolvedBalance_() {
612
- return this.wrapped.creditAccount != null && this.wrapped.creditAccount.balance != null ? new Amount_1.Amount(this.wrapped.creditAccount.balance) : null;
591
+ return this.wrapped.creditAccount != null && this.wrapped.creditAccount.balance != null ? new Amount(this.wrapped.creditAccount.balance) : undefined;
613
592
  }
614
593
  /** @internal */
615
594
  getDaEvolvedBalance_() {
616
- return this.wrapped.debitAccount != null && this.wrapped.debitAccount.balance != null ? new Amount_1.Amount(this.wrapped.debitAccount.balance) : null;
595
+ return this.wrapped.debitAccount != null && this.wrapped.debitAccount.balance != null ? new Amount(this.wrapped.debitAccount.balance) : undefined;
617
596
  }
618
597
  /**
619
598
  * Gets the balance that the [[Account]] has at that day, when listing transactions of that Account.
@@ -635,12 +614,12 @@ class Transaction {
635
614
  if (accountBalance != null) {
636
615
  if (!raw) {
637
616
  var account = isCa ? yield this.getCreditAccount() : yield this.getDebitAccount();
638
- accountBalance = Utils.getRepresentativeValue(accountBalance, account.isCredit());
617
+ accountBalance = Utils.getRepresentativeValue(accountBalance, account === null || account === void 0 ? void 0 : account.isCredit());
639
618
  }
640
619
  return Utils.round(accountBalance, this.book.getFractionDigits());
641
620
  }
642
621
  else {
643
- return null;
622
+ return undefined;
644
623
  }
645
624
  });
646
625
  }
@@ -650,7 +629,7 @@ class Transaction {
650
629
  create() {
651
630
  return __awaiter(this, void 0, void 0, function* () {
652
631
  let operation = yield TransactionService.createTransaction(this.book.getId(), this.wrapped);
653
- this.wrapped = operation.transaction;
632
+ this.wrapped = operation.transaction || {};
654
633
  return this;
655
634
  });
656
635
  }
@@ -660,7 +639,7 @@ class Transaction {
660
639
  update() {
661
640
  return __awaiter(this, void 0, void 0, function* () {
662
641
  let operation = yield TransactionService.updateTransaction(this.book.getId(), this.wrapped);
663
- this.wrapped = operation.transaction;
642
+ this.wrapped = operation.transaction || {};
664
643
  return this;
665
644
  });
666
645
  }
@@ -669,8 +648,9 @@ class Transaction {
669
648
  */
670
649
  check() {
671
650
  return __awaiter(this, void 0, void 0, function* () {
651
+ var _a;
672
652
  let operation = yield TransactionService.checkTransaction(this.book.getId(), this.wrapped);
673
- this.wrapped.checked = operation.transaction.checked;
653
+ this.wrapped.checked = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.checked;
674
654
  return this;
675
655
  });
676
656
  }
@@ -679,8 +659,9 @@ class Transaction {
679
659
  */
680
660
  uncheck() {
681
661
  return __awaiter(this, void 0, void 0, function* () {
662
+ var _a;
682
663
  let operation = yield TransactionService.uncheckTransaction(this.book.getId(), this.wrapped);
683
- this.wrapped.checked = operation.transaction.checked;
664
+ this.wrapped.checked = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.checked;
684
665
  return this;
685
666
  });
686
667
  }
@@ -690,7 +671,7 @@ class Transaction {
690
671
  post() {
691
672
  return __awaiter(this, void 0, void 0, function* () {
692
673
  let operation = yield TransactionService.postTransaction(this.book.getId(), this.wrapped);
693
- this.wrapped = operation.transaction;
674
+ this.wrapped = operation.transaction || {};
694
675
  return this;
695
676
  });
696
677
  }
@@ -699,8 +680,9 @@ class Transaction {
699
680
  */
700
681
  remove() {
701
682
  return __awaiter(this, void 0, void 0, function* () {
683
+ var _a;
702
684
  let operation = yield TransactionService.trashTransaction(this.book.getId(), this.wrapped);
703
- this.wrapped.trashed = operation.transaction.trashed;
685
+ this.wrapped.trashed = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.trashed;
704
686
  return this;
705
687
  });
706
688
  }
@@ -709,11 +691,11 @@ class Transaction {
709
691
  */
710
692
  restore() {
711
693
  return __awaiter(this, void 0, void 0, function* () {
694
+ var _a;
712
695
  let operation = yield TransactionService.restoreTransaction(this.book.getId(), this.wrapped);
713
- this.wrapped.trashed = operation.transaction.trashed;
696
+ this.wrapped.trashed = (_a = operation.transaction) === null || _a === void 0 ? void 0 : _a.trashed;
714
697
  return this;
715
698
  });
716
699
  }
717
700
  }
718
- exports.Transaction = Transaction;
719
701
  //# sourceMappingURL=Transaction.js.map