@dhyasama/totem-models 7.21.1 → 7.22.1
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 +31 -17
- package/lib/Organization.js +2 -2
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
3
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
4
4
|
// NOTES
|
|
@@ -217,8 +217,8 @@ module.exports = function(mongoose, config) {
|
|
|
217
217
|
|
|
218
218
|
var query = self.findOne({
|
|
219
219
|
$or: [
|
|
220
|
-
{
|
|
221
|
-
{
|
|
220
|
+
{ 'snapshots.notifications.company.initial.postmarkMessageId': postmarkMessageId },
|
|
221
|
+
{ 'snapshots.notifications.company.reminder.postmarkMessageId': postmarkMessageId }
|
|
222
222
|
]
|
|
223
223
|
});
|
|
224
224
|
|
|
@@ -278,9 +278,13 @@ module.exports = function(mongoose, config) {
|
|
|
278
278
|
|
|
279
279
|
var query = self.find({
|
|
280
280
|
'customer': customerId,
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
'snapshots': {
|
|
282
|
+
$elemMatch: {
|
|
283
|
+
'managedServices': true,
|
|
284
|
+
'submittedOn': { $ne: null },
|
|
285
|
+
'reviewedOn': null
|
|
286
|
+
}
|
|
287
|
+
}
|
|
284
288
|
});
|
|
285
289
|
|
|
286
290
|
query.exec(function(err, result) {
|
|
@@ -288,6 +292,16 @@ module.exports = function(mongoose, config) {
|
|
|
288
292
|
var snapshots = _.pluck(result || [], 'snapshots');
|
|
289
293
|
snapshots = _.flatten(snapshots);
|
|
290
294
|
|
|
295
|
+
snapshots = _.filter(snapshots, function(snapshot) {
|
|
296
|
+
|
|
297
|
+
var bool = snapshot.managedServices;
|
|
298
|
+
bool = bool && snapshot.submittedOn;
|
|
299
|
+
bool = bool && !snapshot.reviewedOn;
|
|
300
|
+
|
|
301
|
+
return bool;
|
|
302
|
+
|
|
303
|
+
});
|
|
304
|
+
|
|
291
305
|
if (err) { return cb(err, null); }
|
|
292
306
|
return cb(null, snapshots);
|
|
293
307
|
|
|
@@ -316,12 +330,12 @@ module.exports = function(mongoose, config) {
|
|
|
316
330
|
var now = new Date();
|
|
317
331
|
|
|
318
332
|
var query = self.find({
|
|
319
|
-
|
|
333
|
+
'snapshots': {
|
|
320
334
|
$elemMatch: {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
335
|
+
'notifications.company.sendTo.email': { $ne: null },
|
|
336
|
+
'notifications.company.initial.sendOn': { $lte: now },
|
|
337
|
+
'notifications.company.initial.sentOn': null,
|
|
338
|
+
'submittedOn': null
|
|
325
339
|
}
|
|
326
340
|
}
|
|
327
341
|
});
|
|
@@ -356,12 +370,12 @@ module.exports = function(mongoose, config) {
|
|
|
356
370
|
var now = new Date();
|
|
357
371
|
|
|
358
372
|
var query = self.find({
|
|
359
|
-
|
|
373
|
+
'snapshots': {
|
|
360
374
|
$elemMatch: {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
375
|
+
'notifications.company.sendTo.email': { $ne: null },
|
|
376
|
+
'notifications.company.reminder.sendOn': { $lte: now },
|
|
377
|
+
'notifications.company.reminder.sentOn': null,
|
|
378
|
+
'submittedOn': null
|
|
365
379
|
}
|
|
366
380
|
}
|
|
367
381
|
});
|
|
@@ -506,4 +520,4 @@ module.exports = function(mongoose, config) {
|
|
|
506
520
|
|
|
507
521
|
mongoose.model('Financials', Financials);
|
|
508
522
|
|
|
509
|
-
};
|
|
523
|
+
};
|
package/lib/Organization.js
CHANGED
|
@@ -2163,7 +2163,7 @@ module.exports = function(mongoose, config) {
|
|
|
2163
2163
|
|
|
2164
2164
|
var CUSTOMER_ID = config.CUSTOMER_ID;
|
|
2165
2165
|
|
|
2166
|
-
if (CUSTOMER_ID == 'GLOBAL_PROCESS') return next();
|
|
2166
|
+
if (CUSTOMER_ID == 'GLOBAL_PROCESS' && next) return next();
|
|
2167
2167
|
|
|
2168
2168
|
// remove customer details if not viewing self
|
|
2169
2169
|
if (doc._id.toString() != CUSTOMER_ID) doc.customer = {};
|
|
@@ -2195,7 +2195,7 @@ module.exports = function(mongoose, config) {
|
|
|
2195
2195
|
|
|
2196
2196
|
});
|
|
2197
2197
|
|
|
2198
|
-
return next();
|
|
2198
|
+
if (next) return next();
|
|
2199
2199
|
|
|
2200
2200
|
});
|
|
2201
2201
|
|