@dhyasama/totem-models 7.21.0 → 7.22.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/Financials.js +31 -17
  2. package/package.json +1 -1
package/lib/Financials.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ 'use strict';
2
2
 
3
3
  ///////////////////////////////////////////////////////////////////////////////////////
4
4
  // NOTES
@@ -217,8 +217,8 @@ module.exports = function(mongoose, config) {
217
217
 
218
218
  var query = self.findOne({
219
219
  $or: [
220
- { "snapshots.notifications.company.initial.postmarkMessageId": postmarkMessageId },
221
- { "snapshots.notifications.company.reminder.postmarkMessageId": postmarkMessageId }
220
+ { 'snapshots.notifications.company.initial.postmarkMessageId': postmarkMessageId },
221
+ { 'snapshots.notifications.company.reminder.postmarkMessageId': postmarkMessageId }
222
222
  ]
223
223
  });
224
224
 
@@ -278,9 +278,13 @@ module.exports = function(mongoose, config) {
278
278
 
279
279
  var query = self.find({
280
280
  'customer': customerId,
281
- "snapshots.managedServices": true,
282
- "snapshots.submittedOn": { $ne: null },
283
- "snapshots.reviewedOn": null
281
+ 'snapshots': {
282
+ $elemMatch: {
283
+ 'managedServices': true,
284
+ 'submittedOn': { $ne: null },
285
+ 'reviewedOn': null
286
+ }
287
+ }
284
288
  });
285
289
 
286
290
  query.exec(function(err, result) {
@@ -288,6 +292,16 @@ module.exports = function(mongoose, config) {
288
292
  var snapshots = _.pluck(result || [], 'snapshots');
289
293
  snapshots = _.flatten(snapshots);
290
294
 
295
+ snapshots = _.filter(snapshots, function(snapshot) {
296
+
297
+ var bool = snapshot.managedServices;
298
+ bool = bool && snapshot.submittedOn;
299
+ bool = bool && !snapshot.reviewedOn;
300
+
301
+ return bool;
302
+
303
+ });
304
+
291
305
  if (err) { return cb(err, null); }
292
306
  return cb(null, snapshots);
293
307
 
@@ -316,12 +330,12 @@ module.exports = function(mongoose, config) {
316
330
  var now = new Date();
317
331
 
318
332
  var query = self.find({
319
- "snapshots": {
333
+ 'snapshots': {
320
334
  $elemMatch: {
321
- "notifications.company.sendTo.email": { $ne: null },
322
- "notifications.company.initial.sendOn": { $lte: Date() },
323
- "notifications.company.initial.sentOn": null,
324
- "submittedOn": null
335
+ 'notifications.company.sendTo.email': { $ne: null },
336
+ 'notifications.company.initial.sendOn': { $lte: now },
337
+ 'notifications.company.initial.sentOn': null,
338
+ 'submittedOn': null
325
339
  }
326
340
  }
327
341
  });
@@ -356,12 +370,12 @@ module.exports = function(mongoose, config) {
356
370
  var now = new Date();
357
371
 
358
372
  var query = self.find({
359
- "snapshots": {
373
+ 'snapshots': {
360
374
  $elemMatch: {
361
- "notifications.company.sendTo.email": { $ne: null },
362
- "notifications.company.reminder.sendOn": { $lte: Date() },
363
- "notifications.company.reminder.sentOn": null,
364
- "submittedOn": null
375
+ 'notifications.company.sendTo.email': { $ne: null },
376
+ 'notifications.company.reminder.sendOn': { $lte: now },
377
+ 'notifications.company.reminder.sentOn': null,
378
+ 'submittedOn': null
365
379
  }
366
380
  }
367
381
  });
@@ -506,4 +520,4 @@ module.exports = function(mongoose, config) {
506
520
 
507
521
  mongoose.model('Financials', Financials);
508
522
 
509
- };
523
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "7.21.0",
3
+ "version": "7.22.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",