@barchart/portfolio-api-common 1.2.70 → 1.2.74
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.
|
@@ -230,7 +230,7 @@ module.exports = (() => {
|
|
|
230
230
|
const transactionCreateFailedInvalidInitialType = new FailureType('TRANSACTION_CREATE_FAILED_INVALID_INITIAL_TYPE', 'Unable to process operation because the first transaction would to be a {U|transactionType.description}, which is not allowed -- since {U|transactionType.description} transactions cannot open a position.');
|
|
231
231
|
const transactionCreateFailedTypeReserved = new FailureType('TRANSACTION_CREATE_FAILED_TYPE_RESERVED', 'Unable to create {U|type.description} transaction, this type of transaction is managed by the system.');
|
|
232
232
|
const transactionCreateFailedReinvestPriceUnavailable = new FailureType('TRANSACTION_CREATE_FAILED_REINVEST_PRICE_UNAVAILABLE', 'Unable to create transaction, a dividend was paid on {L|day}; however no historical price is available for this day. To successfully create this transaction, please turn off dividend reinvestment for this position.');
|
|
233
|
-
const transactionCreateFailedPositionLocked = new FailureType('TRANSACTION_CREATE_FAILED_POSITION_LOCKED', 'Unable to create transaction,
|
|
233
|
+
const transactionCreateFailedPositionLocked = new FailureType('TRANSACTION_CREATE_FAILED_POSITION_LOCKED', 'Unable to create transaction, your {L|description} history is being recalculated. Please re-enter this transaction in a minute or two.');
|
|
234
234
|
|
|
235
235
|
const transactionDeleteFailedOutOfSequence = new FailureType('TRANSACTION_DELETE_FAILED_OUT_OF_SEQUENCE', 'Deleting any transaction, except for the most recent, will cause transaction history to be re-written. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
|
|
236
236
|
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
|
|
@@ -104,7 +104,7 @@ module.exports = (() => {
|
|
|
104
104
|
assert.argumentIsArray(transactions, 'transactions');
|
|
105
105
|
assert.argumentIsOptional(strict, 'strict', Boolean);
|
|
106
106
|
|
|
107
|
-
return transactions.findIndex((t, i, a) =>
|
|
107
|
+
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));
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/**
|
|
@@ -30,14 +30,12 @@ module.exports = (() => {
|
|
|
30
30
|
* @static
|
|
31
31
|
* @param {Array.<Object>} transactions
|
|
32
32
|
* @param {Array.<Object>} positions
|
|
33
|
-
* @param {Boolean=} mutate
|
|
34
33
|
* @param {Boolean=} descending
|
|
35
34
|
* @returns {Array}
|
|
36
35
|
*/
|
|
37
|
-
static format(transactions, positions,
|
|
36
|
+
static format(transactions, positions, descending) {
|
|
38
37
|
assert.argumentIsArray(transactions, 'transactions');
|
|
39
38
|
assert.argumentIsArray(positions, 'positions');
|
|
40
|
-
assert.argumentIsOptional(mutate, 'mutate', Boolean);
|
|
41
39
|
assert.argumentIsOptional(descending, 'descending', Boolean);
|
|
42
40
|
|
|
43
41
|
const instruments = positions.reduce((map, p) => {
|
|
@@ -70,17 +68,7 @@ module.exports = (() => {
|
|
|
70
68
|
formatted = Object.assign({}, formatted, formattedTransaction);
|
|
71
69
|
}
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (mutate) {
|
|
76
|
-
transaction.formatted = formatted;
|
|
77
|
-
|
|
78
|
-
transactionToInsert = transaction;
|
|
79
|
-
} else {
|
|
80
|
-
transactionToInsert = formatted;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
list.push(transactionToInsert);
|
|
71
|
+
list.push(formatted);
|
|
84
72
|
}
|
|
85
73
|
|
|
86
74
|
return list;
|
|
@@ -102,6 +102,7 @@ module.exports = (() => {
|
|
|
102
102
|
.withField('legacy.portfolio', DataType.STRING, true)
|
|
103
103
|
.withField('legacy.position', DataType.STRING, true)
|
|
104
104
|
.withField('system.version', DataType.NUMBER, true)
|
|
105
|
+
.withField('system.locked', DataType.BOOLEAN, true)
|
|
105
106
|
.withField('root', DataType.STRING, true)
|
|
106
107
|
.schema
|
|
107
108
|
);
|
|
@@ -131,6 +132,7 @@ module.exports = (() => {
|
|
|
131
132
|
.withField('snapshot.basis', DataType.DECIMAL)
|
|
132
133
|
.withField('snapshot.income', DataType.DECIMAL)
|
|
133
134
|
.withField('snapshot.value', DataType.DECIMAL)
|
|
135
|
+
.withField('system.locked', DataType.BOOLEAN, true)
|
|
134
136
|
.withField('previous', DataType.NUMBER, true)
|
|
135
137
|
.schema
|
|
136
138
|
);
|
package/package.json
CHANGED
package/test/SpecRunner.js
CHANGED
|
@@ -1187,7 +1187,7 @@ module.exports = (() => {
|
|
|
1187
1187
|
assert.argumentIsArray(transactions, 'transactions');
|
|
1188
1188
|
assert.argumentIsOptional(strict, 'strict', Boolean);
|
|
1189
1189
|
|
|
1190
|
-
return transactions.findIndex((t, i, a) =>
|
|
1190
|
+
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));
|
|
1191
1191
|
}
|
|
1192
1192
|
|
|
1193
1193
|
/**
|