@barchart/portfolio-api-common 1.0.98 → 1.0.99
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.
|
@@ -136,16 +136,19 @@ module.exports = (() => {
|
|
|
136
136
|
const levelDefinition = levelDefinitions[0];
|
|
137
137
|
|
|
138
138
|
const populatedObjects = array.groupBy(items, levelDefinition.keySelector);
|
|
139
|
-
const populatedGroups = Object.keys(populatedObjects).
|
|
139
|
+
const populatedGroups = Object.keys(populatedObjects).reduce((list, key) => {
|
|
140
|
+
const items = populatedObjects[key];
|
|
140
141
|
const first = items[0];
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
list.push(new PositionGroup(this, parent, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.single && items.length === 1));
|
|
144
|
+
|
|
145
|
+
return list;
|
|
146
|
+
}, [ ]);
|
|
144
147
|
|
|
145
148
|
const missingGroups = array.difference(levelDefinition.requiredGroups.map(group => group.description), populatedGroups.map(group => group.description));
|
|
146
149
|
|
|
147
150
|
const empty = missingGroups.map((description) => {
|
|
148
|
-
return new PositionGroup(this, parent, [ ], levelDefinition.requiredGroups.find(group => group.description === description).currency, description);
|
|
151
|
+
return new PositionGroup(this, parent, [ ], levelDefinition.requiredGroups.find(group => group.description === description).currency, null, description);
|
|
149
152
|
});
|
|
150
153
|
|
|
151
154
|
const compositeGroups = populatedGroups.concat(empty);
|
|
@@ -12,13 +12,14 @@ module.exports = (() => {
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
class PositionGroup {
|
|
15
|
-
constructor(container, parent, items, currency, description, single) {
|
|
15
|
+
constructor(container, parent, items, currency, key, description, single) {
|
|
16
16
|
this._container = container;
|
|
17
17
|
this._parent = parent || null;
|
|
18
18
|
|
|
19
19
|
this._items = items;
|
|
20
20
|
this._currency = currency || Currency.CAD;
|
|
21
21
|
|
|
22
|
+
this._key = key;
|
|
22
23
|
this._description = description;
|
|
23
24
|
|
|
24
25
|
this._single = is.boolean(single) && single;
|
|
@@ -79,16 +80,20 @@ module.exports = (() => {
|
|
|
79
80
|
this.refresh();
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
get
|
|
83
|
-
return this.
|
|
83
|
+
get key() {
|
|
84
|
+
return this._key;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get description() {
|
|
88
|
+
return this._description;
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
get currency() {
|
|
87
92
|
return this._currency;
|
|
88
93
|
}
|
|
89
94
|
|
|
90
|
-
get
|
|
91
|
-
return this.
|
|
95
|
+
get items() {
|
|
96
|
+
return this._items;
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
get data() {
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -852,16 +852,19 @@ module.exports = (() => {
|
|
|
852
852
|
const levelDefinition = levelDefinitions[0];
|
|
853
853
|
|
|
854
854
|
const populatedObjects = array.groupBy(items, levelDefinition.keySelector);
|
|
855
|
-
const populatedGroups = Object.keys(populatedObjects).
|
|
855
|
+
const populatedGroups = Object.keys(populatedObjects).reduce((list, key) => {
|
|
856
|
+
const items = populatedObjects[key];
|
|
856
857
|
const first = items[0];
|
|
857
858
|
|
|
858
|
-
|
|
859
|
-
|
|
859
|
+
list.push(new PositionGroup(this, parent, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.single && items.length === 1));
|
|
860
|
+
|
|
861
|
+
return list;
|
|
862
|
+
}, [ ]);
|
|
860
863
|
|
|
861
864
|
const missingGroups = array.difference(levelDefinition.requiredGroups.map(group => group.description), populatedGroups.map(group => group.description));
|
|
862
865
|
|
|
863
866
|
const empty = missingGroups.map((description) => {
|
|
864
|
-
return new PositionGroup(this, parent, [ ], levelDefinition.requiredGroups.find(group => group.description === description).currency, description);
|
|
867
|
+
return new PositionGroup(this, parent, [ ], levelDefinition.requiredGroups.find(group => group.description === description).currency, null, description);
|
|
865
868
|
});
|
|
866
869
|
|
|
867
870
|
const compositeGroups = populatedGroups.concat(empty);
|
|
@@ -1013,13 +1016,14 @@ module.exports = (() => {
|
|
|
1013
1016
|
* @public
|
|
1014
1017
|
*/
|
|
1015
1018
|
class PositionGroup {
|
|
1016
|
-
constructor(container, parent, items, currency, description, single) {
|
|
1019
|
+
constructor(container, parent, items, currency, key, description, single) {
|
|
1017
1020
|
this._container = container;
|
|
1018
1021
|
this._parent = parent || null;
|
|
1019
1022
|
|
|
1020
1023
|
this._items = items;
|
|
1021
1024
|
this._currency = currency || Currency.CAD;
|
|
1022
1025
|
|
|
1026
|
+
this._key = key;
|
|
1023
1027
|
this._description = description;
|
|
1024
1028
|
|
|
1025
1029
|
this._single = is.boolean(single) && single;
|
|
@@ -1080,16 +1084,20 @@ module.exports = (() => {
|
|
|
1080
1084
|
this.refresh();
|
|
1081
1085
|
}
|
|
1082
1086
|
|
|
1083
|
-
get
|
|
1084
|
-
return this.
|
|
1087
|
+
get key() {
|
|
1088
|
+
return this._key;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
get description() {
|
|
1092
|
+
return this._description;
|
|
1085
1093
|
}
|
|
1086
1094
|
|
|
1087
1095
|
get currency() {
|
|
1088
1096
|
return this._currency;
|
|
1089
1097
|
}
|
|
1090
1098
|
|
|
1091
|
-
get
|
|
1092
|
-
return this.
|
|
1099
|
+
get items() {
|
|
1100
|
+
return this._items;
|
|
1093
1101
|
}
|
|
1094
1102
|
|
|
1095
1103
|
get data() {
|