@barchart/portfolio-api-common 1.2.48 → 1.2.49

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.
@@ -146,13 +146,18 @@ module.exports = (() => {
146
146
  });
147
147
 
148
148
  formatters.set(TransactionType.DIVIDEND_STOCK, (t) => {
149
- const rate = (is.object(t.dividend) && is.string(t.dividend.rate)) || '';
150
-
151
- return {
149
+ const data = {
152
150
  boughtSold: t.quantity,
153
- shares: t.snapshot.open.subtract(t.quantity),
154
- rate: rate
151
+ fee: t.fee
155
152
  };
153
+
154
+ if (t.dividend && t.dividend.rate && t.dividend.price) {
155
+ data.shares = t.snapshot.open.subtract(t.quantity);
156
+ data.price = t.dividend.price;
157
+ data.rate = t.dividend.rate;
158
+ }
159
+
160
+ return data;
156
161
  });
157
162
 
158
163
  formatters.set(TransactionType.DIVIDEND_REINVEST, (t) => {
@@ -174,10 +179,18 @@ module.exports = (() => {
174
179
  });
175
180
 
176
181
  formatters.set(TransactionType.DISTRIBUTION_FUND, (t) => {
177
- return {
178
- shares: t.quantity,
182
+ const data = {
183
+ boughtSold: t.quantity,
179
184
  fee: t.fee
180
185
  };
186
+
187
+ if (t.dividend && t.dividend.rate && t.dividend.price) {
188
+ data.shares = t.snapshot.open.subtract(t.quantity);
189
+ data.price = t.dividend.price;
190
+ data.rate = t.dividend.rate;
191
+ }
192
+
193
+ return data;
181
194
  });
182
195
 
183
196
  formatters.set(TransactionType.DISTRIBUTION_REINVEST, (t) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.48",
3
+ "version": "1.2.49",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -5134,8 +5134,8 @@ module.exports = function () {
5134
5134
  * Compares two strings (in ascending order), using {@link String#localeCompare}.
5135
5135
  *
5136
5136
  * @static
5137
- * @param {String} a
5138
- * @param {String} b
5137
+ * @param {Number} a
5138
+ * @param {Number} b
5139
5139
  * @returns {Number}
5140
5140
  */
5141
5141
  compareStrings: function compareStrings(a, b) {
@@ -5825,7 +5825,7 @@ module.exports = function () {
5825
5825
  * @returns {String}
5826
5826
  */
5827
5827
  value: function format() {
5828
- return leftPad(this._year, 4, '0') + '-' + leftPad(this._month, 2, '0') + '-' + leftPad(this._day, 2, '0');
5828
+ return this._year + '-' + leftPad(this._month) + '-' + leftPad(this._day);
5829
5829
  }
5830
5830
 
5831
5831
  /**
@@ -5942,7 +5942,7 @@ module.exports = function () {
5942
5942
  *
5943
5943
  * @static
5944
5944
  * @public
5945
- * @returns {Day}
5945
+ * @return {Day}
5946
5946
  */
5947
5947
 
5948
5948
  }, {
@@ -6034,11 +6034,8 @@ module.exports = function () {
6034
6034
 
6035
6035
  var dayRegex = /^([0-9]{4}).?([0-9]{2}).?([0-9]{2})$/;
6036
6036
 
6037
- function leftPad(value, digits, character) {
6038
- var string = value.toString();
6039
- var padding = digits - string.length;
6040
-
6041
- return '' + character.repeat(padding) + string;
6037
+ function leftPad(value) {
6038
+ return value < 10 ? '0' + value : '' + value;
6042
6039
  }
6043
6040
 
6044
6041
  var comparator = ComparatorBuilder.startWith(function (a, b) {
@@ -6393,7 +6390,7 @@ module.exports = function () {
6393
6390
  *
6394
6391
  * @public
6395
6392
  * @param {Decimal} instance
6396
- * @returns {Boolean}
6393
+ * @return {Boolean}
6397
6394
  */
6398
6395
  value: function getIsZero(instance) {
6399
6396
  assert.argumentIsRequired(instance, 'instance', Decimal, 'Decimal');
@@ -6406,7 +6403,7 @@ module.exports = function () {
6406
6403
  *
6407
6404
  * @public
6408
6405
  * @param {Decimal} instance
6409
- * @returns {Boolean}
6406
+ * @return {Boolean}
6410
6407
  */
6411
6408
 
6412
6409
  }, {
@@ -6422,7 +6419,7 @@ module.exports = function () {
6422
6419
  *
6423
6420
  * @public
6424
6421
  * @param {Decimal} instance
6425
- * @returns {Boolean}
6422
+ * @return {Boolean}
6426
6423
  */
6427
6424
 
6428
6425
  }, {
@@ -6438,7 +6435,7 @@ module.exports = function () {
6438
6435
  *
6439
6436
  * @public
6440
6437
  * @param {Decimal} instance
6441
- * @returns {Boolean}
6438
+ * @return {Boolean}
6442
6439
  */
6443
6440
 
6444
6441
  }, {
@@ -6454,7 +6451,7 @@ module.exports = function () {
6454
6451
  *
6455
6452
  * @public
6456
6453
  * @param {Decimal} instance
6457
- * @returns {Boolean}
6454
+ * @return {Boolean}
6458
6455
  */
6459
6456
 
6460
6457
  }, {
@@ -6470,7 +6467,7 @@ module.exports = function () {
6470
6467
  *
6471
6468
  * @public
6472
6469
  * @param {Decimal} instance
6473
- * @returns {Boolean}
6470
+ * @return {Boolean}
6474
6471
  */
6475
6472
 
6476
6473
  }, {
@@ -6860,7 +6857,6 @@ module.exports = function () {
6860
6857
  /**
6861
6858
  * The unique code.
6862
6859
  *
6863
- * @public
6864
6860
  * @returns {String}
6865
6861
  */
6866
6862
 
@@ -6873,7 +6869,6 @@ module.exports = function () {
6873
6869
  * Returns true if the provided {@link Enum} argument is equal
6874
6870
  * to the instance.
6875
6871
  *
6876
- * @public
6877
6872
  * @param {Enum} other
6878
6873
  * @returns {boolean}
6879
6874
  */
@@ -6898,7 +6893,6 @@ module.exports = function () {
6898
6893
  * Looks up a enumeration item; given the enumeration type and the enumeration
6899
6894
  * item's value. If no matching item can be found, a null value is returned.
6900
6895
  *
6901
- * @public
6902
6896
  * @param {Function} type - The enumeration type.
6903
6897
  * @param {String} code - The enumeration item's code.
6904
6898
  * @returns {*|null}
@@ -6918,7 +6912,6 @@ module.exports = function () {
6918
6912
  /**
6919
6913
  * The description.
6920
6914
  *
6921
- * @public
6922
6915
  * @returns {String}
6923
6916
  */
6924
6917
 
@@ -6938,7 +6931,6 @@ module.exports = function () {
6938
6931
  /**
6939
6932
  * Returns all of the enumeration's items (given an enumeration type).
6940
6933
  *
6941
- * @public
6942
6934
  * @param {Function} type - The enumeration to list.
6943
6935
  * @returns {Array}
6944
6936
  */
@@ -7396,7 +7388,7 @@ module.exports = function () {
7396
7388
  * Parses the value emitted by {@link Timestamp#toJSON}.
7397
7389
  *
7398
7390
  * @public
7399
- * @param {Number} value
7391
+ * @param {String} value
7400
7392
  * @returns {Timestamp}
7401
7393
  */
7402
7394
 
@@ -8032,7 +8024,7 @@ module.exports = function () {
8032
8024
 
8033
8025
  if (typeof itemConstraint === 'function' && itemConstraint !== Function) {
8034
8026
  itemValidator = function itemValidator(value, index) {
8035
- return itemConstraint.prototype !== undefined && value instanceof itemConstraint || itemConstraint(value, variableName + '[' + index + ']');
8027
+ return value instanceof itemConstraint || itemConstraint(value, variableName + '[' + index + ']');
8036
8028
  };
8037
8029
  } else {
8038
8030
  itemValidator = function itemValidator(value, index) {
@@ -8142,7 +8134,7 @@ module.exports = function () {
8142
8134
  *
8143
8135
  * @static
8144
8136
  * @param {Object} target - The object to check for existence of the property.
8145
- * @param {String|Array.<String>} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
8137
+ * @param {String|Array<String>} propertyNames - The property to check -- either a string with separators, or an array of strings (already split by separator).
8146
8138
  * @param {String=} separator - The separator (defaults to a period character).
8147
8139
  * @returns {boolean}
8148
8140
  */
@@ -8168,7 +8160,7 @@ module.exports = function () {
8168
8160
  *
8169
8161
  * @static
8170
8162
  * @param {Object} target - The object to read from.
8171
- * @param {String|Array.<String>} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
8163
+ * @param {String|Array<String>} propertyNames - The property to read -- either a string with separators, or an array of strings (already split by separator).
8172
8164
  * @param {String=} separator - The separator (defaults to a period character).
8173
8165
  * @returns {*}
8174
8166
  */
@@ -8203,8 +8195,7 @@ module.exports = function () {
8203
8195
  *
8204
8196
  * @static
8205
8197
  * @param {Object} target - The object to write to.
8206
- * @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
8207
- * @param {*} value - The value to assign.
8198
+ * @param {String|Array<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
8208
8199
  * @param {String=} separator - The separator (defaults to a period character).
8209
8200
  */
8210
8201
  write: function write(target, propertyNames, value, separator) {
@@ -8230,7 +8221,7 @@ module.exports = function () {
8230
8221
  *
8231
8222
  * @static
8232
8223
  * @param {Object} target - The object to erase a property from.
8233
- * @param {String|Array.<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
8224
+ * @param {String|Array<String>} propertyNames - The property to write -- either a string with separators, or an array of strings (already split by separator).
8234
8225
  * @param {String=} separator - The separator (defaults to a period character).
8235
8226
  */
8236
8227
  erase: function erase(target, propertyNames, separator) {
@@ -9483,7 +9474,7 @@ module.exports = function () {
9483
9474
  }
9484
9475
 
9485
9476
  /**
9486
- * Generates a function suitable for use by {@link JSON.parse}.
9477
+ * Generates a function suitable for use by JSON.parse.
9487
9478
  *
9488
9479
  * @public
9489
9480
  * @returns {Function}
@@ -13608,9 +13599,9 @@ moment.tz.load(require('./data/packed/latest.json'));
13608
13599
 
13609
13600
  mom = createUTC([2000, 1]).day(i);
13610
13601
  if (strict && !this._fullWeekdaysParse[i]) {
13611
- this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 'i');
13612
- this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 'i');
13613
- this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 'i');
13602
+ this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
13603
+ this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
13604
+ this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
13614
13605
  }
13615
13606
  if (!this._weekdaysParse[i]) {
13616
13607
  regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
@@ -14413,7 +14404,7 @@ moment.tz.load(require('./data/packed/latest.json'));
14413
14404
 
14414
14405
  function preprocessRFC2822(s) {
14415
14406
  // Remove comments and folding whitespace and replace multiple-spaces with a single space
14416
- return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').replace(/^\s\s*/, '').replace(/\s\s*$/, '');
14407
+ return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();
14417
14408
  }
14418
14409
 
14419
14410
  function checkWeekday(weekdayStr, parsedInput, config) {
@@ -16592,7 +16583,7 @@ moment.tz.load(require('./data/packed/latest.json'));
16592
16583
  // Side effect imports
16593
16584
 
16594
16585
 
16595
- hooks.version = '2.22.2';
16586
+ hooks.version = '2.22.1';
16596
16587
 
16597
16588
  setHookCallback(createLocal);
16598
16589