@barchart/portfolio-api-common 1.2.55 → 1.2.56

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.
@@ -109,7 +109,7 @@ module.exports = (() => {
109
109
 
110
110
  /**
111
111
  * Indicates if fractional shares should be closed when the position
112
- * size is less than one.
112
+ * size is less than one (or some of the fractional shares are closed).
113
113
  *
114
114
  * @public
115
115
  * @returns {Boolean}
@@ -118,7 +118,6 @@ module.exports = (() => {
118
118
  return this._closeFractional;
119
119
  }
120
120
 
121
-
122
121
  /**
123
122
  * Generates an identifier for the instrument.
124
123
  *
@@ -82,7 +82,9 @@ module.exports = (() => {
82
82
  static getInvalidIndex(transactions) {
83
83
  assert.argumentIsArray(transactions, 'transactions');
84
84
 
85
- return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
85
+ return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)));
86
+
87
+ //return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
86
88
  }
87
89
 
88
90
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.55",
3
+ "version": "1.2.56",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -110,7 +110,7 @@ module.exports = (() => {
110
110
 
111
111
  /**
112
112
  * Indicates if fractional shares should be closed when the position
113
- * size is less than one.
113
+ * size is less than one (or some of the fractional shares are closed).
114
114
  *
115
115
  * @public
116
116
  * @returns {Boolean}
@@ -119,7 +119,6 @@ module.exports = (() => {
119
119
  return this._closeFractional;
120
120
  }
121
121
 
122
-
123
122
  /**
124
123
  * Generates an identifier for the instrument.
125
124
  *
@@ -1140,7 +1139,9 @@ module.exports = (() => {
1140
1139
  static getInvalidIndex(transactions) {
1141
1140
  assert.argumentIsArray(transactions, 'transactions');
1142
1141
 
1143
- return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
1142
+ return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)));
1143
+
1144
+ //return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
1144
1145
  }
1145
1146
 
1146
1147
  /**
@@ -17245,6 +17246,7 @@ describe('When validating transaction order', () => {
17245
17246
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-04-30'), build(3, '2018-04-30') ])).toEqual(true);
17246
17247
  });
17247
17248
 
17249
+ /*
17248
17250
  it('An array of transactions with ordered sequences, on the same day should be valid, where a dividend occurs last, should be valid', () => {
17249
17251
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-04-30', TransactionType.DIVIDEND) ])).toEqual(true);
17250
17252
  });
@@ -17252,6 +17254,7 @@ describe('When validating transaction order', () => {
17252
17254
  it('An array of transactions with ordered sequences, on the same day should be valid, where a dividend occurs first, should not be valid', () => {
17253
17255
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30', TransactionType.DIVIDEND), build(2, '2018-04-30') ])).toEqual(false);
17254
17256
  });
17257
+ */
17255
17258
 
17256
17259
  it('An array of transactions with ordered sequences, on the sequential days should be valid', () => {
17257
17260
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-05-01'), build(3, '2018-05-02', TransactionType.DIVIDEND) ])).toEqual(true);
@@ -18,6 +18,7 @@ describe('When validating transaction order', () => {
18
18
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-04-30'), build(3, '2018-04-30') ])).toEqual(true);
19
19
  });
20
20
 
21
+ /*
21
22
  it('An array of transactions with ordered sequences, on the same day should be valid, where a dividend occurs last, should be valid', () => {
22
23
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-04-30', TransactionType.DIVIDEND) ])).toEqual(true);
23
24
  });
@@ -25,6 +26,7 @@ describe('When validating transaction order', () => {
25
26
  it('An array of transactions with ordered sequences, on the same day should be valid, where a dividend occurs first, should not be valid', () => {
26
27
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30', TransactionType.DIVIDEND), build(2, '2018-04-30') ])).toEqual(false);
27
28
  });
29
+ */
28
30
 
29
31
  it('An array of transactions with ordered sequences, on the sequential days should be valid', () => {
30
32
  expect(TransactionValidator.validateOrder([ build(1, '2018-04-30'), build(2, '2018-05-01'), build(3, '2018-05-02', TransactionType.DIVIDEND) ])).toEqual(true);