@dhyasama/totem-models 8.77.0 → 8.79.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/Financials.js CHANGED
@@ -41,7 +41,7 @@ module.exports = function(mongoose, config) {
41
41
  form: [{
42
42
  _id: false,
43
43
  name: { type: String, trim: true },
44
- type: { type: String, enum: [null, 'block', 'document', 'metric', 'question']}
44
+ type: { type: String, enum: [null, 'block', 'message', 'document', 'metric', 'question']}
45
45
  }],
46
46
 
47
47
  cash: {
@@ -193,6 +193,15 @@ module.exports = function(mongoose, config) {
193
193
  active: { type: Boolean, default: false }
194
194
  },
195
195
 
196
+ sheet: {
197
+ id: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
198
+ format: {
199
+ transformRounds: { type: Boolean, default: false },
200
+ transformUnrealized: { type: Boolean, default: false },
201
+ transformRealized: { type: Boolean, default: false }
202
+ }
203
+ },
204
+
196
205
  portfolio: {
197
206
 
198
207
  reports: [{
@@ -215,71 +224,75 @@ module.exports = function(mongoose, config) {
215
224
  width: { type: Number, default: 150 }
216
225
  }],
217
226
  view: { type: String, trim: true }
218
- }],
227
+ }]
219
228
 
220
- financials: {
221
- active: { type: Boolean, default: false },
222
- managedServices: { type: Boolean, default: false },
223
- reminders: { type: [Number], default: [7, 7, 7] },
229
+ },
224
230
 
225
- messages: [{
226
- _id: false,
227
- name: { type: String, trim: true },
228
- html: { type: String, trim: true }
229
- }],
230
- templates: [{
231
- _id: false,
232
- name: { type: String, trim: true },
233
- form: [{
234
- _id: false,
235
- name: { type: String, trim: true },
236
- type: { type: String, enum: [null, 'block', 'document', 'metric', 'question']}
237
- }]
238
- }],
239
- documents: [{
240
- _id: false,
241
- name: { type: String, trim: true },
242
- description: { type: String, trim: true },
243
- required: { type: Boolean, default: false }
244
- }],
245
- metrics: [{
246
- _id: false,
247
- name: { type: String, trim: true },
248
- description: { type: String, trim: true },
249
- format: { type: String, enum: [null, 'number', 'money', 'percentage', 'variance']},
250
- required: { type: Boolean, default: false }
251
- }],
252
- questions: [{
253
- _id: false,
254
- prompt: { type: String, trim: true },
255
- required: { type: Boolean, default: false }
256
- }]
257
- },
231
+ financials: {
258
232
 
259
- irr: {
260
- active: { type: Boolean, default: false },
261
- },
233
+ active: { type: Boolean, default: false },
234
+
235
+ managedServices: { type: Boolean, default: false },
236
+ reminders: { type: [Number], default: [7, 7, 7] },
262
237
 
263
238
  carta: {
264
- active: { type: Boolean, default: false },
265
- firmid: { type: String, unique: true, partialFilterExpression : { type :"string" }, trim: true }
239
+ active: { type: Boolean, default: false }
266
240
  },
267
241
 
268
- investmentsSheet: {
269
- sheet: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
270
- format: {
271
- transformRounds: { type: Boolean, default: false },
272
- transformUnrealized: { type: Boolean, default: false },
273
- transformRealized: { type: Boolean, default: false }
242
+ messages: [{
243
+ _id: false,
244
+ name: { type: String, trim: true },
245
+ html: { type: String, trim: true }
246
+ }],
247
+ templates: [{
248
+ _id: false,
249
+ name: { type: String, trim: true },
250
+ form: [{
251
+ _id: false,
252
+ name: { type: String, trim: true },
253
+ type: { type: String, enum: [null, 'block', 'document', 'metric', 'question']}
254
+ }]
255
+ }],
256
+ documents: [{
257
+ _id: false,
258
+ name: { type: String, trim: true },
259
+ description: { type: String, trim: true },
260
+ required: { type: Boolean, default: false }
261
+ }],
262
+ metrics: [{
263
+ _id: false,
264
+ name: { type: String, trim: true },
265
+ description: { type: String, trim: true },
266
+ format: { type: String, enum: [null, 'number', 'money', 'percentage', 'variance']},
267
+ required: { type: Boolean, default: false }
268
+ }],
269
+ questions: [{
270
+ _id: false,
271
+ prompt: { type: String, trim: true },
272
+ required: { type: Boolean, default: false }
273
+ }],
274
+
275
+ reports: [{
276
+ name: { type: String, trim: true },
277
+ filters: [{
278
+ _id: false,
279
+ key: { type: String, trim: true },
280
+ condition: { type: String, enum: [null, 'equals', 'doesNotEqual', 'contains', 'doesNotContain', 'lessThan', 'greaterThan']},
281
+ values: [{ type: String, trim: true }]
282
+ }],
283
+ sort: {
284
+ by: { type: String, trim: true },
285
+ reverse: { type: Boolean, default: false }
274
286
  },
275
- googleSheetCreds: {
276
- private_key_id: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
277
- private_key: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
278
- client_email: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
279
- client_id: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
280
- type: { type: String, trim: true }
281
- }
282
- }
287
+ fields: [{
288
+ _id: false,
289
+ key: { type: String, trim: true },
290
+ label: { type: String, trim: true },
291
+ total: { type: String, enum: [null, 'sum', 'average', 'count', 'multiple']},
292
+ width: { type: Number, default: 150 }
293
+ }],
294
+ view: { type: String, trim: true }
295
+ }]
283
296
 
284
297
  },
285
298
 
@@ -295,146 +308,97 @@ module.exports = function(mongoose, config) {
295
308
  }],
