@dhyasama/totem-models 8.64.0 → 8.67.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 +53 -30
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -138,6 +138,7 @@ module.exports = function(mongoose, config) {
|
|
|
138
138
|
initial: {
|
|
139
139
|
sendOn: { type: Date, required: false },
|
|
140
140
|
sentOn: { type: Date, required: false },
|
|
141
|
+
sentToQueue: { type: Boolean, default: false },
|
|
141
142
|
postmarkMessageId: { type: String, trim: true },
|
|
142
143
|
status: { type: String, enum: [null, 'Sent', 'Bounced', 'Delivered', 'Opened', 'Clicked']}
|
|
143
144
|
},
|
|
@@ -145,6 +146,7 @@ module.exports = function(mongoose, config) {
|
|
|
145
146
|
reminders: [{
|
|
146
147
|
sendOn: { type: Date, required: false },
|
|
147
148
|
sentOn: { type: Date, required: false },
|
|
149
|
+
sentToQueue: { type: Boolean, default: false },
|
|
148
150
|
postmarkMessageId: { type: String, trim: true },
|
|
149
151
|
status: { type: String, enum: [null, 'Sent', 'Bounced', 'Delivered', 'Opened', 'Clicked']}
|
|
150
152
|
}],
|
|
@@ -152,6 +154,7 @@ module.exports = function(mongoose, config) {
|
|
|
152
154
|
rejections: [{
|
|
153
155
|
sendOn: { type: Date, required: false },
|
|
154
156
|
sentOn: { type: Date, required: false },
|
|
157
|
+
sentToQueue: { type: Boolean, default: false },
|
|
155
158
|
postmarkMessageId: { type: String, trim: true },
|
|
156
159
|
status: { type: String, enum: [null, 'Sent', 'Bounced', 'Delivered', 'Opened', 'Clicked']}
|
|
157
160
|
}]
|
|
@@ -169,6 +172,7 @@ module.exports = function(mongoose, config) {
|
|
|
169
172
|
initial: {
|
|
170
173
|
sendOn: { type: Date, required: false },
|
|
171
174
|
sentOn: { type: Date, required: false },
|
|
175
|
+
sentToQueue: { type: Boolean, default: false },
|
|
172
176
|
postmarkMessageId: { type: String, trim: true },
|
|
173
177
|
status: { type: String, enum: [null, 'Sent', 'Bounced', 'Delivered', 'Opened', 'Clicked']}
|
|
174
178
|
},
|
|
@@ -176,6 +180,7 @@ module.exports = function(mongoose, config) {
|
|
|
176
180
|
reminders: [{
|
|
177
181
|
sendOn: { type: Date, required: false },
|
|
178
182
|
sentOn: { type: Date, required: false },
|
|
183
|
+
sentToQueue: { type: Boolean, default: false },
|
|
179
184
|
postmarkMessageId: { type: String, trim: true },
|
|
180
185
|
status: { type: String, enum: [null, 'Sent', 'Bounced', 'Delivered', 'Opened', 'Clicked']}
|
|
181
186
|
}]
|
|
@@ -300,7 +305,8 @@ module.exports = function(mongoose, config) {
|
|
|
300
305
|
$elemMatch: {
|
|
301
306
|
'notifications.company.sendTo': { $gt: [] },
|
|
302
307
|
'notifications.company.initial.sendOn': { $lte: now },
|
|
303
|
-
'notifications.company.initial.sentOn': null
|
|
308
|
+
'notifications.company.initial.sentOn': null,
|
|
309
|
+
'notifications.company.initial.sentToQueue': false,
|
|
304
310
|
}
|
|
305
311
|
}
|
|
306
312
|
});
|
|
@@ -315,10 +321,14 @@ module.exports = function(mongoose, config) {
|
|
|
315
321
|
|
|
316
322
|
_.each(financial.snapshots, function(snapshot) {
|
|
317
323
|
|
|
318
|
-
var
|
|
319
|
-
var
|
|
324
|
+
var hasSendTo = snapshot.notifications.company.sendTo.length > 0;
|
|
325
|
+
var hasSendOnLessThanNow = snapshot.notifications.company.initial.sendOn < now;
|
|
326
|
+
var hasSentOn = snapshot.notifications.company.initial.sentOn;
|
|
327
|
+
var hasSentToQueue = snapshot.notifications.company.initial.sentToQueue;
|
|
320
328
|
|
|
321
|
-
|
|
329
|
+
var conditions = hasSendTo && hasSendOnLessThanNow && !hasSentOn && !hasSentToQueue;
|
|
330
|
+
|
|
331
|
+
if(conditions) {
|
|
322
332
|
|
|
323
333
|
var recipients = snapshot.notifications.company.sendTo.map(function(sendTo) {
|
|
324
334
|
return sendTo.email;
|
|
@@ -352,6 +362,7 @@ module.exports = function(mongoose, config) {
|
|
|
352
362
|
'notifications.company.sendTo': { $gt: [] },
|
|
353
363
|
'notifications.company.reminders.sendOn': { $lte: now },
|
|
354
364
|
'notifications.company.reminders.sentOn': null,
|
|
365
|
+
'notifications.company.reminders.sentToQueue': false,
|
|
355
366
|
'$or': [
|
|
356
367
|
{
|
|
357
368
|
'submittedOn': null,
|
|
@@ -375,14 +386,17 @@ module.exports = function(mongoose, config) {
|
|
|
375
386
|
|
|
376
387
|
_.each(financial.snapshots, function(snapshot) {
|
|
377
388
|
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
389
|
+
var conditions = _.some(snapshot.notifications.company.reminders, function(reminder) {
|
|
390
|
+
var hasSendTo = snapshot.notifications.company.sendTo.length > 0;
|
|
391
|
+
var hasSendOnLessThanNow = reminder.sendOn < now;
|
|
392
|
+
var hasSentOn = reminder.sentOn;
|
|
393
|
+
var hasSentToQueue = reminder.sentToQueue;
|
|
394
|
+
var hasBeenSubmitted = snapshot.submittedOn;
|
|
395
|
+
var hasBeenRejected = snapshot.rejection;
|
|
396
|
+
return hasSendTo && hasSendOnLessThanNow && !hasSentOn && !hasSentToQueue && ((!hasBeenSubmitted) || (hasBeenSubmitted && hasBeenRejected));
|
|
381
397
|
});
|
|
382
|
-
var hasBeenSubmitted = snapshot.submittedOn;
|
|
383
|
-
var hasBeenRejected = snapshot.rejection;
|
|
384
398
|
|
|
385
|
-
if(
|
|
399
|
+
if(conditions) {
|
|
386
400
|
|
|
387
401
|
var recipients = snapshot.notifications.company.sendTo.map(function(sendTo) {
|
|
388
402
|
return sendTo.email;
|
|
@@ -416,6 +430,7 @@ module.exports = function(mongoose, config) {
|
|
|
416
430
|
'notifications.company.sendTo': { $gt: [] },
|
|
417
431
|
'notifications.company.rejections.sendOn': { $lte: now },
|
|
418
432
|
'notifications.company.rejections.sentOn': null,
|
|
433
|
+
'notifications.company.rejections.sentToQueue': false,
|
|
419
434
|
'submittedOn': { $ne: null },
|
|
420
435
|
'rejection': { $ne: null }
|
|
421
436
|
}
|
|
@@ -432,14 +447,17 @@ module.exports = function(mongoose, config) {
|
|
|
432
447
|
|
|
433
448
|
_.each(financial.snapshots, function(snapshot) {
|
|
434
449
|
|
|
435
|
-
var
|
|
436
|
-
|
|
437
|
-
|
|
450
|
+
var conditions = _.some(snapshot.notifications.company.rejections, function(rejection) {
|
|
451
|
+
var hasSendTo = snapshot.notifications.company.sendTo.length > 0;
|
|
452
|
+
var hasSendOnLessThanNow = rejection.sendOn < now;
|
|
453
|
+
var hasSentOn = rejection.sentOn;
|
|
454
|
+
var hasSentToQueue = rejection.sentToQueue;
|
|
455
|
+
var hasBeenSubmitted = snapshot.submittedOn;
|
|
456
|
+
var hasBeenRejected = snapshot.rejection;
|
|
457
|
+
return hasSendTo && hasSendOnLessThanNow && !hasSentOn && !hasSentToQueue && hasBeenSubmitted && hasBeenRejected;
|
|
438
458
|
});
|
|
439
|
-
var hasBeenSubmitted = snapshot.submittedOn;
|
|
440
|
-
var hasBeenRejected = snapshot.rejection;
|
|
441
459
|
|
|
442
|
-
if(
|
|
460
|
+
if(conditions) {
|
|
443
461
|
|
|
444
462
|
var recipients = snapshot.notifications.company.sendTo.map(function(sendTo) {
|
|
445
463
|
return sendTo.email;
|
|
@@ -473,7 +491,8 @@ module.exports = function(mongoose, config) {
|
|
|
473
491
|
'notifications.stakeholders.sendTo.email': { $ne: null },
|
|
474
492
|
'notifications.stakeholders.sendTo.organization': { $ne: null },
|
|
475
493
|
'notifications.stakeholders.initial.sendOn': { $lte: now },
|
|
476
|
-
'notifications.stakeholders.initial.sentOn': null
|
|
494
|
+
'notifications.stakeholders.initial.sentOn': null,
|
|
495
|
+
'notifications.stakeholders.initial.sentToQueue': false,
|
|
477
496
|
}
|
|
478
497
|
}
|
|
479
498
|
});
|
|
@@ -490,11 +509,15 @@ module.exports = function(mongoose, config) {
|
|
|
490
509
|
|
|
491
510
|
_.each(snapshot.notifications.stakeholders, function(stakeholder) {
|
|
492
511
|
|
|
493
|
-
var
|
|
512
|
+
var hasSendTo = stakeholder.sendTo && stakeholder.sendTo.email;
|
|
494
513
|
var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
|
|
495
|
-
var
|
|
514
|
+
var hasSendOnLessThanNow = stakeholder.initial && stakeholder.initial.sendOn < now;
|
|
515
|
+
var hasSentOn = stakeholder.initial && stakeholder.initial.sentOn;
|
|
516
|
+
var hasSentToQueue = stakeholder.initial && stakeholder.initial.sentToQueue;
|
|
517
|
+
|
|
518
|
+
var conditions = hasSendTo && hasOrganization && hasSendOnLessThanNow && !hasSendTo && !hasSentToQueue;
|
|
496
519
|
|
|
497
|
-
if(
|
|
520
|
+
if(conditions) {
|
|
498
521
|
|
|
499
522
|
results.push({
|
|
500
523
|
'uuid': snapshot.uuid,
|
|
@@ -526,7 +549,8 @@ module.exports = function(mongoose, config) {
|
|
|
526
549
|
'notifications.stakeholders.sendTo.email': { $ne: null },
|
|
527
550
|
'notifications.stakeholders.sendTo.organization': { $ne: null },
|
|
528
551
|
'notifications.stakeholders.reminders.sendOn': { $lte: now },
|
|
529
|
-
'notifications.stakeholders.reminders.sentOn': null
|
|
552
|
+
'notifications.stakeholders.reminders.sentOn': null,
|
|
553
|
+
'notifications.stakeholders.reminders.sentToQueue': false
|
|
530
554
|
}
|
|
531
555
|
}
|
|
532
556
|
});
|
|
@@ -543,17 +567,16 @@ module.exports = function(mongoose, config) {
|
|
|
543
567
|
|
|
544
568
|
_.each(snapshot.notifications.stakeholders, function(stakeholder) {
|
|
545
569
|
|
|
546
|
-
var
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return reminder.status != 'Clicked';
|
|
570
|
+
var conditions = _.some(stakeholder.reminders, function(reminder) {
|
|
571
|
+
var hasSendTo = stakeholder.sendTo && stakeholder.sendTo.email;
|
|
572
|
+
var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
|
|
573
|
+
var hasSendOnLessThanNow = reminder.sendOn < now;
|
|
574
|
+
var hasSentOn = reminder.sentOn;
|
|
575
|
+
var hasSentToQueue = reminder.sentToQueue;
|
|
576
|
+
return hasSendTo && hasOrganization && hasSendOnLessThanNow && !hasSentOn && !hasSentToQueue;
|
|
554
577
|
});
|
|
555
578
|
|
|
556
|
-
if(
|
|
579
|
+
if(conditions) {
|
|
557
580
|
|
|
558
581
|
results.push({
|
|
559
582
|
'uuid': snapshot.uuid,
|