@dhyasama/totem-models 8.5.0 → 8.5.2
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 +6 -13
- package/lib/Organization.js +4 -3
- package/lib/Person.js +1 -1
- package/package.json +1 -1
- package/test/Person.js +16 -0
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) {
|
|
@@ -587,10 +580,10 @@ module.exports = function(mongoose, config) {
|
|
|
587
580
|
query = self.find({}, self.getReadFilterKeys(options.role));
|
|
588
581
|
}
|
|
589
582
|
else {
|
|
590
|
-
query = self.find({ '
|
|
583
|
+
query = self.find({ 'transactions.fund': { $in : options.funds }}, self.getReadFilterKeys(options.role));
|
|
591
584
|
}
|
|
592
585
|
|
|
593
|
-
query.populate('
|
|
586
|
+
query.populate('transactions.fund');
|
|
594
587
|
query.sort({ 'name': -1 });
|
|
595
588
|
query.exec(cb);
|
|
596
589
|
|
|
@@ -708,14 +701,14 @@ module.exports = function(mongoose, config) {
|
|
|
708
701
|
|
|
709
702
|
LimitedPartner.plugin(filter, {
|
|
710
703
|
'readFilter': {
|
|
711
|
-
'admin': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', '
|
|
712
|
-
'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'],
|
|
713
706
|
'lp-names': ['name', 'shortName', 'flagged', 'flags', 'customer'],
|
|
714
707
|
'none': []
|
|
715
708
|
},
|
|
716
709
|
'writeFilter': {
|
|
717
|
-
'admin': ['name', 'shortName', 'customer', 'start', 'people', 'documentSlugs', '
|
|
718
|
-
'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'],
|
|
719
712
|
'lp-names': ['flagged', 'flags', 'customer'],
|
|
720
713
|
'none': []
|
|
721
714
|
},
|
package/lib/Organization.js
CHANGED
|
@@ -1618,11 +1618,12 @@ module.exports = function(mongoose, config) {
|
|
|
1618
1618
|
|
|
1619
1619
|
});
|
|
1620
1620
|
|
|
1621
|
+
// todo - fix sorting
|
|
1621
1622
|
// return categorized sources
|
|
1622
1623
|
return cb(null, {
|
|
1623
|
-
all: helpers.sortPeopleSources(all, options.CUSTOMER_ID),
|
|
1624
|
-
current: helpers.sortPeopleSources(current, options.CUSTOMER_ID),
|
|
1625
|
-
past: helpers.sortPeopleSources(past, options.CUSTOMER_ID)
|
|
1624
|
+
all: all, //helpers.sortPeopleSources(all, options.CUSTOMER_ID),
|
|
1625
|
+
current: current, //helpers.sortPeopleSources(current, options.CUSTOMER_ID),
|
|
1626
|
+
past: past //helpers.sortPeopleSources(past, options.CUSTOMER_ID)
|
|
1626
1627
|
});
|
|
1627
1628
|
|
|
1628
1629
|
});
|
package/lib/Person.js
CHANGED
|
@@ -546,7 +546,7 @@ module.exports = function(mongoose, config) {
|
|
|
546
546
|
if (!person) { return cb(err, null); }
|
|
547
547
|
|
|
548
548
|
// get the customer's org
|
|
549
|
-
Organization.
|
|
549
|
+
Organization.findById(options.CUSTOMER_ID, function(err, customer) {
|
|
550
550
|
|
|
551
551
|
if (err) { return cb(err, null); }
|
|
552
552
|
if (!customer) { return cb(null, null); }
|
package/package.json
CHANGED
package/test/Person.js
CHANGED
|
@@ -741,6 +741,22 @@ describe('Person', function() {
|
|
|
741
741
|
|
|
742
742
|
});
|
|
743
743
|
|
|
744
|
+
it('gets sources', function(done) {
|
|
745
|
+
|
|
746
|
+
Person.getSources(person.id, { CUSTOMER_ID: org._id }, function(err, result) {
|
|
747
|
+
|
|
748
|
+
should.not.exist(err);
|
|
749
|
+
should.exist(result);
|
|
750
|
+
should.exist(result.all);
|
|
751
|
+
should.exist(result.current);
|
|
752
|
+
should.exist(result.past);
|
|
753
|
+
|
|
754
|
+
done();
|
|
755
|
+
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
});
|
|
759
|
+
|
|
744
760
|
it('merges a person', function(done) {
|
|
745
761
|
|
|
746
762
|
var merged = person.addMerged(mergeId);
|