@dhyasama/totem-models 5.3.1 → 5.3.3
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.
- package/.npmignore +14 -0
- package/lib/Deal.js +14 -6
- package/lib/Organization.js +4 -5
- package/package-lock.json +1854 -0
- package/package.json +1 -1
- package/test/Deal.js +1 -1
package/.npmignore
ADDED
package/lib/Deal.js
CHANGED
|
@@ -19,12 +19,12 @@ module.exports = function(mongoose, config) {
|
|
|
19
19
|
|
|
20
20
|
sources: [{
|
|
21
21
|
person: { type: Schema.ObjectId, ref: 'Person', required: true },
|
|
22
|
-
type: { type: String, enum: ['
|
|
22
|
+
type: { type: String, enum: ['Inbound', 'Outbound', 'Event', 'Referral', 'Other'], required: true }
|
|
23
23
|
}],
|
|
24
24
|
|
|
25
25
|
referrers: [{
|
|
26
26
|
person: { type: Schema.ObjectId, ref: 'Person', required: true },
|
|
27
|
-
type: { type: String, enum: ['
|
|
27
|
+
type: { type: String, enum: ['Founder', 'Investor', 'Service Provider', 'Friends & Family', 'Limited Partner', 'Other'], required: true }
|
|
28
28
|
}],
|
|
29
29
|
|
|
30
30
|
documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
|
|
@@ -118,16 +118,21 @@ module.exports = function(mongoose, config) {
|
|
|
118
118
|
};
|
|
119
119
|
|
|
120
120
|
// Get all deals belonging to a customer
|
|
121
|
-
Deal.statics.getForCustomer = function (customerId,
|
|
122
|
-
|
|
123
|
-
var self = this;
|
|
121
|
+
Deal.statics.getForCustomer = function (customerId, options, cb) {
|
|
124
122
|
|
|
125
123
|
// todo - fix deep population
|
|
126
124
|
// not sure why chained deepPopulate isn't working (it throws an error)
|
|
127
125
|
// it works to deepPopulate each result instance in parallel
|
|
128
126
|
|
|
127
|
+
var self = this;
|
|
128
|
+
|
|
129
|
+
options = options || {};
|
|
130
|
+
|
|
131
|
+
var terms = { 'customer': customerId };
|
|
132
|
+
if (options.stage) terms['stage'] = { $in: options.stage };
|
|
133
|
+
|
|
129
134
|
self
|
|
130
|
-
.find(
|
|
135
|
+
.find(terms)
|
|
131
136
|
.populate('organization', 'name description logoUrl website websiteAliases chairs')
|
|
132
137
|
.populate('messages')
|
|
133
138
|
.populate('sources.person', 'name avatarUrl title')
|
|
@@ -145,6 +150,9 @@ module.exports = function(mongoose, config) {
|
|
|
145
150
|
// })
|
|
146
151
|
.exec(function(err, deals) {
|
|
147
152
|
|
|
153
|
+
if (err) return cb(err, null);
|
|
154
|
+
else if (!deals || deals.length == 0) return cb(null, []);
|
|
155
|
+
|
|
148
156
|
var calls = [];
|
|
149
157
|
|
|
150
158
|
_.each(deals, function(deal) {
|
package/lib/Organization.js
CHANGED
|
@@ -1084,6 +1084,9 @@ module.exports = function(mongoose, config) {
|
|
|
1084
1084
|
var lpPopulateOptions = { path: 'lps' };
|
|
1085
1085
|
if (config.CUSTOMER_ID != 'GLOBAL_PROCESS') lpPopulateOptions.match = { customer: config.CUSTOMER_ID };
|
|
1086
1086
|
|
|
1087
|
+
var dealPopulateOptions = { path: 'deals' };
|
|
1088
|
+
if (config.CUSTOMER_ID != 'GLOBAL_PROCESS') dealPopulateOptions.match = { customer: config.CUSTOMER_ID };
|
|
1089
|
+
|
|
1087
1090
|
var query = self.findById(id);
|
|
1088
1091
|
|
|
1089
1092
|
query.populate('people.person', 'name avatarUrl title contact doNotDisplay');
|
|
@@ -1093,11 +1096,7 @@ module.exports = function(mongoose, config) {
|
|
|
1093
1096
|
query.populate('funds', 'name hexColorCode abbreviation closeDate');
|
|
1094
1097
|
query.populate('operating.acquired.public.by', 'name logoUrl');
|
|
1095
1098
|
query.populate('operating.acquired.private.by', 'name logoUrl');
|
|
1096
|
-
|
|
1097
|
-
query.populate({
|
|
1098
|
-
path: 'deals',
|
|
1099
|
-
match: { customer: config.CUSTOMER_ID }
|
|
1100
|
-
});
|
|
1099
|
+
query.populate(dealPopulateOptions);
|
|
1101
1100
|
|
|
1102
1101
|
if (options.role != 'none') {
|
|
1103
1102
|
query.populate(lpPopulateOptions);
|