@barchart/portfolio-api-common 1.0.11 → 1.0.15
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.
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const assert = require('@barchart/common-js/lang/assert'),
|
|
2
|
+
Enum = require('@barchart/common-js/lang/Enum');
|
|
3
|
+
|
|
4
|
+
module.exports = (() => {
|
|
5
|
+
'use strict';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* An enumeration item that describes a strategy for calculating basis.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
* @extends {Enum}
|
|
12
|
+
* @param {String} description
|
|
13
|
+
* @param {String} code
|
|
14
|
+
*/
|
|
15
|
+
class PortfolioType extends Enum {
|
|
16
|
+
constructor(code, description) {
|
|
17
|
+
super(code, description);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Given a code, returns the enumeration item.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
* @param {String} code
|
|
25
|
+
* @returns {PortfolioType|null}
|
|
26
|
+
*/
|
|
27
|
+
static parse(code) {
|
|
28
|
+
return Enum.fromCode(PortfolioType, code);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
* @returns {PortfolioType}
|
|
36
|
+
*/
|
|
37
|
+
static get TFSA() {
|
|
38
|
+
return tfsa;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
43
|
+
*
|
|
44
|
+
* @public
|
|
45
|
+
* @returns {PortfolioType}
|
|
46
|
+
*/
|
|
47
|
+
static get RRSP() {
|
|
48
|
+
return rrsp;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @returns {PortfolioType}
|
|
56
|
+
*/
|
|
57
|
+
static get RRIF() {
|
|
58
|
+
return rrif;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @returns {PortfolioType}
|
|
66
|
+
*/
|
|
67
|
+
static get RESP() {
|
|
68
|
+
return resp;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
* @returns {PortfolioType}
|
|
76
|
+
*/
|
|
77
|
+
static get RDSP() {
|
|
78
|
+
return rdsp;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
* @returns {PortfolioType}
|
|
86
|
+
*/
|
|
87
|
+
static get IRA() {
|
|
88
|
+
return ira;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
* @returns {PortfolioType}
|
|
96
|
+
*/
|
|
97
|
+
static get CASH() {
|
|
98
|
+
return cash;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A valuation method that uses first-in, first-out methodology.
|
|
103
|
+
*
|
|
104
|
+
* @public
|
|
105
|
+
* @returns {PortfolioType}
|
|
106
|
+
*/
|
|
107
|
+
static get OTHER() {
|
|
108
|
+
return other;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
toString() {
|
|
112
|
+
return '[PortfolioType]';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const tfsa = new PortfolioType('TFSA', 'Tax-Free Savings (TFSA)');
|
|
117
|
+
const rrsp = new PortfolioType('RRSP', 'Retirement Savings (RRSP)');
|
|
118
|
+
const rrif = new PortfolioType('RRIF', 'Retirement Income (RRIF)');
|
|
119
|
+
const resp = new PortfolioType('RESP', 'Education Savings (RESP)');
|
|
120
|
+
const rdsp = new PortfolioType('RDSP', 'Disability Savings (RDSP)');
|
|
121
|
+
const ira = new PortfolioType('IRA', 'Individual Retirement Account (IRA)');
|
|
122
|
+
const cash = new PortfolioType('CASH', 'Taxable (Cash)');
|
|
123
|
+
const other = new PortfolioType('OTHER', 'Other Assets');
|
|
124
|
+
|
|
125
|
+
return PortfolioType;
|
|
126
|
+
})();
|
|
@@ -65,8 +65,6 @@ module.exports = (() => {
|
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
const create = new PortfolioSchema(SchemaBuilder.withName('Create')
|
|
68
|
-
.withField('user', DataType.STRING)
|
|
69
|
-
.withField('portfolio', DataType.STRING)
|
|
70
68
|
.withField('name', DataType.STRING)
|
|
71
69
|
.withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
|
|
72
70
|
.withField('dates.create', DataType.DAY)
|
|
@@ -74,15 +72,10 @@ module.exports = (() => {
|
|
|
74
72
|
.withField('defaults.currency', DataType.forEnum(Currency, 'Currency'))
|
|
75
73
|
.withField('defaults.reinvest', DataType.BOOLEAN, true)
|
|
76
74
|
.withField('defaults.valuation', DataType.forEnum(ValuationType, 'ValuationType'))
|
|
77
|
-
.withField('legacy.system', DataType.STRING, true)
|
|
78
|
-
.withField('legacy.user', DataType.STRING, true)
|
|
79
|
-
.withField('system.version', DataType.NUMBER, true)
|
|
80
75
|
.schema
|
|
81
76
|
);
|
|
82
77
|
|
|
83
78
|
const update = new PortfolioSchema(SchemaBuilder.withName('Update')
|
|
84
|
-
.withField('user', DataType.STRING)
|
|
85
|
-
.withField('portfolio', DataType.STRING)
|
|
86
79
|
.withField('name', DataType.STRING)
|
|
87
80
|
.withField('timezone', DataType.forEnum(Timezones, 'Timezone'))
|
|
88
81
|
.withField('dates.cash', DataType.DAY, true)
|