@barchart/portfolio-api-common 1.0.209 → 1.0.213

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.
@@ -1,4 +1,5 @@
1
1
  const assert = require('@barchart/common-js/lang/assert'),
2
+ Decimal = require('@barchart/common-js/lang/Decimal'),
2
3
  is = require('@barchart/common-js/lang/is'),
3
4
  formatter = require('@barchart/common-js/lang/formatter');
4
5
 
@@ -53,7 +54,7 @@ module.exports = (() => {
53
54
  const formattedTransaction = formatterFunction(transaction);
54
55
 
55
56
  Object.keys(formattedTransaction).map((key) => {
56
- if (!is.undefined(formattedTransaction[key]) && is.fn(formattedTransaction[key].toFloat)) {
57
+ if (!is.undefined(formattedTransaction[key]) && formattedTransaction[key] instanceof Decimal) {
57
58
  const precision = transaction.instrument.currency.precision;
58
59
 
59
60
  formattedTransaction[key] = formatter.numberToString(formattedTransaction[key].toFloat(), precision, ',');
@@ -371,7 +371,7 @@ module.exports = (() => {
371
371
 
372
372
  const descriptionSelector = this._definition.descriptionSelector;
373
373
 
374
- this._description = descriptionSelector(this._items[0]);
374
+ this._description = PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio);
375
375
 
376
376
  this._dataActual.description = this._description;
377
377
  this._dataFormat.description = this._description;
@@ -596,7 +596,7 @@ module.exports = (() => {
596
596
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
597
597
  updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
598
598
 
599
- if (item.position.type === InstrumentType.CASH) {
599
+ if (item.position.instrument.type === InstrumentType.CASH) {
600
600
  updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
601
601
  }
602
602
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.209",
3
+ "version": "1.0.213",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -2023,7 +2023,7 @@ module.exports = (() => {
2023
2023
 
2024
2024
  const descriptionSelector = this._definition.descriptionSelector;
2025
2025
 
2026
- this._description = descriptionSelector(this._items[0]);
2026
+ this._description = PositionLevelDefinition.getDescriptionForPortfolioGroup(portfolio);
2027
2027
 
2028
2028
  this._dataActual.description = this._description;
2029
2029
  this._dataFormat.description = this._description;
@@ -2248,7 +2248,7 @@ module.exports = (() => {
2248
2248
  updates.summaryTotalCurrent = updates.summaryTotalCurrent.add(translate(item, item.data.summaryTotalCurrent));
2249
2249
  updates.summaryTotalPrevious = updates.summaryTotalPrevious.add(translate(item, item.data.summaryTotalPrevious));
2250
2250
 
2251
- if (item.position.type === InstrumentType.CASH) {
2251
+ if (item.position.instrument.type === InstrumentType.CASH) {
2252
2252
  updates.cashTotal = updates.cashTotal.add(translate(item, item.data.market));
2253
2253
  }
2254
2254