@dhyasama/totem-models 8.12.0 → 8.17.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/helpers.js +1 -0
- package/lib/Financials.js +27 -10
- package/lib/Organization.js +4 -2
- package/package.json +1 -1
package/helpers.js
CHANGED
|
@@ -84,6 +84,7 @@ const getPeopleSources = module.exports.getPeopleSources = function getPeopleSou
|
|
|
84
84
|
people = _.reject(people, function(p) { return !p || !p.sources; });
|
|
85
85
|
|
|
86
86
|
let result = _.compact(_.pluck(people, 'sources'));
|
|
87
|
+
|
|
87
88
|
if (result.length === 0) { return []; }
|
|
88
89
|
|
|
89
90
|
result = _.flatten(result);
|
package/lib/Financials.js
CHANGED
|
@@ -209,23 +209,40 @@ module.exports = function(mongoose, config) {
|
|
|
209
209
|
|
|
210
210
|
};
|
|
211
211
|
|
|
212
|
-
Financials.statics.getByUUID = function getByUUID(
|
|
212
|
+
Financials.statics.getByUUID = function getByUUID(uuid, cb) {
|
|
213
213
|
|
|
214
|
-
|
|
214
|
+
let self = this;
|
|
215
215
|
|
|
216
|
-
|
|
217
|
-
'customer': customerId,
|
|
216
|
+
let query = self.findOne({
|
|
218
217
|
'snapshots.uuid': uuid
|
|
219
218
|
});
|
|
220
219
|
|
|
221
220
|
query.populate('organization', 'name logoUrl');
|
|
222
|
-
query.populate('customer', 'name logoUrl
|
|
223
|
-
query.populate({
|
|
224
|
-
path: 'snapshots.documents',
|
|
225
|
-
match: { customer: customerId }
|
|
226
|
-
});
|
|
221
|
+
query.populate('customer', 'name logoUrl ');
|
|
227
222
|
|
|
228
|
-
query.exec(
|
|
223
|
+
query.exec(function (err, result) {
|
|
224
|
+
|
|
225
|
+
if (err) {
|
|
226
|
+
return cb(err, null);
|
|
227
|
+
}
|
|
228
|
+
else if (!result) {
|
|
229
|
+
return cb(null, null);
|
|
230
|
+
}
|
|
231
|
+
else if (!result.customer) {
|
|
232
|
+
return cb(null, null);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let customerId = result.customer._id;
|
|
236
|
+
|
|
237
|
+
_.each(result.snapshots, function (snapshot) {
|
|
238
|
+
|
|
239
|
+
snapshot.documents = _.filter(snapshot.documents, function (document) {
|
|
240
|
+
return document.customer = customerId;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
});
|
|
229
246
|
|
|
230
247
|
};
|
|
231
248
|
|
package/lib/Organization.js
CHANGED
|
@@ -229,10 +229,12 @@ module.exports = function(mongoose, config) {
|
|
|
229
229
|
name: { type: String, trim: true },
|
|
230
230
|
description: { type: String, trim: true },
|
|
231
231
|
format: { type: String, enum: [null, 'number', 'money', 'percentage', 'variance']},
|
|
232
|
+
required: { type: Boolean, default: false },
|
|
232
233
|
}],
|
|
233
234
|
questions: [{
|
|
234
235
|
_id: false,
|
|
235
|
-
prompt: { type: String, trim: true }
|
|
236
|
+
prompt: { type: String, trim: true },
|
|
237
|
+
required: { type: Boolean, default: false },
|
|
236
238
|
}]
|
|
237
239
|
},
|
|
238
240
|
|
|
@@ -1284,7 +1286,7 @@ module.exports = function(mongoose, config) {
|
|
|
1284
1286
|
|
|
1285
1287
|
};
|
|
1286
1288
|
|
|
1287
|
-
Organization.statics.findByTotemUrl = function
|
|
1289
|
+
Organization.statics.findByTotemUrl = function findByTotemUrl(url, cb) {
|
|
1288
1290
|
this.findOne({ 'customer.totemUrl': url }).exec(cb);
|
|
1289
1291
|
};
|
|
1290
1292
|
|