@dhyasama/totem-models 6.15.3 → 6.16.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 +34 -0
- package/lib/Organization.js +17 -11
- package/package.json +1 -1
package/lib/LimitedPartner.js
CHANGED
|
@@ -429,6 +429,27 @@ module.exports = function(mongoose, config) {
|
|
|
429
429
|
|
|
430
430
|
};
|
|
431
431
|
|
|
432
|
+
LimitedPartner.statics.getByName = function(lpName, role, cb) {
|
|
433
|
+
|
|
434
|
+
var self = this;
|
|
435
|
+
var query;
|
|
436
|
+
|
|
437
|
+
var getLps = function() {
|
|
438
|
+
query.populate('fundsInvested.fund');
|
|
439
|
+
query.exec(cb);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
if (CUSTOMER_ID == 'GLOBAL_PROCESS') {
|
|
443
|
+
query = self.find({'name': lpName}, this.getReadFilterKeys(role))
|
|
444
|
+
getLps();
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
query = self.find({'name': lpName, 'fundsInvested.fund': { $in : self.customerFunds }}, self.getReadFilterKeys(role));
|
|
448
|
+
getLps();
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
};
|
|
452
|
+
|
|
432
453
|
LimitedPartner.statics.getFlags = function getFlags(lpid, cb) {
|
|
433
454
|
|
|
434
455
|
var self = this;
|
|
@@ -692,6 +713,19 @@ module.exports = function(mongoose, config) {
|
|
|
692
713
|
return self.customerFunds;
|
|
693
714
|
};
|
|
694
715
|
|
|
716
|
+
LimitedPartner.statics.removeCustomerCommitments = function removeCustomerCommitments(customerId, cb) {
|
|
717
|
+
|
|
718
|
+
var self = this;
|
|
719
|
+
|
|
720
|
+
var query = self.update(
|
|
721
|
+
{ 'customer': customerId },
|
|
722
|
+
{ $set: { fundsInvested: [] } },
|
|
723
|
+
{ multi : true }
|
|
724
|
+
);
|
|
725
|
+
query.exec(cb);
|
|
726
|
+
|
|
727
|
+
};
|
|
728
|
+
|
|
695
729
|
LimitedPartner.statics.upsert = function(lp, username, role, cb) {
|
|
696
730
|
|
|
697
731
|
if (!lp) { return cb(new Error('lp is required'), null); }
|
package/lib/Organization.js
CHANGED
|
@@ -1321,8 +1321,12 @@ module.exports = function(mongoose, config) {
|
|
|
1321
1321
|
// todo - logic to check public and private
|
|
1322
1322
|
var self = this;
|
|
1323
1323
|
self
|
|
1324
|
-
.find(
|
|
1325
|
-
|
|
1324
|
+
.find(
|
|
1325
|
+
{ $or: [
|
|
1326
|
+
{'operating.acquired.private.by': orgid, 'deleted': {$ne: true} },
|
|
1327
|
+
{'operating.acquired.public.by': orgid, 'deleted': {$ne: true} },
|
|
1328
|
+
]}
|
|
1329
|
+
)
|
|
1326
1330
|
.select('name logoUrl')
|
|
1327
1331
|
.exec(cb);
|
|
1328
1332
|
};
|
|
@@ -1814,18 +1818,20 @@ module.exports = function(mongoose, config) {
|
|
|
1814
1818
|
this.collection.stats(cb);
|
|
1815
1819
|
};
|
|
1816
1820
|
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
if (!org) { return cb(new Error('Organization is required'), null); }
|
|
1820
|
-
if (!username) { return cb(new Error('Username is required'), null); }
|
|
1821
|
+
LimitedPartner.statics.upsert = function(lp, username, role, cb) {
|
|
1821
1822
|
|
|
1822
|
-
|
|
1823
|
-
|
|
1823
|
+
if (!lp) { return cb(new Error('lp is required'), null); }
|
|
1824
|
+
if (!username) { return cb(new Error('username is required'), null); }
|
|
1824
1825
|
|
|
1825
|
-
|
|
1826
|
-
|
|
1826
|
+
lp.entered.by = username;
|
|
1827
|
+
lp.entered.on = new Date();
|
|
1827
1828
|
|
|
1828
|
-
|
|
1829
|
+
lp.extendWithWriteFilter(lp, role);
|
|
1830
|
+
lp.save(function(err, result) {
|
|
1831
|
+
if (err) return cb(err, null);
|
|
1832
|
+
result.applyReadFilter(role);
|
|
1833
|
+
return cb(null, result);
|
|
1834
|
+
});
|
|
1829
1835
|
|
|
1830
1836
|
};
|
|
1831
1837
|
|