@dhyasama/totem-models 8.18.0 → 8.19.1

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/Financials.js CHANGED
@@ -209,20 +209,41 @@ module.exports = function(mongoose, config) {
209
209
 
210
210
  };
211
211
 
212
- Financials.statics.getByUUID = function getByUUID(uuid, cb) {
212
+ Financials.statics.getByUUID = function getByUUID(uuid, cb) {
213
213
 
214
- var self = this;
214
+ let self = this;
215
215
 
216
- var query = self.findOne({
216
+ let query = self.findOne({
217
217
  'snapshots.uuid': uuid
218
218
  });
219
219
 
220
220
  query.populate('organization', 'name logoUrl');
221
- query.populate({
222
- path: 'snapshots.documents',
223
- });
221
+ query.populate('customer');
222
+ query.populate('snapshots.documents');
224
223
 
225
- query.exec(cb);
224
+ query.exec(function (err, result) {
225
+
226
+ if (err) {
227
+ return cb(err, null);
228
+ }
229
+ else if (!result) {
230
+ return cb(null, null);
231
+ }
232
+ else if (!result.customer) {
233
+ return cb(null, null);
234
+ }
235
+
236
+ _.each(result.snapshots, function (snapshot) {
237
+
238
+ snapshot.documents = _.filter(snapshot.documents, function (document) {
239
+ return document.customer.toString() === result.customer._id.toString();
240
+ });
241
+
242
+ });
243
+
244
+ return cb(null, result);
245
+
246
+ });
226
247
 
227
248
  };
228
249
 
@@ -229,12 +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
+ required: { type: Boolean, default: false }
233
233
  }],
234
234
  questions: [{
235
235
  _id: false,
236
236
  prompt: { type: String, trim: true },
237
- required: { type: Boolean, default: false },
237
+ required: { type: Boolean, default: false }
238
238
  }]
239
239
  },
240
240
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.18.0",
3
+ "version": "8.19.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",