@dhyasama/totem-models 1.23.2 → 1.24.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.
@@ -342,22 +342,6 @@ module.exports = function(mongoose, config) {
342
342
 
343
343
  });
344
344
 
345
- Organization.virtual('closed').get(function () {
346
-
347
- var self = this;
348
- var publicData = self.operating.closed.public || {};
349
- var privateData = self.operating.closed.private || [];
350
-
351
- if (publicData.closedOn) return true;
352
- else if (privateData.length == 1) {
353
- if (privateData[0].closedOn) return true;
354
- if (privateData[0].hasZeroUnrealizedValue) return true;
355
- else return false;
356
- }
357
- else return false;
358
-
359
- });
360
-
361
345
  Organization.virtual('employees.all').get(function () {
362
346
 
363
347
  var self = this;
@@ -412,6 +396,19 @@ module.exports = function(mongoose, config) {
412
396
 
413
397
  });
414
398
 
399
+ Organization.virtual('inactive').get(function () {
400
+
401
+ var self = this;
402
+ var privateData = self.operating.closed.private || [];
403
+
404
+ if (privateData.length == 1) {
405
+ if (privateData[0].hasZeroUnrealizedValue) return true;
406
+ else return false;
407
+ }
408
+ else return false;
409
+
410
+ });
411
+
415
412
  Organization.virtual('leaders.all').get(function () {
416
413
 
417
414
  var self = this;
@@ -466,13 +463,29 @@ module.exports = function(mongoose, config) {
466
463
 
467
464
  });
468
465
 
466
+ Organization.virtual('shutdown').get(function () {
467
+
468
+ var self = this;
469
+ var publicData = self.operating.closed.public || {};
470
+ var privateData = self.operating.closed.private || [];
471
+
472
+ if (publicData.closedOn) return true;
473
+ else if (privateData.length == 1) {
474
+ if (privateData[0].closedOn) return true;
475
+ else return false;
476
+ }
477
+ else return false;
478
+
479
+ });
480
+
469
481
  Organization.virtual('status').get(function () {
470
482
 
471
483
  var self = this;
472
484
 
473
485
  if (self.ipo.ticker) return 'IPO';
474
486
  else if (self.acquired.by) return 'Acquired';
475
- else if (self.closed) return 'Dead';
487
+ else if (self.shutdown) return 'Shutdown';
488
+ else if (self.inactive) return 'Inactive';
476
489
  else return 'Active';
477
490
 
478
491
  });
package/lib/Person.js CHANGED
@@ -1215,13 +1215,6 @@ module.exports = function(mongoose, config) {
1215
1215
  var self = this;
1216
1216
  var CUSTOMER_ID = config.CUSTOMER_ID;
1217
1217
 
1218
- // if (self._id.toString() == '5637a9cc281347cc0bc17518') {
1219
- // console.log(self);
1220
- // console.log(JSON.stringify(_.find(self.calendarEventSummaries, function(item) {
1221
- // return item.calendarEventId == '5a81bf645359aef7ff13bfcd';
1222
- // }), null, 2));
1223
- // }
1224
-
1225
1218
  var protectCalendarEventData = function protectCalendarEventData(person) {
1226
1219
 
1227
1220
  if (CUSTOMER_ID == 'GLOBAL_PROCESS') return;
@@ -1246,6 +1239,16 @@ module.exports = function(mongoose, config) {
1246
1239
  protectCalendarEventData(self);
1247
1240
  protectSources(self);
1248
1241
 
1242
+ // // must have person and customer refs
1243
+ // self.sources = _.reject(self.sources, function(source) {
1244
+ // return !source.person || !source.customer;
1245
+ // });
1246
+ //
1247
+ // // dedupe
1248
+ // self.sources = _.uniq(self.sources, function(source) {
1249
+ // return source.person.toString() && source.customer.toString();
1250
+ // });
1251
+
1249
1252
  });
1250
1253
 
1251
1254
  var deepPopulate = require('mongoose-deep-populate')(mongoose);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.23.2",
3
+ "version": "1.24.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -1106,7 +1106,7 @@ describe('Organization', function() {
1106
1106
 
1107
1107
  });
1108
1108
 
1109
- it('gets public closed info', function(done) {
1109
+ it('gets public shutdown info', function(done) {
1110
1110
 
1111
1111
  var org = new Organization();
1112
1112
  org.name = 'The Copper Beaver';
@@ -1121,18 +1121,52 @@ describe('Organization', function() {
1121
1121
  Organization.upsert(org, 'test-user', function(err, result) {
1122
1122
  should.not.exist(err);
1123
1123
  should.exist(result);
1124
- result.status.should.equal('Dead');
1124
+ result.status.should.equal('Shutdown');
1125
1125
  return done();
1126
1126
  });
1127
1127
 
1128
1128
  });
1129
1129
 
1130
- it('gets private closed info', function(done) {
1130
+ it('gets private shutdown info', function(done) {
1131
1131
 
1132
1132
  var org = new Organization();
1133
1133
  org.name = 'Dam Hydraulics';
1134
1134
  org.slug = 'dam-hydraulics';
1135
- org.operating.closed.public.closedOn = new Date();
1135
+ org.operating.closed.public.closedOn = null;
1136
+
1137
+ org.operating.closed.private.push({
1138
+ customer: new mongoose.Types.ObjectId(),
1139
+ hasZeroUnrealizedValue: false,
1140
+ closedOn: null
1141
+ });
1142
+
1143
+ org.operating.closed.private.push({
1144
+ customer: config.CUSTOMER_ID,
1145
+ hasZeroUnrealizedValue: false,
1146
+ closedOn: new Date()
1147
+ });
1148
+
1149
+ Organization.upsert(org, 'test-user', function(err, result) {
1150
+
1151
+ should.not.exist(err);
1152
+ should.exist(result);
1153
+
1154
+ Organization.findById(result._id, function(err, org) {
1155
+ should.not.exist(err);
1156
+ should.exist(org);
1157
+ org.status.should.equal('Shutdown');
1158
+ return done();
1159
+ });
1160
+ });
1161
+
1162
+ });
1163
+
1164
+ it('gets private inactive info', function(done) {
1165
+
1166
+ var org = new Organization();
1167
+ org.name = 'Swollen Nodes';
1168
+ org.slug = 'swollen-nodes';
1169
+ org.operating.closed.public.closedOn = null;
1136
1170
 
1137
1171
  org.operating.closed.private.push({
1138
1172
  customer: new mongoose.Types.ObjectId(),
@@ -1154,7 +1188,7 @@ describe('Organization', function() {
1154
1188
  Organization.findById(result._id, function(err, org) {
1155
1189
  should.not.exist(err);
1156
1190
  should.exist(org);
1157
- org.status.should.equal('Dead');
1191
+ org.status.should.equal('Inactive');
1158
1192
  return done();
1159
1193
  });
1160
1194
  });