@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 +5 -5
- package/lib/LimitedPartner.js +3 -3
- package/package.json +1 -1
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': { $
|
|
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
|
|
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 (!
|
|
553
|
+
if (!hasEmail || !hasOrganization || !hasUnsentSendOnLessThanNow) return callback3();
|
|
554
554
|
|
|
555
555
|
Account.findByEmail(stakeholder.sendTo.email, function(err, account) {
|
|
556
556
|
|
package/lib/LimitedPartner.js
CHANGED
|
@@ -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
|
|