@dhyasama/totem-models 6.20.1 → 6.21.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.
- package/lib/Deal.js +20 -1
- package/package.json +1 -1
package/lib/Deal.js
CHANGED
|
@@ -7,7 +7,8 @@ module.exports = function(mongoose, config) {
|
|
|
7
7
|
Schema = mongoose.Schema,
|
|
8
8
|
postFind = require('mongoose-post-find'),
|
|
9
9
|
async = require('async'),
|
|
10
|
-
_ = require('underscore')
|
|
10
|
+
_ = require('underscore'),
|
|
11
|
+
moment = require('moment');
|
|
11
12
|
|
|
12
13
|
var Deal = new Schema({
|
|
13
14
|
|
|
@@ -166,6 +167,10 @@ module.exports = function(mongoose, config) {
|
|
|
166
167
|
.populate('messages')
|
|
167
168
|
.populate('source.person', 'name avatarUrl title')
|
|
168
169
|
.populate('referrer.person', 'name avatarUrl title')
|
|
170
|
+
.populate({
|
|
171
|
+
path: 'documents',
|
|
172
|
+
match: { customer: config.CUSTOMER_ID }
|
|
173
|
+
})
|
|
169
174
|
.exec(function(err, deals) {
|
|
170
175
|
|
|
171
176
|
if (err) return cb(err, null);
|
|
@@ -240,6 +245,20 @@ module.exports = function(mongoose, config) {
|
|
|
240
245
|
|
|
241
246
|
};
|
|
242
247
|
|
|
248
|
+
Deal.statics.getByReferrer = function (personId, cb) {
|
|
249
|
+
|
|
250
|
+
var self = this;
|
|
251
|
+
|
|
252
|
+
self
|
|
253
|
+
.findOne({
|
|
254
|
+
'referrer.person': personId,
|
|
255
|
+
'customer': config.CUSTOMER_ID
|
|
256
|
+
})
|
|
257
|
+
.populate('organization', 'name logoUrl website websiteAliases')
|
|
258
|
+
.exec(cb);
|
|
259
|
+
|
|
260
|
+
};
|
|
261
|
+
|
|
243
262
|
// Get a deal for a org, belonging to current customer
|
|
244
263
|
Deal.statics.getForOrg = function (orgId, cb) {
|
|
245
264
|
|