bkper 2.7.2 → 3.0.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.
Files changed (41) hide show
  1. package/README.md +8 -8
  2. package/bun.lockb +0 -0
  3. package/package.json +9 -32
  4. package/src/auth/keys.json +12 -0
  5. package/src/auth/local-auth-service.ts +73 -0
  6. package/src/cli.ts +57 -0
  7. package/tsconfig.json +25 -0
  8. package/lib/auth/keys.json +0 -12
  9. package/lib/auth/local-auth-service.js +0 -80
  10. package/lib/cli.js +0 -64
  11. package/lib/index.d.ts +0 -1775
  12. package/lib/index.js +0 -42
  13. package/lib/model/Account.js +0 -381
  14. package/lib/model/Amount.js +0 -295
  15. package/lib/model/App.js +0 -95
  16. package/lib/model/Bkper.js +0 -101
  17. package/lib/model/Book.js +0 -713
  18. package/lib/model/Collection.js +0 -43
  19. package/lib/model/Config.js +0 -3
  20. package/lib/model/Connection.js +0 -257
  21. package/lib/model/Enums.js +0 -138
  22. package/lib/model/File.js +0 -124
  23. package/lib/model/Group.js +0 -244
  24. package/lib/model/Integration.js +0 -112
  25. package/lib/model/Transaction.js +0 -715
  26. package/lib/model/TransactionIterator.js +0 -154
  27. package/lib/model/TransactionPage.js +0 -93
  28. package/lib/model/User.js +0 -93
  29. package/lib/service/account-service.js +0 -43
  30. package/lib/service/app-service.js +0 -35
  31. package/lib/service/balances-service.js +0 -21
  32. package/lib/service/book-service.js +0 -37
  33. package/lib/service/connection-service.js +0 -72
  34. package/lib/service/file-service.js +0 -28
  35. package/lib/service/group-service.js +0 -72
  36. package/lib/service/http-api-request.js +0 -169
  37. package/lib/service/integration-service.js +0 -53
  38. package/lib/service/transaction-service.js +0 -115
  39. package/lib/service/user-service.js +0 -21
  40. package/lib/tsdoc-metadata.json +0 -11
  41. package/lib/utils.js +0 -341
