@barchart/portfolio-api-common 1.2.67 → 1.2.68

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.
@@ -46,7 +46,6 @@ module.exports = (() => {
46
46
  this._usesSymbols = usesSymbols;
47
47
  this._hasCorporateActions = hasCorporateActions;
48
48
  this._closeFractional = closeFractional;
49
- this._closeFractional = strictOrdering;
50
49
  this._roundQuantity = roundQuantity;
51
50
  this._strictOrdering = strictOrdering;
52
51
 
@@ -19,6 +19,25 @@ module.exports = (() => {
19
19
 
20
20
  }
21
21
 
22
+ /**
23
+ * Determines the desired sequence number for a transaction.
24
+ *
25
+ * @public
26
+ * @param {Object} transaction
27
+ * @return {Number}
28
+ */
29
+ static getSortSequence(transaction) {
30
+ let effective;
31
+
32
+ if (is.number(transaction.resequence)) {
33
+ effective = transaction.resequence;
34
+ } else {
35
+ effective = transaction.sequence;
36
+ }
37
+
38
+ return effective;
39
+ }
40
+
22
41
  /**
23
42
  * Given an array of transactions, ensures that all sequence numbers and dates
24
43
  * are properly ordered.
@@ -85,7 +104,7 @@ module.exports = (() => {
85
104
  assert.argumentIsArray(transactions, 'transactions');
86
105
  assert.argumentIsOptional(strict, 'strict', Boolean);
87
106
 
88
- return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
107
+ return transactions.findIndex((t, i, a) => TransactionValidator.getSortSequence(t) !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
89
108
  }
90
109
 
91
110
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.67",
3
+ "version": "1.2.68",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -47,7 +47,6 @@ module.exports = (() => {
47
47
  this._usesSymbols = usesSymbols;
48
48
  this._hasCorporateActions = hasCorporateActions;
49
49
  this._closeFractional = closeFractional;
50
- this._closeFractional = strictOrdering;
51
50
  this._roundQuantity = roundQuantity;
52
51
  this._strictOrdering = strictOrdering;
53
52
 
@@ -1103,6 +1102,25 @@ module.exports = (() => {
1103
1102
 
1104
1103
  }
1105
1104
 
1105
+ /**
1106
+ * Determines the desired sequence number for a transaction.
1107
+ *
1108
+ * @public
1109
+ * @param {Object} transaction
1110
+ * @return {Number}
1111
+ */
1112
+ static getSortSequence(transaction) {
1113
+ let effective;
1114
+
1115
+ if (is.number(transaction.resequence)) {
1116
+ effective = transaction.resequence;
1117
+ } else {
1118
+ effective = transaction.sequence;
1119
+ }
1120
+
1121
+ return effective;
1122
+ }
1123
+
1106
1124
  /**
1107
1125
  * Given an array of transactions, ensures that all sequence numbers and dates
1108
1126
  * are properly ordered.
@@ -1169,7 +1187,7 @@ module.exports = (() => {
1169
1187
  assert.argumentIsArray(transactions, 'transactions');
1170
1188
  assert.argumentIsOptional(strict, 'strict', Boolean);
1171
1189
 
1172
- return transactions.findIndex((t, i, a) => t.sequence !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
1190
+ return transactions.findIndex((t, i, a) => TransactionValidator.getSortSequence(t) !== (i + 1) || (i !== 0 && t.date.getIsBefore(a[ i - 1 ].date)) || (i !== 0 && is.boolean(strict) && strict && t.date.getIsEqual(a[i - 1].date) && t.type.sequence < a[i - 1].type.sequence));
1173
1191
  }
1174
1192
 
1175
1193
  /**