@dhyasama/totem-models 8.31.4 → 8.32.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 +39 -33
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -293,9 +293,6 @@ module.exports = function(mongoose, config) {
|
|
|
293
293
|
}
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
-
query.populate('organization', 'name logoUrl');
|
|
297
|
-
query.populate('customer', 'name logoUrl customer.totemUrl');
|
|
298
|
-
|
|
299
296
|
query.exec(function(err, result) {
|
|
300
297
|
|
|
301
298
|
if (err) { return cb(err, null); }
|
|
@@ -311,10 +308,13 @@ module.exports = function(mongoose, config) {
|
|
|
311
308
|
|
|
312
309
|
if(hasRecipients && hasUnsentSendOnLessThanNow) {
|
|
313
310
|
|
|
311
|
+
var recipients = snapshot.notifications.company.sendTo.map(function(sendTo) {
|
|
312
|
+
return sendTo.email;
|
|
313
|
+
});
|
|
314
|
+
|
|
314
315
|
results.push({
|
|
315
|
-
'
|
|
316
|
-
'
|
|
317
|
-
'organization': financial.organization
|
|
316
|
+
'uuid': snapshot.uuid,
|
|
317
|
+
'recipients': recipients
|
|
318
318
|
});
|
|
319
319
|
|
|
320
320
|
}
|
|
@@ -353,9 +353,6 @@ module.exports = function(mongoose, config) {
|
|
|
353
353
|
}
|
|
354
354
|
});
|
|
355
355
|
|
|
356
|
-
query.populate('organization', 'name logoUrl');
|
|
357
|
-
query.populate('customer', 'name logoUrl customer.totemUrl');
|
|
358
|
-
|
|
359
356
|
query.exec(function(err, result) {
|
|
360
357
|
|
|
361
358
|
if (err) { return cb(err, null); }
|
|
@@ -375,10 +372,13 @@ module.exports = function(mongoose, config) {
|
|
|
375
372
|
|
|
376
373
|
if(hasRecipients && hasUnsentSendOnLessThanNow && ((!hasBeenSubmitted) || (hasBeenSubmitted && hasBeenRejected))) {
|
|
377
374
|
|
|
375
|
+
var recipients = snapshot.notifications.company.sendTo.map(function(sendTo) {
|
|
376
|
+
return sendTo.email;
|
|
377
|
+
});
|
|
378
|
+
|
|
378
379
|
results.push({
|
|
379
|
-
'
|
|
380
|
-
'
|
|
381
|
-
'organization': financial.organization
|
|
380
|
+
'uuid': snapshot.uuid,
|
|
381
|
+
'recipients': recipients
|
|
382
382
|
});
|
|
383
383
|
|
|
384
384
|
}
|
|
@@ -410,9 +410,6 @@ module.exports = function(mongoose, config) {
|
|
|
410
410
|
}
|
|
411
411
|
});
|
|
412
412
|
|
|
413
|
-
query.populate('organization', 'name logoUrl');
|
|
414
|
-
query.populate('customer', 'name logoUrl customer.totemUrl');
|
|
415
|
-
|
|
416
413
|
query.exec(function(err, result) {
|
|
417
414
|
|
|
418
415
|
if (err) { return cb(err, null); }
|
|
@@ -432,10 +429,13 @@ module.exports = function(mongoose, config) {
|
|
|
432
429
|
|
|
433
430
|
if(hasRecipients && hasUnsentSendOnLessThanNow && hasBeenSubmitted && hasBeenRejected) {
|
|
434
431
|
|
|
432
|
+
var recipients = snapshot.notifications.company.sendTo.map(function(sendTo) {
|
|
433
|
+
return sendTo.email;
|
|
434
|
+
});
|
|
435
|
+
|
|
435
436
|
results.push({
|
|
436
|
-
'
|
|
437
|
-
'
|
|
438
|
-
'organization': financial.organization
|
|
437
|
+
'uuid': snapshot.uuid,
|
|
438
|
+
'recipients': recipients
|
|
439
439
|
});
|
|
440
440
|
|
|
441
441
|
}
|
|
@@ -466,10 +466,6 @@ module.exports = function(mongoose, config) {
|
|
|
466
466
|
}
|
|
467
467
|
});
|
|
468
468
|
|
|
469
|
-
query.populate('organization', 'name logoUrl');
|
|
470
|
-
query.populate('customer', 'name logoUrl customer.totemUrl');
|
|
471
|
-
query.populate('snapshots.notifications.stakeholders.sendTo.organization', 'name logoUrl customer.totemUrl');
|
|
472
|
-
|
|
473
469
|
query.exec(function(err, result) {
|
|
474
470
|
|
|
475
471
|
if (err) { return cb(err, null); }
|
|
@@ -496,9 +492,8 @@ module.exports = function(mongoose, config) {
|
|
|
496
492
|
if (!hasAccount || hasAccessToken) return callback3();
|
|
497
493
|
|
|
498
494
|
results.push({
|
|
499
|
-
'
|
|
500
|
-
'
|
|
501
|
-
'organization': financial.organization
|
|
495
|
+
'uuid': snapshot.uuid,
|
|
496
|
+
'recipients': stakeholder.sendTo.email
|
|
502
497
|
});
|
|
503
498
|
|
|
504
499
|
return callback3();
|
|
@@ -537,10 +532,6 @@ module.exports = function(mongoose, config) {
|
|
|
537
532
|
}
|
|
538
533
|
});
|
|
539
534
|
|
|
540
|
-
query.populate('organization', 'name logoUrl');
|
|
541
|
-
query.populate('customer', 'name logoUrl customer.totemUrl');
|
|
542
|
-
query.populate('snapshots.notifications.stakeholders.sendTo.organization', 'name logoUrl customer.totemUrl');
|
|
543
|
-
|
|
544
535
|
query.exec(function(err, result) {
|
|
545
536
|
|
|
546
537
|
if (err) { return cb(err, null); }
|
|
@@ -567,11 +558,10 @@ module.exports = function(mongoose, config) {
|
|
|
567
558
|
var hasAccessToken = !_.isEmpty(account) && account.auth && (account.auth.google && account.auth.google.accessToken) || (account.auth.microsoft && account.auth.microsoft.accessToken);
|
|
568
559
|
|
|
569
560
|
if (!hasAccount || hasAccessToken) return callback3();
|
|
570
|
-
|
|
561
|
+
|
|
571
562
|
results.push({
|
|
572
|
-
'
|
|
573
|
-
'
|
|
574
|
-
'organization': financial.organization
|
|
563
|
+
'uuid': snapshot.uuid,
|
|
564
|
+
'recipients': stakeholder.sendTo.email
|
|
575
565
|
});
|
|
576
566
|
|
|
577
567
|
return callback3();
|
|
@@ -606,6 +596,22 @@ module.exports = function(mongoose, config) {
|
|
|
606
596
|
|
|
607
597
|
};
|
|
608
598
|
|
|
599
|
+
Financials.statics.getToSend = function getToSend(uuid, cb) {
|
|
600
|
+
|
|
601
|
+
var self = this;
|
|
602
|
+
|
|
603
|
+
var query = self.findOne({
|
|
604
|
+
'snapshots.uuid': uuid
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
query.populate('organization', 'name logoUrl');
|
|
608
|
+
query.populate('customer', 'name logoUrl customer.totemUrl');
|
|
609
|
+
query.populate('snapshots.notifications.stakeholders.sendTo.organization', 'name logoUrl customer.totemUrl');
|
|
610
|
+
|
|
611
|
+
query.exec(cb);
|
|
612
|
+
|
|
613
|
+
};
|
|
614
|
+
|
|
609
615
|
Financials.statics.removeCustomerFinancials = function removeCustomerFinancials(customerId, cb) {
|
|
610
616
|
|
|
611
617
|
// this is only used to wipe out financials created by the google sheet import process
|