@dhyasama/totem-models 8.28.1 → 8.28.2

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 +20 -10
  2. package/package.json +1 -1
package/lib/Financials.js CHANGED
@@ -437,11 +437,17 @@ module.exports = function(mongoose, config) {
437
437
 
438
438
  snapshots = _.filter(snapshots, function(snapshot) {
439
439
 
440
- var hasRecipients = snapshot.notifications.stakeholders.sendTo.length > 0;
441
- var hasOrganization = snapshot.notifications.stakeholders.organization;
442
- var hasUnsentSendOnLessThanNow = snapshot.notifications.stakeholders.initial.sendOn < now && !snapshot.notifications.stakeholders.initial.sentOn;
440
+ snapshot = snapshot.toObject();
443
441
 
444
- return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
442
+ return _.some(snapshot.notifications.stakeholders, function(stakeholder) {
443
+
444
+ var hasRecipients = stakeholder.sendTo && stakeholder.sendTo.length > 0;
445
+ var hasOrganization = stakeholder.organization;
446
+ var hasUnsentSendOnLessThanNow = stakeholder.initial && stakeholder.initial.sendOn < now && !stakeholder.initial.sentOn;
447
+
448
+ return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
449
+
450
+ });
445
451
 
446
452
  });
447
453
 
@@ -477,13 +483,17 @@ module.exports = function(mongoose, config) {
477
483
 
478
484
  snapshots = _.filter(snapshots, function(snapshot) {
479
485
 
480
- var hasRecipients = snapshot.notifications.stakeholders.sendTo.length > 0;
481
- var hasOrganization = snapshot.notifications.stakeholders.organization;
482
- var hasUnsentSendOnLessThanNow = _.find(snapshot.notifications.stakeholders.reminders, function(reminder) {
483
- return reminder.sendOn < now && !reminder.sentOn;
484
- });
486
+ return _.some(snapshot.notifications.stakeholders, function(stakeholder) {
487
+
488
+ var hasRecipients = stakeholder.sendTo && stakeholder.sendTo.length > 0;
489
+ var hasOrganization = stakeholder.organization;
490
+ var hasUnsentSendOnLessThanNow = _.find(stakeholder.reminders, function(reminder) {
491
+ return reminder.sendOn < now && !reminder.sentOn;
492
+ });
485
493
 
486
- return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
494
+ return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
495
+
496
+ });
487
497
 
488
498
  });
489
499
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.28.1",
3
+ "version": "8.28.2",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",