@barchart/portfolio-api-common 1.0.259 → 1.0.263

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.
@@ -20,18 +20,34 @@ module.exports = (() => {
20
20
  * @param {Function} descriptionCalculator
21
21
  */
22
22
  class PositionSummaryFrame extends Enum {
23
- constructor(code, description, rangeCalculator, startDateCalculator, descriptionCalculator) {
23
+ constructor(code, description, unique, rangeCalculator, startDateCalculator, descriptionCalculator) {
24
24
  super(code, description);
25
25
 
26
+ assert.argumentIsRequired(unique, 'unique', Boolean);
27
+
26
28
  assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
27
29
  assert.argumentIsRequired(startDateCalculator, 'startDateCalculator', Function);
28
30
  assert.argumentIsRequired(descriptionCalculator, 'descriptionCalculator', Function);
29
31
 
32
+ this._unique = unique;
33
+
30
34
  this._rangeCalculator = rangeCalculator;
31
35
  this._startDateCalculator = startDateCalculator;
32
36
  this._descriptionCalculator = descriptionCalculator;
33
37
  }
34
38
 
39
+ /**
40
+ * If true, only one summary, of the given type, can exist for a
41
+ * position. If false, multiple summaries, of the given type, can
42
+ * exist for a position.
43
+ *
44
+ * @public
45
+ * @return {Boolean}
46
+ */
47
+ get unique() {
48
+ return this._unique;
49
+ }
50
+
35
51
  /**
36
52
  * Returns a human-readable description of the frame, given
37
53
  * start and end dates.
@@ -129,10 +145,10 @@ module.exports = (() => {
129
145
  }
130
146
  }
131
147
 
132
- const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
133
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
134
- const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
135
- const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
148
+ const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
149
+ const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
150
+ const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
151
+ const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
136
152
 
137
153
  /**
138
154
  * The start and and date for a {@link PositionSummaryFrame}
@@ -18,9 +18,10 @@ module.exports = (() => {
18
18
  * @param {Boolean} opening
19
19
  * @param {Boolean} closing
20
20
  * @param {Boolean} fee
21
+ * @param {Boolean} corporateAction
21
22
  */
22
23
  class TransactionType extends Enum {
23
- constructor(code, description, display, purchase, sale, income, opening, closing, fee) {
24
+ constructor(code, description, display, purchase, sale, income, opening, closing, fee, corporateAction) {
24
25
  super(code, description);
25
26
 
26
27
  assert.argumentIsRequired(display, 'display', String);
@@ -30,6 +31,7 @@ module.exports = (() => {
30
31
  assert.argumentIsRequired(opening, 'opening', Boolean);
31
32
  assert.argumentIsRequired(closing, 'closing', Boolean);
32
33
  assert.argumentIsRequired(fee, 'fee', Boolean);
34
+ assert.argumentIsRequired(corporateAction, 'corporateAction', Boolean);
33
35
 
34
36
  this._display = display;
35
37
  this._purchase = purchase;
@@ -38,6 +40,7 @@ module.exports = (() => {
38
40
  this._opening = opening;
39
41
  this._closing = closing;
40
42
  this._fee = fee;
43
+ this._corporateAction = corporateAction;
41
44
  }
42
45
 
43
46
  /**
@@ -123,6 +126,16 @@ module.exports = (() => {
123
126
  return this._fee;
124
127
  }
125
128
 
129
+ /**
130
+ * Indicates if the transaction is a corporate action.
131
+ *
132
+ * @public
133
+ * @returns {Boolean}
134
+ */
135
+ get corporateAction() {
136
+ return this._corporateAction;
137
+ }
138
+
126
139
  /**
127
140
  * A purchase.
128
141
  *
@@ -326,27 +339,27 @@ module.exports = (() => {
326
339
  }
327
340
  }
328
341
 
329
- const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false);
330
- const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false);
331
- const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false);
332
- const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false);
333
- const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false);
334
- const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
335
- const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
336
- const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
337
- const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
338
- const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
339
-
340
- const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
341
- const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false);
342
-
343
- const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false);
344
- const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false);
345
- const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false);
346
- const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false);
347
-
348
- const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false);
349
- const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false);
342
+ const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false, false);
343
+ const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false, false);
344
+ const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false, false);
345
+ const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false, false);
346
+ const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false, true);
347
+ const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false, true);
348
+ const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false, true);
349
+ const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false, true);
350
+ const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true, false);
351
+ const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false, false);
352
+
353
+ const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false, true);
354
+ const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false, true);
355
+
356
+ const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false, false);
357
+ const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false, false);
358
+ const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false, false);
359
+ const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false, false);
360
+
361
+ const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false, false);
362
+ const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false, false);
350
363
 
351
364
  return TransactionType;
352
365
  })();
@@ -123,7 +123,7 @@ module.exports = (() => {
123
123
 
124
124
  this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
125
125
  if (code !== DEFAULT_CURRENCY.code) {
126
- symbols.push(`^${DEFAULT_CURRENCY.code}${code}`);
126
+ symbols.push(`^${code}${DEFAULT_CURRENCY.code}`);
127
127
  }
128
128
 
129
129
  return symbols;
@@ -233,7 +233,6 @@ module.exports = (() => {
233
233
  .withField('dividend.effective', DataType.DAY, true)
234
234
  .withField('dividend.price', DataType.DECIMAL, true)
235
235
  .withField('dividend.amount', DataType.DECIMAL, true)
236
- .withField('dividend.reference', DataType.STRING, true)
237
236
  .withField('split.numerator', DataType.DECIMAL, true)
238
237
  .withField('split.denominator', DataType.DECIMAL, true)
239
238
  .withField('split.effective', DataType.DAY, true)
@@ -283,6 +282,7 @@ module.exports = (() => {
283
282
  .withField('quantity', DataType.DECIMAL)
284
283
  .withField('fee', DataType.DECIMAL, true)
285
284
  .withField('force', DataType.BOOLEAN, true)
285
+ .withField('force', DataType.BOOLEAN, true)
286
286
  .schema
287
287
  );
288
288
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.259",
3
+ "version": "1.0.263",
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 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){
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){
2
2
  const uuid = require('uuid');
3
3
 
4
4
  const assert = require('@barchart/common-js/lang/assert'),
@@ -208,18 +208,34 @@ module.exports = (() => {
208
208
  * @param {Function} descriptionCalculator
209
209
  */
210
210
  class PositionSummaryFrame extends Enum {
211
- constructor(code, description, rangeCalculator, startDateCalculator, descriptionCalculator) {
211
+ constructor(code, description, unique, rangeCalculator, startDateCalculator, descriptionCalculator) {
212
212
  super(code, description);
213
213
 
214
+ assert.argumentIsRequired(unique, 'unique', Boolean);
215
+
214
216
  assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
215
217
  assert.argumentIsRequired(startDateCalculator, 'startDateCalculator', Function);
216
218
  assert.argumentIsRequired(descriptionCalculator, 'descriptionCalculator', Function);
217
219
 
220
+ this._unique = unique;
221
+
218
222
  this._rangeCalculator = rangeCalculator;
219
223
  this._startDateCalculator = startDateCalculator;
220
224
  this._descriptionCalculator = descriptionCalculator;
221
225
  }
222
226
 
227
+ /**
228
+ * If true, only one summary, of the given type, can exist for a
229
+ * position. If false, multiple summaries, of the given type, can
230
+ * exist for a position.
231
+ *
232
+ * @public
233
+ * @return {Boolean}
234
+ */
235
+ get unique() {
236
+ return this._unique;
237
+ }
238
+
223
239
  /**
224
240
  * Returns a human-readable description of the frame, given
225
241
  * start and end dates.
@@ -317,10 +333,10 @@ module.exports = (() => {
317
333
  }
318
334
  }
319
335
 
320
- const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
321
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
322
- const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
323
- const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
336
+ const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
337
+ const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
338
+ const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
339
+ const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
324
340
 
325
341
  /**
326
342
  * The start and and date for a {@link PositionSummaryFrame}
@@ -463,9 +479,10 @@ module.exports = (() => {
463
479
  * @param {Boolean} opening
464
480
  * @param {Boolean} closing
465
481
  * @param {Boolean} fee
482
+ * @param {Boolean} corporateAction
466
483
  */
467
484
  class TransactionType extends Enum {
468
- constructor(code, description, display, purchase, sale, income, opening, closing, fee) {
485
+ constructor(code, description, display, purchase, sale, income, opening, closing, fee, corporateAction) {
469
486
  super(code, description);
470
487
 
471
488
  assert.argumentIsRequired(display, 'display', String);
@@ -475,6 +492,7 @@ module.exports = (() => {
475
492
  assert.argumentIsRequired(opening, 'opening', Boolean);
476
493
  assert.argumentIsRequired(closing, 'closing', Boolean);
477
494
  assert.argumentIsRequired(fee, 'fee', Boolean);
495
+ assert.argumentIsRequired(corporateAction, 'corporateAction', Boolean);
478
496
 
479
497
  this._display = display;
480
498
  this._purchase = purchase;
@@ -483,6 +501,7 @@ module.exports = (() => {
483
501
  this._opening = opening;
484
502
  this._closing = closing;
485
503
  this._fee = fee;
504
+ this._corporateAction = corporateAction;
486
505
  }
487
506
 
488
507
  /**
@@ -568,6 +587,16 @@ module.exports = (() => {
568
587
  return this._fee;
569
588
  }
570
589
 
590
+ /**
591
+ * Indicates if the transaction is a corporate action.
592
+ *
593
+ * @public
594
+ * @returns {Boolean}
595
+ */
596
+ get corporateAction() {
597
+ return this._corporateAction;
598
+ }
599
+
571
600
  /**
572
601
  * A purchase.
573
602
  *
@@ -771,27 +800,27 @@ module.exports = (() => {
771
800
  }
772
801
  }
773
802
 
774
- const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false);
775
- const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false);
776
- const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false);
777
- const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false);
778
- const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false);
779
- const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
780
- const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
781
- const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
782
- const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true);
783
- const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
803
+ const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false, false);
804
+ const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false, false);
805
+ const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false, false);
806
+ const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false, false);
807
+ const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false, true);
808
+ const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false, true);
809
+ const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false, true);
810
+ const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false, true);
811
+ const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, false, false, true, false);
812
+ const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false, false);
784
813
 
785
- const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
786
- const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false);
814
+ const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false, true);
815
+ const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false, true);
787
816
 
788
- const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false);
789
- const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false);
790
- const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false);
791
- const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false);
817
+ const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false, false);
818
+ const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false, false);
819
+ const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false, false);
820
+ const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false, false);
792
821
 
793
- const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false);
794
- const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false);
822
+ const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false, false);
823
+ const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false, false);
795
824
 
796
825
  return TransactionType;
797
826
  })();
@@ -922,7 +951,7 @@ module.exports = (() => {
922
951
 
923
952
  this._forexSymbols = forexCurrencyCodes.reduce((symbols, code) => {
924
953
  if (code !== DEFAULT_CURRENCY.code) {
925
- symbols.push(`^${DEFAULT_CURRENCY.code}${code}`);
954
+ symbols.push(`^${code}${DEFAULT_CURRENCY.code}`);
926
955
  }
927
956
 
928
957
  return symbols;
@@ -3635,14 +3664,31 @@ module.exports = function () {
3635
3664
  }
3636
3665
 
3637
3666
  /**
3638
- * Returns the parent node. If this is the root node, a null value is returned.
3667
+ * Gets the root node.
3639
3668
  *
3640
3669
  * @public
3641
- * @returns {Tree|null}
3670
+ * @returns {Tree}
3642
3671
  */
3643
3672
 
3644
3673
 
3645
3674
  _createClass(Tree, [{
3675
+ key: 'getRoot',
3676
+ value: function getRoot() {
3677
+ if (this.getIsRoot()) {
3678
+ return this;
3679
+ } else {
3680
+ return this._parent.getRoot();
3681
+ }
3682
+ }
3683
+
3684
+ /**
3685
+ * Returns the parent node. If this is the root node, a null value is returned.
3686
+ *
3687
+ * @public
3688
+ * @returns {Tree|null}
3689
+ */
3690
+
3691
+ }, {
3646
3692
  key: 'getParent',
3647
3693
  value: function getParent() {
3648
3694
  return this._parent;
@@ -3743,6 +3789,23 @@ module.exports = function () {
3743
3789
  }
3744
3790
  }
3745
3791
 
3792
+ /**
3793
+ * Removes the current node from the parent tree. Use on a root node
3794
+ * has no effect.
3795
+ *
3796
+ * @public
3797
+ */
3798
+
3799
+ }, {
3800
+ key: 'sever',
3801
+ value: function sever() {
3802
+ if (this.getIsRoot()) {
3803
+ return;
3804
+ }
3805
+
3806
+ this.getParent().removeChild(this);
3807
+ }
3808
+
3746
3809
  /**
3747
3810
  * Searches the children nodes for the first child node that matches the
3748
3811
  * predicate.
@@ -3847,6 +3910,33 @@ module.exports = function () {
3847
3910
  }
3848
3911
  }
3849
3912
 
3913
+ /**
3914
+ * Climbs the tree, evaluating each parent until a predicate is matched. Once matched,
3915
+ * the {@link Tree} node is returned. Otherwise, if the predicate cannot be matched,
3916
+ * a null value is returned.
3917
+ *
3918
+ * @public
3919
+ * @param {Tree~nodePredicate} predicate - A predicate that tests each child node. The predicate takes two arguments -- the node's value, and the node itself.
3920
+ * @param {boolean=} includeCurrentNode - If true, the predicate will be applied to the current node.
3921
+ * @returns {Tree|null}
3922
+ */
3923
+
3924
+ }, {
3925
+ key: 'findParent',
3926
+ value: function findParent(predicate, includeCurrentNode) {
3927
+ var returnRef = void 0;
3928
+
3929
+ if (is.boolean(includeCurrentNode) && includeCurrentNode && predicate(this.getValue(), this)) {
3930
+ returnRef = this;
3931
+ } else if (this._parent !== null) {
3932
+ returnRef = this._parent.findParent(predicate, true);
3933
+ } else {
3934
+ returnRef = null;
3935
+ }
3936
+
3937
+ return returnRef;
3938
+ }
3939
+
3850
3940
  /**
3851
3941
  * Creates a representation of the tree using JavaScript objects and arrays.
3852
3942
  *
@@ -5137,6 +5227,20 @@ module.exports = function () {
5137
5227
  return this._big.gt(getBig(other));
5138
5228
  }
5139
5229
 
5230
+ /**
5231
+ * Returns true if the current instance is greater than or equal to the value.
5232
+ *
5233
+ * @public
5234
+ * @param {Decimal|Number|String} other - The value to compare.
5235
+ * @returns {Boolean}
5236
+ */
5237
+
5238
+ }, {
5239
+ key: 'getIsGreaterThanOrEqual',
5240
+ value: function getIsGreaterThanOrEqual(other) {
5241
+ return this._big.gte(getBig(other));
5242
+ }
5243
+
5140
5244
  /**
5141
5245
  * Returns true if the current instance is less than the value.
5142
5246
  *
@@ -5151,6 +5255,20 @@ module.exports = function () {
5151
5255
  return this._big.lt(getBig(other));
5152
5256
  }
5153
5257
 
5258
+ /**
5259
+ * Returns true if the current instance is less than or equal to the value.
5260
+ *
5261
+ * @public
5262
+ * @param {Decimal|Number|String} other - The value to compare.
5263
+ * @returns {Boolean}
5264
+ */
5265
+
5266
+ }, {
5267
+ key: 'getIsLessThanOrEqual',
5268
+ value: function getIsLessThanOrEqual(other) {
5269
+ return this._big.lte(getBig(other));
5270
+ }
5271
+
5154
5272
  /**
5155
5273
  * Returns true if the current instance is equal to the value.
5156
5274
  *
@@ -5350,9 +5468,9 @@ module.exports = function () {
5350
5468
  assert.argumentIsRequired(a, 'a', Decimal, 'Decimal');
5351
5469
  assert.argumentIsRequired(b, 'b', Decimal, 'Decimal');
5352
5470
 
5353
- if (a._big.gt(b)) {
5471
+ if (a._big.gt(b._big)) {
5354
5472
  return 1;
5355
- } else if (a._big.lt(b)) {
5473
+ } else if (a._big.lt(b._big)) {
5356
5474
  return -1;
5357
5475
  } else {
5358
5476
  return 0;
@@ -5813,12 +5931,10 @@ var _createClass = function () { function defineProperties(target, props) { for
5813
5931
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5814
5932
 
5815
5933
  var assert = require('./assert'),
5816
- is = require('./is'),
5817
5934
  memoize = require('./memoize');
5818
5935
 
5819
5936
  var Currency = require('./Currency'),
5820
- Decimal = require('./Decimal'),
5821
- Enum = require('./Enum');
5937
+ Decimal = require('./Decimal');
5822
5938
 
5823
5939
  module.exports = function () {
5824
5940
  'use strict';
@@ -5998,12 +6114,7 @@ module.exports = function () {
5998
6114
  assert.argumentIsRequired(amount, 'amount', Decimal, 'Decimal');
5999
6115
  assert.argumentIsRequired(currency, 'currency', Currency, 'Currency');
6000
6116
  assert.argumentIsRequired(desiredCurrency, 'desiredCurrency', Currency, 'Currency');
6001
-
6002
- for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
6003
- rates[_key - 3] = arguments[_key];
6004
- }
6005
-
6006
- assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
6117
+ //assert.argumentIsArray(rates, 'rates', Rate, 'Rate');
6007
6118
 
6008
6119
  var converted = void 0;
6009
6120
 
@@ -6013,6 +6124,10 @@ module.exports = function () {
6013
6124
  var numerator = desiredCurrency;
6014
6125
  var denominator = currency;
6015
6126
 
6127
+ for (var _len = arguments.length, rates = Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
6128
+ rates[_key - 3] = arguments[_key];
6129
+ }
6130
+
6016
6131
  var rate = rates.find(function (r) {
6017
6132
  return r.numerator === numerator && r.denominator === denominator || r.numerator === denominator && r.denominator === numerator;
6018
6133
  });
@@ -6063,7 +6178,7 @@ module.exports = function () {
6063
6178
  return Rate;
6064
6179
  }();
6065
6180
 
6066
- },{"./Currency":15,"./Decimal":17,"./Enum":19,"./assert":22,"./is":24,"./memoize":25}],21:[function(require,module,exports){
6181
+ },{"./Currency":15,"./Decimal":17,"./assert":22,"./memoize":25}],21:[function(require,module,exports){
6067
6182
  'use strict';
6068
6183
 
6069
6184
  var assert = require('./assert'),
@@ -6440,6 +6555,26 @@ module.exports = function () {
6440
6555
  });
6441
6556
 
6442
6557
  return returnRef;
6558
+ },
6559
+
6560
+
6561
+ /**
6562
+ * Removes the first item from an array which matches a predicate.
6563
+ *
6564
+ * @static
6565
+ * @public
6566
+ * @param {Array} a
6567
+ * @param {Function} predicate
6568
+ */
6569
+ remove: function remove(a, predicate) {
6570
+ assert.argumentIsArray(a, 'a');
6571
+ assert.argumentIsRequired(predicate, 'predicate', Function);
6572
+
6573
+ var index = a.findIndex(predicate);
6574
+
6575
+ if (!(index < 0)) {
6576
+ a.splice(index, 1);
6577
+ }
6443
6578
  }
6444
6579
  };
6445
6580
  }();