@dhyasama/totem-models 8.33.0 → 8.35.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/LimitedPartner.js +3 -3
- package/lib/Message.js +4 -3
- package/package.json +1 -1
- package/test/Message.js +1 -0
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
|
|
package/lib/Message.js
CHANGED
|
@@ -19,6 +19,7 @@ module.exports = function(mongoose, config) {
|
|
|
19
19
|
subtype: { type: String, required: true, enum: ['boards', 'updates', 'deals', 'portfolio'] },
|
|
20
20
|
customer: { type: Schema.ObjectId, ref: 'Organization', required: true },
|
|
21
21
|
organization: { type: Schema.ObjectId, ref: 'Organization' },
|
|
22
|
+
processed: { type: Boolean, default: false },
|
|
22
23
|
originalMessageDate: { type: Date, required: false, default: null },
|
|
23
24
|
subject: { type: String, required: false, default: null, trim: true },
|
|
24
25
|
body: { type: String, required: false, default: null, trim: true },
|
|
@@ -319,7 +320,7 @@ module.exports = function(mongoose, config) {
|
|
|
319
320
|
let query = self.find({
|
|
320
321
|
customer: customerId,
|
|
321
322
|
subtype: 'deals',
|
|
322
|
-
|
|
323
|
+
processed: { $ne: true }
|
|
323
324
|
});
|
|
324
325
|
query.populate({
|
|
325
326
|
path: 'documents',
|
|
@@ -336,7 +337,7 @@ module.exports = function(mongoose, config) {
|
|
|
336
337
|
let query = self.find({
|
|
337
338
|
customer: customerId,
|
|
338
339
|
subtype: 'portfolio',
|
|
339
|
-
|
|
340
|
+
processed: { $ne: true }
|
|
340
341
|
});
|
|
341
342
|
query.populate({
|
|
342
343
|
path: 'documents',
|
|
@@ -387,4 +388,4 @@ module.exports = function(mongoose, config) {
|
|
|
387
388
|
|
|
388
389
|
mongoose.model('Message', Message);
|
|
389
390
|
|
|
390
|
-
};
|
|
391
|
+
};
|
package/package.json
CHANGED