package/lib/index.d.ts DELETED
@@ -1,1775 +0,0 @@
1
- /**
2
- * Bkper REST API Node client.
3
- *
4
- * Learn more at https://bkper.com/docs
5
- *
6
- * @packageDocumentation
7
- */
8
-
9
- /// <reference types="bkper-api-types" />
10
-
11
- /**
12
- *
13
- * This class defines an [Account](https://en.wikipedia.org/wiki/Account_(bookkeeping)) of a [[Book]].
14
- *
15
- * It mantains a balance of all amount [credited and debited](http://en.wikipedia.org/wiki/Debits_and_credits) in it by [[Transactions]].
16
- *
17
- * An Account can be grouped by [[Groups]].
18
- *
19
- * @public
20
- */
21
- export declare class Account {
22
-
23
-
24
- /**
25
- *
26
- * @returns The wrapped plain json object
27
- */
28
- json(): bkper.Account;
29
- /**
30
- * Gets the account internal id.
31
- */
32
- getId(): string;
33
- /**
34
- * Gets the account name.
35
- */
36
- getName(): string;
37
- /**
38
- *
39
- * Sets the name of the Account.
40
- *
41
- * @returns This Account, for chainning.
42
- */
43
- setName(name: string): Account;
44
- /**
45
- * @returns The name of this account without spaces or special characters.
46
- */
47
- getNormalizedName(): string;
48
- /**
49
- * @returns The type for of this account.
50
- */
51
- getType(): AccountType;
52
- /**
53
- *
54
- * Sets the type of the Account.
55
- *
56
- * @returns This Account, for chainning
57
- */
58
- setType(type: AccountType): Account;
59
- /**
60
- * Gets the custom properties stored in this Account.
61
- */
62
- getProperties(): {
63
- [key: string]: string;
64
- };
65
- /**
66
- * Sets the custom properties of the Account
67
- *
68
- * @param properties - Object with key/value pair properties
69
- *
70
- * @returns This Account, for chainning.
71
- */
72
- setProperties(properties: {
73
- [key: string]: string;
74
- }): Account;
75
- /**
76
- * Gets the property value for given keys. First property found will be retrieved
77
- *
78
- * @param keys - The property key
79
- */
80
- getProperty(...keys: string[]): string;
81
- /**
82
- * Sets a custom property in the Account.
83
- *
84
- * @param key - The property key
85
- * @param value - The property value
86
- *
87
- * @returns This Account, for chainning.
88
- */
89
- setProperty(key: string, value: string): Account;
90
- /**
91
- * Delete a custom property
92
- *
93
- * @param key - The property key
94
- *
95
- * @returns This Account, for chainning.
96
- */
97
- deleteProperty(key: string): Account;
98
- /**
99
- * Gets the balance based on credit nature of this Account.
100
- * @deprecated Use `Book.getBalancesReport` instead.
101
- * @returns The balance of this account.
102
- */
103
- getBalance(): Amount;
104
- /**
105
- * Gets the raw balance, no matter credit nature of this Account.
106
- * @deprecated Use `Book.getBalancesReport` instead.
107
- * @returns The balance of this account.
108
- */
109
- getBalanceRaw(): Amount;
110
- /**
111
- * Tell if this account is archived.
112
- */
113
- isArchived(): boolean;
114
- /**
115
- * Set account archived/unarchived.
116
- *
117
- * @returns This Account, for chainning.
118
- */
119
- setArchived(archived: boolean): Account;
120
- /**
121
- * Tell if the Account has any transaction already posted.
122
- *
123
- * Accounts with transaction posted, even with zero balance, can only be archived.
124
- */
125
- hasTransactionPosted(): boolean;
126
- /**
127
- *
128
- * Tell if the account is permanent.
129
- *
130
- * Permanent Accounts are the ones which final balance is relevant and keep its balances over time.
131
- *
132
- * They are also called [Real Accounts](http://en.wikipedia.org/wiki/Account_(accountancy)#Based_on_periodicity_of_flow)
133
- *
134
- * Usually represents assets or tangibles, capable of being perceived by the senses or the mind, like bank accounts, money, debts and so on.
135
- *
136
- * @returns True if its a permanent Account
137
- */
138
- isPermanent(): boolean;
139
- /**
140
- * Tell if the account has a Credit nature or Debit otherwise
141
- *
142
- * Credit accounts are just for representation purposes. It increase or decrease the absolute balance. It doesn't affect the overall balance or the behavior of the system.
143
- *
144
- * The absolute balance of credit accounts increase when it participate as a credit/origin in a transaction. Its usually for Accounts that increase the balance of the assets, like revenue accounts.
145
- *
146
- * ```
147
- * Crediting a credit
148
- * Thus ---------------------> account increases its absolute balance
149
- * Debiting a debit
150
- *
151
- *
152
- * Debiting a credit
153
- * Thus ---------------------> account decreases its absolute balance
154
- * Crediting a debit
155
- * ```
156
- *
157
- * As a rule of thumb, and for simple understanding, almost all accounts are Debit nature (NOT credit), except the ones that "offers" amount for the books, like revenue accounts.
158
- */
159
- isCredit(): boolean;
160
- /**
161
- * Get the [[Groups]] of this account.
162
- */
163
- getGroups(): Promise<Group[]>;
164
- /**
165
- * Sets the groups of the Account.
166
- *
167
- * @returns This Account, for chainning.
168
- */
169
- setGroups(groups: Group[] | bkper.Group[]): Account;
170
- /**
171
- * Add a group to the Account.
172
- *
173
- * @returns This Account, for chainning.
174
- */
175
- addGroup(group: Group | bkper.Group): Account;
176
- /**
177
- * Remove a group from the Account.
178
- */
179
- removeGroup(group: string | Group): Promise<Account>;
180
- /**
181
- * Tell if this account is in the [[Group]]
182
- *
183
- * @param group - The Group name, id or object
184
- */
185
- isInGroup(group: string | Group): Promise<boolean>;
186
-
187
- /**
188
- * Perform create new account.
189
- */
190
- create(): Promise<Account>;
191
- /**
192
- * Perform update account, applying pending changes.
193
- */
194
- update(): Promise<Account>;
195
- /**
196
- * Perform delete account.
197
- */
198
- remove(): Promise<Account>;
199
- }
200
-
201
- /**
202
- * Enum that represents account types.
203
- *
204
- * @public
205
- */
206
- export declare enum AccountType {
207
- /**
208
- * Asset account type
209
- */
210
- ASSET = "ASSET",
211
- /**
212
- * Liability account type
213
- */
214
- LIABILITY = "LIABILITY",
215
- /**
216
- * Incoming account type
217
- */
218
- INCOMING = "INCOMING",
219
- /**
220
- * Outgoing account type
221
- */
222
- OUTGOING = "OUTGOING"
223
- }
224
-
225
- /**
226
- * This class defines an Amount for arbitrary-precision decimal arithmetic.
227
- *
228
- * It inherits methods from [big.js](http://mikemcl.github.io/big.js/) library
229
- *
230
- * @public
231
- */
232
- export declare class Amount {
233
-
234
- /**
235
- * The Amount constructor.
236
- */
237
- constructor(n: number | string | Amount);
238
- /**
239
- * Returns an absolute Amount.
240
- */
241
- abs(): Amount;
242
- /**
243
- * Compare
244
- */
245
- cmp(n: number | string | Amount): -1 | 0 | 1;
246
- /**
247
- * Divide by
248
- */
249
- div(n: number | string | Amount): Amount;
250
- /**
251
- * Equals to
252
- */
253
- eq(n: number | string | Amount): boolean;
254
- /**
255
- * Greater than
256
- */
257
- gt(n: number | string | Amount): boolean;
258
- /**
259
- * Greater than or equal
260
- */
261
- gte(n: number | string | Amount): boolean;
262
- /**
263
- * Less than
264
- */
265
- lt(n: number | string | Amount): boolean;
266
- /**
267
- * Less than or equal to
268
- */
269
- lte(n: number | string | Amount): boolean;
270
- /**
271
- * Sum
272
- */
273
- plus(n: number | string | Amount): Amount;
274
- /**
275
- * Minus
276
- */
277
- minus(n: number | string | Amount): Amount;
278
- /**
279
- * Modulo - the integer remainder of dividing this Amount by n.
280
- *
281
- * Similar to % operator
282
- *
283
- */
284
- mod(n: number | string | Amount): Amount;
285
- /**
286
- * Round to a maximum of dp decimal places.
287
- */
288
- round(dp?: number): Amount;
289
- /**
290
- * Multiply
291
- */
292
- times(n: number | string | Amount): Amount;
293
- /**
294
- * Returns a string representing the value of this Amount in normal notation to a fixed number of decimal places dp.
295
- */
296
- toFixed(dp?: number): string;
297
- /**
298
- * Returns a string representing the value of this Amount.
299
- */
300
- toString(): string;
301
- /**
302
- * Returns a primitive number representing the value of this Amount.
303
- */
304
- toNumber(): number;
305
-
306
-
307
-
308
- }
309
-
310
- /**
311
- * Defines an App on Bkper.
312
- *
313
- * Apps can be installed on Books by users.
314
- *
315
- * @public
316
- */
317
- export declare class App {
318
-
319
-
320
- /**
321
- *
322
- * Sets the webhook url for development.
323
- *
324
- * @returns This App, for chainning.
325
- */
326
- setWebhookUrlDev(webhookUrlDev: string): App;
327
- /**
328
- * Partially update an App, applying pending changes.
329
- */
330
- patch(): Promise<App>;
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
-
339
- }
340
-
341
- /**
342
- * This is the main Entry Point of the [bkper-node](https://www.npmjs.com/package/bkper) library.
343
- *
344
- * @public
345
- */
346
- export declare class Bkper {
347
- /**
348
- * Gets the [[Book]] with the specified bookId from url param.
349
- *
350
- * @param id - The universal book id - The same bookId param of URL you access at app.bkper.com
351
- *
352
- * @returns The retrieved Book, for chaining
353
- */
354
- static getBook(id: string): Promise<Book>;
355
- /**
356
- * Gets the current logged [[User]].
357
- *
358
- * @returns The retrieved User, for chaining
359
- */
360
- static getUser(): Promise<User>;
361
- /**
362
- * Sets the API [[Config]] object.
363
- *
364
- * @param config - The Config object
365
- */
366
- static setConfig(config: Config): void;
367
- /**
368
- * Sets the API key to identify the agent.
369
- *
370
- * @param key - The API key
371
- *
372
- * @returns The defined [[App]] object
373
- *
374
- * @deprecated Use `setConfig()` instead
375
- */
376
- static setApiKey(key: string): App;
377
- /**
378
- * Sets the provider of the valid OAuth2 access token
379
- *
380
- * @deprecated Use `setConfig()` instead
381
- */
382
- static setOAuthTokenProvider(oauthTokenProvider: () => Promise<string>): Promise<void>;
383
- }
384
-
385
- /**
386
- *
387
- * A Book represents [General Ledger](https://en.wikipedia.org/wiki/General_ledger) for a company or business, but can also represent a [Ledger](https://en.wikipedia.org/wiki/Ledger) for a project or department
388
- *
389
- * It contains all [[Accounts]] where [[Transactions]] are recorded/posted;
390
- *
391
- * @public
392
- */
393
- export declare class Book {
394
-
395
-
396
-
397
-
398
- constructor(json: bkper.Book);
399
- /**
400
- * @returns The wrapped plain json object
401
- */
402
- json(): bkper.Book;
403
- /**
404
- * Same as bookId param
405
- */
406
- getId(): string;
407
- /**
408
- * @returns The name of this Book
409
- */
410
- getName(): string;
411
- /**
412
- *
413
- * Sets the name of the Book.
414
- *
415
- * @returns This Book, for chainning.
416
- */
417
- setName(name: string): Book;
418
- /**
419
- * @returns The number of fraction digits supported by this Book. Same as getDecimalPlaces
420
- */
421
- getFractionDigits(): number;
422
- /**
423
- * @returns The number of decimal places supported by this Book. Same as getFractionDigits
424
- */
425
- getDecimalPlaces(): number;
426
- /**
427
- *
428
- * Sets the number of fraction digits (decimal places) supported by this Book
429
- *
430
- * @returns This Book, for chainning.
431
- */
432
- setFractionDigits(fractionDigits: number): Book;
433
- /**
434
- * @returns The period slice for balances visualization
435
- */
436
- getPeriod(): Period;
437
- /**
438
- * Sets the period slice for balances visualization
439
- *
440
- * @returns This Book, for chainning.
441
- */
442
- setPeriod(period: Period): Book;
443
- /**
444
- * @returns The start month when YEAR period set
445
- */
446
- getPeriodStartMonth(): Month;
447
- /**
448
- * Sets the start month when YEAR period set
449
- *
450
- * @returns This Book, for chainning.
451
- */
452
- setPeriodStartMonth(month: Month): Book;
453
- /**
454
- * @returns The transactions pagination page size
455
- */
456
- getPageSize(): number;
457
- /**
458
- * Sets the transactions pagination page size
459
- *
460
- * @returns This Book, for chainning.
461
- */
462
- setPageSize(pageSize: number): Book;
463
- /**
464
- * @returns The name of the owner of the Book
465
- */
466
- getOwnerName(): string;
467
- /**
468
- * @returns The permission for the current user
469
- */
470
- getPermission(): Permission;
471
- /**
472
- * @returns The collection of this book
473
- */
474
- getCollection(): Collection;
475
- /**
476
- * @returns The date pattern of the Book. Current: dd/MM/yyyy | MM/dd/yyyy | yyyy/MM/dd
477
- */
478
- getDatePattern(): string;
479
- /**
480
- *
481
- * Sets the date pattern of the Book. Current: dd/MM/yyyy | MM/dd/yyyy | yyyy/MM/dd
482
- *
483
- * @returns This Book, for chainning.
484
- */
485
- setDatePattern(datePattern: string): Book;
486
- /**
487
- * @returns The lock date of the Book in ISO format yyyy-MM-dd
488
- */
489
- getLockDate(): string;
490
- /**
491
- *
492
- * Sets the lock date of the Book in ISO format yyyy-MM-dd.
493
- *
494
- * @returns This Book, for chainning.
495
- */
496
- setLockDate(lockDate: string): Book;
497
- /**
498
- * @returns The closing date of the Book in ISO format yyyy-MM-dd
499
- */
500
- getClosingDate(): string;
501
- /**
502
- *
503
- * Sets the closing date of the Book in ISO format yyyy-MM-dd.
504
- *
505
- * @returns This Book, for chainning.
506
- */
507
- setClosingDate(closingDate: string): Book;
508
- /**
509
- * @returns The decimal separator of the Book
510
- */
511
- getDecimalSeparator(): DecimalSeparator;
512
- /**
513
- *
514
- * Sets the decimal separator of the Book
515
- *
516
- * @returns This Book, for chainning.
517
- */
518
- setDecimalSeparator(decimalSeparator: DecimalSeparator): Book;
519
- /**
520
- * @returns The time zone of the Book
521
- */
522
- getTimeZone(): string;
523
- /**
524
- *
525
- * Sets the time zone of the Book
526
- *
527
- * @returns This Book, for chainning.
528
- */
529
- setTimeZone(timeZone: string): Book;
530
- /**
531
- * @returns The time zone offset of the book, in minutes
532
- */
533
- getTimeZoneOffset(): number;
534
- /**
535
- * @returns The last update date of the book, in in milliseconds
536
- */
537
- getLastUpdateMs(): number;
538
- /**
539
- * Gets the custom properties stored in this Book
540
- */
541
- getProperties(): {
542
- [key: string]: string;
543
- };
544
- /**
545
- * Gets the property value for given keys. First property found will be retrieved
546
- *
547
- * @param keys - The property key
548
- */
549
- getProperty(...keys: string[]): string;
550
- /**
551
- * Sets the custom properties of the Book
552
- *
553
- * @param properties - Object with key/value pair properties
554
- *
555
- * @returns This Book, for chainning.
556
- */
557
- setProperties(properties: {
558
- [key: string]: string;
559
- }): Book;
560
- /**
561
- * Sets a custom property in the Book.
562
- *
563
- * @param key - The property key
564
- * @param value - The property value
565
- *
566
- * @returns This Book, for chainning.
567
- */
568
- setProperty(key: string, value: string): Book;
569
- /**
570
- * Formats a date according to date pattern of the Book.
571
- *
572
- * @param date - The date to format as string.
573
- * @param timeZone - The output timezone of the result. Default to script's timeZone
574
- *
575
- * @returns The date formated
576
- */
577
- formatDate(date: Date, timeZone?: string): string;
578
- /**
579
- * Parse a date string according to date pattern and timezone of the Book.
580
- *
581
- * Also parse ISO yyyy-mm-dd format.
582
- */
583
- parseDate(date: string): Date;
584
- /**
585
- * Formats a value according to [[DecimalSeparator]] and fraction digits of the Book.
586
- *
587
- * @param value - The value to be formatted.
588
- *
589
- * @returns The value formated
590
- */
591
- formatValue(value: Amount | number | null | undefined): string;
592
- /**
593
- * Parse a value string according to [[DecimalSeparator]] and fraction digits of the Book.
594
- */
595
- parseValue(value: string): Amount;
596
- /**
597
- * Rounds a value according to the number of fraction digits of the Book
598
- *
599
- * @param value - The value to be rounded
600
- *
601
- * @returns The value rounded
602
- */
603
- round(value: Amount | number): Amount;
604
- /**
605
- * Create [[Transactions]] on the Book, in batch.
606
- */
607
- batchCreateTransactions(transactions: Transaction[]): Promise<Transaction[]>;
608
- /**
609
- * Trash [[Transactions]] on the Book, in batch.
610
- */
611
- batchTrashTransactions(transactions: Transaction[]): Promise<void>;
612
- /**
613
- * Trigger [Balances Audit](https://help.bkper.com/en/articles/4412038-balances-audit) async process.
614
- */
615
- audit(): void;
616
- /**
617
- * Gets the existing [[Integrations]] in the Book.
618
- *
619
- * @returns The existing Integration objects
620
- */
621
- getIntegrations(): Promise<Integration[]>;
622
- /**
623
- * Creates a new [[Integration]] in the Book.
624
- *
625
- * @param integration - The Integration object or wrapped plain json
626
- *
627
- * @returns The created Integration object
628
- */
629
- createIntegration(integration: bkper.Integration | Integration): Promise<Integration>;
630
- /**
631
- * Updates an existing [[Integration]] in the Book.
632
- *
633
- * @param integration - The Integration wrapped plain json
634
- *
635
- * @returns The updated Integration object
636
- */
637
- updateIntegration(integration: bkper.Integration): Promise<Integration>;
638
- /**
639
- * Resumes a transaction iteration using a continuation token from a previous iterator.
640
- *
641
- * @param continuationToken - continuation token from a previous transaction iterator
642
- *
643
- * @returns a collection of transactions that remained in a previous iterator when the continuation token was generated
644
- */
645
- continueTransactionIterator(query: string, continuationToken: string): TransactionIterator;
646
- configureTransactions_(transactions: Transaction[]): Transaction[];
647
-
648
- /**
649
- * Instantiate a new [[Transaction]]
650
- *
651
- * Example:
652
- *
653
- * ```js
654
- * var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
655
- *
656
- * book.newTransaction()
657
- * .setDate('2013-01-25')
658
- * .setDescription("Filling tank of my truck")
659
- * .from('Credit Card')
660
- * .to('Gas')
661
- * .setAmount(126.50)
662
- * .create();
663
- *
664
- * ```
665
- *
666
- */
667
- newTransaction(): Transaction;
668
- /**
669
- * Instantiate a new [[Account]]
670
- *
671
- * Example:
672
- * ```js
673
- * var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
674
- *
675
- * book.newAccount()
676
- * .setName('Some New Account')
677
- * .setType('INCOMING')
678
- * .addGroup('Revenue').addGroup('Salary')
679
- * .setProperties({prop_a: 'A', prop_b: 'B'})
680
- * .create();
681
- * ```
682
- */
683
- newAccount(): Account;
684
- /**
685
- * Instantiate a new [[Group]]
686
- *
687
- * Example:
688
- * ```js
689
- * var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
690
- *
691
- * book.newGroup()
692
- * .setName('Some New Group')
693
- * .setProperty('key', 'value')
694
- * .create();
695
- * ```
696
- */
697
- newGroup(): Group;
698
- /**
699
- * Gets an [[Account]] object
700
- *
701
- * @param idOrName - The id or name of the Account
702
- *
703
- * @returns The matching Account object
704
- */
705
- getAccount(idOrName: string): Promise<Account>;
706
-
707
- removeGroupCache(group: Group): void;
708
- /**
709
- * Gets a [[Group]] object
710
- *
711
- * @param idOrName - The id or name of the Group
712
- *
713
- * @returns The matching Group object
714
- */
715
- getGroup(idOrName: string): Promise<Group>;
716
- /**
717
- * Gets all [[Groups]] of this Book
718
- */
719
- getGroups(): Promise<Group[]>;
720
- /**
721
- * Get the [[Groups]] of a given account.
722
- */
723
- getGroupsByAccount(accountIdOrName: string): Promise<Group[]>;
724
- /**
725
- * Get Book transactions based on a query.
726
- *
727
- * See [Query Guide](https://help.bkper.com/en/articles/2569178-search-query-guide) to learn more
728
- *
729
- * @param query - The query string.
730
- *
731
- * @returns The Transactions result as an iterator.
732
- *
733
- * Example:
734
- *
735
- * ```js
736
- * var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
737
- *
738
- * var transactions = book.getTransactions("account:CreditCard after:28/01/2013 before:29/01/2013");
739
- *
740
- * while (transactions.hasNext()) {
741
- * var transaction = transactions.next();
742
- * Logger.log(transaction.getDescription());
743
- * }
744
- * ```
745
- */
746
- getTransactions(query?: string): TransactionIterator;
747
- /**
748
- * Retrieve a transaction by id
749
- */
750
- getTransaction(id: string): Promise<Transaction>;
751
- /**
752
- * Instantiate a new [[BkperFile]]
753
- *
754
- * Example:
755
- * ```js
756
- * var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
757
- *
758
- * book.newFile()
759
- * .setBlob(UrlFetchApp.fetch('https://bkper.com/images/index/integrations4.png').getBlob())
760
- * .create();
761
- * ```
762
- */
763
- newFile(): File;
764
- /**
765
- * Retrieve a file by id
766
- */
767
- getFile(id: string): Promise<File>;
768
- /**
769
- * Perform update Book, applying pending changes.
770
- */
771
- update(): Promise<Book>;
772
- }
773
-
774
- /**
775
- * This class defines a Collection of [[Books]].
776
- *
777
- * @public
778
- */
779
- export declare class Collection {
780
-
781
-
782
- /**
783
- * @returns The id of this Collection
784
- */
785
- getId(): string;
786
- /**
787
- * @returns The name of this Collection
788
- */
789
- getName(): string;
790
- /**
791
- * @returns All Books of this collection.
792
- */
793
- getBooks(): Book[];
794
- }
795
-
796
- /**
797
- * This class defines the [[Bkper]] API Config.
798
- *
799
- * @public
800
- */
801
- export declare interface Config {
802
- /**
803
- * The API key to identify the agent.
804
- *
805
- * API keys are intended for agent identification only, not for authentication. [Learn more](https://cloud.google.com/endpoints/docs/frameworks/java/when-why-api-key)
806
- *
807
- * See how to create your api key [here](https://cloud.google.com/docs/authentication/api-keys).
808
- */
809
- apiKeyProvider?: () => Promise<string>;
810
- /**
811
- * Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.
812
- */
813
- oauthTokenProvider?: () => Promise<string>;
814
- /**
815
- * Provides additional headers to append to the API request
816
- */
817
- requestHeadersProvider?: () => Promise<{
818
- [key: string]: string;
819
- }>;
820
- /**
821
- * Custom request error handler
822
- */
823
- requestErrorHandler?: (error: any) => any;
824
- /**
825
- * Sets the base api url. Default to https://app.bkper.com/_ah/api/bkper
826
- */
827
- apiBaseUrl?: string;
828
- }
829
-
830
- /**
831
- * This class defines a Connection from an [[User]] to an external service.
832
- *
833
- * @public
834
- */
835
- export declare class Connection {
836
-
837
- constructor(json?: bkper.Connection);
838
- /**
839
- * Gets the wrapped plain json object of the Connection.
840
- *
841
- * @returns The Connection wrapped plain json object
842
- */
843
- json(): bkper.Connection;
844
- /**
845
- * Gets the id of the Connection.
846
- *
847
- * @returns The Connection's id
848
- */
849
- getId(): string;
850
- /**
851
- * Gets the agentId of the Connection.
852
- *
853
- * @returns The Connection's agentId
854
- */
855
- getAgentId(): string;
856
- /**
857
- * Sets the Connection agentId.
858
- *
859
- * @param agentId - The Connection agentId
860
- *
861
- * @returns The Connection, for chainning
862
- */
863
- setAgentId(agentId: string): Connection;
864
- /**
865
- * Gets the name of the Connection.
866
- *
867
- * @returns The Connection name
868
- */
869
- getName(): string;
870
- /**
871
- * Gets the email of the owner of the Connection.
872
- *
873
- * @returns The Connection owner's email
874
- */
875
- getEmail(): string;
876
- /**
877
- * Sets the name of the Connection.
878
- *
879
- * @param name - The name of the Connection
880
- *
881
- * @returns The Connection, for chainning
882
- */
883
- setName(name: string): Connection;
884
- /**
885
- * Sets the universal unique identifier of the Connection.
886
- *
887
- * @param uuid - The universal unique identifier of the Connection
888
- *
889
- * @returns The Connection, for chainning
890
- */
891
- setUUID(uuid: string): Connection;
892
- /**
893
- * Gets the universal unique identifier of this Connection.
894
- *
895
- * @returns The Connection's universal unique identifier name
896
- */
897
- getUUID(): string;
898
- /**
899
- * Gets the type of the Connection.
900
- *
901
- * @returns The Connection type
902
- */
903
- getType(): "APP" | "BANK";
904
- /**
905
- * Sets the Connection type.
906
- *
907
- * @param type - The Connection type
908
- *
909
- * @returns The Connection, for chainning
910
- */
911
- setType(type: "APP" | "BANK"): Connection;
912
- /**
913
- * Gets the custom properties stored in the Connection
914
- *
915
- * @returns Object with key/value pair properties
916
- */
917
- getProperties(): {
918
- [key: string]: string;
919
- };
920
- /**
921
- * Sets the custom properties of the Connection.
922
- *
923
- * @param properties - Object with key/value pair properties
924
- *
925
- * @returns The Connection, for chainning
926
- */
927
- setProperties(properties: {
928
- [key: string]: string;
929
- }): Connection;
930
- /**
931
- * Gets the property value for given keys. First property found will be retrieved.
932
- *
933
- * @param keys - The property key
934
- *
935
- * @returns The retrieved property value
936
- */
937
- getProperty(...keys: string[]): string;
938
- /**
939
- * Sets a custom property in the Connection.
940
- *
941
- * @param key - The property key
942
- * @param value - The property value
943
- *
944
- * @returns The Connection, for chaining
945
- */
946
- setProperty(key: string, value: string): Connection;
947
- /**
948
- * Deletes a custom property stored in the Connection.
949
- *
950
- * @param key - The property key
951
- *
952
- * @returns The Connection, for chainning
953
- */
954
- deleteProperty(key: string): Connection;
955
- /**
956
- * Cleans any token property stored in the Connection.
957
- */
958
- clearTokenProperties(): void;
959
- /**
960
- * Gets the custom properties keys stored in the Connection.
961
- *
962
- * @returns The retrieved property keys
963
- */
964
- getPropertyKeys(): string[];
965
- /**
966
- * Gets the existing [[Integrations]] on the Connection.
967
- *
968
- * @returns The existing Integration objects
969
- */
970
- getIntegrations(): Promise<Integration[]>;
971
- /**
972
- * Performs create new Connection.
973
- *
974
- * @returns The Connection, for chaining
975
- */
976
- create(): Promise<Connection>;
977
- }
978
-
979
- /**
980
- * Decimal separator of numbers on book
981
- *
982
- * @public
983
- */
984
- export declare enum DecimalSeparator {
985
- /**
986
- * ,
987
- */
988
- COMMA = "COMMA",
989
- /**
990
- * .
991
- */
992
- DOT = "DOT"
993
- }
994
-
995
- /**
996
- *
997
- * This class defines a File uploaded to a [[Book]].
998
- *
999
- * A File can be attached to a [[Transaction]] or used to import data.
1000
- *
1001
- * @public
1002
- */
1003
- export declare class File {
1004
-
1005
-
1006
- /**
1007
- * Gets the File id
1008
- */
1009
- getId(): string;
1010
- /**
1011
- * Gets the File name
1012
- */
1013
- getName(): string;
1014
- /**
1015
- *
1016
- * Sets the name of the File.
1017
- *
1018
- * @returns This File, for chainning.
1019
- */
1020
- setName(name: string): File;
1021
- /**
1022
- * Gets the File content type
1023
- */
1024
- getContentType(): string;
1025
- /**
1026
- *
1027
- * Sets the File content type.
1028
- *
1029
- * @returns This File, for chainning.
1030
- */
1031
- setContentType(contentType: string): File;
1032
- /**
1033
- * Gets the file content Base64 encoded
1034
- */
1035
- getContent(): Promise<string>;
1036
- /**
1037
- *
1038
- * Sets the File content Base64 encoded.
1039
- *
1040
- * @returns This File, for chainning.
1041
- */
1042
- setContent(content: string): File;
1043
- /**
1044
- * Gets the file serving url for accessing via browser
1045
- */
1046
- getUrl(): string;
1047
- /**
1048
- * Gets the file size in bytes
1049
- */
1050
- getSize(): number;
1051
- /**
1052
- * Perform create new File.
1053
- */
1054
- create(): Promise<File>;
1055
- }
1056
-
1057
- /**
1058
- * This class defines a Group of [[Accounts]].
1059
- *
1060
- * Accounts can be grouped by different meaning, like Expenses, Revenue, Assets, Liabilities and so on
1061
- *
1062
- * Its useful to keep organized and for high level analysis.
1063
- *
1064
- * @public
1065
- */
1066
- export declare class Group {
1067
-
1068
- accounts: Set<Account>;
1069
-
1070
- /**
1071
- *
1072
- * @returns The wrapped plain json object
1073
- */
1074
- json(): bkper.Group;
1075
- /**
1076
- * @returns The id of this Group
1077
- */
1078
- getId(): string;
1079
- /**
1080
- * @returns The parent Group
1081
- */
1082
- getParent(): Promise<Group>;
1083
- /**
1084
- * Sets the parent Group.
1085
- *
1086
- * @returns This Group, for chainning.
1087
- */
1088
- setParent(group: Group | null): Group;
1089
- /**
1090
- * @returns The name of this Group
1091
- */
1092
- getName(): string;
1093
- /**
1094
- * Sets the name of the Group.
1095
- *
1096
- * @returns This Group, for chainning.
1097
- */
1098
- setName(name: string): Group;
1099
- /**
1100
- * @returns The name of this group without spaces and special characters
1101
- */
1102
- getNormalizedName(): string;
1103
- /**
1104
- * @returns All Accounts of this group.
1105
- */
1106
- getAccounts(): Promise<Account[]>;
1107
- /**
1108
- * @returns True if this group has any account in it
1109
- */
1110
- hasAccounts(): boolean;
1111
- /**
1112
- * @returns The type for of the accounts of this group. Null if mixed
1113
- */
1114
- getType(): AccountType;
1115
- /**
1116
- * Gets the custom properties stored in this Group
1117
- */
1118
- getProperties(): {
1119
- [key: string]: string;
1120
- };
1121
- /**
1122
- * Sets the custom properties of the Group
1123
- *
1124
- * @param properties - Object with key/value pair properties
1125
- *
1126
- * @returns This Group, for chainning.
1127
- */
1128
- setProperties(properties: {
1129
- [key: string]: string;
1130
- }): Group;
1131
- /**
1132
- * Gets the property value for given keys. First property found will be retrieved
1133
- *
1134
- * @param keys - The property key
1135
- */
1136
- getProperty(...keys: string[]): string;
1137
- /**
1138
- * Sets a custom property in the Group.
1139
- *
1140
- * @param key - The property key
1141
- * @param value - The property value
1142
- */
1143
- setProperty(key: string, value: string): Group;
1144
- /**
1145
- * Delete a custom property
1146
- *
1147
- * @param key - The property key
1148
- *
1149
- * @returns This Group, for chainning.
1150
- */
1151
- deleteProperty(key: string): Group;
1152
- /**
1153
- * Tell if the Group is hidden on main transactions menu
1154
- */
1155
- isHidden(): boolean;
1156
- /**
1157
- * Hide/Show group on main menu.
1158
- */
1159
- setHidden(hidden: boolean): Group;
1160
- /**
1161
- * Perform create new group.
1162
- */
1163
- create(): Promise<Group>;
1164
- /**
1165
- * Perform update group, applying pending changes.
1166
- */
1167
- update(): Promise<Group>;
1168
- /**
1169
- * Perform delete group.
1170
- */
1171
- remove(): Promise<Group>;
1172
- }
1173
-
1174
- /**
1175
- * This class defines a Integration from an [[User]] to an external service.
1176
- *
1177
- * @public
1178
- */
1179
- export declare class Integration {
1180
-
1181
- constructor(json: bkper.Integration);
1182
- /**
1183
- * Gets the wrapped plain json object of the Integration.
1184
- *
1185
- * @returns The Integration wrapped plain json object
1186
- */
1187
- json(): bkper.Integration;
1188
- /**
1189
- * Gets the [[Book]] id of the Integration.
1190
- *
1191
- * @returns The Integration's Book id
1192
- */
1193
- getBookId(): string;
1194
- /**
1195
- * Gets the id of the Integration.
1196
- *
1197
- * @returns This Integration's id
1198
- */
1199
- getId(): string;
1200
- /**
1201
- * Gets the name of the Integration.
1202
- *
1203
- * @returns The Integration's name
1204
- */
1205
- getName(): string;
1206
- /**
1207
- * Gets the custom properties stored in the Integration.
1208
- *
1209
- * @returns Object with key/value pair properties
1210
- */
1211
- getProperties(): {
1212
- [key: string]: string;
1213
- };
1214
- /**
1215
- * Sets the custom properties of the Integration.
1216
- *
1217
- * @param properties - Object with key/value pair properties
1218
- *
1219
- * @returns The Integration, for chainning
1220
- */
1221
- setProperties(properties: {
1222
- [key: string]: string;
1223
- }): Integration;
1224
- /**
1225
- * Gets the property value for given keys. First property found will be retrieved.
1226
- *
1227
- * @param keys - The property key
1228
- *
1229
- * @returns The retrieved property value
1230
- */
1231
- getProperty(...keys: string[]): string;
1232
- /**
1233
- * Sets a custom property in the Integration.
1234
- *
1235
- * @param key - The property key
1236
- * @param value - The property value
1237
- *
1238
- * @returns The Integration, for chaining
1239
- */
1240
- setProperty(key: string, value: string): Integration;
1241
- /**
1242
- * Deletes a custom property stored in the Integration.
1243
- *
1244
- * @param key - The property key
1245
- *
1246
- * @returns The Integration, for chainning
1247
- */
1248
- deleteProperty(key: string): Integration;
1249
- }
1250
-
1251
- /**
1252
- * Enum that represents a Month.
1253
- *
1254
- * @public
1255
- */
1256
- declare enum Month {
1257
- JANUARY = "JANUARY",
1258
- FEBRUARY = "FEBRUARY",
1259
- MARCH = "MARCH",
1260
- APRIL = "APRIL",
1261
- MAY = "MAY",
1262
- JUNE = "JUNE",
1263
- JULY = "JULY",
1264
- AUGUST = "AUGUST",
1265
- SEPTEMBER = "SEPTEMBER",
1266
- OCTOBER = "OCTOBER",
1267
- NOVEMBER = "NOVEMBER",
1268
- DECEMBER = "DECEMBER"
1269
- }
1270
-
1271
- /**
1272
- * Enum that represents a period slice.
1273
- *
1274
- * @public
1275
- */
1276
- declare enum Period {
1277
- /**
1278
- * Monthly period
1279
- */
1280
- MONTH = "MONTH",
1281
- /**
1282
- * Quarterly period
1283
- */
1284
- QUARTER = "QUARTER",
1285
- /**
1286
- * Yearly period
1287
- */
1288
- YEAR = "YEAR"
1289
- }
1290
-
1291
- /**
1292
- * The Periodicity of the query. It may depend on the level of granularity you write the range params.
1293
- *
1294
- * @public
1295
- */
1296
- export declare enum Periodicity {
1297
- /**
1298
- * Example: after:25/01/1983, before:04/03/2013, after:$d-30, before:$d, after:$d-15/$m
1299
- */
1300
- DAILY = "DAILY",
1301
- /**
1302
- * Example: after:jan/2013, before:mar/2013, after:$m-1, before:$m
1303
- */
1304
- MONTHLY = "MONTHLY",
1305
- /**
1306
- * Example: on:2013, after:2013, $y
1307
- */
1308
- YEARLY = "YEARLY"
1309
- }
1310
-
1311
- /**
1312
- * Enum representing permissions of user in the Book
1313
- *
1314
- * Learn more at [share article](https://help.bkper.com/en/articles/2569153-share-your-book-with-your-peers).
1315
- *
1316
- * @public
1317
- */
1318
- export declare enum Permission {
1319
- /**
1320
- * No permission
1321
- */
1322
- NONE = "NONE",
1323
- /**
1324
- * View transactions, accounts and balances.
1325
- */
1326
- VIEWER = "VIEWER",
1327
- /**
1328
- * Record and delete drafts only. Useful to collect data only
1329
- */
1330
- RECORDER = "RECORDER",
1331
- /**
1332
- * View transactions, accounts, record and delete drafts
1333
- */
1334
- POSTER = "POSTER",
1335
- /**
1336
- * Manage accounts, transactions, book configuration and sharing
1337
- */
1338
- EDITOR = "EDITOR",
1339
- /**
1340
- * Manage everything, including book visibility and deletion. Only one owner per book.
1341
- */
1342
- OWNER = "OWNER"
1343
- }
1344
-
1345
- /**
1346
- *
1347
- * This class defines a Transaction between [credit and debit](http://en.wikipedia.org/wiki/Debits_and_credits) [[Accounts]].
1348
- *
1349
- * A Transaction is the main entity on the [Double Entry](http://en.wikipedia.org/wiki/Double-entry_bookkeeping_system) [Bookkeeping](http://en.wikipedia.org/wiki/Bookkeeping) system.
1350
- *
1351
- * @public
1352
- */
1353
- export declare class Transaction {
1354
-
1355
-
1356
- /**
1357
- *
1358
- * @returns The wrapped plain json object
1359
- */
1360
- json(): bkper.Transaction;
1361
- /**
1362
- * @returns The id of the Transaction.
1363
- */
1364
- getId(): string;
1365
- /**
1366
- * @returns The id of the agent that created this transaction
1367
- */
1368
- getAgentId(): string;
1369
- /**
1370
- * Remote ids are used to avoid duplication.
1371
- *
1372
- * @returns The remote ids of the Transaction.
1373
- */
1374
- getRemoteIds(): string[];
1375
- /**
1376
- * Add a remote id to the Transaction.
1377
- *
1378
- * @param remoteId - The remote id to add.
1379
- *
1380
- * @returns This Transaction, for chainning.
1381
- */
1382
- addRemoteId(remoteId: string): Transaction;
1383
- /**
1384
- * @returns True if transaction was already posted to the accounts. False if is still a Draft.
1385
- */
1386
- isPosted(): boolean;
1387
- /**
1388
- * @returns True if transaction is checked.
1389
- */
1390
- isChecked(): boolean;
1391
- /**
1392
- * Set the check state of the Transaction.
1393
- *
1394
- * @param checked - The check state.
1395
- *
1396
- * @returns This Transaction, for chainning.
1397
- */
1398
- setChecked(checked: boolean): Transaction;
1399
- /**
1400
- * @returns True if transaction is in trash.
1401
- */
1402
- isTrashed(): boolean;
1403
- /**
1404
- * @returns All #hashtags used on the transaction.
1405
- */
1406
- getTags(): string[];
1407
- /**
1408
- * @returns All urls of the transaction.
1409
- */
1410
- getUrls(): string[];
1411
- /**
1412
- * Sets the Transaction urls. Url starts with https://
1413
- *
1414
- * @param urls - The urls array.
1415
- *
1416
- * @returns This Transaction, for chainning.
1417
- */
1418
- setUrls(urls: string[]): Transaction;
1419
- /**
1420
- * Add a url to the Transaction. Url starts with https://
1421
- *
1422
- * @param url - The url to add.
1423
- *
1424
- * @returns This Transaction, for chainning.
1425
- */
1426
- addUrl(url: string): Transaction;
1427
- /**
1428
- * @returns The files attached to the transaction.
1429
- */
1430
- getFiles(): File[];
1431
- /**
1432
- *
1433
- * Adds a file attachment to the Transaction.
1434
- *
1435
- * Files not previously created in the Book will be automatically created.
1436
- *
1437
- * @param file - The file to add
1438
- *
1439
- * @returns This Transaction, for chainning.
1440
- */
1441
- addFile(file: File): Promise<Transaction>;
1442
- /**
1443
- * Check if the transaction has the specified tag.
1444
- */
1445
- hasTag(tag: string): boolean;
1446
- /**
1447
- * Gets the custom properties stored in this Transaction.
1448
- */
1449
- getProperties(): {
1450
- [key: string]: string;
1451
- };
1452
- /**
1453
- * Sets the custom properties of the Transaction
1454
- *
1455
- * @param properties - Object with key/value pair properties
1456
- *
1457
- * @returns This Transaction, for chainning.
1458
- */
1459
- setProperties(properties: {
1460
- [key: string]: string;
1461
- }): Transaction;
1462
- /**
1463
- * Gets the property value for given keys. First property found will be retrieved
1464
- *
1465
- * @param keys - The property key
1466
- */
1467
- getProperty(...keys: string[]): string;
1468
- /**
1469
- * Gets the custom properties keys stored in this Transaction.
1470
- */
1471
- getPropertyKeys(): string[];
1472
- /**
1473
- * Sets a custom property in the Transaction.
1474
- *
1475
- * @param key - The property key
1476
- * @param value - The property value
1477
- *
1478
- * @returns This Transaction, for chainning.
1479
- */
1480
- setProperty(key: string, value: string): Transaction;
1481
- /**
1482
- * Delete a custom property
1483
- *
1484
- * @param key - The property key
1485
- *
1486
- * @returns This Transaction, for chainning.
1487
- */
1488
- deleteProperty(key: string): Transaction;
1489
- /**
1490
- * @returns The credit account. The same as origin account.
1491
- */
1492
- getCreditAccount(): Promise<Account>;
1493
- /**
1494
- * @returns The credit account name.
1495
- */
1496
- getCreditAccountName(): Promise<string>;
1497
- /**
1498
- *
1499
- * Sets the credit/origin Account of the Transaction. Same as from().
1500
- *
1501
- * @param account - Account id, name or object.
1502
- *
1503
- * @returns This Transaction, for chainning.
1504
- */
1505
- setCreditAccount(account: Account | bkper.Account): Transaction;
1506
- /**
1507
- *
1508
- * Sets the credit/origin Account of the Transaction. Same as setCreditAccount().
1509
- *
1510
- * @param account - Account id, name or object.
1511
- *
1512
- * @returns This Transaction, for chainning.
1513
- */
1514
- from(account: Account | bkper.Account): Transaction;
1515
- /**
1516
- * @returns The debit account. The same as destination account.
1517
- *
1518
- */
1519
- getDebitAccount(): Promise<Account>;
1520
- /**
1521
- * @returns The debit account name.
1522
- */
1523
- getDebitAccountName(): Promise<string>;
1524
- /**
1525
- *
1526
- * Sets the debit/destination Account of the Transaction. Same as to().
1527
- *
1528
- * @param account - Account id, name or object.
1529
- *
1530
- * @returns This Transaction, for chainning.
1531
- */
1532
- setDebitAccount(account: Account | bkper.Account): Transaction;
1533
- /**
1534
- *
1535
- * Sets the debit/destination Account of the Transaction. Same as setDebitAccount().
1536
- *
1537
- * @param account - Account id, name or object.
1538
- *
1539
- * @returns This Transaction, for chainning.
1540
- */
1541
- to(account: Account | bkper.Account): Transaction;
1542
- /**
1543
- * @returns The amount of the transaction.
1544
- */
1545
- getAmount(): Amount;
1546
- /**
1547
- *
1548
- * Sets the amount of the Transaction.
1549
- *
1550
- * @returns This Transaction, for chainning.
1551
- */
1552
- setAmount(amount: Amount | number | string): Transaction;
1553
- /**
1554
- * Get the absolute amount of this transaction if the given account is at the credit side, else null.
1555
- *
1556
- * @param account - The account object, id or name.
1557
- */
1558
- getCreditAmount(account: Account | string): Promise<Amount>;
1559
- /**
1560
- * Gets the absolute amount of this transaction if the given account is at the debit side, else null.
1561
- *
1562
- * @param account - The account object, id or name.
1563
- */
1564
- getDebitAmount(account: Account | string): Promise<Amount>;
1565
- /**
1566
- * Gets the [[Account]] at the other side of the transaction given the one in one side.
1567
- *
1568
- * @param account - The account object, id or name.
1569
- */
1570
- getOtherAccount(account: Account | string): Promise<Account>;
1571
- /**
1572
- *
1573
- * The account name at the other side of the transaction given the one in one side.
1574
- *
1575
- * @param account - The account object, id or name.
1576
- */
1577
- getOtherAccountName(account: string | Account): Promise<string>;
1578
- /**
1579
- *
1580
- * Tell if the given account is credit on the transaction
1581
- *
1582
- * @param account - The account object
1583
- */
1584
- isCredit(account: Account): Promise<boolean>;
1585
- /**
1586
- *
1587
- * Tell if the given account is debit on the transaction
1588
- *
1589
- * @param account - The account object
1590
- */
1591
- isDebit(account: Account): Promise<boolean>;
1592
-
1593
- /**
1594
- * @returns The description of this transaction.
1595
- */
1596
- getDescription(): string;
1597
- /**
1598
- *
1599
- * Sets the description of the Transaction.
1600
- *
1601
- * @returns This Transaction, for chainning.
1602
- */
1603
- setDescription(description: string): Transaction;
1604
- /**
1605
- * @returns The Transaction date, in ISO format yyyy-MM-dd.
1606
- */
1607
- getDate(): string;
1608
- /**
1609
- *
1610
- * Sets the date of the Transaction.
1611
- *
1612
- * @returns This Transaction, for chainning
1613
- */
1614
- setDate(date: string | Date): Transaction;
1615
- /**
1616
- * @returns The Transaction Date object, on the time zone of the [[Book]].
1617
- */
1618
- getDateObject(): Date;
1619
- /**
1620
- * @returns The Transaction date number, in format YYYYMMDD.
1621
- */
1622
- getDateValue(): number;
1623
- /**
1624
- * @returns The Transaction date, formatted on the date pattern of the [[Book]].
1625
- */
1626
- getDateFormatted(): string;
1627
- /**
1628
- * @returns The date the transaction was created.
1629
- */
1630
- getCreatedAt(): Date;
1631
- /**
1632
- * @returns The date the transaction was created, formatted according to the date pattern of [[Book]].
1633
- */
1634
- getCreatedAtFormatted(): string;
1635
-
1636
-
1637
- /**
1638
- * Gets the balance that the [[Account]] has at that day, when listing transactions of that Account.
1639
- *
1640
- * Evolved balances is returned when searching for transactions of a permanent [[Account]].
1641
- *
1642
- * Only comes with the last posted transaction of the day.
1643
- *
1644
- * @param raw - True to get the raw balance, no matter the credit nature of the [[Account]].
1645
- */
1646
- getAccountBalance(raw?: boolean): Promise<Amount>;
1647
- /**
1648
- * Perform create new draft transaction.
1649
- */
1650
- create(): Promise<Transaction>;
1651
- /**
1652
- * Upddate transaction, applying pending changes.
1653
- */
1654
- update(): Promise<Transaction>;
1655
- /**
1656
- * Perform check transaction.
1657
- */
1658
- check(): Promise<Transaction>;
1659
- /**
1660
- * Perform uncheck transaction.
1661
- */
1662
- uncheck(): Promise<Transaction>;
1663
- /**
1664
- * Perform post transaction, changing credit and debit [[Account]] balances.
1665
- */
1666
- post(): Promise<Transaction>;
1667
- /**
1668
- * Remove the transaction, sending to trash.
1669
- */
1670
- remove(): Promise<Transaction>;
1671
- /**
1672
- * Restore the transaction from trash.
1673
- */
1674
- restore(): Promise<Transaction>;
1675
- }
1676
-
1677
- /**
1678
- *
1679
- * An iterator that allows scripts to iterate over a potentially large collection of transactions.
1680
- *
1681
- * Example:
1682
- *
1683
- * ```js
1684
- * var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
1685
- *
1686
- * var transactionIterator = book.getTransactions("account:CreditCard after:28/01/2013 before:29/01/2013");
1687
- *
1688
- * while (transactionIterator.hasNext()) {
1689
- * var transaction = transactions.next();
1690
- * Logger.log(transaction.getDescription());
1691
- * }
1692
- * ```
1693
- *
1694
- * @public
1695
- */
1696
- export declare class TransactionIterator {
1697
-
1698
-
1699
-
1700
-
1701
-
1702
-
1703
- /**
1704
- * Gets the Book that originate the iterator
1705
- */
1706
- getBook(): Book;
1707
- /**
1708
- * Gets a token that can be used to resume this iteration at a later time.
1709
- *
1710
- * This method is useful if processing an iterator in one execution would exceed the maximum execution time.
1711
- *
1712
- * Continuation tokens are generally valid short period of time.
1713
- */
1714
- getContinuationToken(): string;
1715
- /**
1716
- * Sets a continuation token from previous paused iteration
1717
- */
1718
- setContinuationToken(continuationToken: string): Promise<void>;
1719
- /**
1720
- * Determines whether calling next() will return a transaction.
1721
- */
1722
- hasNext(): Promise<boolean>;
1723
- /**
1724
- * Gets the next transaction in the collection of transactions.
1725
- */
1726
- next(): Promise<Transaction>;
1727
- /**
1728
- * @returns The account, when filtering by a single account.
1729
- */
1730
- getAccount(): Promise<Account>;
1731
- }
1732
-
1733
- /**
1734
- * This class defines a User.
1735
- *
1736
- * @public
1737
- */
1738
- export declare class User {
1739
-
1740
- constructor(wrapped: bkper.User);
1741
- /**
1742
- * Gets the id of the User.
1743
- *
1744
- * @returns The User's id
1745
- */
1746
- getId(): string;
1747
- /**
1748
- * Gets the name of the User.
1749
- *
1750
- * @returns The User's name
1751
- */
1752
- getName(): string;
1753
- /**
1754
- * Gets the full name of the User.
1755
- *
1756
- * @returns The User's full name
1757
- */
1758
- getFullName(): string;
1759
- /**
1760
- * Gets the [[Connections]] of the User.
1761
- *
1762
- * @returns The retrieved Connection objects
1763
- */
1764
- getConnections(): Promise<Connection[]>;
1765
- /**
1766
- * Gets a [[Connection]] of the User.
1767
- *
1768
- * @param id - The Connection's id
1769
- *
1770
- * @returns The retrieved Connection object
1771
- */
1772
- getConnection(id: string): Promise<Connection>;
1773
- }
1774
-
1775
- export { }