@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.
- package/lib/Financials.js +26 -20
- 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
|
|
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 &&
|
|
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
|
-
|
|
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
|
|
320
|
-
|
|
321
|
-
|
|
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 &&
|
|
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
|
|
364
|
-
|
|
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 &&
|
|
372
|
+
return hasRecipients && hasUnsentSendOnLessThanNow && hasBeenSubmitted && hasBeenRejected;
|
|
367
373
|
|
|
368
374
|
});
|
|
369
375
|
|