@dhyasama/totem-models 8.4.0 → 8.5.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/LimitedPartner.js +30 -11
- package/lib/Person.js +1 -1
- package/package.json +1 -1
package/lib/LimitedPartner.js
CHANGED
|
@@ -97,13 +97,6 @@ module.exports = function(mongoose, config) {
|
|
|
97
97
|
|
|
98
98
|
/////////////////////
|
|
99
99
|
|
|
100
|
-
LimitedPartner.virtual('totalCommitted').get(function () {
|
|
101
|
-
const self = this;
|
|
102
|
-
return _.reduce(self.fundsInvested, function (memo, fund) {
|
|
103
|
-
return memo + (fund.committed > 0 ? fund.committed : 0);
|
|
104
|
-
}, 0);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
100
|
LimitedPartner.virtual('totalCommitment').get(function () {
|
|
108
101
|
var self = this;
|
|
109
102
|
return _.reduce(self.transactions, function(memo, transaction) {
|
|
@@ -570,6 +563,32 @@ module.exports = function(mongoose, config) {
|
|
|
570
563
|
|
|
571
564
|
};
|
|
572
565
|
|
|
566
|
+
LimitedPartner.statics.list = function (customerId, options, cb) {
|
|
567
|
+
|
|
568
|
+
const self = this;
|
|
569
|
+
|
|
570
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
571
|
+
if (!customerId) { return cb(new Error('customerId is required'), null); }
|
|
572
|
+
if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
|
|
573
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
574
|
+
|
|
575
|
+
options = helpers.getDefaultOptions(options);
|
|
576
|
+
|
|
577
|
+
let query;
|
|
578
|
+
|
|
579
|
+
if (options.isWorkerProcess) {
|
|
580
|
+
query = self.find({}, self.getReadFilterKeys(options.role));
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
query = self.find({ 'transactions.fund': { $in : options.funds }}, self.getReadFilterKeys(options.role));
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
query.populate('transactions.fund');
|
|
587
|
+
query.sort({ 'name': -1 });
|
|
588
|
+
query.exec(cb);
|
|
589
|
+
|
|
590
|
+
};
|
|
591
|
+
|
|
573
592
|
LimitedPartner.statics.listByFund = function (fundId, options, cb) {
|
|
574
593
|
|
|
575
594
|
const self = this;
|
|
@@ -682,14 +701,14 @@ module.exports = function(mongoose, config) {
|
|
|
682
701
|
|
|
683
702
|
LimitedPartner.plugin(filter, {
|
|
684
703
|
'readFilter': {
|
|
685
|
-
'admin': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', '
|
|
686
|
-
'lp-full': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', '
|
|
704
|
+
'admin': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', 'transactions', 'contact', 'entered', 'status', 'flagged', 'flags', 'notes'],
|
|
705
|
+
'lp-full': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', 'transactions', 'contact', 'entered', 'status', 'flagged', 'flags', 'notes'],
|
|
687
706
|
'lp-names': ['name', 'shortName', 'flagged', 'flags', 'customer'],
|
|
688
707
|
'none': []
|
|
689
708
|
},
|
|
690
709
|
'writeFilter': {
|
|
691
|
-
'admin': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', '
|
|
692
|
-
'lp-full': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', '
|
|
710
|
+
'admin': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', 'transactions', 'contact', 'entered', 'status', 'flagged', 'flags', 'notes'],
|
|
711
|
+
'lp-full': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', 'transactions', 'contact', 'entered', 'status', 'flagged', 'flags', 'notes'],
|
|
693
712
|
'lp-names': ['flagged', 'flags', 'customer'],
|
|
694
713
|
'none': []
|
|
695
714
|
},
|
package/lib/Person.js
CHANGED
|
@@ -314,7 +314,7 @@ module.exports = function(mongoose, config) {
|
|
|
314
314
|
|
|
315
315
|
this
|
|
316
316
|
.find({ 'contact.email.email': { $in : emails }, 'deleted': {$ne: true}})
|
|
317
|
-
.select('name avatarUrl title doNotDisplay')
|
|
317
|
+
.select('name avatarUrl title doNotDisplay contact')
|
|
318
318
|
.sort('name.full')
|
|
319
319
|
.exec(cb);
|
|
320
320
|
|