@dhyasama/totem-models 8.28.2 → 8.29.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 +13 -17
  2. package/package.json +1 -1
package/lib/Financials.js CHANGED
@@ -30,7 +30,6 @@ module.exports = function(mongoose, config) {
30
30
  managedServices: { type: Boolean, default: false, required: true },
31
31
 
32
32
  status: { type: String },
33
-
34
33
  action: { type: String },
35
34
 
36
35
  year: { type: Number, default: 0 },
@@ -147,12 +146,11 @@ module.exports = function(mongoose, config) {
147
146
 
148
147
  stakeholders: [{
149
148
 
150
- organization: { type: Schema.ObjectId, ref: 'Organization' },
151
-
152
- sendTo: [{
149
+ sendTo: {
150
+ organization: { type: Schema.ObjectId, ref: 'Organization' },
153
151
  email: { type: String, trim: true },
154
152
  name: { type: String, trim: true }
155
- }],
153
+ },
156
154
 
157
155
  initial: {
158
156
  sendOn: { type: Date, required: false },
@@ -419,8 +417,8 @@ module.exports = function(mongoose, config) {
419
417
  var query = self.find({
420
418
  'snapshots': {
421
419
  $elemMatch: {
422
- 'notifications.stakeholders.sendTo': { $gt: [] },
423
- 'notifications.stakeholders.organization': { $ne: null },
420
+ 'notifications.stakeholders.sendTo.email': { $ne: null },
421
+ 'notifications.stakeholders.sendTo.organization': { $ne: null },
424
422
  'notifications.stakeholders.initial.sendOn': { $lte: now },
425
423
  'notifications.stakeholders.initial.sentOn': null
426
424
  }
@@ -437,15 +435,13 @@ module.exports = function(mongoose, config) {
437
435
 
438
436
  snapshots = _.filter(snapshots, function(snapshot) {
439
437
 
440
- snapshot = snapshot.toObject();
441
-
442
438
  return _.some(snapshot.notifications.stakeholders, function(stakeholder) {
443
439
 
444
- var hasRecipients = stakeholder.sendTo && stakeholder.sendTo.length > 0;
445
- var hasOrganization = stakeholder.organization;
440
+ var hasEmail = stakeholder.sendTo && stakeholder.sendTo.email;
441
+ var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
446
442
  var hasUnsentSendOnLessThanNow = stakeholder.initial && stakeholder.initial.sendOn < now && !stakeholder.initial.sentOn;
447
443
 
448
- return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
444
+ return hasEmail && hasOrganization && hasUnsentSendOnLessThanNow;
449
445
 
450
446
  });
451
447
 
@@ -465,8 +461,8 @@ module.exports = function(mongoose, config) {
465
461
  var query = self.find({
466
462
  'snapshots': {
467
463
  $elemMatch: {
468
- 'notifications.stakeholders.sendTo': { $gt: [] },
469
- 'notifications.stakeholders.organization': { $ne: null },
464
+ 'notifications.stakeholders.sendTo.email': { $ne: null },
465
+ 'notifications.stakeholders.sendTo.organization': { $ne: null },
470
466
  'notifications.stakeholders.reminders.sendOn': { $lte: now },
471
467
  'notifications.stakeholders.reminders.sentOn': null
472
468
  }
@@ -485,13 +481,13 @@ module.exports = function(mongoose, config) {
485
481
 
486
482
  return _.some(snapshot.notifications.stakeholders, function(stakeholder) {
487
483
 
488
- var hasRecipients = stakeholder.sendTo && stakeholder.sendTo.length > 0;
489
- var hasOrganization = stakeholder.organization;
484
+ var hasEmail = stakeholder.sendTo && stakeholder.sendTo.email;
485
+ var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
490
486
  var hasUnsentSendOnLessThanNow = _.find(stakeholder.reminders, function(reminder) {
491
487
  return reminder.sendOn < now && !reminder.sentOn;
492
488
  });
493
489
 
494
- return hasRecipients && hasOrganization && hasUnsentSendOnLessThanNow;
490
+ return hasEmail && hasOrganization && hasUnsentSendOnLessThanNow;
495
491
 
496
492
  });
497
493
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.28.2",
3
+ "version": "8.29.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",