@barchart/portfolio-api-common 1.0.262 → 1.0.263

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.
@@ -20,18 +20,34 @@ module.exports = (() => {
20
20
  * @param {Function} descriptionCalculator
21
21
  */
22
22
  class PositionSummaryFrame extends Enum {
23
- constructor(code, description, rangeCalculator, startDateCalculator, descriptionCalculator) {
23
+ constructor(code, description, unique, rangeCalculator, startDateCalculator, descriptionCalculator) {
24
24
  super(code, description);
25
25
 
26
+ assert.argumentIsRequired(unique, 'unique', Boolean);
27
+
26
28
  assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
27
29
  assert.argumentIsRequired(startDateCalculator, 'startDateCalculator', Function);
28
30
  assert.argumentIsRequired(descriptionCalculator, 'descriptionCalculator', Function);
29
31
 
32
+ this._unique = unique;
33
+
30
34
  this._rangeCalculator = rangeCalculator;
31
35
  this._startDateCalculator = startDateCalculator;
32
36
  this._descriptionCalculator = descriptionCalculator;
33
37
  }
34
38
 
39
+ /**
40
+ * If true, only one summary, of the given type, can exist for a
41
+ * position. If false, multiple summaries, of the given type, can
42
+ * exist for a position.
43
+ *
44
+ * @public
45
+ * @return {Boolean}
46
+ */
47
+ get unique() {
48
+ return this._unique;
49
+ }
50
+
35
51
  /**
36
52
  * Returns a human-readable description of the frame, given
37
53
  * start and end dates.
@@ -129,10 +145,10 @@ module.exports = (() => {
129
145
  }
130
146
  }
131
147
 
132
- const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
133
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
134
- const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
135
- const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
148
+ const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
149
+ const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
150
+ const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
151
+ const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
136
152
 
137
153
  /**
138
154
  * The start and and date for a {@link PositionSummaryFrame}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.0.262",
3
+ "version": "1.0.263",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -208,18 +208,34 @@ module.exports = (() => {
208
208
  * @param {Function} descriptionCalculator
209
209
  */
210
210
  class PositionSummaryFrame extends Enum {
211
- constructor(code, description, rangeCalculator, startDateCalculator, descriptionCalculator) {
211
+ constructor(code, description, unique, rangeCalculator, startDateCalculator, descriptionCalculator) {
212
212
  super(code, description);
213
213
 
214
+ assert.argumentIsRequired(unique, 'unique', Boolean);
215
+
214
216
  assert.argumentIsRequired(rangeCalculator, 'rangeCalculator', Function);
215
217
  assert.argumentIsRequired(startDateCalculator, 'startDateCalculator', Function);
216
218
  assert.argumentIsRequired(descriptionCalculator, 'descriptionCalculator', Function);
217
219
 
220
+ this._unique = unique;
221
+
218
222
  this._rangeCalculator = rangeCalculator;
219
223
  this._startDateCalculator = startDateCalculator;
220
224
  this._descriptionCalculator = descriptionCalculator;
221
225
  }
222
226
 
227
+ /**
228
+ * If true, only one summary, of the given type, can exist for a
229
+ * position. If false, multiple summaries, of the given type, can
230
+ * exist for a position.
231
+ *
232
+ * @public
233
+ * @return {Boolean}
234
+ */
235
+ get unique() {
236
+ return this._unique;
237
+ }
238
+
223
239
  /**
224
240
  * Returns a human-readable description of the frame, given
225
241
  * start and end dates.
@@ -317,10 +333,10 @@ module.exports = (() => {
317
333
  }
318
334
  }
319
335
 
320
- const yearly = new PositionSummaryFrame('YEARLY', 'year', getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
321
- const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
322
- const monthly = new PositionSummaryFrame('MONTH', 'month', getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
323
- const ytd = new PositionSummaryFrame('YTD', 'year-to-date', getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
336
+ const yearly = new PositionSummaryFrame('YEARLY', 'year', false, getYearlyRanges, getYearlyStartDate, getYearlyRangeDescription);
337
+ const quarterly = new PositionSummaryFrame('QUARTER', 'quarter', false, getQuarterlyRanges, getQuarterlyStartDate, getQuarterlyRangeDescription);
338
+ const monthly = new PositionSummaryFrame('MONTH', 'month', false, getMonthlyRanges, getMonthlyStartDate, getMonthlyRangeDescription);
339
+ const ytd = new PositionSummaryFrame('YTD', 'year-to-date', true, getYearToDateRanges, getYearToDateStartDate, getYearToDateRangeDescription);
324
340
 
325
341
  /**
326
342
  * The start and and date for a {@link PositionSummaryFrame}