@dhyasama/totem-models 8.28.1 → 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.
- package/lib/Financials.js +25 -19
- 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
|
-
|
|
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': { $
|
|
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,11 +435,15 @@ module.exports = function(mongoose, config) {
|
|
|
437
435
|
|
|
438
436
|
snapshots = _.filter(snapshots, function(snapshot) {
|
|
439
437
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
438
|
+
return _.some(snapshot.notifications.stakeholders, function(stakeholder) {
|
|
439
|
+
|
|
440
|
+
var hasEmail = stakeholder.sendTo && stakeholder.sendTo.email;
|
|
441
|
+
var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
|
|
442
|
+
var hasUnsentSendOnLessThanNow = stakeholder.initial && stakeholder.initial.sendOn < now && !stakeholder.initial.sentOn;
|
|
443
443
|
|
|
444
|
-
|
|
444
|
+
return hasEmail && hasOrganization && hasUnsentSendOnLessThanNow;
|
|
445
|
+
|
|
446
|
+
});
|
|
445
447
|
|
|
446
448
|
});
|
|
447
449
|
|
|
@@ -459,8 +461,8 @@ module.exports = function(mongoose, config) {
|
|
|
459
461
|
var query = self.find({
|
|
460
462
|
'snapshots': {
|
|
461
463
|
$elemMatch: {
|
|
462
|
-
'notifications.stakeholders.sendTo': { $
|
|
463
|
-
'notifications.stakeholders.organization': { $ne: null },
|
|
464
|
+
'notifications.stakeholders.sendTo.email': { $ne: null },
|
|
465
|
+
'notifications.stakeholders.sendTo.organization': { $ne: null },
|
|
464
466
|
'notifications.stakeholders.reminders.sendOn': { $lte: now },
|
|
465
467
|
'notifications.stakeholders.reminders.sentOn': null
|
|
466
468
|
}
|
|
@@ -477,13 +479,17 @@ module.exports = function(mongoose, config) {
|
|
|
477
479
|
|
|
478
480
|
snapshots = _.filter(snapshots, function(snapshot) {
|
|
479
481
|
|
|
480
|
-
|
|
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
|
-
});
|
|
482
|
+
return _.some(snapshot.notifications.stakeholders, function(stakeholder) {
|
|
485
483
|
|
|
486
|
-
|
|
484
|
+
var hasEmail = stakeholder.sendTo && stakeholder.sendTo.email;
|
|
485
|
+
var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
|
|
486
|
+
var hasUnsentSendOnLessThanNow = _.find(stakeholder.reminders, function(reminder) {
|
|
487
|
+
return reminder.sendOn < now && !reminder.sentOn;
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
return hasEmail && hasOrganization && hasUnsentSendOnLessThanNow;
|
|
491
|
+
|
|
492
|
+
});
|
|
487
493
|
|
|
488
494
|
});
|
|
489
495
|
|