@barchart/portfolio-api-common 1.0.179 → 1.0.183
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.
|
@@ -611,7 +611,9 @@ module.exports = (() => {
|
|
|
611
611
|
}));
|
|
612
612
|
|
|
613
613
|
addGroupBinding.call(this, group, group.registerMarketPercentChangeHandler(() => {
|
|
614
|
-
groupTree.
|
|
614
|
+
if (!groupTree.getIsRoot()) {
|
|
615
|
+
groupTree.getParent().walk((childGroup) => childGroup.refreshMarketPercent());
|
|
616
|
+
}
|
|
615
617
|
}));
|
|
616
618
|
}
|
|
617
619
|
|
|
@@ -629,7 +631,7 @@ module.exports = (() => {
|
|
|
629
631
|
const items = populatedObjects[key];
|
|
630
632
|
const first = items[0];
|
|
631
633
|
|
|
632
|
-
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.
|
|
634
|
+
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.aggregateCash));
|
|
633
635
|
|
|
634
636
|
return list;
|
|
635
637
|
}, [ ]);
|
|
@@ -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;
|
|
@@ -79,7 +78,7 @@ module.exports = (() => {
|
|
|
79
78
|
this._dataActual.quantity = null;
|
|
80
79
|
this._dataActual.basisPrice = null;
|
|
81
80
|
|
|
82
|
-
if (this._single) {
|
|
81
|
+
if (this._single && items.length === 1) {
|
|
83
82
|
const item = items[0];
|
|
84
83
|
|
|
85
84
|
this._dataFormat.portfolio = item.portfolio.portfolio;
|
|
@@ -565,7 +564,7 @@ module.exports = (() => {
|
|
|
565
564
|
|
|
566
565
|
calculateUnrealizedPercent(group);
|
|
567
566
|
|
|
568
|
-
if (group.single) {
|
|
567
|
+
if (group.single && group._items.length === 1) {
|
|
569
568
|
const item = group._items[0];
|
|
570
569
|
|
|
571
570
|
actual.quantity = item.position.snapshot.open;
|
|
@@ -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
|
@@ -1327,7 +1327,9 @@ module.exports = (() => {
|
|
|
1327
1327
|
}));
|
|
1328
1328
|
|
|
1329
1329
|
addGroupBinding.call(this, group, group.registerMarketPercentChangeHandler(() => {
|
|
1330
|
-
groupTree.
|
|
1330
|
+
if (!groupTree.getIsRoot()) {
|
|
1331
|
+
groupTree.getParent().walk((childGroup) => childGroup.refreshMarketPercent());
|
|
1332
|
+
}
|
|
1331
1333
|
}));
|
|
1332
1334
|
}
|
|
1333
1335
|
|
|
@@ -1345,7 +1347,7 @@ module.exports = (() => {
|
|
|
1345
1347
|
const items = populatedObjects[key];
|
|
1346
1348
|
const first = items[0];
|
|
1347
1349
|
|
|
1348
|
-
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.
|
|
1350
|
+
list.push(new PositionGroup(this, parent, levelDefinition, items, levelDefinition.currencySelector(first), key, levelDefinition.descriptionSelector(first), levelDefinition.aggregateCash));
|
|
1349
1351
|
|
|
1350
1352
|
return list;
|
|
1351
1353
|
}, [ ]);
|
|
@@ -1554,11 +1556,10 @@ module.exports = (() => {
|
|
|
1554
1556
|
* @param {Currency} currency
|
|
1555
1557
|
* @param {String} key
|
|
1556
1558
|
* @param {String} description
|
|
1557
|
-
* @param {Boolean=} single
|
|
1558
1559
|
* @param {Boolean=} aggregateCash
|
|
1559
1560
|
*/
|
|
1560
1561
|
class PositionGroup {
|
|
1561
|
-
constructor(container, parent, definition, items, currency, key, description,
|
|
1562
|
+
constructor(container, parent, definition, items, currency, key, description, aggregateCash) {
|
|
1562
1563
|
this._id = counter++;
|
|
1563
1564
|
|
|
1564
1565
|
this._definition = definition;
|
|
@@ -1572,7 +1573,7 @@ module.exports = (() => {
|
|
|
1572
1573
|
this._key = key;
|
|
1573
1574
|
this._description = description;
|
|
1574
1575
|
|
|
1575
|
-
this._single =
|
|
1576
|
+
this._single = this._definition.single;
|
|
1576
1577
|
this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
|
|
1577
1578
|
|
|
1578
1579
|
this._excluded = false;
|
|
@@ -1605,7 +1606,7 @@ module.exports = (() => {
|
|
|
1605
1606
|
this._dataActual.quantity = null;
|
|
1606
1607
|
this._dataActual.basisPrice = null;
|
|
1607
1608
|
|
|
1608
|
-
if (this._single) {
|
|
1609
|
+
if (this._single && items.length === 1) {
|
|
1609
1610
|
const item = items[0];
|
|
1610
1611
|
|
|
1611
1612
|
this._dataFormat.portfolio = item.portfolio.portfolio;
|
|
@@ -2091,7 +2092,7 @@ module.exports = (() => {
|
|
|
2091
2092
|
|
|
2092
2093
|
calculateUnrealizedPercent(group);
|
|
2093
2094
|
|
|
2094
|
-
if (group.single) {
|
|
2095
|
+
if (group.single && group._items.length === 1) {
|
|
2095
2096
|
const item = group._items[0];
|
|
2096
2097
|
|
|
2097
2098
|
actual.quantity = item.position.snapshot.open;
|
|
@@ -2711,12 +2712,11 @@ module.exports = (() => {
|
|
|
2711
2712
|
* @param {PositionLevelDefinition~descriptionSelector} descriptionSelector
|
|
2712
2713
|
* @param {PositionLevelDefinition~currencySelector} currencySelector
|
|
2713
2714
|
* @param {Array.<PositionLevelDefinition~RequiredGroup>=} requiredGroups
|
|
2714
|
-
* @param {Boolean=} single
|
|
2715
2715
|
* @param {Boolean=} aggregateCash
|
|
2716
2716
|
* @param {Function=} requiredGroupGenerator
|
|
2717
2717
|
*/
|
|
2718
2718
|
class PositionLevelDefinition {
|
|
2719
|
-
constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups,
|
|
2719
|
+
constructor(name, type, keySelector, descriptionSelector, currencySelector, requiredGroups, aggregateCash, requiredGroupGenerator) {
|
|
2720
2720
|
assert.argumentIsRequired(name, 'name', String);
|
|
2721
2721
|
assert.argumentIsRequired(type, 'type', PositionLevelType, 'PositionLevelType');
|
|
2722
2722
|
assert.argumentIsRequired(keySelector, 'keySelector', Function);
|
|
@@ -2727,7 +2727,6 @@ module.exports = (() => {
|
|
|
2727
2727
|
assert.argumentIsArray(requiredGroups, 'requiredGroups', String);
|
|
2728
2728
|
}
|
|
2729
2729
|
|
|
2730
|
-
assert.argumentIsOptional(single, 'single', Boolean);
|
|
2731
2730
|
assert.argumentIsOptional(aggregateCash, 'aggregateCash', Boolean);
|
|
2732
2731
|
assert.argumentIsOptional(requiredGroupGenerator, 'requiredGroupGenerator', Function);
|
|
2733
2732
|
|
|
@@ -2740,7 +2739,7 @@ module.exports = (() => {
|
|
|
2740
2739
|
|
|
2741
2740
|
this._requiredGroups = requiredGroups || [ ];
|
|
2742
2741
|
|
|
2743
|
-
this._single =
|
|
2742
|
+
this._single = type === PositionLevelType.POSITION;
|
|
2744
2743
|
this._aggregateCash = is.boolean(aggregateCash) && aggregateCash;
|
|
2745
2744
|
|
|
2746
2745
|
this._requiredGroupGenerator = requiredGroupGenerator || (input => null);
|