@barchart/portfolio-api-common 1.2.46 → 1.2.50

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.
@@ -146,13 +146,18 @@ module.exports = (() => {
146
146
  });
147
147
 
148
148
  formatters.set(TransactionType.DIVIDEND_STOCK, (t) => {
149
- const rate = (is.object(t.dividend) && is.string(t.dividend.rate)) || '';
150
-
151
- return {
149
+ const data = {
152
150
  boughtSold: t.quantity,
153
- shares: t.snapshot.open.subtract(t.quantity),
154
- rate: rate
151
+ fee: t.fee
155
152
  };
153
+
154
+ if (t.dividend && t.dividend.rate && t.dividend.price) {
155
+ data.shares = t.snapshot.open.subtract(t.quantity);
156
+ data.price = t.dividend.price;
157
+ data.rate = t.dividend.rate;
158
+ }
159
+
160
+ return data;
156
161
  });
157
162
 
158
163
  formatters.set(TransactionType.DIVIDEND_REINVEST, (t) => {
@@ -174,15 +179,22 @@ module.exports = (() => {
174
179
  });
175
180
 
176
181
  formatters.set(TransactionType.DISTRIBUTION_FUND, (t) => {
177
- return {
178
- shares: t.snapshot.open.subtract(t.quantity),
182
+ const data = {
183
+ boughtSold: t.quantity,
179
184
  fee: t.fee
180
185
  };
186
+
187
+ if (t.dividend && t.dividend.rate && t.dividend.price) {
188
+ data.shares = t.snapshot.open.subtract(t.quantity);
189
+ data.price = t.dividend.price;
190
+ data.rate = t.dividend.rate;
191
+ }
192
+
193
+ return data;
181
194
  });
182
195
 
183
196
  formatters.set(TransactionType.DISTRIBUTION_REINVEST, (t) => {
184
197
  return {
185
- boughtSold: t.quantity,
186
198
  shares: t.snapshot.open.subtract(t.quantity),
187
199
  price: t.dividend.price,
188
200
  fee: t.fee,
@@ -205,7 +217,6 @@ module.exports = (() => {
205
217
 
206
218
  formatters.set(TransactionType.FEE_UNITS, (t) => {
207
219
  return {
208
- total: t.charge.amount,
209
220
  boughtSold: t.quantity
210
221
  };
211
222
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.46",
3
+ "version": "1.2.50",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",