@dhyasama/totem-models 7.56.0 → 7.58.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 +26 -20
  2. package/package.json +1 -1
package/lib/Financials.js CHANGED
@@ -272,10 +272,9 @@ module.exports = function(mongoose, config) {
272
272
  snapshots = _.filter(snapshots, function(snapshot) {
273
273
 
274
274
  var hasRecipients = snapshot.notifications.company.sendTo.length > 0;
275
- var hasSendOnLessThanNow = snapshot.notifications.company.initial.sendOn < now;
276
- var hasNotBeenSentTo = !snapshot.notifications.company.initial.sentOn;
275
+ var hasUnsentSendOnLessThanNow = snapshot.notifications.company.initial.sendOn < now && !snapshot.notifications.company.initial.sentOn;
277
276
 
278
- return hasRecipients && hasSendOnLessThanNow && hasNotBeenSentTo;
277
+ return hasRecipients && hasUnsentSendOnLessThanNow;
279
278
 
280
279
  });
281
280
 
@@ -296,7 +295,15 @@ module.exports = function(mongoose, config) {
296
295
  'notifications.company.sendTo': { $gt: [] },
297
296
  'notifications.company.reminders.sendOn': { $lte: now },
298
297
  'notifications.company.reminders.sentOn': null,
299
- 'submittedOn': null
298
+ "$or": [
299
+ {
300
+ "submittedOn": null,
301
+ },
302
+ {
303
+ "submittedOn": { $ne: null },
304
+ "rejection": { $ne: null }
305
+ }
306
+ ]
300
307
  }
301
308
  }
302
309
  });
@@ -311,16 +318,14 @@ module.exports = function(mongoose, config) {
311
318
 
312
319
  snapshots = _.filter(snapshots, function(snapshot) {
313
320
 
314
- var sendOnLessThanNow = _.find(snapshot.notifications.company.reminders, function(reminder) {
315
- return reminder.sendOn < now;
316
- });
317
-
318
321
  var hasRecipients = snapshot.notifications.company.sendTo.length > 0;
319
- var hasSendOnLessThanNow = sendOnLessThanNow;
320
- var hasNotBeenSentTo = sendOnLessThanNow && !sendOnLessThanNow.sentOn;
321
- var hasNotBeenSubmitted = !snapshot.submittedOn;
322
+ var hasUnsentSendOnLessThanNow = _.find(snapshot.notifications.company.reminders, function(reminder) {
323
+ return reminder.sendOn < now && !reminder.sentOn;
324
+ });
325
+ var hasBeenSubmitted = snapshot.submittedOn;
326
+ var hasBeenRejected = snapshot.rejection;
322
327
 
323
- return hasRecipients && hasSendOnLessThanNow && hasNotBeenSentTo && hasNotBeenSubmitted;
328
+ return hasRecipients && hasUnsentSendOnLessThanNow && ((!hasBeenSubmitted) || (hasBeenSubmitted && hasBeenRejected));
324
329
 
325
330
  });
326
331
 
@@ -340,7 +345,9 @@ module.exports = function(mongoose, config) {
340
345
  $elemMatch: {
341
346
  'notifications.company.sendTo': { $gt: [] },
342
347
  'notifications.company.rejections.sendOn': { $lte: now },
343
- 'notifications.company.rejections.sentOn': null
348
+ 'notifications.company.rejections.sentOn': null,
349
+ "submittedOn": { $ne: null },
350
+ "rejection": { $ne: null }
344
351
  }
345
352
  }
346
353
  });
@@ -355,15 +362,14 @@ module.exports = function(mongoose, config) {
355
362
 
356
363
  snapshots = _.filter(snapshots, function(snapshot) {
357
364
 
358
- var sendOnLessThanNow = _.find(snapshot.notifications.company.rejections, function(rejection) {
359
- return rejection.sendOn < now;
360
- });
361
-
362
365
  var hasRecipients = snapshot.notifications.company.sendTo.length > 0;
363
- var hasSendOnLessThanNow = sendOnLessThanNow;
364
- var hasNotBeenSentTo = sendOnLessThanNow && !sendOnLessThanNow.sentOn;
366
+ var hasUnsentSendOnLessThanNow = _.find(snapshot.notifications.company.rejections, function(rejection) {
367
+ return rejection.sendOn < now && !rejection.sentOn;
368
+ });
369
+ var hasBeenSubmitted = snapshot.submittedOn;
370
+ var hasBeenRejected = snapshot.rejection;
365
371
 
366
- return hasRecipients && hasSendOnLessThanNow && hasNotBeenSentTo;
372
+ return hasRecipients && hasUnsentSendOnLessThanNow && hasBeenSubmitted && hasBeenRejected;
367
373
 
368
374
  });
369
375
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "7.56.0",
3
+ "version": "7.58.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",