296
309
 
297
310
  sourceTypes: { type: Array, default: ['Cold Inbound', 'Cold Outbound', 'Met at Event', 'Was Referred', 'Other'] },
298
-
299
311
  referrerTypes: { type: Array, default: ['Founder', 'Investor', 'Service Provider', 'Friends & Family', 'Limited Partner', 'Other'] },
300
312
 
301
- standardFields: {
302
-
303
- // Standard fields are always "on" in the system
304
- // They can be configured in how they work on the deal list page
305
- // order for standard fields only sets the order on the list page. their position is fixed on the org page deal section and edit form.
306
- // order is co-mingled with order for custom fields
307
- // colspan is for the number of columns the field should take up on the list page
308
- // showOnFilter controls whether values are extracted and used in filtering options on list page
309
- // showOnList controls if the field will be on deal list page
310
-
311
- action: {
312
- order: { type: Number, default: 99 },
313
- colspan: { type: Number, default: 1 },
314
- showOnFilter: { type: Boolean, default: true },
315
- showOnList: { type: Boolean, default: true }
316
- },
317
-
318
- raise: {
319
- order: { type: Number, default: 99 },
320
- colspan: { type: Number, default: 1 },
321
- showOnFilter: { type: Boolean, default: true },
322
- showOnList: { type: Boolean, default: true }
313
+ reports: [{
314
+ name: { type: String, trim: true },
315
+ filters: [{
316
+ _id: false,
317
+ key: { type: String, trim: true },
318
+ condition: { type: String, enum: [null, 'equals', 'doesNotEqual', 'contains', 'doesNotContain', 'lessThan', 'greaterThan']},
319
+ values: [{ type: String, trim: true }]
320
+ }],
321
+ sort: {
322
+ by: { type: String, trim: true },
323
+ reverse: { type: Boolean, default: false }
323
324
  },
325
+ fields: [{
326
+ _id: false,
327
+ key: { type: String, trim: true },
328
+ label: { type: String, trim: true },
329
+ total: { type: String, enum: [null, 'sum', 'average', 'count', 'multiple']},
330
+ width: { type: Number, default: 150 }
331
+ }],
332
+ view: { type: String, trim: true }
333
+ }]
324
334
 
325
- valuation: {
326
- order: { type: Number, default: 99 },
327
- colspan: { type: Number, default: 1 },
328
- showOnFilter: { type: Boolean, default: true },
329
- showOnList: { type: Boolean, default: true }
330
- },
335
+ },
331
336
 
332
- sourcePerson: {
333
- order: { type: Number, default: 99 },
334
- colspan: { type: Number, default: 1 },
335
- showOnFilter: { type: Boolean, default: true },
336
- showOnList: { type: Boolean, default: true }
337
- },
337
+ funds: {
338
338
 
339
- sourceType: {
340
- order: { type: Number, default: 99 },
341
- colspan: { type: Number, default: 1 },
342
- showOnFilter: { type: Boolean, default: true },
343
- showOnList: { type: Boolean, default: true }
344
- },
339
+ irr: {
340
+ active: { type: Boolean, default: false },
341
+ },
345
342
 
346
- referrerPerson: {
347
- order: { type: Number, default: 99 },
348
- colspan: { type: Number, default: 1 },
349
- showOnFilter: { type: Boolean, default: true },
350
- showOnList: { type: Boolean, default: true }
343
+ reports: [{
344
+ name: { type: String, trim: true },
345
+ filters: [{
346
+ _id: false,
347
+ key: { type: String, trim: true },
348
+ condition: { type: String, enum: [null, 'equals', 'doesNotEqual', 'contains', 'doesNotContain', 'lessThan', 'greaterThan']},
349
+ values: [{ type: String, trim: true }]
350
+ }],
351
+ sort: {
352
+ by: { type: String, trim: true },
353
+ reverse: { type: Boolean, default: false }
351
354
  },
355
+ fields: [{
356
+ _id: false,
357
+ key: { type: String, trim: true },
358
+ label: { type: String, trim: true },
359
+ total: { type: String, enum: [null, 'sum', 'average', 'count', 'multiple']},
360
+ width: { type: Number, default: 150 }
361
+ }],
362
+ view: { type: String, trim: true }
363
+ }]
352
364
 
353
- referrerType: {
354
- order: { type: Number, default: 99 },
355
- colspan: { type: Number, default: 1 },
356
- showOnFilter: { type: Boolean, default: true },
357
- showOnList: { type: Boolean, default: true }
358
- },
365
+ },
359
366
 
360
- chairs: {
361
- order: { type: Number, default: 99 },
362
- colspan: { type: Number, default: 1 },
363
- showOnFilter: { type: Boolean, default: true },
364
- showOnList: { type: Boolean, default: true }
365
- },
367
+ lps: {
366
368
 
367
- location: {
368
- order: { type: Number, default: 99 },
369
- colspan: { type: Number, default: 1 },
370
- showOnFilter: { type: Boolean, default: true },
371
- showOnList: { type: Boolean, default: true }
372
- }
369
+ active: { type: Boolean, default: false },
373
370
 
371
+ irr: {
372
+ active: { type: Boolean, default: false },
374
373
  },
375
374
 
376
- customFields: [{
377
-
378
- // Data stored on deals will be accessed with this key
379
- // It must follow standard js variable naming rules
380
- // Whenever possible, just use the label and replace spaces with underscore
381
- // Will not be displayed
382
- // Changing it after data is in the system will make data on deal inaccessible
383
- key: { type: String, trim: true },
384
-
385
- // User friendly text, will be displayed
386
- label: { type: String, trim: true },
387
-
388
- // Dictates the type of control rendered on form
389
- // Also impacts data validation
390
- type: { type: String, enum: ['Text', 'Number', 'Money', 'Tags', 'Poll', 'Checkbox', 'Single Select', 'Multiple Select'] },
391
-
392
- // These will be the choices in polls, single-selects and multi-selects
393
- options: [{
394
-
395
- // This is the option shown to users
375
+ reports: [{
376
+ name: { type: String, trim: true },
377
+ filters: [{
378
+ _id: false,
379
+ key: { type: String, trim: true },
380
+ condition: { type: String, enum: [null, 'equals', 'doesNotEqual', 'contains', 'doesNotContain', 'lessThan', 'greaterThan']},
381
+ values: [{ type: String, trim: true }]
382
+ }],
383
+ sort: {
384
+ by: { type: String, trim: true },
385
+ reverse: { type: Boolean, default: false }
386
+ },
387
+ fields: [{
388
+ _id: false,
389
+ key: { type: String, trim: true },
396
390
  label: { type: String, trim: true },
397
-
398
- // This is the value that gets stored
399
- value: { type: String, trim: true },
400
-
401
- // This is used to aggregate answers for polls
402
- type: { type: String, enum: ['String', 'Number', 'Boolean'] }
403
-
391
+ total: { type: String, enum: [null, 'sum', 'average', 'count', 'multiple']},
392
+ width: { type: Number, default: 150 }
404
393
  }],
405
-
406
- // For controlling display on web pages
407
- display: {
408
-
409
- // sets the order to render fields on list, org page deal section and deal edit form
410
- // order is co-mingled with order for standard fields
411
- order: { type: Number },
412
-
413
- // colspan is for the number of columns the field should take up on the list page
414
- colspan: { type: Number, default: 1 },
415
-
416
- // showOnFilter controls whether values are extracted and used in filtering options on list page
417
- showOnFilter: { type: Boolean, default: true },
418
-
419
- // showOnList controls if the field will be on deal list page
420
- // fields are always shown on org pages and in edit forms
421
- showOnList: { type: Boolean, default: true }
422
-
423
- }
424
-
394
+ view: { type: String, trim: true }
425
395
  }]
426
396
 
427
397
  },
428
398
 
429
- lps: {
430
-
431
- active: {type: Boolean, default: false},
432
-
433
- },
434
-
435
399
  lists: {
436
400
 
437
- active: {type: Boolean, default: false},
401
+ active: { type: Boolean, default: false },
438
402
 
439
403
  }
440
404
 
@@ -451,22 +415,9 @@ module.exports = function(mongoose, config) {
451
415
  // Another way to put it, these are funds from which this organization makes investments
452
416
  funds: [{ type: Schema.ObjectId, ref: 'Fund' }],
453
417
 
454
- financials: [{
455
-
456
- customer: { type: Schema.ObjectId, ref: 'Organization' },
457
-
458
- // ok to send emails to collect financials
459
- allowed: { type: Boolean, default: true },
460
-
461
- // email to send link to
462
- email: { type: String, trim: true }
463
-
464
- }]
465
-
466
418
  });
467
419
 
468
420
 
469
-
470
421
  ///////////////////////////////////////////////////////////////////////////////////////
471
422
  // VIRTUALS
472
423
  // Properties that are not persisted to the database
@@ -600,169 +551,6 @@ module.exports = function(mongoose, config) {
600
551
 
601
552
  });
602
553
 
603
- Organization.virtual('customer.deals.fields').get(function () {
604
-
605
- // Combine standard fields and custom fields into a single list and sort by column order
606
- // Fundraise is actually two fields, so multiply the order by ten to make room for the extra field
607
-
608
- var self = this;
609
-
610
- var standardFields = self.customer.deals.standardFields;
611
-
612
- // Defaulting to off so it will be immediately apparent the customer hasn't been properly configured
613
- standardFields = standardFields || {
614
- fundraise: {
615
- showOnList: false
616
- },
617
- sources: {
618
- showOnList: false
619
- },
620
- referrers: {
621
- showOnList: false
622
- }
623
- };
624
-
625
- var customFields = self.customer.deals.customFields;
626
- var result = [];
627
-
628
- // Add standard fields
629
- if (standardFields.action.showOnList) {
630
- result.push({
631
- name: 'Next Steps',
632
- type: 'Text',
633
- key: 'action',
634
- isStandard: true,
635
- order: standardFields.action.order * 10,
636
- colspan: standardFields.action.colspan || 1,
637
- showOnFilter: standardFields.action.showOnFilter === true ? true : false
638
- });
639
- }
640
-
641
- if (standardFields.raise.showOnList) {
642
- result.push({
643
- name: 'Raise',
644
- type: 'Money',
645
- key: 'fundraise.amount',
646
- isStandard: true,
647
- order: standardFields.raise.order * 10,
648
- colspan: standardFields.raise.colspan || 1,
649
- showOnFilter: standardFields.raise.showOnFilter === true ? true : false
650
- });
651
- }
652
-
653
- if(standardFields.valuation.showOnList) {
654
- result.push({
655
- name: 'Valuation',
656
- type: 'Money',
657
- key: 'fundraise.valuation',
658
- isStandard: true,
659
- order: standardFields.valuation.order * 10 + 1,
660
- colspan: standardFields.valuation.colspan || 1,
661
- showOnFilter: standardFields.valuation.showOnFilter === true ? true : false
662
- });
663
- }
664
-
665
- if (standardFields.sourcePerson.showOnList) {
666
- result.push({
667
- name: 'Source',
668
- type: 'Reference',
669
- key: 'source.person',
670
- isStandard: true,
671
- order: standardFields.sourcePerson.order * 10,
672
- colspan: standardFields.sourcePerson.colspan || 1,
673
- showOnFilter: standardFields.sourcePerson.showOnFilter === true ? true : false
674
- });
675
- }
676
-
677
- if (standardFields.sourceType.showOnList) {
678
- result.push({
679
- name: 'Source Type',
680
- type: 'Single Select',
681
- key: 'source.type',
682
- isStandard: true,
683
- order: standardFields.sourceType.order * 10,
684
- colspan: standardFields.sourceType.colspan || 1,
685
- showOnFilter: standardFields.sourceType.showOnFilter === true ? true : false
686
- });
687
- }
688
-
689
- if (standardFields.referrerPerson.showOnList) {
690
- result.push({
691
- name: 'Referrer',
692
- type: 'Reference',
693
- key: 'referrer.person',
694
- isStandard: true,
695
- order: standardFields.referrerPerson.order * 10,
696
- colspan: standardFields.referrerPerson.colspan || 1,
697
- showOnFilter: standardFields.referrerPerson.showOnFilter === true ? true : false
698
- });
699
- }
700
-
701
- if (standardFields.referrerType.showOnList) {
702
- result.push({
703
- name: 'Referrer Type',
704
- type: 'Single Select',
705
- key: 'referrer.type',
706
- isStandard: true,
707
- order: standardFields.referrerType.order * 10,
708
- colspan: standardFields.referrerType.colspan || 1,
709
- showOnFilter: standardFields.referrerType.showOnFilter === true ? true : false
710
- });
711
- }
712
-
713
- if (standardFields.chairs.showOnList) {
714
- result.push({
715
- name: 'Leads',
716
- type: 'Reference',
717
- key: 'organization.chairs',
718
- isStandard: true,
719
- order: standardFields.chairs.order * 10,
720
- colspan: standardFields.chairs.colspan || 1,
721
- showOnFilter: standardFields.chairs.showOnFilter === true ? true : false
722
- });
723
- }
724
-
725
- if (standardFields.location.showOnList) {
726
- result.push({
727
- name: 'Location',
728
- type: 'Location',
729
- key: 'organization.contact.address',
730
- isStandard: true,
731
- order: standardFields.location.order * 10,
732
- colspan: standardFields.location.colspan || 1,
733
- showOnFilter: standardFields.location.showOnFilter === true ? true : false
734
- });
735
- }
736
-
737
- // Add custom fields
738
- _.each(customFields, function(field) {
739
- if (field.display.showOnList) {
740
- result.push({
741
- name: field.label,
742
- type: field.type,
743
- isStandard: false,
744
- key: field.key,
745
- options: field.options,
746
- order: field.display.order * 10,
747
- colspan: field.display.colspan || 1,
748
- showOnFilter: field.display.showOnFilter === true ? true : false
749
- });
750
- }
751
- });
752
-
753
- // Sort the combined standard and custom fields
754
- result = _.sortBy(result, function(item) { return item.order; });
755
-
756
- // Now that we have all fields combined and ordered, make column order zero-indexed and gap-free
757
- result = _.map(result, function(item, index) {
758
- item.order = index;
759
- return item;
760
- });
761
-
762
- return result;
763
-
764
- });
765
-
766
554
  Organization.virtual('employees.all').get(function () {
767
555
 
768
556
  var self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.77.0",
3
+ "version": "8.79.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",