bkper-js 2.28.0 → 2.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -10
- package/lib/builders/AccountsDataTableBuilder.js +247 -0
- package/lib/{model → builders}/BalancesDataTableBuilder.js +36 -13
- package/lib/builders/BooksDataTableBuilder.js +127 -0
- package/lib/builders/GroupsDataTableBuilder.js +193 -0
- package/lib/builders/TransactionsDataTableBuilder.js +359 -0
- package/lib/index.d.ts +371 -0
- package/lib/index.js +31 -27
- package/lib/model/Account.js +24 -10
- package/lib/model/BalancesContainerAccount.js +4 -4
- package/lib/model/BalancesContainerGroup.js +5 -5
- package/lib/model/BalancesReport.js +3 -3
- package/lib/model/Book.js +104 -60
- package/lib/model/Enums.js +24 -0
- package/lib/model/Transaction.js +46 -35
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -125,6 +125,10 @@ export declare class Account extends ResourceProperty<bkper.Account> {
|
|
|
125
125
|
/**
|
|
126
126
|
* Gets the [[Groups]] of this Account.
|
|
127
127
|
*
|
|
128
|
+
* When groups are already embedded in the account payload (e.g. from
|
|
129
|
+
* {@link Bkper.getBook} with includeGroups), resolves them from the
|
|
130
|
+
* book's cache instead of making API calls.
|
|
131
|
+
*
|
|
128
132
|
* @returns Promise with the [[Groups]] of this Account
|
|
129
133
|
*/
|
|
130
134
|
getGroups(): Promise<Group[]>;
|
|
@@ -182,6 +186,81 @@ export declare class Account extends ResourceProperty<bkper.Account> {
|
|
|
182
186
|
|
|
183
187
|
}
|
|
184
188
|
|
|
189
|
+
/**
|
|
190
|
+
* A AccountsDataTableBuilder is used to setup and build two-dimensional arrays containing accounts.
|
|
191
|
+
*
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare class AccountsDataTableBuilder {
|
|
195
|
+
private accounts;
|
|
196
|
+
private shouldIncludeArchived;
|
|
197
|
+
private shouldAddGroups;
|
|
198
|
+
private shouldAddProperties;
|
|
199
|
+
private shouldAddIds;
|
|
200
|
+
private shouldAddHiddenProperties;
|
|
201
|
+
private propertyKeys;
|
|
202
|
+
constructor(accounts: Account[]);
|
|
203
|
+
/**
|
|
204
|
+
* Defines whether the archived accounts should be included.
|
|
205
|
+
*
|
|
206
|
+
* @param include - Whether to include archived accounts
|
|
207
|
+
*
|
|
208
|
+
* @returns This builder with respective include archived option, for chaining.
|
|
209
|
+
*/
|
|
210
|
+
archived(include: boolean): AccountsDataTableBuilder;
|
|
211
|
+
/**
|
|
212
|
+
* Defines whether include account groups.
|
|
213
|
+
*
|
|
214
|
+
* @param include - Whether to include groups
|
|
215
|
+
*
|
|
216
|
+
* @returns This builder with respective include groups option, for chaining.
|
|
217
|
+
*/
|
|
218
|
+
groups(include: boolean): AccountsDataTableBuilder;
|
|
219
|
+
/**
|
|
220
|
+
* Defines whether include custom account properties.
|
|
221
|
+
*
|
|
222
|
+
* @param include - Whether to include properties
|
|
223
|
+
*
|
|
224
|
+
* @returns This builder with respective include properties option, for chaining.
|
|
225
|
+
*/
|
|
226
|
+
properties(include: boolean): AccountsDataTableBuilder;
|
|
227
|
+
/**
|
|
228
|
+
* Defines whether include account ids.
|
|
229
|
+
*
|
|
230
|
+
* @param include - Whether to include ids
|
|
231
|
+
*
|
|
232
|
+
* @returns This builder with respective include ids option, for chaining.
|
|
233
|
+
*/
|
|
234
|
+
ids(include: boolean): AccountsDataTableBuilder;
|
|
235
|
+
/**
|
|
236
|
+
* Defines whether to include hidden properties (keys ending with underscore "_").
|
|
237
|
+
* Only relevant when {@link properties} is enabled.
|
|
238
|
+
* Default is false — hidden properties are excluded.
|
|
239
|
+
*
|
|
240
|
+
* @param include - Whether to include hidden properties
|
|
241
|
+
*
|
|
242
|
+
* @returns This builder with respective option, for chaining.
|
|
243
|
+
*/
|
|
244
|
+
hiddenProperties(include: boolean): AccountsDataTableBuilder;
|
|
245
|
+
private getPropertyKeys;
|
|
246
|
+
private getTypeIndex;
|
|
247
|
+
private getMaxNumberOfGroups;
|
|
248
|
+
/**
|
|
249
|
+
* Sorts groups for an account in hierarchy-path order:
|
|
250
|
+
* 1. Hierarchical groups (those with parent or children) come first, ordered by:
|
|
251
|
+
* - Root group name (alphabetically)
|
|
252
|
+
* - Depth within the hierarchy (parent before child)
|
|
253
|
+
* 2. Free groups (no parent and no children) come last, sorted alphabetically
|
|
254
|
+
*/
|
|
255
|
+
private sortGroupsHierarchyPath_;
|
|
256
|
+
/**
|
|
257
|
+
* Builds a two-dimensional array containing all accounts.
|
|
258
|
+
*
|
|
259
|
+
* @returns A promise resolving to a two-dimensional array containing all accounts
|
|
260
|
+
*/
|
|
261
|
+
build(): Promise<any[][]>;
|
|
262
|
+
}
|
|
263
|
+
|
|
185
264
|
/**
|
|
186
265
|
* Enum that represents account types.
|
|
187
266
|
*
|
|
@@ -939,6 +1018,7 @@ export declare class BalancesDataTableBuilder implements BalancesDataTableBuilde
|
|
|
939
1018
|
private shouldPeriod;
|
|
940
1019
|
private shouldRaw;
|
|
941
1020
|
private shouldAddProperties;
|
|
1021
|
+
private shouldAddHiddenProperties;
|
|
942
1022
|
private maxDepth;
|
|
943
1023
|
private expandAllAccounts;
|
|
944
1024
|
private expandAllGroups;
|
|
@@ -1058,6 +1138,16 @@ export declare class BalancesDataTableBuilder implements BalancesDataTableBuilde
|
|
|
1058
1138
|
* @returns This builder with respective include properties option, for chaining.
|
|
1059
1139
|
*/
|
|
1060
1140
|
properties(include: boolean): BalancesDataTableBuilder;
|
|
1141
|
+
/**
|
|
1142
|
+
* Defines whether to include hidden properties (keys ending with underscore "_").
|
|
1143
|
+
* Only relevant when {@link properties} is enabled.
|
|
1144
|
+
* Default is false — hidden properties are excluded.
|
|
1145
|
+
*
|
|
1146
|
+
* @param include - Whether to include hidden properties
|
|
1147
|
+
*
|
|
1148
|
+
* @returns This builder with respective option, for chaining.
|
|
1149
|
+
*/
|
|
1150
|
+
hiddenProperties(include: boolean): BalancesDataTableBuilder;
|
|
1061
1151
|
/**
|
|
1062
1152
|
* Defines whether should split **TOTAL** [[BalanceType]] into debit and credit.
|
|
1063
1153
|
*
|
|
@@ -2002,6 +2092,78 @@ export declare class Book extends ResourceProperty<bkper.Book> {
|
|
|
2002
2092
|
* @returns The Backlog object
|
|
2003
2093
|
*/
|
|
2004
2094
|
getBacklog(): Promise<Backlog>;
|
|
2095
|
+
/**
|
|
2096
|
+
* Create a {@link AccountsDataTableBuilder}, to build two dimensional Array representations of {@link Account} dataset.
|
|
2097
|
+
*
|
|
2098
|
+
* @param accounts - Optional array of accounts. If not provided, all accounts will be fetched.
|
|
2099
|
+
*
|
|
2100
|
+
* @returns Accounts data table builder.
|
|
2101
|
+
*/
|
|
2102
|
+
createAccountsDataTable(accounts?: Account[]): Promise<AccountsDataTableBuilder>;
|
|
2103
|
+
/**
|
|
2104
|
+
* Create a {@link GroupsDataTableBuilder}, to build two dimensional Array representations of {@link Group} dataset.
|
|
2105
|
+
*
|
|
2106
|
+
* @param groups - Optional array of groups. If not provided, all groups will be fetched.
|
|
2107
|
+
*
|
|
2108
|
+
* @returns Groups data table builder.
|
|
2109
|
+
*/
|
|
2110
|
+
createGroupsDataTable(groups?: Group[]): Promise<GroupsDataTableBuilder>;
|
|
2111
|
+
/**
|
|
2112
|
+
* Create a {@link TransactionsDataTableBuilder}, to build two dimensional Array representations of {@link Transaction} dataset.
|
|
2113
|
+
*
|
|
2114
|
+
* @param transactions - Array of transactions to include in the table.
|
|
2115
|
+
* @param account - Optional account for balance column display.
|
|
2116
|
+
*
|
|
2117
|
+
* @returns Transactions data table builder.
|
|
2118
|
+
*/
|
|
2119
|
+
createTransactionsDataTable(transactions: Transaction[], account?: Account): TransactionsDataTableBuilder;
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2122
|
+
/**
|
|
2123
|
+
* A BooksDataTableBuilder is used to setup and build two-dimensional arrays containing books.
|
|
2124
|
+
*
|
|
2125
|
+
* @public
|
|
2126
|
+
*/
|
|
2127
|
+
export declare class BooksDataTableBuilder {
|
|
2128
|
+
private books;
|
|
2129
|
+
private shouldAddProperties;
|
|
2130
|
+
private shouldAddIds;
|
|
2131
|
+
private shouldAddHiddenProperties;
|
|
2132
|
+
private propertyKeys;
|
|
2133
|
+
constructor(books: Book[]);
|
|
2134
|
+
/**
|
|
2135
|
+
* Defines whether to include custom book properties.
|
|
2136
|
+
*
|
|
2137
|
+
* @param include - Whether to include properties
|
|
2138
|
+
*
|
|
2139
|
+
* @returns This builder with respective include properties option, for chaining.
|
|
2140
|
+
*/
|
|
2141
|
+
properties(include: boolean): BooksDataTableBuilder;
|
|
2142
|
+
/**
|
|
2143
|
+
* Defines whether to include book ids.
|
|
2144
|
+
*
|
|
2145
|
+
* @param include - Whether to include ids
|
|
2146
|
+
*
|
|
2147
|
+
* @returns This builder with respective include ids option, for chaining.
|
|
2148
|
+
*/
|
|
2149
|
+
ids(include: boolean): BooksDataTableBuilder;
|
|
2150
|
+
/**
|
|
2151
|
+
* Defines whether to include hidden properties (keys ending with underscore "_").
|
|
2152
|
+
* Only relevant when {@link properties} is enabled.
|
|
2153
|
+
* Default is false — hidden properties are excluded.
|
|
2154
|
+
*
|
|
2155
|
+
* @param include - Whether to include hidden properties
|
|
2156
|
+
*
|
|
2157
|
+
* @returns This builder with respective option, for chaining.
|
|
2158
|
+
*/
|
|
2159
|
+
hiddenProperties(include: boolean): BooksDataTableBuilder;
|
|
2160
|
+
private mapPropertyKeys;
|
|
2161
|
+
/**
|
|
2162
|
+
* Builds a two-dimensional array containing all Books.
|
|
2163
|
+
*
|
|
2164
|
+
* @returns A two-dimensional array containing all Books
|
|
2165
|
+
*/
|
|
2166
|
+
build(): any[][];
|
|
2005
2167
|
}
|
|
2006
2168
|
|
|
2007
2169
|
/**
|
|
@@ -2861,6 +3023,70 @@ export declare class Group extends ResourceProperty<bkper.Group> {
|
|
|
2861
3023
|
|
|
2862
3024
|
}
|
|
2863
3025
|
|
|
3026
|
+
/**
|
|
3027
|
+
* A GroupsDataTableBuilder is used to setup and build two-dimensional arrays containing groups.
|
|
3028
|
+
*
|
|
3029
|
+
* @public
|
|
3030
|
+
*/
|
|
3031
|
+
export declare class GroupsDataTableBuilder {
|
|
3032
|
+
private groups;
|
|
3033
|
+
private shouldAddProperties;
|
|
3034
|
+
private shouldAddIds;
|
|
3035
|
+
private shouldAddHiddenProperties;
|
|
3036
|
+
private shouldShowTree;
|
|
3037
|
+
private propertyKeys;
|
|
3038
|
+
constructor(groups: Group[]);
|
|
3039
|
+
/**
|
|
3040
|
+
* Defines whether include custom group properties.
|
|
3041
|
+
*
|
|
3042
|
+
* @param include - Whether to include properties
|
|
3043
|
+
*
|
|
3044
|
+
* @returns This builder with respective include properties option, for chaining.
|
|
3045
|
+
*/
|
|
3046
|
+
properties(include: boolean): GroupsDataTableBuilder;
|
|
3047
|
+
/**
|
|
3048
|
+
* Defines whether include group ids.
|
|
3049
|
+
*
|
|
3050
|
+
* @param include - Whether to include ids
|
|
3051
|
+
*
|
|
3052
|
+
* @returns This builder with respective include ids option, for chaining.
|
|
3053
|
+
*/
|
|
3054
|
+
ids(include: boolean): GroupsDataTableBuilder;
|
|
3055
|
+
/**
|
|
3056
|
+
* Defines whether to include hidden properties (keys ending with underscore "_").
|
|
3057
|
+
* Only relevant when {@link properties} is enabled.
|
|
3058
|
+
* Default is false — hidden properties are excluded.
|
|
3059
|
+
*
|
|
3060
|
+
* @param include - Whether to include hidden properties
|
|
3061
|
+
*
|
|
3062
|
+
* @returns This builder with respective option, for chaining.
|
|
3063
|
+
*/
|
|
3064
|
+
hiddenProperties(include: boolean): GroupsDataTableBuilder;
|
|
3065
|
+
/**
|
|
3066
|
+
* Defines whether to render groups as an indented tree instead of flat rows with a Parent column.
|
|
3067
|
+
* When enabled, child group names are indented by depth level and the Parent column is removed.
|
|
3068
|
+
* Default is false.
|
|
3069
|
+
*
|
|
3070
|
+
* @param enable - Whether to enable tree rendering
|
|
3071
|
+
*
|
|
3072
|
+
* @returns This builder with respective option, for chaining.
|
|
3073
|
+
*/
|
|
3074
|
+
tree(enable: boolean): GroupsDataTableBuilder;
|
|
3075
|
+
private mapPropertyKeys;
|
|
3076
|
+
private getStringType;
|
|
3077
|
+
private getTypeIndex;
|
|
3078
|
+
private getHasChildrenIndex;
|
|
3079
|
+
/**
|
|
3080
|
+
* Builds a two-dimensional array containing all Groups.
|
|
3081
|
+
*
|
|
3082
|
+
* @returns A two-dimensional array containing all Groups
|
|
3083
|
+
*/
|
|
3084
|
+
build(): any[][];
|
|
3085
|
+
private buildGroupLine;
|
|
3086
|
+
private traverse;
|
|
3087
|
+
private readonly COMPARATOR;
|
|
3088
|
+
}
|
|
3089
|
+
|
|
2864
3090
|
/**
|
|
2865
3091
|
* This class defines a Integration from an [[User]] to an external service.
|
|
2866
3092
|
*
|
|
@@ -3375,6 +3601,12 @@ export declare class Transaction extends ResourceProperty<bkper.Transaction> {
|
|
|
3375
3601
|
* @returns True if a transaction is locked by the book lock/closing date
|
|
3376
3602
|
*/
|
|
3377
3603
|
isLocked(): boolean;
|
|
3604
|
+
/**
|
|
3605
|
+
* Gets the status of the transaction.
|
|
3606
|
+
*
|
|
3607
|
+
* @returns The status of the Transaction
|
|
3608
|
+
*/
|
|
3609
|
+
getStatus(): TransactionStatus;
|
|
3378
3610
|
/**
|
|
3379
3611
|
* Gets all hashtags used in the transaction.
|
|
3380
3612
|
*
|
|
@@ -3736,6 +3968,145 @@ export declare class TransactionList {
|
|
|
3736
3968
|
getItems(): Transaction[];
|
|
3737
3969
|
}
|
|
3738
3970
|
|
|
3971
|
+
/**
|
|
3972
|
+
* A TransactionsDataTableBuilder is used to setup and build two-dimensional arrays containing transactions.
|
|
3973
|
+
*
|
|
3974
|
+
* @public
|
|
3975
|
+
*/
|
|
3976
|
+
export declare class TransactionsDataTableBuilder {
|
|
3977
|
+
private book;
|
|
3978
|
+
private transactions;
|
|
3979
|
+
private account;
|
|
3980
|
+
private shouldFormatDates;
|
|
3981
|
+
private shouldFormatValues;
|
|
3982
|
+
private shouldAddUrls;
|
|
3983
|
+
private shouldAddProperties;
|
|
3984
|
+
private shouldAddIds;
|
|
3985
|
+
private shouldAddRecordedAt;
|
|
3986
|
+
private shouldAddHiddenProperties;
|
|
3987
|
+
private propertyKeys;
|
|
3988
|
+
private attachmentHeaders;
|
|
3989
|
+
private remoteIdHeaders;
|
|
3990
|
+
constructor(book: Book, transactions: Transaction[], account?: Account);
|
|
3991
|
+
/**
|
|
3992
|
+
* Defines whether the dates should be formatted, based on date pattern of the [[Book]].
|
|
3993
|
+
*
|
|
3994
|
+
* @param format - Whether to format dates
|
|
3995
|
+
*
|
|
3996
|
+
* @returns This builder with respective formatting option, for chaining.
|
|
3997
|
+
*/
|
|
3998
|
+
formatDates(format: boolean): TransactionsDataTableBuilder;
|
|
3999
|
+
/**
|
|
4000
|
+
* Defines whether amounts should be formatted based on [[DecimalSeparator]] of the [[Book]].
|
|
4001
|
+
*
|
|
4002
|
+
* @param format - Whether to format values
|
|
4003
|
+
*
|
|
4004
|
+
* @returns This builder with respective formatting option, for chaining.
|
|
4005
|
+
*/
|
|
4006
|
+
formatValues(format: boolean): TransactionsDataTableBuilder;
|
|
4007
|
+
/**
|
|
4008
|
+
* Defines whether to include attachments and url links.
|
|
4009
|
+
*
|
|
4010
|
+
* @param include - Whether to include URLs
|
|
4011
|
+
*
|
|
4012
|
+
* @returns This builder with respective option, for chaining.
|
|
4013
|
+
*/
|
|
4014
|
+
urls(include: boolean): TransactionsDataTableBuilder;
|
|
4015
|
+
/**
|
|
4016
|
+
* Defines whether to include custom transaction properties.
|
|
4017
|
+
*
|
|
4018
|
+
* @param include - Whether to include properties
|
|
4019
|
+
*
|
|
4020
|
+
* @returns This builder with respective option, for chaining.
|
|
4021
|
+
*/
|
|
4022
|
+
properties(include: boolean): TransactionsDataTableBuilder;
|
|
4023
|
+
/**
|
|
4024
|
+
* Defines whether to include transaction ids and remote ids.
|
|
4025
|
+
*
|
|
4026
|
+
* @param include - Whether to include ids
|
|
4027
|
+
*
|
|
4028
|
+
* @returns This builder with respective option, for chaining.
|
|
4029
|
+
*/
|
|
4030
|
+
ids(include: boolean): TransactionsDataTableBuilder;
|
|
4031
|
+
/**
|
|
4032
|
+
* Defines whether to include the "Recorded at" column.
|
|
4033
|
+
*
|
|
4034
|
+
* @param include - Whether to include the recorded at column
|
|
4035
|
+
*
|
|
4036
|
+
* @returns This builder with respective option, for chaining.
|
|
4037
|
+
*/
|
|
4038
|
+
recordedAt(include: boolean): TransactionsDataTableBuilder;
|
|
4039
|
+
/**
|
|
4040
|
+
* Defines whether to include hidden properties (keys ending with underscore "_").
|
|
4041
|
+
* Only relevant when {@link properties} is enabled.
|
|
4042
|
+
* Default is false — hidden properties are excluded.
|
|
4043
|
+
*
|
|
4044
|
+
* @param include - Whether to include hidden properties
|
|
4045
|
+
*
|
|
4046
|
+
* @returns This builder with respective option, for chaining.
|
|
4047
|
+
*/
|
|
4048
|
+
hiddenProperties(include: boolean): TransactionsDataTableBuilder;
|
|
4049
|
+
/**
|
|
4050
|
+
* @deprecated Use {@link urls} instead.
|
|
4051
|
+
*/
|
|
4052
|
+
includeUrls(include: boolean): TransactionsDataTableBuilder;
|
|
4053
|
+
/**
|
|
4054
|
+
* @deprecated Use {@link properties} instead.
|
|
4055
|
+
*/
|
|
4056
|
+
includeProperties(include: boolean): TransactionsDataTableBuilder;
|
|
4057
|
+
/**
|
|
4058
|
+
* @deprecated Use {@link ids} instead.
|
|
4059
|
+
*/
|
|
4060
|
+
includeIds(include: boolean): TransactionsDataTableBuilder;
|
|
4061
|
+
/**
|
|
4062
|
+
* Gets the account used to filter transactions, when applicable.
|
|
4063
|
+
*
|
|
4064
|
+
* @returns The account, when filtering by a single account.
|
|
4065
|
+
*/
|
|
4066
|
+
getAccount(): Account | undefined;
|
|
4067
|
+
/**
|
|
4068
|
+
* Builds a two-dimensional array containing all transactions.
|
|
4069
|
+
*
|
|
4070
|
+
* @returns A promise resolving to a two-dimensional array containing all transactions
|
|
4071
|
+
*/
|
|
4072
|
+
build(): Promise<any[][]>;
|
|
4073
|
+
private getHeaderLine;
|
|
4074
|
+
private get2DArray_;
|
|
4075
|
+
private shouldShowBalances;
|
|
4076
|
+
private isCreditOnTransaction_;
|
|
4077
|
+
private getPropertyKeys;
|
|
4078
|
+
private getAttachmentHeaders;
|
|
4079
|
+
private getRemoteIdHeaders;
|
|
4080
|
+
private addPropertiesToLine;
|
|
4081
|
+
private addRemoteIdsToLine;
|
|
4082
|
+
private addUrlsToLine;
|
|
4083
|
+
private getUrls;
|
|
4084
|
+
}
|
|
4085
|
+
|
|
4086
|
+
/**
|
|
4087
|
+
* Enum that represents the status of a Transaction.
|
|
4088
|
+
*
|
|
4089
|
+
* @public
|
|
4090
|
+
*/
|
|
4091
|
+
export declare enum TransactionStatus {
|
|
4092
|
+
/**
|
|
4093
|
+
* Transaction is in the trash
|
|
4094
|
+
*/
|
|
4095
|
+
TRASHED = "TRASHED",
|
|
4096
|
+
/**
|
|
4097
|
+
* Transaction is a draft, not yet posted
|
|
4098
|
+
*/
|
|
4099
|
+
DRAFT = "DRAFT",
|
|
4100
|
+
/**
|
|
4101
|
+
* Transaction is posted but not checked
|
|
4102
|
+
*/
|
|
4103
|
+
UNCHECKED = "UNCHECKED",
|
|
4104
|
+
/**
|
|
4105
|
+
* Transaction is posted and checked
|
|
4106
|
+
*/
|
|
4107
|
+
CHECKED = "CHECKED"
|
|
4108
|
+
}
|
|
4109
|
+
|
|
3739
4110
|
/**
|
|
3740
4111
|
* This class defines a User on the Bkper platform.
|
|
3741
4112
|
*
|
package/lib/index.js
CHANGED
|
@@ -5,31 +5,35 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
|
-
export { Account } from
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
8
|
+
export { Account } from './model/Account.js';
|
|
9
|
+
export { AccountsDataTableBuilder } from './builders/AccountsDataTableBuilder.js';
|
|
10
|
+
export { Agent } from './model/Agent.js';
|
|
11
|
+
export { Amount } from './model/Amount.js';
|
|
12
|
+
export { App } from './model/App.js';
|
|
13
|
+
export { Backlog } from './model/Backlog.js';
|
|
14
|
+
export { Balance } from './model/Balance.js';
|
|
15
|
+
export { BalancesDataTableBuilder } from './builders/BalancesDataTableBuilder.js';
|
|
16
|
+
export { BalancesReport } from './model/BalancesReport.js';
|
|
17
|
+
export { Billing } from './model/Billing.js';
|
|
18
|
+
export { Bkper } from './model/Bkper.js';
|
|
19
|
+
export { Book } from './model/Book.js';
|
|
20
|
+
export { BooksDataTableBuilder } from './builders/BooksDataTableBuilder.js';
|
|
21
|
+
export { Collaborator } from './model/Collaborator.js';
|
|
22
|
+
export { Collection } from './model/Collection.js';
|
|
23
|
+
export { Connection } from './model/Connection.js';
|
|
24
|
+
export { File } from './model/File.js';
|
|
25
|
+
export { Group } from './model/Group.js';
|
|
26
|
+
export { GroupsDataTableBuilder } from './builders/GroupsDataTableBuilder.js';
|
|
27
|
+
export { Integration } from './model/Integration.js';
|
|
28
|
+
export { Query } from './model/Query.js';
|
|
29
|
+
export { Template } from './model/Template.js';
|
|
30
|
+
export { Transaction } from './model/Transaction.js';
|
|
31
|
+
export { TransactionList } from './model/TransactionList.js';
|
|
32
|
+
export { TransactionsDataTableBuilder } from './builders/TransactionsDataTableBuilder.js';
|
|
33
|
+
export { Event } from './model/Event.js';
|
|
34
|
+
export { BotResponse } from './model/BotResponse.js';
|
|
35
|
+
export { EventList } from './model/EventList.js';
|
|
36
|
+
export { User } from './model/User.js';
|
|
37
|
+
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, BalanceType, Period, Month, EventType, BotResponseType, TransactionStatus, } from './model/Enums.js';
|
|
38
|
+
export { BkperError } from './model/BkperError.js';
|
|
35
39
|
//# sourceMappingURL=index.js.map
|
package/lib/model/Account.js
CHANGED
|
@@ -7,11 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import * as AccountService from
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { ResourceProperty } from "./ResourceProperty.js";
|
|
10
|
+
import * as AccountService from '../service/account-service.js';
|
|
11
|
+
import { Group } from './Group.js';
|
|
12
|
+
import { normalizeText } from '../utils.js';
|
|
13
|
+
import { ResourceProperty } from './ResourceProperty.js';
|
|
15
14
|
/**
|
|
16
15
|
* This class defines an [Account](https://en.wikipedia.org/wiki/Account_(bookkeeping)) of a [[Book]].
|
|
17
16
|
*
|
|
@@ -168,6 +167,10 @@ export class Account extends ResourceProperty {
|
|
|
168
167
|
/**
|
|
169
168
|
* Gets the [[Groups]] of this Account.
|
|
170
169
|
*
|
|
170
|
+
* When groups are already embedded in the account payload (e.g. from
|
|
171
|
+
* {@link Bkper.getBook} with includeGroups), resolves them from the
|
|
172
|
+
* book's cache instead of making API calls.
|
|
173
|
+
*
|
|
171
174
|
* @returns Promise with the [[Groups]] of this Account
|
|
172
175
|
*/
|
|
173
176
|
getGroups() {
|
|
@@ -176,9 +179,20 @@ export class Account extends ResourceProperty {
|
|
|
176
179
|
if (!id) {
|
|
177
180
|
return [];
|
|
178
181
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
+
//Ensure groups are pre-loaded in the book cache to avoid multiple API calls when resolving groups from the payload
|
|
183
|
+
yield this.book.getGroups();
|
|
184
|
+
// resolve them from the book's group cache to get properly tree-linked Group objects
|
|
185
|
+
if (this.payload.groups != null) {
|
|
186
|
+
const groups = [];
|
|
187
|
+
for (const groupPayload of this.payload.groups) {
|
|
188
|
+
const group = yield this.book.getGroup(groupPayload.id);
|
|
189
|
+
if (group) {
|
|
190
|
+
groups.push(group);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return groups;
|
|
194
|
+
}
|
|
195
|
+
return [];
|
|
182
196
|
});
|
|
183
197
|
}
|
|
184
198
|
/**
|
|
@@ -191,7 +205,7 @@ export class Account extends ResourceProperty {
|
|
|
191
205
|
setGroups(groups) {
|
|
192
206
|
this.payload.groups = undefined;
|
|
193
207
|
if (groups != null) {
|
|
194
|
-
groups.forEach(
|
|
208
|
+
groups.forEach(group => this.addGroup(group));
|
|
195
209
|
}
|
|
196
210
|
return this;
|
|
197
211
|
}
|
|
@@ -228,7 +242,7 @@ export class Account extends ResourceProperty {
|
|
|
228
242
|
if (group instanceof Group) {
|
|
229
243
|
groupObject = group;
|
|
230
244
|
}
|
|
231
|
-
else if (typeof group ==
|
|
245
|
+
else if (typeof group == 'string') {
|
|
232
246
|
groupObject = yield this.book.getGroup(group);
|
|
233
247
|
}
|
|
234
248
|
if (groupObject) {
|
|
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { getRepresentativeValue, normalizeName } from
|
|
11
|
-
import { Amount } from
|
|
12
|
-
import { Balance } from
|
|
13
|
-
import { BalancesDataTableBuilder } from
|
|
10
|
+
import { getRepresentativeValue, normalizeName } from '../utils.js';
|
|
11
|
+
import { Amount } from './Amount.js';
|
|
12
|
+
import { Balance } from './Balance.js';
|
|
13
|
+
import { BalancesDataTableBuilder } from '../builders/BalancesDataTableBuilder.js';
|
|
14
14
|
/** @internal */
|
|
15
15
|
export class AccountBalancesContainer {
|
|
16
16
|
constructor(parent, balancesReport, payload) {
|
|
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { Amount } from
|
|
11
|
-
import { getRepresentativeValue, normalizeName } from
|
|
12
|
-
import { AccountBalancesContainer } from
|
|
13
|
-
import { Balance } from
|
|
14
|
-
import { BalancesDataTableBuilder } from
|
|
10
|
+
import { Amount } from './Amount.js';
|
|
11
|
+
import { getRepresentativeValue, normalizeName } from '../utils.js';
|
|
12
|
+
import { AccountBalancesContainer } from './BalancesContainerAccount.js';
|
|
13
|
+
import { Balance } from './Balance.js';
|
|
14
|
+
import { BalancesDataTableBuilder } from '../builders/BalancesDataTableBuilder.js';
|
|
15
15
|
/** @internal */
|
|
16
16
|
export class GroupBalancesContainer {
|
|
17
17
|
constructor(parent, balancesReport, payload) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeName } from '../utils.js';
|
|
2
|
-
import { AccountBalancesContainer } from
|
|
3
|
-
import { GroupBalancesContainer } from
|
|
4
|
-
import { BalancesDataTableBuilder } from '
|
|
2
|
+
import { AccountBalancesContainer } from './BalancesContainerAccount.js';
|
|
3
|
+
import { GroupBalancesContainer } from './BalancesContainerGroup.js';
|
|
4
|
+
import { BalancesDataTableBuilder } from '../builders/BalancesDataTableBuilder.js';
|
|
5
5
|
/**
|
|
6
6
|
* Class representing a Balance Report, generated when calling [Book.getBalanceReport](#book_getbalancesreport)
|
|
7
7
|
*
|