@barchart/portfolio-api-common 1.0.177 → 1.0.181
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.
|
@@ -629,7 +629,7 @@ module.exports = (() => {
|
|
|
629
629
|
const items = populatedObjects[key];
|
|
630
630
|
const first = items[0];
|
|
631
631
|
|
|
632
|
-
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.
|
|
632
|
+
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.aggregateCash));
|
|
633
633
|
|
|
634
634
|
return list;
|
|
635
635
|
}, [ ]);
|
|
@@ -784,7 +784,7 @@ module.exports = (() => {
|
|
|
784
784
|
const displaySymbol = extractSymbolForDisplay(positionItem.position);
|
|
785
785
|
|
|
786
786
|
if (this._symbolsDisplay.hasOwnProperty(displaySymbol)) {
|
|
787
|
-
array.remove(this.
|
|
787
|
+
array.remove(this._symbolsDisplay[displaySymbol], i => i === positionItem);
|
|
788
788
|
}
|
|
789
789
|
|
|
790
790
|
const currency = extractCurrency(positionItem.position);
|
|
@@ -793,11 +793,13 @@ module.exports = (() => {
|
|
|
793
793
|
array.remove(this._currencies[currency.code], i => i === positionItem);
|
|
794
794
|
}
|
|
795
795
|
|
|
796
|
-
this._trees
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
796
|
+
Object.keys(this._trees).forEach((key) => {
|
|
797
|
+
this._trees[key].walk((group, groupNode) => {
|
|
798
|
+
if (group.definition.type === PositionLevelType.POSITION && group.key === positionItem.position.position) {
|
|
799
|
+
groupNode.sever();
|
|
800
|
+
}
|
|
801
|
+
}, true, false);
|
|
802
|
+
});
|
|
801
803
|
|
|
802
804
|
positionItem.dispose();
|
|
803
805
|
}
|
|
@@ -28,11 +28,10 @@ module.exports = (() => {
|
|
|
28
28
|
* @param {Currency} currency
|
|
29
29
|
* @param {String} key
|
|
30
30
|
* @param {String} description
|
|
31
|
-
* @param {Boolean=} single
|
|
32
31
|
* @param {Boolean=} aggregateCash
|
|
33
32
|
*/
|
|
34
33
|
class PositionGroup {
|
|
35
|
-
constructor(container, parent, definition, items, currency, key, description,
|
|
34
|
+
constructor(container, parent, definition, items, currency, key, description, aggregateCash) {
|
|
36
35
|
this._id = counter++;
|
|
37
36
|
|
|
38
37
|
this._definition = definition;
|
|
@@ -46,7 +45,7 @@ module.exports = (() => {
|
|
|
46
45
|
this._key = key;
|
|
47
46
|
this._description = description;
|
|
48
47
|
|
|
49
|
-
this._single =
|
|
48
|
+
this._single = this._definition.single;
|
|
50
49
|
this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
|
|
51
50
|
|
|
52
51
|
this._excluded = false;
|
|
@@ -20,12 +20,11 @@ module.exports = (() => {
|
|
|
20
20
|
* @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
|
|
21
21
|
* @param {PositionLevelDefinition~currencySelector} currencySelector
|
|
22
22
|
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
23
|
-
* @param {Boolean=} single
|
|
24
23
|
* @param {Boolean=} aggregateCash
|
|
25
24
|
* @param {Function=} requiredGroupGenerator
|
|
26
25
|
*/
|
|
27
26
|
class PositionLevelDefinition {
|
|
28
|
-
constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups,
|
|
27
|
+
constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, aggregateCash, requiredGroupGenerator) {
|
|
29
28
|
assert.argumentIsRequired(name, 'name', String);
|
|
30
29
|
assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
|
|
31
30
|
assert.argumentIsRequired(keySelector, 'keySelector', Function);
|
|
@@ -36,7 +35,6 @@ module.exports = (() => {
|
|
|
36
35
|
assert.argumentIsArray(requiredGroups, 'requiredGroups', String);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
assert.argumentIsOptional(single, 'single', Boolean);
|
|
40
38
|
assert.argumentIsOptional(aggregateCash, 'aggregateCash', Boolean);
|
|
41
39
|
assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
|
|
42
40
|
|
|
@@ -49,7 +47,7 @@ module.exports = (() => {
|
|
|
49
47
|
|
|
50
48
|
this._requiredGroups = requiredGroups || [ ];
|
|
51
49
|
|
|
52
|
-
this._single =
|
|
50
|
+
this._single = type === PositionLevelType.POSITION;
|
|
53
51
|
this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
|
|
54
52
|
|
|
55
53
|
this._requiredGroupGenerator = requiredGroupGenerator || (input => null);
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1345,7 +1345,7 @@ module.exports = (() => {
|
|
|
1345
1345
|
const items = populatedObjects[key];
|
|
1346
1346
|
const first = items[0];
|
|
1347
1347
|
|
|
1348
|
-
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.
|
|
1348
|
+
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.aggregateCash));
|
|
1349
1349
|
|
|
1350
1350
|
return list;
|
|
1351
1351
|
}, [ ]);
|
|
@@ -1500,7 +1500,7 @@ module.exports = (() => {
|
|
|
1500
1500
|
const displaySymbol = extractSymbolForDisplay(positionItem.position);
|
|
1501
1501
|
|
|
1502
1502
|
if (this._symbolsDisplay.hasOwnProperty(displaySymbol)) {
|
|
1503
|
-
array.remove(this.
|
|
1503
|
+
array.remove(this._symbolsDisplay[displaySymbol], i => i === positionItem);
|
|
1504
1504
|
}
|
|
1505
1505
|
|
|
1506
1506
|
const currency = extractCurrency(positionItem.position);
|
|
@@ -1509,11 +1509,13 @@ module.exports = (() => {
|
|
|
1509
1509
|
array.remove(this._currencies[currency.code], i => i === positionItem);
|
|
1510
1510
|
}
|
|
1511
1511
|
|
|
1512
|
-
this._trees
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1512
|
+
Object.keys(this._trees).forEach((key) => {
|
|
1513
|
+
this._trees[key].walk((group, groupNode) => {
|
|
1514
|
+
if (group.definition.type === PositionLevelType.POSITION && group.key === positionItem.position.position) {
|
|
1515
|
+
groupNode.sever();
|
|
1516
|
+
}
|
|
1517
|
+
}, true, false);
|
|
1518
|
+
});
|
|
1517
1519
|
|
|
1518
1520
|
positionItem.dispose();
|
|
1519
1521
|
}
|
|
@@ -1552,11 +1554,10 @@ module.exports = (() => {
|
|
|
1552
1554
|
* @param {Currency} currency
|
|
1553
1555
|
* @param {String} key
|
|
1554
1556
|
* @param {String} description
|
|
1555
|
-
* @param {Boolean=} single
|
|
1556
1557
|
* @param {Boolean=} aggregateCash
|
|
1557
1558
|
*/
|
|
1558
1559
|
class PositionGroup {
|
|
1559
|
-
constructor(container, parent, definition, items, currency, key, description,
|
|
1560
|
+
constructor(container, parent, definition, items, currency, key, description, aggregateCash) {
|
|
1560
1561
|
this._id = counter++;
|
|
1561
1562
|
|
|
1562
1563
|
this._definition = definition;
|
|
@@ -1570,7 +1571,7 @@ module.exports = (() => {
|
|
|
1570
1571
|
this._key = key;
|
|
1571
1572
|
this._description = description;
|
|
1572
1573
|
|
|
1573
|
-
this._single =
|
|
1574
|
+
this._single = this._definition.single;
|
|
1574
1575
|
this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
|
|
1575
1576
|
|
|
1576
1577
|
this._excluded = false;
|
|
@@ -2709,12 +2710,11 @@ module.exports = (() => {
|
|
|
2709
2710
|
* @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
|
|
2710
2711
|
* @param {PositionLevelDefinition~currencySelector} currencySelector
|
|
2711
2712
|
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
2712
|
-
* @param {Boolean=} single
|
|
2713
2713
|
* @param {Boolean=} aggregateCash
|
|
2714
2714
|
* @param {Function=} requiredGroupGenerator
|
|
2715
2715
|
*/
|
|
2716
2716
|
class PositionLevelDefinition {
|
|
2717
|
-
constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups,
|
|
2717
|
+
constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, aggregateCash, requiredGroupGenerator) {
|
|
2718
2718
|
assert.argumentIsRequired(name, 'name', String);
|
|
2719
2719
|
assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
|
|
2720
2720
|
assert.argumentIsRequired(keySelector, 'keySelector', Function);
|
|
@@ -2725,7 +2725,6 @@ module.exports = (() => {
|
|
|
2725
2725
|
assert.argumentIsArray(requiredGroups, 'requiredGroups', String);
|
|
2726
2726
|
}
|
|
2727
2727
|
|
|
2728
|
-
assert.argumentIsOptional(single, 'single', Boolean);
|
|
2729
2728
|
assert.argumentIsOptional(aggregateCash, 'aggregateCash', Boolean);
|
|
2730
2729
|
assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
|
|
2731
2730
|
|
|
@@ -2738,7 +2737,7 @@ module.exports = (() => {
|
|
|
2738
2737
|
|
|
2739
2738
|
this._requiredGroups = requiredGroups || [ ];
|
|
2740
2739
|
|
|
2741
|
-
this._single =
|
|
2740
|
+
this._single = type === PositionLevelType.POSITION;
|
|
2742
2741
|
this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
|
|
2743
2742
|
|
|
2744
2743
|
this._requiredGroupGenerator = requiredGroupGenerator || (input => null);
|