bkper-js 1.47.2 → 1.47.3
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 +882 -357
- package/lib/model/Account.js +86 -42
- package/lib/model/Agent.js +6 -0
- package/lib/model/Amount.js +72 -13
- package/lib/model/App.js +77 -26
- package/lib/model/BalancesReport.js +11 -5
- package/lib/model/Bkper.js +2 -2
- package/lib/model/Book.js +164 -94
- package/lib/model/BotResponse.js +13 -3
- package/lib/model/Collection.js +16 -2
- package/lib/model/Connection.js +8 -6
- package/lib/model/Conversation.js +9 -2
- package/lib/model/Event.js +18 -0
- package/lib/model/EventList.js +10 -5
- package/lib/model/File.js +31 -12
- package/lib/model/Group.js +75 -33
- package/lib/model/Integration.js +4 -2
- package/lib/model/Message.js +18 -5
- package/lib/model/Query.js +18 -4
- package/lib/model/Template.js +2 -0
- package/lib/model/Transaction.js +165 -81
- package/lib/model/TransactionList.js +14 -7
- package/lib/model/User.js +7 -1
- package/package.json +1 -1
package/lib/model/Transaction.js
CHANGED
|
@@ -28,51 +28,65 @@ export class Transaction {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
+
* Gets the JSON representation of the transaction.
|
|
32
|
+
*
|
|
31
33
|
* @returns An immutable copy of the json payload
|
|
32
34
|
*/
|
|
33
35
|
json() {
|
|
34
36
|
return Object.assign({}, this.payload);
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
|
-
*
|
|
39
|
+
* Gets the book associated with this transaction.
|
|
40
|
+
*
|
|
41
|
+
* @returns The book of the Transaction
|
|
38
42
|
*/
|
|
39
43
|
getBook() {
|
|
40
44
|
return this.book;
|
|
41
45
|
}
|
|
42
46
|
/**
|
|
43
|
-
*
|
|
47
|
+
* Gets the unique identifier of the transaction.
|
|
48
|
+
*
|
|
49
|
+
* @returns The id of the Transaction
|
|
44
50
|
*/
|
|
45
51
|
getId() {
|
|
46
52
|
return this.payload.id;
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
55
|
+
* Gets the unique identifier of the agent that created this transaction.
|
|
56
|
+
*
|
|
49
57
|
* @returns The id of the agent that created this transaction
|
|
50
58
|
*/
|
|
51
59
|
getAgentId() {
|
|
52
60
|
return this.payload.agentId;
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
63
|
+
* Gets the name of the agent that created this transaction.
|
|
64
|
+
*
|
|
55
65
|
* @returns The name of the agent that created this transaction
|
|
56
66
|
*/
|
|
57
67
|
getAgentName() {
|
|
58
68
|
return this.payload.agentName;
|
|
59
69
|
}
|
|
60
70
|
/**
|
|
71
|
+
* Gets the logo URL of the agent that created this transaction.
|
|
72
|
+
*
|
|
61
73
|
* @returns The logo of the agent that created this transaction
|
|
62
74
|
*/
|
|
63
75
|
getAgentLogoUrl() {
|
|
64
76
|
return this.payload.agentLogo;
|
|
65
77
|
}
|
|
66
78
|
/**
|
|
79
|
+
* Gets the dark mode logo URL of the agent that created this transaction.
|
|
80
|
+
*
|
|
67
81
|
* @returns The logo of the agent that created this transaction in dark mode
|
|
68
82
|
*/
|
|
69
83
|
getAgentLogoUrlDark() {
|
|
70
84
|
return this.payload.agentLogoDark;
|
|
71
85
|
}
|
|
72
86
|
/**
|
|
73
|
-
* Remote ids are used to avoid duplication.
|
|
87
|
+
* Gets the remote IDs associated with this transaction. Remote ids are used to avoid duplication.
|
|
74
88
|
*
|
|
75
|
-
* @returns The remote ids of the Transaction
|
|
89
|
+
* @returns The remote ids of the Transaction
|
|
76
90
|
*/
|
|
77
91
|
getRemoteIds() {
|
|
78
92
|
return this.payload.remoteIds || [];
|
|
@@ -80,9 +94,9 @@ export class Transaction {
|
|
|
80
94
|
/**
|
|
81
95
|
* Add a remote id to the Transaction.
|
|
82
96
|
*
|
|
83
|
-
* @param remoteId - The remote id to add
|
|
97
|
+
* @param remoteId - The remote id to add
|
|
84
98
|
*
|
|
85
|
-
* @returns This Transaction, for
|
|
99
|
+
* @returns This Transaction, for chaining
|
|
86
100
|
*/
|
|
87
101
|
addRemoteId(remoteId) {
|
|
88
102
|
if (this.payload.remoteIds == null) {
|
|
@@ -94,13 +108,17 @@ export class Transaction {
|
|
|
94
108
|
return this;
|
|
95
109
|
}
|
|
96
110
|
/**
|
|
97
|
-
*
|
|
111
|
+
* Checks if the transaction has been posted to the accounts.
|
|
112
|
+
*
|
|
113
|
+
* @returns True if transaction was already posted to the accounts. False if is still a Draft
|
|
98
114
|
*/
|
|
99
115
|
isPosted() {
|
|
100
116
|
return this.payload.posted;
|
|
101
117
|
}
|
|
102
118
|
/**
|
|
103
|
-
*
|
|
119
|
+
* Checks if the transaction is marked as checked.
|
|
120
|
+
*
|
|
121
|
+
* @returns True if transaction is checked
|
|
104
122
|
*/
|
|
105
123
|
isChecked() {
|
|
106
124
|
return this.payload.checked;
|
|
@@ -108,21 +126,25 @@ export class Transaction {
|
|
|
108
126
|
/**
|
|
109
127
|
* Set the check state of the Transaction.
|
|
110
128
|
*
|
|
111
|
-
* @param checked - The check state
|
|
129
|
+
* @param checked - The check state
|
|
112
130
|
*
|
|
113
|
-
* @returns This Transaction, for
|
|
131
|
+
* @returns This Transaction, for chaining
|
|
114
132
|
*/
|
|
115
133
|
setChecked(checked) {
|
|
116
134
|
this.payload.checked = checked;
|
|
117
135
|
return this;
|
|
118
136
|
}
|
|
119
137
|
/**
|
|
120
|
-
*
|
|
138
|
+
* Checks if the transaction is in the trash.
|
|
139
|
+
*
|
|
140
|
+
* @returns True if transaction is in trash
|
|
121
141
|
*/
|
|
122
142
|
isTrashed() {
|
|
123
143
|
return this.payload.trashed;
|
|
124
144
|
}
|
|
125
145
|
/**
|
|
146
|
+
* Checks if the transaction is locked by the book's lock or closing date.
|
|
147
|
+
*
|
|
126
148
|
* @returns True if a transaction is locked by the book lock/closing date
|
|
127
149
|
*/
|
|
128
150
|
isLocked() {
|
|
@@ -131,13 +153,17 @@ export class Transaction {
|
|
|
131
153
|
return lockOrClosingDate != null && (Utils.getIsoDateValue(lockOrClosingDate) >= Utils.getIsoDateValue(date));
|
|
132
154
|
}
|
|
133
155
|
/**
|
|
134
|
-
*
|
|
156
|
+
* Gets all hashtags used in the transaction.
|
|
157
|
+
*
|
|
158
|
+
* @returns All #hashtags used on the transaction
|
|
135
159
|
*/
|
|
136
160
|
getTags() {
|
|
137
161
|
return this.payload.tags || [];
|
|
138
162
|
}
|
|
139
163
|
/**
|
|
140
|
-
*
|
|
164
|
+
* Gets all URLs associated with the transaction.
|
|
165
|
+
*
|
|
166
|
+
* @returns All urls of the transaction
|
|
141
167
|
*/
|
|
142
168
|
getUrls() {
|
|
143
169
|
return this.payload.urls || [];
|
|
@@ -145,9 +171,9 @@ export class Transaction {
|
|
|
145
171
|
/**
|
|
146
172
|
* Sets the Transaction urls. Url starts with https://
|
|
147
173
|
*
|
|
148
|
-
* @param urls - The urls array
|
|
174
|
+
* @param urls - The urls array
|
|
149
175
|
*
|
|
150
|
-
* @returns This Transaction, for
|
|
176
|
+
* @returns This Transaction, for chaining
|
|
151
177
|
*/
|
|
152
178
|
setUrls(urls) {
|
|
153
179
|
this.payload.urls = undefined;
|
|
@@ -161,9 +187,9 @@ export class Transaction {
|
|
|
161
187
|
/**
|
|
162
188
|
* Add a url to the Transaction. Url starts with https://
|
|
163
189
|
*
|
|
164
|
-
* @param url - The url to add
|
|
190
|
+
* @param url - The url to add
|
|
165
191
|
*
|
|
166
|
-
* @returns This Transaction, for
|
|
192
|
+
* @returns This Transaction, for chaining
|
|
167
193
|
*/
|
|
168
194
|
addUrl(url) {
|
|
169
195
|
if (this.payload.urls == null) {
|
|
@@ -175,7 +201,9 @@ export class Transaction {
|
|
|
175
201
|
return this;
|
|
176
202
|
}
|
|
177
203
|
/**
|
|
178
|
-
*
|
|
204
|
+
* Gets all files attached to the transaction.
|
|
205
|
+
*
|
|
206
|
+
* @returns The files attached to the transaction
|
|
179
207
|
*/
|
|
180
208
|
getFiles() {
|
|
181
209
|
if (this.payload.files && this.payload.files.length > 0) {
|
|
@@ -187,14 +215,13 @@ export class Transaction {
|
|
|
187
215
|
}
|
|
188
216
|
}
|
|
189
217
|
/**
|
|
190
|
-
*
|
|
191
218
|
* Adds a file attachment to the Transaction.
|
|
192
219
|
*
|
|
193
220
|
* Files MUST be previously created in the Book.
|
|
194
221
|
*
|
|
195
222
|
* @param file - The file to add
|
|
196
223
|
*
|
|
197
|
-
* @returns This Transaction, for
|
|
224
|
+
* @returns This Transaction, for chaining
|
|
198
225
|
*/
|
|
199
226
|
addFile(file) {
|
|
200
227
|
if (this.payload.files == null) {
|
|
@@ -205,6 +232,10 @@ export class Transaction {
|
|
|
205
232
|
}
|
|
206
233
|
/**
|
|
207
234
|
* Check if the transaction has the specified tag.
|
|
235
|
+
*
|
|
236
|
+
* @param tag - The tag to check for
|
|
237
|
+
*
|
|
238
|
+
* @returns True if the transaction has the specified tag
|
|
208
239
|
*/
|
|
209
240
|
hasTag(tag) {
|
|
210
241
|
var tags = this.getTags();
|
|
@@ -217,6 +248,8 @@ export class Transaction {
|
|
|
217
248
|
}
|
|
218
249
|
/**
|
|
219
250
|
* Gets the custom properties stored in this Transaction.
|
|
251
|
+
*
|
|
252
|
+
* @returns Object with key/value pair properties
|
|
220
253
|
*/
|
|
221
254
|
getProperties() {
|
|
222
255
|
return this.payload.properties != null ? Object.assign({}, this.payload.properties) : {};
|
|
@@ -226,7 +259,7 @@ export class Transaction {
|
|
|
226
259
|
*
|
|
227
260
|
* @param properties - Object with key/value pair properties
|
|
228
261
|
*
|
|
229
|
-
* @returns This Transaction, for
|
|
262
|
+
* @returns This Transaction, for chaining
|
|
230
263
|
*/
|
|
231
264
|
setProperties(properties) {
|
|
232
265
|
this.payload.properties = Object.assign({}, properties);
|
|
@@ -236,6 +269,8 @@ export class Transaction {
|
|
|
236
269
|
* Gets the property value for given keys. First property found will be retrieved
|
|
237
270
|
*
|
|
238
271
|
* @param keys - The property key
|
|
272
|
+
*
|
|
273
|
+
* @returns The property value or undefined if not found
|
|
239
274
|
*/
|
|
240
275
|
getProperty(...keys) {
|
|
241
276
|
for (let index = 0; index < keys.length; index++) {
|
|
@@ -248,8 +283,10 @@ export class Transaction {
|
|
|
248
283
|
return undefined;
|
|
249
284
|
}
|
|
250
285
|
/**
|
|
251
|
-
|
|
252
|
-
|
|
286
|
+
* Gets the custom properties keys stored in this Transaction.
|
|
287
|
+
*
|
|
288
|
+
* @returns Array of property keys
|
|
289
|
+
*/
|
|
253
290
|
getPropertyKeys() {
|
|
254
291
|
let properties = this.getProperties();
|
|
255
292
|
let propertyKeys = [];
|
|
@@ -269,7 +306,7 @@ export class Transaction {
|
|
|
269
306
|
* @param key - The property key
|
|
270
307
|
* @param value - The property value
|
|
271
308
|
*
|
|
272
|
-
* @returns This Transaction, for
|
|
309
|
+
* @returns This Transaction, for chaining
|
|
273
310
|
*/
|
|
274
311
|
setProperty(key, value) {
|
|
275
312
|
if (key == null || key.trim() == '') {
|
|
@@ -289,15 +326,16 @@ export class Transaction {
|
|
|
289
326
|
*
|
|
290
327
|
* @param key - The property key
|
|
291
328
|
*
|
|
292
|
-
* @returns This Transaction, for
|
|
329
|
+
* @returns This Transaction, for chaining
|
|
293
330
|
*/
|
|
294
331
|
deleteProperty(key) {
|
|
295
332
|
this.setProperty(key, null);
|
|
296
333
|
return this;
|
|
297
334
|
}
|
|
298
|
-
//ORIGIN ACCOUNT
|
|
299
335
|
/**
|
|
300
|
-
*
|
|
336
|
+
* Gets the credit account associated with this Transaction. Same as origin account
|
|
337
|
+
*
|
|
338
|
+
* @returns The credit (origin) account
|
|
301
339
|
*/
|
|
302
340
|
getCreditAccount() {
|
|
303
341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -308,7 +346,9 @@ export class Transaction {
|
|
|
308
346
|
});
|
|
309
347
|
}
|
|
310
348
|
/**
|
|
311
|
-
*
|
|
349
|
+
* Gets the name of this Transaction's credit account.
|
|
350
|
+
*
|
|
351
|
+
* @returns The credit account name
|
|
312
352
|
*/
|
|
313
353
|
getCreditAccountName() {
|
|
314
354
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -322,12 +362,11 @@ export class Transaction {
|
|
|
322
362
|
});
|
|
323
363
|
}
|
|
324
364
|
/**
|
|
365
|
+
* Sets the credit/origin [[Account]] of this Transaction. Same as from()
|
|
325
366
|
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* @param account - Account id, name or object.
|
|
367
|
+
* @param account - The Account object
|
|
329
368
|
*
|
|
330
|
-
* @returns This Transaction, for
|
|
369
|
+
* @returns This Transaction, for chaining
|
|
331
370
|
*/
|
|
332
371
|
setCreditAccount(account) {
|
|
333
372
|
if (account instanceof Account) {
|
|
@@ -343,20 +382,19 @@ export class Transaction {
|
|
|
343
382
|
return this;
|
|
344
383
|
}
|
|
345
384
|
/**
|
|
385
|
+
* Sets the credit/origin [[Account]] of this Transaction. Same as setCreditAccount()
|
|
346
386
|
*
|
|
347
|
-
*
|
|
387
|
+
* @param account - The Account object
|
|
348
388
|
*
|
|
349
|
-
* @
|
|
350
|
-
*
|
|
351
|
-
* @returns This Transaction, for chainning.
|
|
389
|
+
* @returns This Transaction, for chaining
|
|
352
390
|
*/
|
|
353
391
|
from(account) {
|
|
354
392
|
return this.setCreditAccount(account);
|
|
355
393
|
}
|
|
356
|
-
//DESTINATION ACCOUNT
|
|
357
394
|
/**
|
|
358
|
-
*
|
|
395
|
+
* Gets the debit account associated with this Transaction. Same as destination account
|
|
359
396
|
*
|
|
397
|
+
* @returns The debit (destination) account
|
|
360
398
|
*/
|
|
361
399
|
getDebitAccount() {
|
|
362
400
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -367,7 +405,9 @@ export class Transaction {
|
|
|
367
405
|
});
|
|
368
406
|
}
|
|
369
407
|
/**
|
|
370
|
-
*
|
|
408
|
+
* Gets the name of this Transaction's debit account.
|
|
409
|
+
*
|
|
410
|
+
* @returns The debit account name
|
|
371
411
|
*/
|
|
372
412
|
getDebitAccountName() {
|
|
373
413
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -381,12 +421,11 @@ export class Transaction {
|
|
|
381
421
|
});
|
|
382
422
|
}
|
|
383
423
|
/**
|
|
424
|
+
* Sets the debit/destination [[Account]] of this Transaction. Same as to()
|
|
384
425
|
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
* @param account - Account id, name or object.
|
|
426
|
+
* @param account - The Account object
|
|
388
427
|
*
|
|
389
|
-
* @returns This Transaction, for
|
|
428
|
+
* @returns This Transaction, for chaining
|
|
390
429
|
*/
|
|
391
430
|
setDebitAccount(account) {
|
|
392
431
|
if (account instanceof Account) {
|
|
@@ -402,25 +441,27 @@ export class Transaction {
|
|
|
402
441
|
return this;
|
|
403
442
|
}
|
|
404
443
|
/**
|
|
444
|
+
* Sets the debit/destination [[Account]] of this Transaction. Same as setDebitAccount()
|
|
405
445
|
*
|
|
406
|
-
*
|
|
446
|
+
* @param account - The Account object
|
|
407
447
|
*
|
|
408
|
-
* @
|
|
409
|
-
*
|
|
410
|
-
* @returns This Transaction, for chainning.
|
|
448
|
+
* @returns This Transaction, for chaining
|
|
411
449
|
*/
|
|
412
450
|
to(account) {
|
|
413
451
|
return this.setDebitAccount(account);
|
|
414
452
|
}
|
|
415
|
-
//AMOUNT
|
|
416
453
|
/**
|
|
417
|
-
*
|
|
454
|
+
* Gets the amount of this Transaction.
|
|
455
|
+
*
|
|
456
|
+
* @returns The amount of this Transaction
|
|
418
457
|
*/
|
|
419
458
|
getAmount() {
|
|
420
459
|
return this.payload.amount != null && this.payload.amount.trim() != '' ? new Amount(this.payload.amount) : undefined;
|
|
421
460
|
}
|
|
422
461
|
/**
|
|
423
|
-
*
|
|
462
|
+
* Gets the formatted amount of this Transaction according to the Book format.
|
|
463
|
+
*
|
|
464
|
+
* @returns The amount of this Transaction, formatted according to the Book format
|
|
424
465
|
*/
|
|
425
466
|
getAmountFormatted() {
|
|
426
467
|
const amount = this.getAmount();
|
|
@@ -430,10 +471,11 @@ export class Transaction {
|
|
|
430
471
|
return undefined;
|
|
431
472
|
}
|
|
432
473
|
/**
|
|
474
|
+
* Sets the amount of this Transaction.
|
|
433
475
|
*
|
|
434
|
-
*
|
|
476
|
+
* @param amount - The amount to set
|
|
435
477
|
*
|
|
436
|
-
* @returns This Transaction, for
|
|
478
|
+
* @returns This Transaction, for chaining
|
|
437
479
|
*/
|
|
438
480
|
setAmount(amount) {
|
|
439
481
|
if (typeof amount == "string") {
|
|
@@ -450,9 +492,11 @@ export class Transaction {
|
|
|
450
492
|
return this;
|
|
451
493
|
}
|
|
452
494
|
/**
|
|
453
|
-
* Get the absolute amount of this
|
|
495
|
+
* Get the absolute amount of this Transaction if the given account is at the credit side.
|
|
496
|
+
*
|
|
497
|
+
* @param account - The account object, id or name
|
|
454
498
|
*
|
|
455
|
-
* @
|
|
499
|
+
* @returns The credit amount or undefined
|
|
456
500
|
*/
|
|
457
501
|
getCreditAmount(account) {
|
|
458
502
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -464,9 +508,11 @@ export class Transaction {
|
|
|
464
508
|
});
|
|
465
509
|
}
|
|
466
510
|
/**
|
|
467
|
-
* Gets the absolute amount of this
|
|
511
|
+
* Gets the absolute amount of this Transaction if the given account is at the debit side.
|
|
468
512
|
*
|
|
469
|
-
* @param account - The account object, id or name
|
|
513
|
+
* @param account - The account object, id or name
|
|
514
|
+
*
|
|
515
|
+
* @returns The debit amount or undefined
|
|
470
516
|
*/
|
|
471
517
|
getDebitAmount(account) {
|
|
472
518
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -480,7 +526,9 @@ export class Transaction {
|
|
|
480
526
|
/**
|
|
481
527
|
* Gets the [[Account]] at the other side of the transaction given the one in one side.
|
|
482
528
|
*
|
|
483
|
-
* @param account - The account object, id or name
|
|
529
|
+
* @param account - The account object, id or name
|
|
530
|
+
*
|
|
531
|
+
* @returns The account at the other side of the transaction
|
|
484
532
|
*/
|
|
485
533
|
getOtherAccount(account) {
|
|
486
534
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -495,10 +543,11 @@ export class Transaction {
|
|
|
495
543
|
});
|
|
496
544
|
}
|
|
497
545
|
/**
|
|
546
|
+
* The Account name at the other side of this Transaction given the one in one side.
|
|
498
547
|
*
|
|
499
|
-
*
|
|
548
|
+
* @param account - The Account object, id or name
|
|
500
549
|
*
|
|
501
|
-
* @
|
|
550
|
+
* @returns The name of the Account at the other side
|
|
502
551
|
*/
|
|
503
552
|
getOtherAccountName(account) {
|
|
504
553
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -512,10 +561,11 @@ export class Transaction {
|
|
|
512
561
|
});
|
|
513
562
|
}
|
|
514
563
|
/**
|
|
564
|
+
* Tell if the given account is credit on this Transaction
|
|
515
565
|
*
|
|
516
|
-
*
|
|
566
|
+
* @param account - The Account object
|
|
517
567
|
*
|
|
518
|
-
* @
|
|
568
|
+
* @returns True if the account is the credit account
|
|
519
569
|
*/
|
|
520
570
|
isCredit(account) {
|
|
521
571
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -524,10 +574,11 @@ export class Transaction {
|
|
|
524
574
|
});
|
|
525
575
|
}
|
|
526
576
|
/**
|
|
577
|
+
* Tell if the given account is debit on the Transaction
|
|
527
578
|
*
|
|
528
|
-
*
|
|
579
|
+
* @param account - The [[Account]] object
|
|
529
580
|
*
|
|
530
|
-
* @
|
|
581
|
+
* @returns True if the Account is the debit account
|
|
531
582
|
*/
|
|
532
583
|
isDebit(account) {
|
|
533
584
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -544,9 +595,10 @@ export class Transaction {
|
|
|
544
595
|
return yield this.book.getAccount(account);
|
|
545
596
|
});
|
|
546
597
|
}
|
|
547
|
-
//DESCRIPTION
|
|
548
598
|
/**
|
|
549
|
-
*
|
|
599
|
+
* Gets the description of this Transaction.
|
|
600
|
+
*
|
|
601
|
+
* @returns The description of this Transaction
|
|
550
602
|
*/
|
|
551
603
|
getDescription() {
|
|
552
604
|
if (this.payload.description == null) {
|
|
@@ -555,27 +607,30 @@ export class Transaction {
|
|
|
555
607
|
return this.payload.description;
|
|
556
608
|
}
|
|
557
609
|
/**
|
|
558
|
-
*
|
|
559
610
|
* Sets the description of the Transaction.
|
|
560
611
|
*
|
|
561
|
-
* @
|
|
612
|
+
* @param description - The description to set
|
|
613
|
+
*
|
|
614
|
+
* @returns This Transaction, for chaining
|
|
562
615
|
*/
|
|
563
616
|
setDescription(description) {
|
|
564
617
|
this.payload.description = description;
|
|
565
618
|
return this;
|
|
566
619
|
}
|
|
567
|
-
//DATE
|
|
568
620
|
/**
|
|
569
|
-
*
|
|
621
|
+
* Gets the transaction date in ISO format.
|
|
622
|
+
*
|
|
623
|
+
* @returns The Transaction date, in ISO format yyyy-MM-dd
|
|
570
624
|
*/
|
|
571
625
|
getDate() {
|
|
572
626
|
return this.payload.date;
|
|
573
627
|
}
|
|
574
628
|
/**
|
|
575
|
-
*
|
|
576
629
|
* Sets the date of the Transaction.
|
|
577
630
|
*
|
|
578
|
-
* @
|
|
631
|
+
* @param date - The date to set as string or Date object
|
|
632
|
+
*
|
|
633
|
+
* @returns This Transaction, for chaining
|
|
579
634
|
*/
|
|
580
635
|
setDate(date) {
|
|
581
636
|
if (typeof date == "string") {
|
|
@@ -593,48 +648,61 @@ export class Transaction {
|
|
|
593
648
|
return this;
|
|
594
649
|
}
|
|
595
650
|
/**
|
|
596
|
-
*
|
|
651
|
+
* Gets the transaction date as a Date object in the book's timezone.
|
|
652
|
+
*
|
|
653
|
+
* @returns The Transaction Date object, on the time zone of the [[Book]]
|
|
597
654
|
*/
|
|
598
655
|
getDateObject() {
|
|
599
656
|
return Utils.convertValueToDate(this.getDateValue(), this.book.getTimeZoneOffset());
|
|
600
657
|
}
|
|
601
658
|
/**
|
|
602
|
-
*
|
|
659
|
+
* Gets the transaction date as a numeric value.
|
|
660
|
+
*
|
|
661
|
+
* @returns The Transaction date number, in format YYYYMMDD
|
|
603
662
|
*/
|
|
604
663
|
getDateValue() {
|
|
605
664
|
return this.payload.dateValue;
|
|
606
665
|
}
|
|
607
666
|
/**
|
|
608
|
-
*
|
|
667
|
+
* Gets the transaction date formatted according to the book's date pattern.
|
|
668
|
+
*
|
|
669
|
+
* @returns The Transaction date, formatted on the date pattern of the [[Book]]
|
|
609
670
|
*/
|
|
610
671
|
getDateFormatted() {
|
|
611
672
|
return this.payload.dateFormatted;
|
|
612
673
|
}
|
|
613
674
|
/**
|
|
614
|
-
*
|
|
675
|
+
* Gets the date when the transaction was created.
|
|
676
|
+
*
|
|
677
|
+
* @returns The date the transaction was created
|
|
615
678
|
*/
|
|
616
679
|
getCreatedAt() {
|
|
617
680
|
return new Date(new Number(this.payload.createdAt).valueOf());
|
|
618
681
|
}
|
|
619
682
|
/**
|
|
620
|
-
*
|
|
683
|
+
* Gets the formatted creation date of the transaction.
|
|
684
|
+
*
|
|
685
|
+
* @returns The date the transaction was created, formatted according to the date pattern of the [[Book]]
|
|
621
686
|
*/
|
|
622
687
|
getCreatedAtFormatted() {
|
|
623
688
|
return Utils.formatDate(this.getCreatedAt(), this.book.getDatePattern() + " HH:mm:ss", this.book.getTimeZone());
|
|
624
689
|
}
|
|
625
690
|
/**
|
|
626
|
-
*
|
|
691
|
+
* Gets the date when the transaction was last updated.
|
|
692
|
+
*
|
|
693
|
+
* @returns The date the transaction was last updated
|
|
627
694
|
*/
|
|
628
695
|
getUpdatedAt() {
|
|
629
696
|
return new Date(new Number(this.payload.updatedAt).valueOf());
|
|
630
697
|
}
|
|
631
698
|
/**
|
|
632
|
-
*
|
|
699
|
+
* Gets the formatted last update date of the transaction.
|
|
700
|
+
*
|
|
701
|
+
* @returns The date the transaction was last updated, formatted according to the date pattern of the [[Book]]
|
|
633
702
|
*/
|
|
634
703
|
getUpdatedAtFormatted() {
|
|
635
704
|
return Utils.formatDate(this.getUpdatedAt(), this.book.getDatePattern() + " HH:mm:ss", this.book.getTimeZone());
|
|
636
705
|
}
|
|
637
|
-
//EVOLVED BALANCES
|
|
638
706
|
/** @internal */
|
|
639
707
|
getCaEvolvedBalance_() {
|
|
640
708
|
return this.payload.creditAccount != null && this.payload.creditAccount.balance != null ? new Amount(this.payload.creditAccount.balance) : undefined;
|
|
@@ -650,7 +718,9 @@ export class Transaction {
|
|
|
650
718
|
*
|
|
651
719
|
* Only comes with the last posted transaction of the day.
|
|
652
720
|
*
|
|
653
|
-
* @param raw - True to get the raw balance, no matter the credit nature of the [[Account]]
|
|
721
|
+
* @param raw - True to get the raw balance, no matter the credit nature of the [[Account]]
|
|
722
|
+
*
|
|
723
|
+
* @returns The account balance at the transaction date
|
|
654
724
|
*/
|
|
655
725
|
getAccountBalance(raw) {
|
|
656
726
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -674,6 +744,8 @@ export class Transaction {
|
|
|
674
744
|
}
|
|
675
745
|
/**
|
|
676
746
|
* Perform create new draft transaction.
|
|
747
|
+
*
|
|
748
|
+
* @returns This Transaction, for chaining
|
|
677
749
|
*/
|
|
678
750
|
create() {
|
|
679
751
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -683,7 +755,9 @@ export class Transaction {
|
|
|
683
755
|
});
|
|
684
756
|
}
|
|
685
757
|
/**
|
|
686
|
-
*
|
|
758
|
+
* Update transaction, applying pending changes.
|
|
759
|
+
*
|
|
760
|
+
* @returns This Transaction, for chaining
|
|
687
761
|
*/
|
|
688
762
|
update() {
|
|
689
763
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -694,6 +768,8 @@ export class Transaction {
|
|
|
694
768
|
}
|
|
695
769
|
/**
|
|
696
770
|
* Perform check transaction.
|
|
771
|
+
*
|
|
772
|
+
* @returns This Transaction, for chaining
|
|
697
773
|
*/
|
|
698
774
|
check() {
|
|
699
775
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -705,6 +781,8 @@ export class Transaction {
|
|
|
705
781
|
}
|
|
706
782
|
/**
|
|
707
783
|
* Perform uncheck transaction.
|
|
784
|
+
*
|
|
785
|
+
* @returns This Transaction, for chaining
|
|
708
786
|
*/
|
|
709
787
|
uncheck() {
|
|
710
788
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -716,6 +794,8 @@ export class Transaction {
|
|
|
716
794
|
}
|
|
717
795
|
/**
|
|
718
796
|
* Perform post transaction, changing credit and debit [[Account]] balances.
|
|
797
|
+
*
|
|
798
|
+
* @returns This Transaction, for chaining
|
|
719
799
|
*/
|
|
720
800
|
post() {
|
|
721
801
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -726,6 +806,8 @@ export class Transaction {
|
|
|
726
806
|
}
|
|
727
807
|
/**
|
|
728
808
|
* Trash the transaction.
|
|
809
|
+
*
|
|
810
|
+
* @returns This Transaction, for chaining
|
|
729
811
|
*/
|
|
730
812
|
trash() {
|
|
731
813
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -737,6 +819,8 @@ export class Transaction {
|
|
|
737
819
|
}
|
|
738
820
|
/**
|
|
739
821
|
* Untrash the transaction.
|
|
822
|
+
*
|
|
823
|
+
* @returns This Transaction, for chaining
|
|
740
824
|
*/
|
|
741
825
|
untrash() {
|
|
742
826
|
return __awaiter(this, void 0, void 0, function* () {
|