@barchart/portfolio-api-common 1.0.228 → 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/api/failures/PortfolioFailureType.js +10 -3
- package/lib/data/TransactionType.js +25 -22
- package/lib/data/TransactionValidator.js +1 -1
- package/package-lock.json +5484 -0
- package/package.json +1 -1
- package/test/SpecRunner.js +37 -113
|
@@ -76,8 +76,15 @@ module.exports = (() => {
|
|
|
76
76
|
return transactionDeleteFailedOutOfSequence;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Unable to delete, the transaction cannot be found.
|
|
81
|
+
*
|
|
82
|
+
* @public
|
|
83
|
+
* @static
|
|
84
|
+
* @returns {FailureType}
|
|
85
|
+
*/
|
|
86
|
+
static get TRANSACTION_DELETE_FAILED_NO_TRANSACTION() {
|
|
87
|
+
return transactionDeleteFailedNoTransaction;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
toString() {
|
|
@@ -93,7 +100,7 @@ module.exports = (() => {
|
|
|
93
100
|
const transactionCreateFailedInvalidDirectionSwitch = new FailureType('TRANSACTION_CREATE_FAILED_INVALID_DIRECTION_SWITCH', 'Unable to process transaction, the transaction would switch the position from {L|currentDirection.description} to {L|proposedDirection.description} (i.e. {L|currentDirection.sign} to {L|proposedDirection.sign} shares/units). This is not allowed. Please close the current position (i.e. zero it out) and then enter a second transaction.');
|
|
94
101
|
|
|
95
102
|
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).');
|
|
96
|
-
const
|
|
103
|
+
const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
|
|
97
104
|
|
|
98
105
|
return PortfolioFailureType;
|
|
99
106
|
})();
|
|
@@ -17,9 +17,10 @@ module.exports = (() => {
|
|
|
17
17
|
* @param {Boolean} income
|
|
18
18
|
* @param {Boolean} opening
|
|
19
19
|
* @param {Boolean} closing
|
|
20
|
+
* @param {Boolean} fee
|
|
20
21
|
*/
|
|
21
22
|
class TransactionType extends Enum {
|
|
22
|
-
constructor(code, description, display, purchase, sale, income, opening, closing) {
|
|
23
|
+
constructor(code, description, display, purchase, sale, income, opening, closing, fee) {
|
|
23
24
|
super(code, description);
|
|
24
25
|
|
|
25
26
|
assert.argumentIsRequired(display, 'display', String);
|
|
@@ -28,6 +29,7 @@ module.exports = (() => {
|
|
|
28
29
|
assert.argumentIsRequired(income, 'income', Boolean);
|
|
29
30
|
assert.argumentIsRequired(opening, 'opening', Boolean);
|
|
30
31
|
assert.argumentIsRequired(closing, 'closing', Boolean);
|
|
32
|
+
assert.argumentIsRequired(fee, 'fee', Boolean);
|
|
31
33
|
|
|
32
34
|
this._display = display;
|
|
33
35
|
this._purchase = purchase;
|
|
@@ -35,6 +37,7 @@ module.exports = (() => {
|
|
|
35
37
|
this._income = income;
|
|
36
38
|
this._opening = opening;
|
|
37
39
|
this._closing = closing;
|
|
40
|
+
this._fee = fee
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/**
|
|
@@ -312,27 +315,27 @@ module.exports = (() => {
|
|
|
312
315
|
}
|
|
313
316
|
}
|
|
314
317
|
|
|
315
|
-
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false);
|
|
316
|
-
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true);
|
|
317
|
-
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true);
|
|
318
|
-
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false);
|
|
319
|
-
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false);
|
|
320
|
-
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false);
|
|
321
|
-
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false);
|
|
322
|
-
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false);
|
|
323
|
-
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, true, false);
|
|
324
|
-
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, false);
|
|
325
|
-
|
|
326
|
-
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false);
|
|
327
|
-
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false);
|
|
328
|
-
|
|
329
|
-
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false);
|
|
330
|
-
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false);
|
|
331
|
-
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false);
|
|
332
|
-
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false);
|
|
333
|
-
|
|
334
|
-
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false);
|
|
335
|
-
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false);
|
|
318
|
+
const buy = new TransactionType('B', 'Buy', 'Buy', true, false, false, true, false, false);
|
|
319
|
+
const sell = new TransactionType('S', 'Sell', 'Sell', false, true, false, false, true, false);
|
|
320
|
+
const buyShort = new TransactionType('BS', 'Buy To Cover', 'Buy To Cover', true, false, false, false, true, false);
|
|
321
|
+
const sellShort = new TransactionType('SS', 'Sell Short', 'Sell Short', false, true, false, true, false, false);
|
|
322
|
+
const dividend = new TransactionType('DV', 'Dividend', 'Dividend', false, false, true, false, false, false);
|
|
323
|
+
const dividendReinvest = new TransactionType('DX', 'Dividend (Reinvested)', 'Dividend Reinvest', false, false, false, true, false, false);
|
|
324
|
+
const dividendStock = new TransactionType('DS', 'Dividend (Stock)', 'Dividend Stock', false, false, false, true, false, false);
|
|
325
|
+
const split = new TransactionType('SP', 'Split', 'Split', false, false, false, true, false, false);
|
|
326
|
+
const fee = new TransactionType('F', 'Fee', 'Fee', false, false, false, true, false, true);
|
|
327
|
+
const feeUnits = new TransactionType('FU', 'Fee Units', 'Fee', false, false, false, false, true, false);
|
|
328
|
+
|
|
329
|
+
const distributionCash = new TransactionType('DC', 'Distribution (Cash)', 'Cash Distribution', false, false, true, false, false, false);
|
|
330
|
+
const distributionFund = new TransactionType('DF', 'Distribution (Units)', 'Unit Distribution', false, false, false, true, false, false);
|
|
331
|
+
|
|
332
|
+
const deposit = new TransactionType('D', 'Deposit', 'Deposit', false, false, false, false, false, false);
|
|
333
|
+
const withdrawal = new TransactionType('W', 'Withdrawal', 'Withdrawal', false, false, false, false, false, false);
|
|
334
|
+
const debit = new TransactionType('DR', 'Debit', 'Debit', false, false, false, false, false, false);
|
|
335
|
+
const credit = new TransactionType('CR', 'Credit', 'Credit', false, false, false, false, false, false);
|
|
336
|
+
|
|
337
|
+
const valuation = new TransactionType('V', 'Valuation', 'Valuation', false, false, false, false, false, false);
|
|
338
|
+
const income = new TransactionType('I', 'Income', 'Income', false, false, true, false, false, false);
|
|
336
339
|
|
|
337
340
|
return TransactionType;
|
|
338
341
|
})();
|
|
@@ -132,7 +132,7 @@ module.exports = (() => {
|
|
|
132
132
|
associateTypes(InstrumentType.OTHER, TransactionType.SELL, true, [ PositionDirection.LONG ]);
|
|
133
133
|
associateTypes(InstrumentType.OTHER, TransactionType.INCOME, true, [ PositionDirection.LONG ]);
|
|
134
134
|
associateTypes(InstrumentType.OTHER, TransactionType.FEE, true, [ PositionDirection.LONG ]);
|
|
135
|
-
associateTypes(InstrumentType.OTHER, TransactionType.VALUATION, true);
|
|
135
|
+
associateTypes(InstrumentType.OTHER, TransactionType.VALUATION, true, [ PositionDirection.LONG ]);
|
|
136
136
|
|
|
137
137
|
associateTypes(InstrumentType.CASH, TransactionType.DEPOSIT, true);
|
|
138
138
|
associateTypes(InstrumentType.CASH, TransactionType.WITHDRAWAL, true);
|