@barchart/portfolio-api-common 1.0.181 → 1.0.185

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.
@@ -326,10 +326,10 @@ module.exports = (() => {
326
326
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false);
327
327
  const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false);
328
328
 
329
- const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, true, false);
330
- const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, true);
331
- const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, true);
332
- const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, true, false);
329
+ const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false);
330
+ const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false);
331
+ const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false);
332
+ const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false);
333
333
 
334
334
  const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false);
335
335
  const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false);
@@ -486,7 +486,7 @@ module.exports = (() => {
486
486
  getPositions(portfolio) {
487
487
  assert.argumentIsRequired(portfolio, 'portfolio', String);
488
488
 
489
- return getPositionItemsForPortfolio(this._items, portfolio).map(item => item.position);
489
+ return getPositionItemsForPortfolio(this._items, portfolio);
490
490
  }
491
491
 
492
492
  /**
@@ -611,7 +611,9 @@ module.exports = (() => {
611
611
  }));
612
612
 
613
613
  addGroupBinding.call(this, group, group.registerMarketPercentChangeHandler(() => {
614
- groupTree.getParent().walk((childGroup) => childGroup.refreshMarketPercent());
614
+ if (!groupTree.getIsRoot()) {
615
+ groupTree.getParent().walk((childGroup) => childGroup.refreshMarketPercent());
616
+ }
615
617
  }));
616
618
  }
617
619
 
@@ -78,7 +78,7 @@ module.exports = (() => {
78
78
  this._dataActual.quantity = null;
79
79
  this._dataActual.basisPrice = null;
80
80
 
81
- if (this._single) {
81
+ if (this._single && items.length === 1) {
82
82
  const item = items[0];
83
83
 
84
84
  this._dataFormat.portfolio = item.portfolio.portfolio;
@@ -564,7 +564,7 @@ module.exports = (() => {
564
564
 
565
565
  calculateUnrealizedPercent(group);
566
566
 
567
- if (group.single) {
567
+ if (group.single && group._items.length === 1) {
568
568
  const item = group._items[0];
569
569
 
570
570
  actual.quantity = item.position.snapshot.open;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.181",
3
+ "version": "1.0.185",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1,4 +1,4 @@
1
- (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
1
+ (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
2
2
  const assert = require('@barchart/common-js/lang/assert'),
3
3
  Enum = require('@barchart/common-js/lang/Enum');
4
4
 
@@ -702,10 +702,10 @@ module.exports = (() => {
702
702
  const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false);
703
703
  const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false);
704
704
 
705
- const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, true, false);
706
- const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, true);
707
- const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, true);
708
- const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, true, false);
705
+ const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false);
706
+ const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false);
707
+ const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false);
708
+ const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false);
709
709
 
710
710
  const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false);
711
711
  const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false);
@@ -1202,7 +1202,7 @@ module.exports = (() => {
1202
1202
  getPositions(portfolio) {
1203
1203
  assert.argumentIsRequired(portfolio, 'portfolio', String);
1204
1204
 
1205
- return getPositionItemsForPortfolio(this._items, portfolio).map(item => item.position);
1205
+ return getPositionItemsForPortfolio(this._items, portfolio);
1206
1206
  }
1207
1207
 
1208
1208
  /**
@@ -1327,7 +1327,9 @@ module.exports = (() => {
1327
1327
  }));
1328
1328
 
1329
1329
  addGroupBinding.call(this, group, group.registerMarketPercentChangeHandler(() => {
1330
- groupTree.getParent().walk((childGroup) => childGroup.refreshMarketPercent());
1330
+ if (!groupTree.getIsRoot()) {
1331
+ groupTree.getParent().walk((childGroup) => childGroup.refreshMarketPercent());
1332
+ }
1331
1333
  }));
1332
1334
  }
1333
1335
 
@@ -1604,7 +1606,7 @@ module.exports = (() => {
1604
1606
  this._dataActual.quantity = null;
1605
1607
  this._dataActual.basisPrice = null;
1606
1608
 
1607
- if (this._single) {
1609
+ if (this._single && items.length === 1) {
1608
1610
  const item = items[0];
1609
1611
 
1610
1612
  this._dataFormat.portfolio = item.portfolio.portfolio;
@@ -2090,7 +2092,7 @@ module.exports = (() => {
2090
2092
 
2091
2093
  calculateUnrealizedPercent(group);
2092
2094
 
2093
- if (group.single) {
2095
+ if (group.single && group._items.length === 1) {
2094
2096
  const item = group._items[0];
2095
2097
 
2096
2098
  actual.quantity = item.position.snapshot.open;
@@ -3341,23 +3343,6 @@ module.exports = function () {
3341
3343
  }
3342
3344
  }
3343
3345
 
3344
- /**
3345
- * Removes the current node from the parent tree. Use on a root node
3346
- * has no effect.
3347
- *
3348
- * @public
3349
- */
3350
-
3351
- }, {
3352
- key: 'sever',
3353
- value: function sever() {
3354
- if (this.getIsRoot()) {
3355
- return;
3356
- }
3357
-
3358
- this.getParent().removeChild(this);
3359
- }
3360
-
3361
3346
  /**
3362
3347
  * Searches the children nodes for the first child node that matches the
3363
3348
  * predicate.
@@ -3884,7 +3869,7 @@ module.exports = function () {
3884
3869
  var Currency = function (_Enum) {
3885
3870
  _inherits(Currency, _Enum);
3886
3871
 
3887
- function Currency(code, description, precision, alternateDescription) {
3872
+ function Currency(code, description, precision) {
3888
3873
  _classCallCheck(this, Currency);
3889
3874
 
3890
3875
  var _this = _possibleConstructorReturn(this, (Currency.__proto__ || Object.getPrototypeOf(Currency)).call(this, code, description));
@@ -3892,11 +3877,7 @@ module.exports = function () {
3892
3877
  assert.argumentIsRequired(precision, 'precision', Number);
3893
3878
  assert.argumentIsValid(precision, 'precision', is.integer, 'is an integer');
3894
3879
 
3895
- assert.argumentIsOptional(alternateDescription, 'alternateDescription', String);
3896
-
3897
3880
  _this._precision = precision;
3898
-
3899
- _this._alternateDescription = alternateDescription || description;
3900
3881
  return _this;
3901
3882
  }
3902
3883
 
@@ -3919,19 +3900,6 @@ module.exports = function () {
3919
3900
  return this._precision;
3920
3901
  }
3921
3902
 
3922
- /**
3923
- * An alternate human-readable description.
3924
- *
3925
- * @public
3926
- * @returns {String}
3927
- */
3928
-
3929
- }, {
3930
- key: 'alternateDescription',
3931
- get: function get() {
3932
- return this._alternateDescription;
3933
- }
3934
-
3935
3903
  /**
3936
3904
  * Given a code, returns the enumeration item.
3937
3905
  *
@@ -3989,9 +3957,9 @@ module.exports = function () {
3989
3957
  return Currency;
3990
3958
  }(Enum);
3991
3959
 
3992
- var cad = new Currency('CAD', 'Canadian Dollar', 2, 'CAD$');
3993
- var eur = new Currency('EUR', 'Euro', 2, 'EUR');
3994
- var usd = new Currency('USD', 'US Dollar', 2, 'US$');
3960
+ var cad = new Currency('CAD', 'Canadian Dollar', 2);
3961
+ var eur = new Currency('EUR', 'Euro', 2);
3962
+ var usd = new Currency('USD', 'US Dollar', 2);
3995
3963
 
3996
3964
  return Currency;
3997
3965
  }();
@@ -4752,20 +4720,6 @@ module.exports = function () {
4752
4720
  return this._big.gt(getBig(other));
4753
4721
  }
4754
4722
 
4755
- /**
4756
- * Returns true if the current instance is greater than or equal to the value.
4757
- *
4758
- * @public
4759
- * @param {Decimal|Number|String} other - The value to compare.
4760
- * @returns {Boolean}
4761
- */
4762
-
4763
- }, {
4764
- key: 'getIsGreaterThanOrEqual',
4765
- value: function getIsGreaterThanOrEqual(other) {
4766
- return this._big.gte(getBig(other));
4767
- }
4768
-
4769
4723
  /**
4770
4724
  * Returns true if the current instance is less than the value.
4771
4725
  *
@@ -4780,20 +4734,6 @@ module.exports = function () {
4780
4734
  return this._big.lt(getBig(other));
4781
4735
  }
4782
4736
 
4783
- /**
4784
- * Returns true if the current instance is less than or equal to the value.
4785
- *
4786
- * @public
4787
- * @param {Decimal|Number|String} other - The value to compare.
4788
- * @returns {Boolean}
4789
- */
4790
-
4791
- }, {
4792
- key: 'getIsLessThanOrEqual',
4793
- value: function getIsLessThanOrEqual(other) {
4794
- return this._big.lte(getBig(other));
4795
- }
4796
-
4797
4737
  /**
4798
4738
  * Returns true if the current instance is equal to the value.
4799
4739
  *
@@ -4993,9 +4933,9 @@ module.exports = function () {
4993
4933
  assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
4994
4934
  assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
4995
4935
 
4996
- if (a._big.gt(b._big)) {
4936
+ if (a._big.gt(b)) {
4997
4937
  return 1;
4998
- } else if (a._big.lt(b._big)) {
4938
+ } else if (a._big.lt(b)) {
4999
4939
  return -1;
5000
4940
  } else {
5001
4941
  return 0;
@@ -5456,10 +5396,12 @@ var _createClass = function () { function defineProperties(target, props) { for
5456
5396
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5457
5397
 
5458
5398
  var assert = require('./assert'),
5399
+ is = require('./is'),
5459
5400
  memoize = require('./memoize');
5460
5401
 
5461
5402
  var Currency = require('./Currency'),
5462
- Decimal = require('./Decimal');
5403
+ Decimal = require('./Decimal'),
5404
+ Enum = require('./Enum');
5463
5405
 
5464
5406
  module.exports = function () {
5465
5407
  'use strict';
@@ -5639,7 +5581,12 @@ module.exports = function () {
5639
5581
  assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
5640
5582
  assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
5641
5583
  assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
5642
- //assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
5584
+
5585
+ for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
5586
+ rates[_key - 3] = arguments[_key];
5587
+ }
5588
+
5589
+ assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
5643
5590
 
5644
5591
  var converted = void 0;
5645
5592
 
@@ -5649,10 +5596,6 @@ module.exports = function () {
5649
5596
  var numerator = desiredCurrency;
5650
5597
  var denominator = currency;
5651
5598
 
5652
- for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
5653
- rates[_key - 3] = arguments[_key];
5654
- }
5655
-
5656
5599
  var rate = rates.find(function (r) {
5657
5600
  return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
5658
5601
  });
@@ -5703,7 +5646,7 @@ module.exports = function () {
5703
5646
  return Rate;
5704
5647
  }();
5705
5648
 
5706
- },{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
5649
+ },{"./Currency":15,"./Decimal":17,"./Enum":19,"./assert":22,"./is":24,"./memoize":25}],21:[function(require,module,exports){
5707
5650
  'use strict';
5708
5651
 
5709
5652
  var assert = require('./assert'),
@@ -6080,26 +6023,6 @@ module.exports = function () {
6080
6023
  });
6081
6024
 
6082
6025
  return returnRef;
6083
- },
6084
-
6085
-
6086
- /**
6087
- * Removes the first item from an array which matches a predicate.
6088
- *
6089
- * @static
6090
- * @public
6091
- * @param {Array} a
6092
- * @param {Function} predicate
6093
- */
6094
- remove: function remove(a, predicate) {
6095
- assert.argumentIsArray(a, 'a');
6096
- assert.argumentIsRequired(predicate, 'predicate', Function);
6097
-
6098
- var index = a.findIndex(predicate);
6099
-
6100
- if (!(index < 0)) {
6101
- a.splice(index, 1);
6102
- }
6103
6026
  }
6104
6027
  };
6105
6028
  }();