@barchart/portfolio-api-common 1.2.107 → 1.2.111

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.
@@ -56,6 +56,17 @@ module.exports = (() => {
56
56
  return positionUpdateFailedNoPosition;
57
57
  }
58
58
 
59
+ /**
60
+ * Unable to delete, a related position is locked.
61
+ *
62
+ * @public
63
+ * @static
64
+ * @returns {FailureType}
65
+ */
66
+ static get POSITION_DELETE_FAILED_POSITION_LOCKED() {
67
+ return positionDeleteFailedPositionLocked;
68
+ }
69
+
59
70
  /**
60
71
  * The position does not exist.
61
72
  *
@@ -97,8 +108,8 @@ module.exports = (() => {
97
108
  }
98
109
 
99
110
  /**
100
- * The transaction would cause the position to change (from long to
101
- * short, or vice versa).
111
+ * The transaction would cause the position direction to change
112
+ * from long to short, or vice versa.
102
113
  *
103
114
  * @public
104
115
  * @static
@@ -144,7 +155,7 @@ module.exports = (() => {
144
155
  }
145
156
 
146
157
  /**
147
- * The transaction failed because the position has been locked.
158
+ * The transaction failed because a related position is locked.
148
159
  *
149
160
  * @public
150
161
  * @static
@@ -188,6 +199,17 @@ module.exports = (() => {
188
199
  return transactionDeleteFailedDirectionSwitchOnRewrite;
189
200
  }
190
201
 
202
+ /**
203
+ * Unable to delete, a related position is locked.
204
+ *
205
+ * @public
206
+ * @static
207
+ * @returns {FailureType}
208
+ */
209
+ static get TRANSACTION_DELETE_FAILED_POSITION_LOCKED() {
210
+ return transactionDeleteFailedPositionLocked;
211
+ }
212
+
191
213
  /**
192
214
  * Unable to edit, the transaction doesn't exist.
193
215
  *
@@ -221,6 +243,7 @@ module.exports = (() => {
221
243
 
222
244
  const positionCreateFailedNoPortfolio = new FailureType('POSITION_CREATE_FAILED_NO_PORTFOLIO', 'Unable to create transaction. The portfolio does not exist, has it been deleted?');
223
245
  const positionUpdateFailedNoPosition = new FailureType('POSITION_UPDATE_FAILED_NO_POSITION', 'Unable to update preferences for position. The position does not exist, has it been deleted?');
246
+ const positionDeleteFailedPositionLocked = new FailureType('POSITION_DELETE_FAILED_POSITION_LOCKED', 'Unable to delete position, your {L|description} history is being recalculated. Please wait a minute or two and retry.');
224
247
 
225
248
  const transactionCreateFailedNoPosition = new FailureType('TRANSACTION_CREATE_FAILED_NO_POSITION', 'Unable to create transaction. The referenced position does not exist. Has it been deleted?');
226
249
  const transactionCreateFailedOutOfSequence = new FailureType('TRANSACTION_CREATE_FAILED_OUT_OF_SEQUENCE', 'Unable to process transaction, because the transaction date is out-of-sequence. In other words, it would occur before an existing transaction. Please confirm your intent to re-write transaction history (which could take some time and alter the historical results for this position).');
@@ -235,6 +258,7 @@ module.exports = (() => {
235
258
  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
259
  const transactionDeleteFailedNoTransaction = new FailureType('TRANSACTION_DELETE_FAILED_NO_TRANSACTION', 'Unable to delete transaction. The referenced transaction does not exist.');
237
260
  const transactionDeleteFailedDirectionSwitchOnRewrite = new FailureType('TRANSACTION_DELETE_FAILED_DIRECTION_SWITCH_ON_REWRITE', 'Deleting this transaction would cause your history to be re-written and the position to switch from long to short (i.e. positive to negative) or vice versa.');
261
+ const transactionDeleteFailedPositionLocked = new FailureType('TRANSACTION_DELETE_FAILED_POSITION_LOCKED', 'Unable to delete transaction, your {L|description} history is being recalculated. Please wait a minute or two and retry.');
238
262
 
239
263
  const transactionEditFailedNoTransaction = new FailureType('TRANSACTION_EDIT_FAILED_NO_TRANSACTION', 'Unable to edit transaction. The referenced transaction does not exist.');
240
264
  const transactionEditFailedTypeReserved = new FailureType('TRANSACTION_EDIT_FAILED_TYPE_RESERVED', 'Unable to edit {U|type.description} transaction, this type of transaction is managed by the system.');
@@ -205,6 +205,7 @@ module.exports = (() => {
205
205
 
206
206
  formatters.set(TransactionType.DISTRIBUTION_REINVEST, (t) => {
207
207
  return {
208
+ boughtSold: t.quantity,
208
209
  shares: t.snapshot.open.subtract(t.quantity),
209
210
  price: t.dividend.price,
210
211
  fee: t.fee,
@@ -734,7 +734,7 @@ module.exports = (() => {
734
734
  if (group.single && group._items.length === 1) {
735
735
  const item = group._items[0];
736
736
 
737
- actual.quantity = item.position.snapshot.open;
737
+ actual.quantity = item.data.quantity;
738
738
  actual.quantityPrevious = item.data.quantityPrevious;
739
739
 
740
740
  actual.basisPrice = item.data.basisPrice;
@@ -71,8 +71,8 @@ module.exports = (() => {
71
71
  this._data.marketPrevious = null;
72
72
  this._data.marketPrevious2 = null;
73
73
 
74
+ this._data.quantity = null;
74
75
  this._data.quantityPrevious = null;
75
- this._data.quantityPrevious2 = null;
76
76
 
77
77
  this._data.realized = null;
78
78
  this._data.income = null;
@@ -385,6 +385,7 @@ module.exports = (() => {
385
385
 
386
386
  const data = item._data;
387
387
 
388
+ data.quantity = snapshot.open;
388
389
  data.previousPrice = position.previous || null;
389
390
 
390
391
  let basis;
@@ -317,7 +317,8 @@ module.exports = (() => {
317
317
  .withField('sequence', DataType.NUMBER, true)
318
318
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
319
319
  .withField('date', DataType.DAY)
320
- .withField('value', DataType.DECIMAL)
320
+ .withField('rate', DataType.DECIMAL, true)
321
+ .withField('value', DataType.DECIMAL, true)
321
322
  .withField('force', DataType.BOOLEAN, true)
322
323
  .schema
323
324
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.107",
3
+ "version": "1.2.111",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -3194,7 +3194,7 @@ module.exports = (() => {
3194
3194
  if (group.single && group._items.length === 1) {
3195
3195
  const item = group._items[0];
3196
3196
 
3197
- actual.quantity = item.position.snapshot.open;
3197
+ actual.quantity = item.data.quantity;
3198
3198
  actual.quantityPrevious = item.data.quantityPrevious;
3199
3199
 
3200
3200
  actual.basisPrice = item.data.basisPrice;
@@ -3472,8 +3472,8 @@ module.exports = (() => {
3472
3472
  this._data.marketPrevious = null;
3473
3473
  this._data.marketPrevious2 = null;
3474
3474
 
3475
+ this._data.quantity = null;
3475
3476
  this._data.quantityPrevious = null;
3476
- this._data.quantityPrevious2 = null;
3477
3477
 
3478
3478
  this._data.realized = null;
3479
3479
  this._data.income = null;
@@ -3786,6 +3786,7 @@ module.exports = (() => {
3786
3786
 
3787
3787
  const data = item._data;
3788
3788
 
3789
+ data.quantity = snapshot.open;
3789
3790
  data.previousPrice = position.previous || null;
3790
3791
 
3791
3792
  let basis;
@@ -4757,7 +4758,8 @@ module.exports = (() => {
4757
4758
  .withField('sequence', DataType.NUMBER, true)
4758
4759
  .withField('type', DataType.forEnum(TransactionType, 'TransactionType'))
4759
4760
  .withField('date', DataType.DAY)
4760
- .withField('value', DataType.DECIMAL)
4761
+ .withField('rate', DataType.DECIMAL, true)
4762
+ .withField('value', DataType.DECIMAL, true)
4761
4763
  .withField('force', DataType.BOOLEAN, true)
4762
4764
  .schema
4763
4765
  );