@dhyasama/totem-models 9.104.0 → 9.106.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.
Files changed (2) hide show
  1. package/lib/Organization.js +106 -132
  2. package/package.json +1 -1
@@ -567,81 +567,6 @@ module.exports = function(mongoose, config) {
567
567
  // Properties that are not persisted to the database
568
568
  ///////////////////////////////////////////////////////////////////////////////////////
569
569
 
570
- Organization.virtual('acquired.amount').get(function () {
571
-
572
- const self = this;
573
- const publicData = self.operating.acquired.public || {};
574
- const privateData = self.operating.acquired.private || [];
575
-
576
- if (publicData.amount) return publicData.amount;
577
- else if (privateData.length >= 1) {
578
- if (privateData[0].amount) return privateData[0].amount;
579
- else return 0;
580
- }
581
- else return 0;
582
-
583
- });
584
-
585
- Organization.virtual('acquired.by').get(function () {
586
-
587
- const self = this;
588
- const publicData = self.operating.acquired.public || {};
589
- const privateData = self.operating.acquired.private || [];
590
-
591
- if (publicData.by) return publicData.by;
592
- else if (privateData.length >= 1) {
593
- if (privateData[0].by) return privateData[0].by;
594
- else return null;
595
- }
596
- else return null;
597
-
598
- });
599
-
600
- Organization.virtual('acquired.on').get(function () {
601
-
602
- const self = this;
603
- const publicData = self.operating.acquired.public || {};
604
- const privateData = self.operating.acquired.private || [];
605
-
606
- if (publicData.acquiredOn) return publicData.acquiredOn;
607
- else if (privateData.length >= 1) {
608
- if (privateData[0].acquiredOn) return privateData[0].acquiredOn;
609
- else return null;
610
- }
611
- else return null;
612
-
613
- });
614
-
615
- Organization.virtual('merged.with').get(function () {
616
-
617
- const self = this;
618
- const publicData = self.operating.merged.public || {};
619
- const privateData = self.operating.merged.private || [];
620
-
621
- if (publicData.with) return publicData.with;
622
- else if (privateData.length >= 1) {
623
- if (privateData[0].with) return privateData[0].with;
624
- else return null;
625
- }
626
- else return null;
627
-
628
- });
629
-
630
- Organization.virtual('merged.on').get(function () {
631
-
632
- const self = this;
633
- const publicData = self.operating.merged.public || {};
634
- const privateData = self.operating.merged.private || [];
635
-
636
- if (publicData.mergedOn) return publicData.mergedOn;
637
- else if (privateData.length >= 1) {
638
- if (privateData[0].mergedOn) return privateData[0].mergedOn;
639
- else return null;
640
- }
641
- else return null;
642
-
643
- });
644
-
645
570
  Organization.virtual('address.primary').get(function () {
646
571
  var primary = _.find(this.contact.address, function(address) {
647
572
  return address.primary;
@@ -779,19 +704,6 @@ module.exports = function(mongoose, config) {
779
704
 
780
705
  });
781
706
 
782
- Organization.virtual('inactive').get(function () {
783
-
784
- var self = this;
785
- var privateData = self.operating.closed.private || [];
786
-
787
- if (privateData.length == 1) {
788
- if (privateData[0].hasZeroUnrealizedValue) return true;
789
- else return false;
790
- }
791
- else return false;
792
-
793
- });
794
-
795
707
  Organization.virtual('leaders.all').get(function () {
796
708
 
797
709
  var self = this;
@@ -846,18 +758,108 @@ module.exports = function(mongoose, config) {
846
758
 
847
759
  });
848
760
 
849
- Organization.virtual('shutdown').get(function () {
761
+ Organization.virtual('operating.closed.on').get(function () {
850
762
 
851
- var self = this;
852
- var publicData = self.operating.closed.public || {};
853
- var privateData = self.operating.closed.private || [];
763
+ const self = this;
764
+ const publicData = self.operating.closed.public || {};
765
+ const privateData = self.operating.closed.private || [];
766
+
767
+ if (publicData.closedOn) return publicData.closedOn;
768
+ else if (privateData.length >= 1) {
769
+ if (privateData[0].closedOn) return privateData[0].closedOn;
770
+ else return null;
771
+ }
772
+ else return null;
854
773
 
855
- if (publicData.closedOn) return true;
856
- else if (privateData.length == 1) {
857
- if (privateData[0].closedOn) return true;
858
- else return false;
774
+ });
775
+
776
+ Organization.virtual('operating.closed.hasZeroUnrealizedValue').get(function () {
777
+
778
+ const self = this;
779
+ const publicData = self.operating.closed.public || {};
780
+ const privateData = self.operating.closed.private || [];
781
+
782
+ if (publicData.closedOn) return false;
783
+ else if (privateData.length >= 1) {
784
+ if (privateData[0].hasZeroUnrealizedValue) return privateData[0].hasZeroUnrealizedValue;
785
+ else return null;
786
+ }
787
+ else return null;
788
+
789
+ });
790
+
791
+ Organization.virtual('operating.acquired.amount').get(function () {
792
+
793
+ const self = this;
794
+ const publicData = self.operating.acquired.public || {};
795
+ const privateData = self.operating.acquired.private || [];
796
+
797
+ if (publicData.amount) return publicData.amount;
798
+ else if (privateData.length >= 1) {
799
+ if (privateData[0].amount) return privateData[0].amount;
800
+ else return 0;
801
+ }
802
+ else return 0;
803
+
804
+ });
805
+
806
+ Organization.virtual('operating.acquired.by').get(function () {
807
+
808
+ const self = this;
809
+ const publicData = self.operating.acquired.public || {};
810
+ const privateData = self.operating.acquired.private || [];
811
+
812
+ if (publicData.by) return publicData.by;
813
+ else if (privateData.length >= 1) {
814
+ if (privateData[0].by) return privateData[0].by;
815
+ else return null;
816
+ }
817
+ else return null;
818
+
819
+ });
820
+
821
+ Organization.virtual('operating.acquired.on').get(function () {
822
+
823
+ const self = this;
824
+ const publicData = self.operating.acquired.public || {};
825
+ const privateData = self.operating.acquired.private || [];
826
+
827
+ if (publicData.acquiredOn) return publicData.acquiredOn;
828
+ else if (privateData.length >= 1) {
829
+ if (privateData[0].acquiredOn) return privateData[0].acquiredOn;
830
+ else return null;
831
+ }
832
+ else return null;
833
+
834
+ });
835
+
836
+ Organization.virtual('operating.merged.with').get(function () {
837
+
838
+ const self = this;
839
+ const publicData = self.operating.merged.public || {};
840
+ const privateData = self.operating.merged.private || [];
841
+
842
+ if (publicData.with) return publicData.with;
843
+ else if (privateData.length >= 1) {
844
+ if (privateData[0].with) return privateData[0].with;
845
+ else return null;
859
846
  }
860
- else return false;
847
+ else return null;
848
+
849
+ });
850
+
851
+ Organization.virtual('operating.merged.on').get(function () {
852
+
853
+ const self = this;
854
+ const publicData = self.operating.merged.public || {};
855
+ const privateData = self.operating.merged.private || [];
856
+
857
+ if (publicData.mergedOn) return publicData.mergedOn;
858
+ else if (privateData.length >= 1) {
859
+ if (privateData[0].mergedOn) return privateData[0].mergedOn;
860
+ else return null;
861
+ }
862
+ else return null;
861
863
 
862
864
  });
863
865
 
@@ -865,11 +867,11 @@ module.exports = function(mongoose, config) {
865
867
 
866
868
  const self = this;
867
869
 
868
- if (self.ipo.ticker) return 'IPO';
869
- else if (self.acquired.by || self.acquired.on) return 'Acquired';
870
- else if (self.merged.with || self.merged.on) return 'Merged';
871
- else if (self.shutdown) return 'Shutdown';
872
- else if (self.inactive) return 'Inactive';
870
+ if (self.ipo && self.ipo.ticker) return 'IPO';
871
+ else if (self.operating && self.operating.acquired && (self.operating.acquired.by || self.operating.acquired.on)) return 'Acquired';
872
+ else if (self.operating && self.operating.merged && (self.operating.merged.with || self.operating.merged.on)) return 'Merged';
873
+ else if (self.operating && self.operating.closed && self.operating.closed.on && !self.operating.closed.hasZeroUnrealizedValue) return 'Shutdown';
874
+ else if (self.operating && self.operating.closed && self.operating.closed.on && self.operating.closed.hasZeroUnrealizedValue) return 'Inactive';
873
875
  else return 'Active';
874
876
 
875
877
  });
@@ -1357,6 +1359,8 @@ module.exports = function(mongoose, config) {
1357
1359
  query.populate('funds', 'name shortName hexColorCode abbreviation closeDate');
1358
1360
  query.populate('operating.acquired.public.by', 'name logoUrl');
1359
1361
  query.populate('operating.acquired.private.by', 'name logoUrl');
1362
+ query.populate('operating.merged.public.with', 'name logoUrl');
1363
+ query.populate('operating.merged.private.with', 'name logoUrl');
1360
1364
  query.populate(dealPopulateOptions);
1361
1365
 
1362
1366
  if (options.role !== 'none') {
@@ -2002,29 +2006,6 @@ module.exports = function(mongoose, config) {
2002
2006
 
2003
2007
  Organization.post('init', function(doc, next) {
2004
2008
 
2005
- // Protect private data
2006
- // Merge public and private data
2007
-
2008
- // const CUSTOMER_ID = this[CUSTOMER_ID];
2009
- // let err;
2010
- //
2011
- // if (!CUSTOMER_ID) {
2012
- // err = new Error('Missing CUSTOMER_ID');
2013
- // if (next) { return next(err); }
2014
- // else { throw err; }
2015
- // }
2016
- //
2017
- // else if (CUSTOMER_ID === 'GLOBAL_PROCESS' && next) { return next(); }
2018
- //
2019
- // else if (!mongoose.Types.ObjectId.isValid(CUSTOMER_ID)) {
2020
- // err = new Error('CUSTOMER_ID is not a valid ObjectId');
2021
- // if (next) { return next(err); }
2022
- // else { throw err; }
2023
- // }
2024
-
2025
- // remove customer details if not viewing self
2026
- //if (doc._id.toString() !== CUSTOMER_ID) { doc.customer = {}; }
2027
-
2028
2009
  // Website is stored in aliases to facilitate enforcing uniqueness
2029
2010
  // Remove it here to make it easier for consumers to provide a good ux
2030
2011
  // It will get added back in during pre save hook
@@ -2032,13 +2013,6 @@ module.exports = function(mongoose, config) {
2032
2013
  doc.websiteAliases = _.reject(doc.websiteAliases, function(alias) { return alias === doc.website; });
2033
2014
  }
2034
2015
 
2035
- // doc.lps = _.reject(doc.lps, function(item) { return !item.customer || item.customer.toString() !== CUSTOMER_ID; });
2036
- // doc.filters = _.reject(doc.filters, function(item) { return !item.customer || item.customer.toString() !== CUSTOMER_ID; });
2037
- // doc.valuations = _.reject(doc.valuations, function(item) { return !item.customer || item.customer.toString() !== CUSTOMER_ID; });
2038
- // doc.chairs = _.reject(doc.chairs, function(item) { return !item.customer || item.customer.toString() !== CUSTOMER_ID; });
2039
- // doc.operating.acquired.private = _.find(doc.operating.acquired.private, function(item) { return !item.customer || item.customer.toString() === CUSTOMER_ID; });
2040
- // doc.operating.closed.private = _.find(doc.operating.closed.private, function(item) { return !item.customer || item.customer.toString() === CUSTOMER_ID; });
2041
-
2042
2016
  // people
2043
2017
  _.each(doc.people, function(person) {
2044
2018
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "9.104.0",
3
+ "version": "9.106.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",