@dhyasama/totem-models 6.15.4 → 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 +11 -9
- 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
|
@@ -1818,18 +1818,20 @@ module.exports = function(mongoose, config) {
|
|
|
1818
1818
|
this.collection.stats(cb);
|
|
1819
1819
|
};
|
|
1820
1820
|
|
|
1821
|
-
|
|
1821
|
+
LimitedPartner.statics.upsert = function(lp, username, role, cb) {
|
|
1822
1822
|
|
|
1823
|
-
if (!
|
|
1824
|
-
if (!username) { return cb(new Error('
|
|
1823
|
+
if (!lp) { return cb(new Error('lp is required'), null); }
|
|
1824
|
+
if (!username) { return cb(new Error('username is required'), null); }
|
|
1825
1825
|
|
|
1826
|
-
|
|
1827
|
-
|
|
1826
|
+
lp.entered.by = username;
|
|
1827
|
+
lp.entered.on = new Date();
|
|
1828
1828
|
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
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
|
+
});
|
|
1833
1835
|
|
|
1834
1836
|
};
|
|
1835
1837
|
|