@dhyasama/totem-models 1.17.1 → 1.17.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/Round.js +104 -80
- package/package.json +1 -1
package/lib/Round.js
CHANGED
|
@@ -400,43 +400,49 @@ module.exports = function(mongoose, config) {
|
|
|
400
400
|
|
|
401
401
|
var self = this;
|
|
402
402
|
|
|
403
|
-
self
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
403
|
+
var query = self.find({
|
|
404
|
+
'deleted': { $ne: true },
|
|
405
|
+
'organization': orgId
|
|
406
|
+
});
|
|
407
|
+
query.populate('organization', 'name logoUrl');
|
|
408
|
+
query.populate('people.person', 'name avatarUrl title');
|
|
409
|
+
query.populate('vehicles.fund', 'name shortName');
|
|
410
|
+
|
|
411
|
+
if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
|
|
412
|
+
query.populate('vehicles.investments');
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
query.populate({
|
|
412
416
|
path: 'vehicles.investments',
|
|
413
417
|
match: { customer: config.CUSTOMER_ID }
|
|
414
|
-
})
|
|
415
|
-
|
|
418
|
+
});
|
|
419
|
+
}
|
|
416
420
|
|
|
417
|
-
|
|
418
|
-
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
421
|
+
query.exec(function(err, rounds) {
|
|
419
422
|
|
|
420
|
-
|
|
421
|
-
|
|
423
|
+
if (err) return cb(err, null);
|
|
424
|
+
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
422
425
|
|
|
423
|
-
|
|
424
|
-
|
|
426
|
+
var error = checkForUnpopulatedData(rounds, 'Round.getByOrg');
|
|
427
|
+
if (error) return cb(error, null);
|
|
425
428
|
|
|
426
|
-
|
|
429
|
+
// reverse chronological
|
|
430
|
+
rounds = _.sortBy(rounds, function(r) {
|
|
427
431
|
|
|
428
|
-
|
|
429
|
-
if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
|
|
430
|
-
date = r.vehicles[0].investments[0].investmentDate;
|
|
431
|
-
}
|
|
432
|
+
var date = r.closingDate;
|
|
432
433
|
|
|
433
|
-
|
|
434
|
+
// use investment date in absence of closing date
|
|
435
|
+
if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
|
|
436
|
+
date = r.vehicles[0].investments[0].investmentDate;
|
|
437
|
+
}
|
|
434
438
|
|
|
435
|
-
|
|
439
|
+
return date;
|
|
436
440
|
|
|
437
|
-
|
|
441
|
+
}).reverse();
|
|
438
442
|
|
|
439
|
-
|
|
443
|
+
return cb(null, rounds);
|
|
444
|
+
|
|
445
|
+
});
|
|
440
446
|
|
|
441
447
|
};
|
|
442
448
|
|
|
@@ -444,43 +450,49 @@ module.exports = function(mongoose, config) {
|
|
|
444
450
|
|
|
445
451
|
var self = this;
|
|
446
452
|
|
|
447
|
-
self
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
var query = self.find({
|
|
454
|
+
'deleted': { $ne: true },
|
|
455
|
+
'organization': { $in: orgIds }
|
|
456
|
+
});
|
|
457
|
+
query.populate('organization', 'name logoUrl');
|
|
458
|
+
query.populate('people.person', 'name avatarUrl');
|
|
459
|
+
query.populate('vehicles.fund');
|
|
460
|
+
|
|
461
|
+
if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
|
|
462
|
+
query.populate('vehicles.investments');
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
query.populate({
|
|
456
466
|
path: 'vehicles.investments',
|
|
457
467
|
match: { customer: config.CUSTOMER_ID }
|
|
458
|
-
})
|
|
459
|
-
|
|
468
|
+
});
|
|
469
|
+
}
|
|
460
470
|
|
|
461
|
-
|
|
462
|
-
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
471
|
+
query.exec(function(err, rounds) {
|
|
463
472
|
|
|
464
|
-
|
|
465
|
-
|
|
473
|
+
if (err) return cb(err, null);
|
|
474
|
+
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
466
475
|
|
|
467
|
-
|
|
468
|
-
|
|
476
|
+
var error = checkForUnpopulatedData(rounds, 'Round.getByOrgs');
|
|
477
|
+
if (error) return cb(error, null);
|
|
469
478
|
|
|
470
|
-
|
|
479
|
+
// reverse chronological
|
|
480
|
+
rounds = _.sortBy(rounds, function(r) {
|
|
471
481
|
|
|
472
|
-
|
|
473
|
-
if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
|
|
474
|
-
date = r.vehicles[0].investments[0].investmentDate;
|
|
475
|
-
}
|
|
482
|
+
var date = r.closingDate;
|
|
476
483
|
|
|
477
|
-
|
|
484
|
+
// use investment date in absence of closing date
|
|
485
|
+
if (!date && r.vehicles.length && r.vehicles[0].investments.length) {
|
|
486
|
+
date = r.vehicles[0].investments[0].investmentDate;
|
|
487
|
+
}
|
|
478
488
|
|
|
479
|
-
|
|
489
|
+
return date;
|
|
480
490
|
|
|
481
|
-
|
|
491
|
+
}).reverse();
|
|
482
492
|
|
|
483
|
-
|
|
493
|
+
return cb(null, rounds);
|
|
494
|
+
|
|
495
|
+
});
|
|
484
496
|
|
|
485
497
|
};
|
|
486
498
|
|
|
@@ -530,26 +542,32 @@ module.exports = function(mongoose, config) {
|
|
|
530
542
|
|
|
531
543
|
var self = this;
|
|
532
544
|
|
|
533
|
-
self
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
545
|
+
var query = self.find({ 'vehicles.fund': fundId });
|
|
546
|
+
query.select('organization vehicles preMoneyValuation');
|
|
547
|
+
query.populate('organization', 'name logoUrl description contact industries status ipo closed acquired operating');
|
|
548
|
+
query.populate('vehicles.fund');
|
|
549
|
+
|
|
550
|
+
if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
|
|
551
|
+
query.populate('vehicles.investments');
|
|
552
|
+
}
|
|
553
|
+
else {
|
|
554
|
+
query.populate({
|
|
539
555
|
path: 'vehicles.investments',
|
|
540
556
|
match: { customer: config.CUSTOMER_ID }
|
|
541
|
-
})
|
|
542
|
-
|
|
557
|
+
});
|
|
558
|
+
}
|
|
543
559
|
|
|
544
|
-
|
|
545
|
-
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
560
|
+
query.exec(function(err, rounds) {
|
|
546
561
|
|
|
547
|
-
|
|
548
|
-
|
|
562
|
+
if (err) return cb(err, null);
|
|
563
|
+
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
549
564
|
|
|
550
|
-
|
|
565
|
+
var error = checkForUnpopulatedData(rounds, 'Round.getPortfolioByFund');
|
|
566
|
+
if (error) return cb(error, null);
|
|
551
567
|
|
|
552
|
-
|
|
568
|
+
return cb(null, buildPortfolio(rounds, [fundId]));
|
|
569
|
+
|
|
570
|
+
});
|
|
553
571
|
|
|
554
572
|
};
|
|
555
573
|
|
|
@@ -560,26 +578,32 @@ module.exports = function(mongoose, config) {
|
|
|
560
578
|
|
|
561
579
|
var self = this;
|
|
562
580
|
|
|
563
|
-
self
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
581
|
+
var query = self.find({ 'vehicles.fund': { $in: fundIds } });
|
|
582
|
+
query.select('organization vehicles preMoneyValuation');
|
|
583
|
+
query.populate('organization', 'name logoUrl description contact industries status ipo closed acquired operating');
|
|
584
|
+
query.populate('vehicles.fund');
|
|
585
|
+
|
|
586
|
+
if (config.CUSTOMER_ID == 'GLOBAL_PROCESS') {
|
|
587
|
+
query.populate('vehicles.investments');
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
query.populate({
|
|
569
591
|
path: 'vehicles.investments',
|
|
570
592
|
match: { customer: config.CUSTOMER_ID }
|
|
571
|
-
})
|
|
572
|
-
|
|
593
|
+
});
|
|
594
|
+
}
|
|
573
595
|
|
|
574
|
-
|
|
575
|
-
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
596
|
+
query.exec(function(err, rounds) {
|
|
576
597
|
|
|
577
|
-
|
|
578
|
-
|
|
598
|
+
if (err) return cb(err, null);
|
|
599
|
+
if (!rounds || rounds.length == 0) return cb(null, []);
|
|
579
600
|
|
|
580
|
-
|
|
601
|
+
var error = checkForUnpopulatedData(rounds, 'Round.getPortfolioByFunds');
|
|
602
|
+
if (error) return cb(error, null);
|
|
581
603
|
|
|
582
|
-
|
|
604
|
+
return cb(null, buildPortfolio(rounds, fundIds));
|
|
605
|
+
|
|
606
|
+
});
|
|
583
607
|
|
|
584
608
|
};
|
|
585
609
|
|