@barchart/portfolio-api-common 1.0.231 → 1.0.232
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.
- package/lib/data/TransactionType.js +25 -22
- package/package-lock.json +5484 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +37 -113
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){function
|
|
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 uuid = require('uuid');
|
|
3
3
|
|
|
4
4
|
const assert = require('@barchart/common-js/lang/assert'),
|
|
@@ -462,9 +462,10 @@ module.exports = (() => {
|
|
|
462
462
|
* @param {Boolean} income
|
|
463
463
|
* @param {Boolean} opening
|
|
464
464
|
* @param {Boolean} closing
|
|
465
|
+
* @param {Boolean} fee
|
|
465
466
|
*/
|
|
466
467
|
class TransactionType extends Enum {
|
|
467
|
-
constructor(code, description, display, purchase, sale, income, opening, closing) {
|
|
468
|
+
constructor(code, description, display, purchase, sale, income, opening, closing, fee) {
|
|
468
469
|
super(code, description);
|
|
469
470
|
|
|
470
471
|
assert.argumentIsRequired(display, 'display', String);
|
|
@@ -473,6 +474,7 @@ module.exports = (() => {
|
|
|
473
474
|
assert.argumentIsRequired(income, 'income', Boolean);
|
|
474
475
|
assert.argumentIsRequired(opening, 'opening', Boolean);
|
|
475
476
|
assert.argumentIsRequired(closing, 'closing', Boolean);
|
|
477
|
+
assert.argumentIsRequired(fee, 'fee', Boolean);
|
|
476
478
|
|
|
477
479
|
this._display = display;
|
|
478
480
|
this._purchase = purchase;
|
|
@@ -480,6 +482,7 @@ module.exports = (() => {
|
|
|
480
482
|
this._income = income;
|
|
481
483
|
this._opening = opening;
|
|
482
484
|
this._closing = closing;
|
|
485
|
+
this._fee = fee
|
|
483
486
|
}
|
|
484
487
|
|
|
485
488
|
/**
|
|
@@ -757,27 +760,27 @@ module.exports = (() => {
|
|
|
757
760
|
}
|
|
758
761
|
}
|
|
759
762
|
|
|
760
|
-
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false);
|
|
761
|
-
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true);
|
|
762
|
-
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true);
|
|
763
|
-
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false);
|
|
764
|
-
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false);
|
|
765
|
-
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false);
|
|
766
|
-
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false);
|
|
767
|
-
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false);
|
|
768
|
-
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, true, false);
|
|
769
|
-
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, false);
|
|
763
|
+
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false);
|
|
764
|
+
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false);
|
|
765
|
+
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false);
|
|
766
|
+
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false);
|
|
767
|
+
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false);
|
|
768
|
+
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
|
|
769
|
+
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
|
|
770
|
+
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
|
|
771
|
+
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, true, false, true);
|
|
772
|
+
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
|
|
770
773
|
|
|
771
|
-
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false);
|
|
772
|
-
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false);
|
|
774
|
+
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
|
|
775
|
+
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false);
|
|
773
776
|
|
|
774
|
-
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false);
|
|
775
|
-
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false);
|
|
776
|
-
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false);
|
|
777
|
-
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false);
|
|
777
|
+
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false);
|
|
778
|
+
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false);
|
|
779
|
+
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false);
|
|
780
|
+
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false);
|
|
778
781
|
|
|
779
|
-
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false);
|
|
780
|
-
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false);
|
|
782
|
+
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false);
|
|
783
|
+
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false);
|
|
781
784
|
|
|
782
785
|
return TransactionType;
|
|
783
786
|
})();
|
|
@@ -3479,31 +3482,14 @@ module.exports = function () {
|
|
|
3479
3482
|
}
|
|
3480
3483
|
|
|
3481
3484
|
/**
|
|
3482
|
-
*
|
|
3485
|
+
* Returns the parent node. If this is the root node, a null value is returned.
|
|
3483
3486
|
*
|
|
3484
3487
|
* @public
|
|
3485
|
-
* @returns {Tree}
|
|
3488
|
+
* @returns {Tree|null}
|
|
3486
3489
|
*/
|
|
3487
3490
|
|
|
3488
3491
|
|
|
3489
3492
|
_createClass(Tree, [{
|
|
3490
|
-
key: 'getRoot',
|
|
3491
|
-
value: function getRoot() {
|
|
3492
|
-
if (this.getIsRoot()) {
|
|
3493
|
-
return this;
|
|
3494
|
-
} else {
|
|
3495
|
-
return this._parent.getRoot();
|
|
3496
|
-
}
|
|
3497
|
-
}
|
|
3498
|
-
|
|
3499
|
-
/**
|
|
3500
|
-
* Returns the parent node. If this is the root node, a null value is returned.
|
|
3501
|
-
*
|
|
3502
|
-
* @public
|
|
3503
|
-
* @returns {Tree|null}
|
|
3504
|
-
*/
|
|
3505
|
-
|
|
3506
|
-
}, {
|
|
3507
3493
|
key: 'getParent',
|
|
3508
3494
|
value: function getParent() {
|
|
3509
3495
|
return this._parent;
|
|
@@ -3604,23 +3590,6 @@ module.exports = function () {
|
|
|
3604
3590
|
}
|
|
3605
3591
|
}
|
|
3606
3592
|
|
|
3607
|
-
/**
|
|
3608
|
-
* Removes the current node from the parent tree. Use on a root node
|
|
3609
|
-
* has no effect.
|
|
3610
|
-
*
|
|
3611
|
-
* @public
|
|
3612
|
-
*/
|
|
3613
|
-
|
|
3614
|
-
}, {
|
|
3615
|
-
key: 'sever',
|
|
3616
|
-
value: function sever() {
|
|
3617
|
-
if (this.getIsRoot()) {
|
|
3618
|
-
return;
|
|
3619
|
-
}
|
|
3620
|
-
|
|
3621
|
-
this.getParent().removeChild(this);
|
|
3622
|
-
}
|
|
3623
|
-
|
|
3624
3593
|
/**
|
|
3625
3594
|
* Searches the children nodes for the first child node that matches the
|
|
3626
3595
|
* predicate.
|
|
@@ -5015,20 +4984,6 @@ module.exports = function () {
|
|
|
5015
4984
|
return this._big.gt(getBig(other));
|
|
5016
4985
|
}
|
|
5017
4986
|
|
|
5018
|
-
/**
|
|
5019
|
-
* Returns true if the current instance is greater than or equal to the value.
|
|
5020
|
-
*
|
|
5021
|
-
* @public
|
|
5022
|
-
* @param {Decimal|Number|String} other - The value to compare.
|
|
5023
|
-
* @returns {Boolean}
|
|
5024
|
-
*/
|
|
5025
|
-
|
|
5026
|
-
}, {
|
|
5027
|
-
key: 'getIsGreaterThanOrEqual',
|
|
5028
|
-
value: function getIsGreaterThanOrEqual(other) {
|
|
5029
|
-
return this._big.gte(getBig(other));
|
|
5030
|
-
}
|
|
5031
|
-
|
|
5032
4987
|
/**
|
|
5033
4988
|
* Returns true if the current instance is less than the value.
|
|
5034
4989
|
*
|
|
@@ -5043,20 +4998,6 @@ module.exports = function () {
|
|
|
5043
4998
|
return this._big.lt(getBig(other));
|
|
5044
4999
|
}
|
|
5045
5000
|
|
|
5046
|
-
/**
|
|
5047
|
-
* Returns true if the current instance is less than or equal to the value.
|
|
5048
|
-
*
|
|
5049
|
-
* @public
|
|
5050
|
-
* @param {Decimal|Number|String} other - The value to compare.
|
|
5051
|
-
* @returns {Boolean}
|
|
5052
|
-
*/
|
|
5053
|
-
|
|
5054
|
-
}, {
|
|
5055
|
-
key: 'getIsLessThanOrEqual',
|
|
5056
|
-
value: function getIsLessThanOrEqual(other) {
|
|
5057
|
-
return this._big.lte(getBig(other));
|
|
5058
|
-
}
|
|
5059
|
-
|
|
5060
5001
|
/**
|
|
5061
5002
|
* Returns true if the current instance is equal to the value.
|
|
5062
5003
|
*
|
|
@@ -5256,9 +5197,9 @@ module.exports = function () {
|
|
|
5256
5197
|
assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
|
|
5257
5198
|
assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
|
|
5258
5199
|
|
|
5259
|
-
if (a._big.gt(b
|
|
5200
|
+
if (a._big.gt(b)) {
|
|
5260
5201
|
return 1;
|
|
5261
|
-
} else if (a._big.lt(b
|
|
5202
|
+
} else if (a._big.lt(b)) {
|
|
5262
5203
|
return -1;
|
|
5263
5204
|
} else {
|
|
5264
5205
|
return 0;
|
|
@@ -5719,10 +5660,12 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
|
5719
5660
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5720
5661
|
|
|
5721
5662
|
var assert = require('./assert'),
|
|
5663
|
+
is = require('./is'),
|
|
5722
5664
|
memoize = require('./memoize');
|
|
5723
5665
|
|
|
5724
5666
|
var Currency = require('./Currency'),
|
|
5725
|
-
Decimal = require('./Decimal')
|
|
5667
|
+
Decimal = require('./Decimal'),
|
|
5668
|
+
Enum = require('./Enum');
|
|
5726
5669
|
|
|
5727
5670
|
module.exports = function () {
|
|
5728
5671
|
'use strict';
|
|
@@ -5902,7 +5845,12 @@ module.exports = function () {
|
|
|
5902
5845
|
assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
|
|
5903
5846
|
assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
|
|
5904
5847
|
assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
|
|
5905
|
-
|
|
5848
|
+
|
|
5849
|
+
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5850
|
+
rates[_key - 3] = arguments[_key];
|
|
5851
|
+
}
|
|
5852
|
+
|
|
5853
|
+
assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
|
|
5906
5854
|
|
|
5907
5855
|
var converted = void 0;
|
|
5908
5856
|
|
|
@@ -5912,10 +5860,6 @@ module.exports = function () {
|
|
|
5912
5860
|
var numerator = desiredCurrency;
|
|
5913
5861
|
var denominator = currency;
|
|
5914
5862
|
|
|
5915
|
-
for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
5916
|
-
rates[_key - 3] = arguments[_key];
|
|
5917
|
-
}
|
|
5918
|
-
|
|
5919
5863
|
var rate = rates.find(function (r) {
|
|
5920
5864
|
return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
|
|
5921
5865
|
});
|
|
@@ -5966,7 +5910,7 @@ module.exports = function () {
|
|
|
5966
5910
|
return Rate;
|
|
5967
5911
|
}();
|
|
5968
5912
|
|
|
5969
|
-
},{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
|
|
5913
|
+
},{"./Currency":15,"./Decimal":17,"./Enum":19,"./assert":22,"./is":24,"./memoize":25}],21:[function(require,module,exports){
|
|
5970
5914
|
'use strict';
|
|
5971
5915
|
|
|
5972
5916
|
var assert = require('./assert'),
|
|
@@ -6343,26 +6287,6 @@ module.exports = function () {
|
|
|
6343
6287
|
});
|
|
6344
6288
|
|
|
6345
6289
|
return returnRef;
|
|
6346
|
-
},
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
/**
|
|
6350
|
-
* Removes the first item from an array which matches a predicate.
|
|
6351
|
-
*
|
|
6352
|
-
* @static
|
|
6353
|
-
* @public
|
|
6354
|
-
* @param {Array} a
|
|
6355
|
-
* @param {Function} predicate
|
|
6356
|
-
*/
|
|
6357
|
-
remove: function remove(a, predicate) {
|
|
6358
|
-
assert.argumentIsArray(a, 'a');
|
|
6359
|
-
assert.argumentIsRequired(predicate, 'predicate', Function);
|
|
6360
|
-
|
|
6361
|
-
var index = a.findIndex(predicate);
|
|
6362
|
-
|
|
6363
|
-
if (!(index < 0)) {
|
|
6364
|
-
a.splice(index, 1);
|
|
6365
|
-
}
|
|
6366
6290
|
}
|
|
6367
6291
|
};
|
|
6368
6292
|
}();
|