@dhyasama/totem-models 8.104.0 → 8.105.0

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.
Files changed (2) hide show
  1. package/lib/CapTable.js +37 -7
  2. package/package.json +1 -1
package/lib/CapTable.js CHANGED
@@ -50,6 +50,21 @@ module.exports = function(mongoose, config) {
50
50
  // verbatim text from the cap table
51
51
  name: { type: String, trim: true, required: true },
52
52
 
53
+ // link to a fund in our system
54
+ fund: {
55
+ type: Schema.ObjectId,
56
+ ref: 'Fund',
57
+ default: null,
58
+ required: false,
59
+ validate: {
60
+ validator: function(v) {
61
+ if (v && this.person || this.org || this.lp) return false;
62
+ else return true;
63
+ },
64
+ message: 'A stakeholder can only be linked to one of the following: fund, person, org, lp'
65
+ }
66
+ },
67
+
53
68
  // link stakeholder to a person in our system
54
69
  person: {
55
70
  type: Schema.ObjectId,
@@ -58,25 +73,40 @@ module.exports = function(mongoose, config) {
58
73
  required: false,
59
74
  validate: {
60
75
  validator: function(v) {
61
- if (v && this.fund) return false;
76
+ if (v && this.fund || this.org || this.lp) return false;
62
77
  else return true;
63
78
  },
64
- message: 'A stakeholder can be linked to a person or a fund, but not both'
79
+ message: 'A stakeholder can only be linked to one of the following: fund, person, org, lp'
65
80
  }
66
81
  },
67
82
 
68
- // link stakeholder to a fund in our system
69
- fund: {
83
+ // link stakeholder to a person in our system
84
+ org: {
70
85
  type: Schema.ObjectId,
71
- ref: 'Fund',
86
+ ref: 'Organization',
87
+ default: null,
88
+ required: false,
89
+ validate: {
90
+ validator: function(v) {
91
+ if (v || this.fund || this.person || this.lp) return false;
92
+ else return true;
93
+ },
94
+ message: 'A stakeholder can only be linked to one of the following: fund, person, org, lp'
95
+ }
96
+ },
97
+
98
+ // link stakeholder to a lp in our system
99
+ lp: {
100
+ type: Schema.ObjectId,
101
+ ref: 'LimitedPartner',
72
102
  default: null,
73
103
  required: false,
74
104
  validate: {
75
105
  validator: function(v) {
76
- if (v && this.person) return false;
106
+ if (v || this.fund || this.person || this.org) return false;
77
107
  else return true;
78
108
  },
79
- message: 'A stakeholder can be linked to a person or a fund, but not both'
109
+ message: 'A stakeholder can only be linked to one of the following: fund, person, org, lp'
80
110
  }
81
111
  },
82
112
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.104.0",
3
+ "version": "8.105.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",