@dhyasama/totem-models 8.32.1 → 8.34.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 CHANGED
@@ -524,8 +524,8 @@ module.exports = function(mongoose, config) {
524
524
  var query = self.find({
525
525
  'snapshots': {
526
526
  $elemMatch: {
527
- 'notifications.stakeholders.sendTo': { $gt: [] },
528
- 'notifications.stakeholders.organization': { $ne: null },
527
+ 'notifications.stakeholders.sendTo.email': { $ne: null },
528
+ 'notifications.stakeholders.sendTo.organization': { $ne: null },
529
529
  'notifications.stakeholders.reminders.sendOn': { $lte: now },
530
530
  'notifications.stakeholders.reminders.sentOn': null
531
531
  }
@@ -544,13 +544,13 @@ module.exports = function(mongoose, config) {
544
544
 
545
545
  async.each(snapshot.notifications.stakeholders, function(stakeholder, callback3) {
546
546
 
547
- var hasRecipients = stakeholder.sendTo && stakeholder.sendTo.length > 0;
548
- var hasOrganization = stakeholder.organization;
547
+ var hasEmail = stakeholder.sendTo && stakeholder.sendTo.email;
548
+ var hasOrganization = stakeholder.sendTo && stakeholder.sendTo.organization;
549
549
  var hasUnsentSendOnLessThanNow = _.find(stakeholder.reminders, function(reminder) {
550
550
  return reminder.sendOn < now && !reminder.sentOn;
551
551
  });
552
552
 
553
- if (!hasRecipients || !hasOrganization || !hasUnsentSendOnLessThanNow) return callback3();
553
+ if (!hasEmail || !hasOrganization || !hasUnsentSendOnLessThanNow) return callback3();
554
554
 
555
555
  Account.findByEmail(stakeholder.sendTo.email, function(err, account) {
556
556
 
@@ -100,21 +100,21 @@ module.exports = function(mongoose, config) {
100
100
  LimitedPartner.virtual('totalCommitment').get(function () {
101
101
  var self = this;
102
102
  return _.reduce(self.transactions, function(memo, transaction) {
103
- return memo + ((transaction.type === 'commitment' && transaction.amount > 0) ? transaction.amount : 0);
103
+ return memo + ((transaction.type === 'commitment' && Math.abs(transaction.amount) > 0) ? transaction.amount : 0);
104
104
  }, 0);
105
105
  });
106
106
 
107
107
  LimitedPartner.virtual('totalContribution').get(function () {
108
108
  var self = this;
109
109
  return _.reduce(self.transactions, function(memo, transaction) {
110
- return memo + ((transaction.type === 'contribution' && transaction.amount > 0) ? transaction.amount : 0);
110
+ return memo + ((transaction.type === 'contribution' && Math.abs(transaction.amount) > 0) ? transaction.amount : 0);
111
111
  }, 0);
112
112
  });
113
113
 
114
114
  LimitedPartner.virtual('totalDistribution').get(function () {
115
115
  var self = this;
116
116
  return _.reduce(self.transactions, function(memo, transaction) {
117
- return memo + ((transaction.type === 'distribution' && transaction.amount > 0) ? transaction.amount : 0);
117
+ return memo + ((transaction.type === 'distribution' && Math.abs(transaction.amount) > 0) ? transaction.amount : 0);
118
118
  }, 0);
119
119
  });
120
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.32.1",
3
+ "version": "8.34.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",