@barchart/portfolio-api-common 1.0.229 → 1.0.233

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.
@@ -76,8 +76,15 @@ module.exports = (() => {
76
76
  return transactionDeleteFailedOutOfSequence;
77
77
  }
78
78
 
79
- static get TRANSACTION_DELETE_UNSUPPORTED() {
80
- return transactionDeleteUnsupported;
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 transactionDeleteUnsupported = new FailureType('TRANSACTION_DELETE_UNSUPPORTED', 'Unable to delete transaction. This operation is not currently supported (but will be implemented soon).');
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
  /**
@@ -109,6 +112,17 @@ module.exports = (() => {
109
112
  return this._closing;
110
113
  }
111
114
 
115
+ /**
116
+ * Indicates if the transactions is a fee (which neither opens or closes) the
117
+ * position.
118
+ *
119
+ * @public
120
+ * @returns {Boolean}
121
+ */
122
+ get fee() {
123
+ return this._fee;
124
+ }
125
+
112
126
  /**
113
127
  * A purchase.
114
128
  *
@@ -312,27 +326,27 @@ module.exports = (() => {
312
326
  }
313
327
  }
314
328
 
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);
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, true, 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);
336
350
 
337
351
  return TransactionType;
338
352
  })();