bkper-js 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +39 -20
- package/lib/index.js +3 -1
- package/lib/model/Balance.js +12 -12
- package/lib/model/BalancesDataTableBuilder.js +20 -22
- package/lib/model/BalancesReport.js +9 -2
- package/lib/model/Book.js +12 -0
- package/lib/model/Group.js +2 -0
- package/lib/utils.js +10 -0
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -628,8 +628,8 @@ export declare class App {
|
|
|
628
628
|
*
|
|
629
629
|
* @public
|
|
630
630
|
*/
|
|
631
|
-
declare class Balance {
|
|
632
|
-
|
|
631
|
+
export declare class Balance {
|
|
632
|
+
payload: bkper.Balance;
|
|
633
633
|
private container;
|
|
634
634
|
constructor(container: BalancesContainer, balancePlain: bkper.Balance);
|
|
635
635
|
/**
|
|
@@ -651,7 +651,7 @@ declare class Balance {
|
|
|
651
651
|
/**
|
|
652
652
|
* Date object constructed based on [[Book]] time zone offset. Usefull for
|
|
653
653
|
*
|
|
654
|
-
* If Month or Day is zero, the date will be constructed with first Month (January) or Day (1).
|
|
654
|
+
* If Month or Day is zero, the date will be constructed with first Month (January) or Day (1) of the next period.
|
|
655
655
|
*/
|
|
656
656
|
getDate(): Date;
|
|
657
657
|
/**
|
|
@@ -712,6 +712,7 @@ declare class Balance {
|
|
|
712
712
|
* @public
|
|
713
713
|
*/
|
|
714
714
|
export declare interface BalancesContainer {
|
|
715
|
+
payload: bkper.AccountBalances | bkper.GroupBalances;
|
|
715
716
|
/**
|
|
716
717
|
* Gets the parent [[BalancesReport]] of the container.
|
|
717
718
|
*
|
|
@@ -890,7 +891,7 @@ export declare interface BalancesContainer {
|
|
|
890
891
|
*
|
|
891
892
|
* Gets the property value for given keys. First property found will be retrieved
|
|
892
893
|
*
|
|
893
|
-
* @param keys The property key
|
|
894
|
+
* @param keys - The property key
|
|
894
895
|
*/
|
|
895
896
|
getProperty(...keys: string[]): string | undefined;
|
|
896
897
|
/**
|
|
@@ -924,7 +925,7 @@ export declare interface BalancesContainer {
|
|
|
924
925
|
*
|
|
925
926
|
* @public
|
|
926
927
|
*/
|
|
927
|
-
declare class BalancesDataTableBuilder implements BalancesDataTableBuilder {
|
|
928
|
+
export declare class BalancesDataTableBuilder implements BalancesDataTableBuilder {
|
|
928
929
|
private balanceType;
|
|
929
930
|
private balancesContainers;
|
|
930
931
|
private periodicity;
|
|
@@ -947,7 +948,7 @@ declare class BalancesDataTableBuilder implements BalancesDataTableBuilder {
|
|
|
947
948
|
private getRepresentativeBalance;
|
|
948
949
|
private getBalanceText;
|
|
949
950
|
/**
|
|
950
|
-
* Defines whether the dates should be formatted
|
|
951
|
+
* Defines whether the dates should be ISO formatted YYYY-MM-DD. E.g. 2025-01-01
|
|
951
952
|
*
|
|
952
953
|
* @returns This builder with respective formatting option, for chaining.
|
|
953
954
|
*/
|
|
@@ -968,7 +969,7 @@ declare class BalancesDataTableBuilder implements BalancesDataTableBuilder {
|
|
|
968
969
|
/**
|
|
969
970
|
* Fluent method to set the [[BalanceType]] for the builder.
|
|
970
971
|
*
|
|
971
|
-
* @param type The type of balance for this data table
|
|
972
|
+
* @param type - The type of balance for this data table
|
|
972
973
|
*
|
|
973
974
|
* For **TOTAL** [[BalanceType]], the table format looks like:
|
|
974
975
|
*
|
|
@@ -985,17 +986,16 @@ declare class BalancesDataTableBuilder implements BalancesDataTableBuilder {
|
|
|
985
986
|
* For **PERIOD** or **CUMULATIVE** [[BalanceType]], the table will be a time table, and the format looks like:
|
|
986
987
|
*
|
|
987
988
|
* ```
|
|
988
|
-
*
|
|
989
|
-
* | |
|
|
990
|
-
* |
|
|
991
|
-
* |
|
|
992
|
-
* |
|
|
993
|
-
* |
|
|
994
|
-
* |____________|___________|_________|__________|
|
|
989
|
+
* _______________________________________________________________
|
|
990
|
+
* | | 15/01/2014 | 15/02/2014 | 15/03/2014 | ... |
|
|
991
|
+
* | Expenses | -2345.23 | -2345.93 | -2456.45 | ... |
|
|
992
|
+
* | Income | 3452.93 | 3456.46 | 3567.87 | ... |
|
|
993
|
+
* | ... | ... | ... | ... | ... |
|
|
994
|
+
* |____________|____________|____________|____________|___________|
|
|
995
995
|
*
|
|
996
996
|
* ```
|
|
997
997
|
*
|
|
998
|
-
* First column will be the
|
|
998
|
+
* First column will be the [[Account]] or [[Group]] name, and one column for each Date.
|
|
999
999
|
*
|
|
1000
1000
|
* @returns This builder with respective balance type, for chaining.
|
|
1001
1001
|
*/
|
|
@@ -1019,15 +1019,16 @@ declare class BalancesDataTableBuilder implements BalancesDataTableBuilder {
|
|
|
1019
1019
|
*
|
|
1020
1020
|
* ```
|
|
1021
1021
|
* _______________________________________________________________
|
|
1022
|
-
* | |
|
|
1023
|
-
* |
|
|
1024
|
-
* |
|
|
1022
|
+
* | | Expenses | Income | ... | ... |
|
|
1023
|
+
* | 15/01/2014 | -2345.23 | 3452.93 | ... | ... |
|
|
1024
|
+
* | 15/02/2014 | -2345.93 | 3456.46 | ... | ... |
|
|
1025
|
+
* | 15/03/2014 | -2456.45 | 3567.87 | ... | ... |
|
|
1025
1026
|
* | ... | ... | ... | ... | ... |
|
|
1026
1027
|
* |____________|____________|____________|____________|___________|
|
|
1027
1028
|
*
|
|
1028
1029
|
* ```
|
|
1029
1030
|
*
|
|
1030
|
-
* First column will be each [[Account]] or [[Group]]
|
|
1031
|
+
* First column will be each Date, and one column for each [[Account]] or [[Group]].
|
|
1031
1032
|
*
|
|
1032
1033
|
* @returns This builder with respective transposed option, for chaining.
|
|
1033
1034
|
*/
|
|
@@ -1102,6 +1103,10 @@ export declare class BalancesReport {
|
|
|
1102
1103
|
* @returns The [[Book]] that generated the report
|
|
1103
1104
|
*/
|
|
1104
1105
|
getBook(): Book;
|
|
1106
|
+
/**
|
|
1107
|
+
* Creates a BalancesDataTableBuilder to generate a two-dimensional array with all [[BalancesContainers]].
|
|
1108
|
+
*/
|
|
1109
|
+
createDataTable(): BalancesDataTableBuilder;
|
|
1105
1110
|
/**
|
|
1106
1111
|
* Gets the [[Periodicity]] of the query used to generate the report.
|
|
1107
1112
|
*
|
|
@@ -1132,7 +1137,7 @@ export declare class BalancesReport {
|
|
|
1132
1137
|
*
|
|
1133
1138
|
* @public
|
|
1134
1139
|
*/
|
|
1135
|
-
declare enum BalanceType {
|
|
1140
|
+
export declare enum BalanceType {
|
|
1136
1141
|
/**
|
|
1137
1142
|
* Total balance
|
|
1138
1143
|
*/
|
|
@@ -1368,6 +1373,8 @@ export declare class Book {
|
|
|
1368
1373
|
/**
|
|
1369
1374
|
* Sets the date pattern of the Book. Current: dd/MM/yyyy | MM/dd/yyyy | yyyy/MM/dd
|
|
1370
1375
|
*
|
|
1376
|
+
* @param datePattern - The date pattern to set
|
|
1377
|
+
*
|
|
1371
1378
|
* @returns This Book, for chaining
|
|
1372
1379
|
*/
|
|
1373
1380
|
setDatePattern(datePattern: string): Book;
|
|
@@ -1380,6 +1387,8 @@ export declare class Book {
|
|
|
1380
1387
|
/**
|
|
1381
1388
|
* Sets the lock date of the Book in ISO format yyyy-MM-dd.
|
|
1382
1389
|
*
|
|
1390
|
+
* @param lockDate - The lock date to set in ISO format yyyy-MM-dd
|
|
1391
|
+
*
|
|
1383
1392
|
* @returns This Book, for chaining
|
|
1384
1393
|
*/
|
|
1385
1394
|
setLockDate(lockDate: string | null): Book;
|
|
@@ -1392,6 +1401,8 @@ export declare class Book {
|
|
|
1392
1401
|
/**
|
|
1393
1402
|
* Sets the closing date of the Book in ISO format yyyy-MM-dd.
|
|
1394
1403
|
*
|
|
1404
|
+
* @param closingDate - The closing date to set in ISO format yyyy-MM-dd
|
|
1405
|
+
*
|
|
1395
1406
|
* @returns This Book, for chaining
|
|
1396
1407
|
*/
|
|
1397
1408
|
setClosingDate(closingDate: string | null): Book;
|
|
@@ -1404,6 +1415,8 @@ export declare class Book {
|
|
|
1404
1415
|
/**
|
|
1405
1416
|
* Sets the decimal separator of the Book
|
|
1406
1417
|
*
|
|
1418
|
+
* @param decimalSeparator - The decimal separator to set
|
|
1419
|
+
*
|
|
1407
1420
|
* @returns This Book, for chaining
|
|
1408
1421
|
*/
|
|
1409
1422
|
setDecimalSeparator(decimalSeparator: DecimalSeparator): Book;
|
|
@@ -1416,6 +1429,8 @@ export declare class Book {
|
|
|
1416
1429
|
/**
|
|
1417
1430
|
* Sets the time zone of the Book.
|
|
1418
1431
|
*
|
|
1432
|
+
* @param timeZone - The time zone to set
|
|
1433
|
+
*
|
|
1419
1434
|
* @returns This Book, for chaining
|
|
1420
1435
|
*/
|
|
1421
1436
|
setTimeZone(timeZone: string): Book;
|
|
@@ -1434,6 +1449,8 @@ export declare class Book {
|
|
|
1434
1449
|
/**
|
|
1435
1450
|
* Sets the auto post status of the Book.
|
|
1436
1451
|
*
|
|
1452
|
+
* @param autoPost - The auto post status to set
|
|
1453
|
+
*
|
|
1437
1454
|
* @returns This Book, for chaining
|
|
1438
1455
|
*/
|
|
1439
1456
|
setAutoPost(autoPost: boolean): Book;
|
|
@@ -2507,6 +2524,8 @@ export declare class Group {
|
|
|
2507
2524
|
/**
|
|
2508
2525
|
* Sets the name of the Group.
|
|
2509
2526
|
*
|
|
2527
|
+
* @param name - The name to set
|
|
2528
|
+
*
|
|
2510
2529
|
* @returns This Group, for chaining
|
|
2511
2530
|
*/
|
|
2512
2531
|
setName(name: string): Group;
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export { Account } from './model/Account.js';
|
|
|
9
9
|
export { Agent } from './model/Agent.js';
|
|
10
10
|
export { Amount } from "./model/Amount.js";
|
|
11
11
|
export { App } from './model/App.js';
|
|
12
|
+
export { Balance } from './model/Balance.js';
|
|
13
|
+
export { BalancesDataTableBuilder } from './model/BalancesDataTableBuilder.js';
|
|
12
14
|
export { BalancesReport } from './model/BalancesReport.js';
|
|
13
15
|
export { Bkper } from './model/Bkper.js';
|
|
14
16
|
export { Book } from './model/Book.js';
|
|
@@ -27,5 +29,5 @@ export { Event } from './model/Event.js';
|
|
|
27
29
|
export { BotResponse } from './model/BotResponse.js';
|
|
28
30
|
export { EventList } from './model/EventList.js';
|
|
29
31
|
export { User } from './model/User.js';
|
|
30
|
-
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, Period, Month, EventType, BotResponseType } from './model/Enums.js';
|
|
32
|
+
export { Periodicity, DecimalSeparator, Permission, Visibility, AccountType, BalanceType, Period, Month, EventType, BotResponseType } from './model/Enums.js';
|
|
31
33
|
//# sourceMappingURL=index.js.map
|
package/lib/model/Balance.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Amount } from "./Amount.js";
|
|
|
8
8
|
export class Balance {
|
|
9
9
|
constructor(container, balancePlain) {
|
|
10
10
|
this.container = container;
|
|
11
|
-
this.
|
|
11
|
+
this.payload = balancePlain;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* The day of the balance. Days starts on 1 to 31.
|
|
@@ -16,7 +16,7 @@ export class Balance {
|
|
|
16
16
|
* Day can be 0 (zero) in case of Monthly or Early [[Periodicity]] of the [[BalancesReport]]
|
|
17
17
|
*/
|
|
18
18
|
getDay() {
|
|
19
|
-
return this.
|
|
19
|
+
return this.payload.day;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* The month of the balance. Months starts on 1 (January) to 12 (December)
|
|
@@ -24,18 +24,18 @@ export class Balance {
|
|
|
24
24
|
* Month can be 0 (zero) in case of Early [[Periodicity]] of the [[BalancesReport]]
|
|
25
25
|
*/
|
|
26
26
|
getMonth() {
|
|
27
|
-
return this.
|
|
27
|
+
return this.payload.month;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* The year of the balance
|
|
31
31
|
*/
|
|
32
32
|
getYear() {
|
|
33
|
-
return this.
|
|
33
|
+
return this.payload.year;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Date object constructed based on [[Book]] time zone offset. Usefull for
|
|
37
37
|
*
|
|
38
|
-
* If Month or Day is zero, the date will be constructed with first Month (January) or Day (1).
|
|
38
|
+
* If Month or Day is zero, the date will be constructed with first Month (January) or Day (1) of the next period.
|
|
39
39
|
*/
|
|
40
40
|
getDate() {
|
|
41
41
|
var year = this.getYear();
|
|
@@ -66,7 +66,7 @@ export class Balance {
|
|
|
66
66
|
* **20180000** - 2018 - YEARLY Periodicity
|
|
67
67
|
*/
|
|
68
68
|
getFuzzyDate() {
|
|
69
|
-
return this.
|
|
69
|
+
return this.payload.fuzzyDate;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* The cumulative balance to the date, based on the credit nature of the container
|
|
@@ -78,19 +78,19 @@ export class Balance {
|
|
|
78
78
|
* The raw cumulative balance to the date.
|
|
79
79
|
*/
|
|
80
80
|
getCumulativeBalanceRaw() {
|
|
81
|
-
return new Amount(this.
|
|
81
|
+
return new Amount(this.payload.cumulativeBalance);
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* The cumulative credit to the date.
|
|
85
85
|
*/
|
|
86
86
|
getCumulativeCredit() {
|
|
87
|
-
return new Amount(this.
|
|
87
|
+
return new Amount(this.payload.cumulativeCredit);
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* The cumulative debit to the date.
|
|
91
91
|
*/
|
|
92
92
|
getCumulativeDebit() {
|
|
93
|
-
return new Amount(this.
|
|
93
|
+
return new Amount(this.payload.cumulativeDebit);
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* The balance on the date period, based on credit nature of the container.
|
|
@@ -102,19 +102,19 @@ export class Balance {
|
|
|
102
102
|
* The raw balance on the date period.
|
|
103
103
|
*/
|
|
104
104
|
getPeriodBalanceRaw() {
|
|
105
|
-
return new Amount(this.
|
|
105
|
+
return new Amount(this.payload.periodBalance);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* The credit on the date period.
|
|
109
109
|
*/
|
|
110
110
|
getPeriodCredit() {
|
|
111
|
-
return new Amount(this.
|
|
111
|
+
return new Amount(this.payload.periodCredit);
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* The debit on the date period.
|
|
115
115
|
*/
|
|
116
116
|
getPeriodDebit() {
|
|
117
|
-
return new Amount(this.
|
|
117
|
+
return new Amount(this.payload.periodDebit);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
//# sourceMappingURL=Balance.js.map
|
|
@@ -42,7 +42,7 @@ export class BalancesDataTableBuilder {
|
|
|
42
42
|
return this.book.formatValue(this.getRepresentativeBalance(balance, permanent));
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Defines whether the dates should be formatted
|
|
45
|
+
* Defines whether the dates should be ISO formatted YYYY-MM-DD. E.g. 2025-01-01
|
|
46
46
|
*
|
|
47
47
|
* @returns This builder with respective formatting option, for chaining.
|
|
48
48
|
*/
|
|
@@ -84,7 +84,7 @@ export class BalancesDataTableBuilder {
|
|
|
84
84
|
/**
|
|
85
85
|
* Fluent method to set the [[BalanceType]] for the builder.
|
|
86
86
|
*
|
|
87
|
-
* @param type The type of balance for this data table
|
|
87
|
+
* @param type - The type of balance for this data table
|
|
88
88
|
*
|
|
89
89
|
* For **TOTAL** [[BalanceType]], the table format looks like:
|
|
90
90
|
*
|
|
@@ -101,17 +101,16 @@ export class BalancesDataTableBuilder {
|
|
|
101
101
|
* For **PERIOD** or **CUMULATIVE** [[BalanceType]], the table will be a time table, and the format looks like:
|
|
102
102
|
*
|
|
103
103
|
* ```
|
|
104
|
-
*
|
|
105
|
-
* | |
|
|
106
|
-
* |
|
|
107
|
-
* |
|
|
108
|
-
* |
|
|
109
|
-
* |
|
|
110
|
-
* |____________|___________|_________|__________|
|
|
104
|
+
* _______________________________________________________________
|
|
105
|
+
* | | 15/01/2014 | 15/02/2014 | 15/03/2014 | ... |
|
|
106
|
+
* | Expenses | -2345.23 | -2345.93 | -2456.45 | ... |
|
|
107
|
+
* | Income | 3452.93 | 3456.46 | 3567.87 | ... |
|
|
108
|
+
* | ... | ... | ... | ... | ... |
|
|
109
|
+
* |____________|____________|____________|____________|___________|
|
|
111
110
|
*
|
|
112
111
|
* ```
|
|
113
112
|
*
|
|
114
|
-
* First column will be the
|
|
113
|
+
* First column will be the [[Account]] or [[Group]] name, and one column for each Date.
|
|
115
114
|
*
|
|
116
115
|
* @returns This builder with respective balance type, for chaining.
|
|
117
116
|
*/
|
|
@@ -138,15 +137,16 @@ export class BalancesDataTableBuilder {
|
|
|
138
137
|
*
|
|
139
138
|
* ```
|
|
140
139
|
* _______________________________________________________________
|
|
141
|
-
* | |
|
|
142
|
-
* |
|
|
143
|
-
* |
|
|
140
|
+
* | | Expenses | Income | ... | ... |
|
|
141
|
+
* | 15/01/2014 | -2345.23 | 3452.93 | ... | ... |
|
|
142
|
+
* | 15/02/2014 | -2345.93 | 3456.46 | ... | ... |
|
|
143
|
+
* | 15/03/2014 | -2456.45 | 3567.87 | ... | ... |
|
|
144
144
|
* | ... | ... | ... | ... | ... |
|
|
145
145
|
* |____________|____________|____________|____________|___________|
|
|
146
146
|
*
|
|
147
147
|
* ```
|
|
148
148
|
*
|
|
149
|
-
* First column will be each [[Account]] or [[Group]]
|
|
149
|
+
* First column will be each Date, and one column for each [[Account]] or [[Group]].
|
|
150
150
|
*
|
|
151
151
|
* @returns This builder with respective transposed option, for chaining.
|
|
152
152
|
*/
|
|
@@ -235,7 +235,7 @@ export class BalancesDataTableBuilder {
|
|
|
235
235
|
this.flattenAllAccounts(container, containersFlat, propertyKeys);
|
|
236
236
|
containersFlat.sort(this.sortContainersFunction);
|
|
237
237
|
}
|
|
238
|
-
else if (this.expandAllGroups) {
|
|
238
|
+
else if (container.isFromGroup() && this.expandAllGroups) {
|
|
239
239
|
this.flattenAllGroups(container, containersFlat, propertyKeys);
|
|
240
240
|
}
|
|
241
241
|
else {
|
|
@@ -302,8 +302,7 @@ export class BalancesDataTableBuilder {
|
|
|
302
302
|
let depth = container.getDepth();
|
|
303
303
|
if (depth <= this.maxDepth) {
|
|
304
304
|
if (!this.skipRoot && !this.shouldTranspose) {
|
|
305
|
-
|
|
306
|
-
container.json.name = Utils_.repeatString(" ", depth * 4) + container.json.name;
|
|
305
|
+
container.payload.name = Utils.repeatString(" ", depth * 4) + container.payload.name;
|
|
307
306
|
}
|
|
308
307
|
if (!this.skipRoot || depth != 0) {
|
|
309
308
|
containersFlat.push(container);
|
|
@@ -324,8 +323,7 @@ export class BalancesDataTableBuilder {
|
|
|
324
323
|
if (container.isFromGroup()) {
|
|
325
324
|
if (!this.shouldTranspose) {
|
|
326
325
|
let depth = container.getDepth();
|
|
327
|
-
|
|
328
|
-
container.json.name = Utils_.repeatString(" ", depth * 4) + container.json.name;
|
|
326
|
+
container.payload.name = Utils.repeatString(" ", depth * 4) + container.payload.name;
|
|
329
327
|
}
|
|
330
328
|
containersFlat.push(container);
|
|
331
329
|
if (this.shouldAddProperties) {
|
|
@@ -553,12 +551,12 @@ export class BalancesDataTableBuilder {
|
|
|
553
551
|
table.push(row);
|
|
554
552
|
}
|
|
555
553
|
if (this.shouldFormatDate && table.length > 0) {
|
|
556
|
-
var pattern = Utils.getDateFormatterPattern(this.book.getDatePattern(), this.periodicity);
|
|
554
|
+
// var pattern = Utils.getDateFormatterPattern(this.book.getDatePattern(), this.periodicity);
|
|
557
555
|
for (var j = 1; j < table.length; j++) {
|
|
558
556
|
var row = table[j];
|
|
559
557
|
if (row.length > 0) {
|
|
560
558
|
//first column
|
|
561
|
-
row[0] = Utils.
|
|
559
|
+
row[0] = Utils.formatDateISO(row[0], this.book.getTimeZone());
|
|
562
560
|
}
|
|
563
561
|
}
|
|
564
562
|
}
|
|
@@ -578,7 +576,7 @@ export class BalancesDataTableBuilder {
|
|
|
578
576
|
if (this.shouldHideDates) {
|
|
579
577
|
table = table.map(row => row.slice(1));
|
|
580
578
|
}
|
|
581
|
-
if (this.shouldTranspose && table.length > 0) {
|
|
579
|
+
if (!this.shouldTranspose && table.length > 0) {
|
|
582
580
|
table = table[0].map((col, i) => table.map(row => row[i]));
|
|
583
581
|
}
|
|
584
582
|
return table;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeName } from '../utils.js';
|
|
2
2
|
import { AccountBalancesContainer } from "./BalancesContainerAccount.js";
|
|
3
3
|
import { GroupBalancesContainer } from "./BalancesContainerGroup.js";
|
|
4
|
+
import { BalancesDataTableBuilder } from './BalancesDataTableBuilder.js';
|
|
4
5
|
/**
|
|
5
6
|
* Class representing a Balance Report, generated when calling [Book.getBalanceReport](#book_getbalancesreport)
|
|
6
7
|
*
|
|
@@ -19,6 +20,12 @@ export class BalancesReport {
|
|
|
19
20
|
getBook() {
|
|
20
21
|
return this.book;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a BalancesDataTableBuilder to generate a two-dimensional array with all [[BalancesContainers]].
|
|
25
|
+
*/
|
|
26
|
+
createDataTable() {
|
|
27
|
+
return new BalancesDataTableBuilder(this.book, this.getBalancesContainers(), this.getPeriodicity());
|
|
28
|
+
}
|
|
22
29
|
/**
|
|
23
30
|
* Gets the [[Periodicity]] of the query used to generate the report.
|
|
24
31
|
*
|
|
@@ -35,11 +42,11 @@ export class BalancesReport {
|
|
|
35
42
|
getBalancesContainers() {
|
|
36
43
|
let containers = [];
|
|
37
44
|
const accountContainers = this.getRootAccountBalancesContainers();
|
|
38
|
-
if (accountContainers && accountContainers.length > 0) {
|
|
45
|
+
if (accountContainers != null && accountContainers.length > 0) {
|
|
39
46
|
containers = containers.concat(accountContainers);
|
|
40
47
|
}
|
|
41
48
|
const groupContainers = this.getGroupBalancesContainers();
|
|
42
|
-
if (groupContainers && groupContainers.length > 0) {
|
|
49
|
+
if (groupContainers != null && groupContainers.length > 0) {
|
|
43
50
|
containers = containers.concat(groupContainers);
|
|
44
51
|
}
|
|
45
52
|
return containers;
|
package/lib/model/Book.js
CHANGED
|
@@ -203,6 +203,8 @@ export class Book {
|
|
|
203
203
|
/**
|
|
204
204
|
* Sets the date pattern of the Book. Current: dd/MM/yyyy | MM/dd/yyyy | yyyy/MM/dd
|
|
205
205
|
*
|
|
206
|
+
* @param datePattern - The date pattern to set
|
|
207
|
+
*
|
|
206
208
|
* @returns This Book, for chaining
|
|
207
209
|
*/
|
|
208
210
|
setDatePattern(datePattern) {
|
|
@@ -220,6 +222,8 @@ export class Book {
|
|
|
220
222
|
/**
|
|
221
223
|
* Sets the lock date of the Book in ISO format yyyy-MM-dd.
|
|
222
224
|
*
|
|
225
|
+
* @param lockDate - The lock date to set in ISO format yyyy-MM-dd
|
|
226
|
+
*
|
|
223
227
|
* @returns This Book, for chaining
|
|
224
228
|
*/
|
|
225
229
|
setLockDate(lockDate) {
|
|
@@ -240,6 +244,8 @@ export class Book {
|
|
|
240
244
|
/**
|
|
241
245
|
* Sets the closing date of the Book in ISO format yyyy-MM-dd.
|
|
242
246
|
*
|
|
247
|
+
* @param closingDate - The closing date to set in ISO format yyyy-MM-dd
|
|
248
|
+
*
|
|
243
249
|
* @returns This Book, for chaining
|
|
244
250
|
*/
|
|
245
251
|
setClosingDate(closingDate) {
|
|
@@ -260,6 +266,8 @@ export class Book {
|
|
|
260
266
|
/**
|
|
261
267
|
* Sets the decimal separator of the Book
|
|
262
268
|
*
|
|
269
|
+
* @param decimalSeparator - The decimal separator to set
|
|
270
|
+
*
|
|
263
271
|
* @returns This Book, for chaining
|
|
264
272
|
*/
|
|
265
273
|
setDecimalSeparator(decimalSeparator) {
|
|
@@ -277,6 +285,8 @@ export class Book {
|
|
|
277
285
|
/**
|
|
278
286
|
* Sets the time zone of the Book.
|
|
279
287
|
*
|
|
288
|
+
* @param timeZone - The time zone to set
|
|
289
|
+
*
|
|
280
290
|
* @returns This Book, for chaining
|
|
281
291
|
*/
|
|
282
292
|
setTimeZone(timeZone) {
|
|
@@ -302,6 +312,8 @@ export class Book {
|
|
|
302
312
|
/**
|
|
303
313
|
* Sets the auto post status of the Book.
|
|
304
314
|
*
|
|
315
|
+
* @param autoPost - The auto post status to set
|
|
316
|
+
*
|
|
305
317
|
* @returns This Book, for chaining
|
|
306
318
|
*/
|
|
307
319
|
setAutoPost(autoPost) {
|
package/lib/model/Group.js
CHANGED
package/lib/utils.js
CHANGED
|
@@ -10,6 +10,16 @@ export function sleep(ms) {
|
|
|
10
10
|
export function base64Decode(data) {
|
|
11
11
|
return Buffer.from(data, 'base64');
|
|
12
12
|
}
|
|
13
|
+
export function repeatString(text, times) {
|
|
14
|
+
if (times <= 0) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
if (times === 1) {
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
return text + repeatString(text, times - 1);
|
|
21
|
+
;
|
|
22
|
+
}
|
|
13
23
|
//SAME AS bkper-app
|
|
14
24
|
var diacriticsMap_ = null;
|
|
15
25
|
export function round(number, fractionDigits) {
|