@dhyasama/totem-models 8.83.0 → 8.84.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/helpers.js CHANGED
@@ -16,11 +16,11 @@ const cleanOrg = module.exports.cleanOrg = function cleanOrg(doc, customerId) {
16
16
  // remove customer details if not viewing self
17
17
  if (doc._id.toString() !== customerId.toString()) { doc.customer = {}; }
18
18
 
19
- doc.lps = _.reject(doc.lps, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
19
+ doc.chairs = _.reject(doc.chairs, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
20
+ doc.customFields = _.reject(doc.customFields, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
20
21
  doc.filters = _.reject(doc.filters, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
22
+ doc.lps = _.reject(doc.lps, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
21
23
  doc.valuations = _.reject(doc.valuations, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
22
- doc.iLevel = _.reject(doc.iLevel, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
23
- doc.chairs = _.reject(doc.chairs, function(item) { return !item.customer || item.customer.toString() !== customerId.toString(); });
24
24
  doc.operating.acquired.private = _.find(doc.operating.acquired.private, function(item) { return !item.customer || item.customer.toString() === customerId.toString(); });
25
25
  doc.operating.closed.private = _.find(doc.operating.closed.private, function(item) { return !item.customer || item.customer.toString() === customerId.toString(); });
26
26
 
package/lib/Fund.js CHANGED
@@ -21,6 +21,7 @@ module.exports = function(mongoose, config) {
21
21
  amount: { type: Number, default: 0 },
22
22
  date: { type: Date, default: null },
23
23
  }],
24
+ customFields: { type: Schema.Types.Mixed }
24
25
  });
25
26
 
26
27
  /************* BASIC FIELDS **********************/
@@ -131,6 +132,9 @@ module.exports = function(mongoose, config) {
131
132
  if (!fund) { return cb(new Error('Fund is required'), null); }
132
133
  if (!username) { return cb(new Error('Username is required'), null); }
133
134
 
135
+ // Required for mixed types
136
+ fund.markModified('customFields');
137
+
134
138
  fund.save(cb);
135
139
 
136
140
  };
@@ -99,7 +99,9 @@ module.exports = function(mongoose, config) {
99
99
  value: { type: Schema.Types.Mixed, required: true },
100
100
  format: { type: String, enum: [null, 'number', 'decimal', 'money', 'percentage', 'date']},
101
101
  _id: false
102
- }]
102
+ }],
103
+
104
+ customFields: { type: Schema.Types.Mixed }
103
105
 
104
106
  });
105
107
 
@@ -726,6 +728,7 @@ module.exports = function(mongoose, config) {
726
728
 
727
729
  // Required for mixed types
728
730
  lp.markModified('details');
731
+ lp.markModified('customFields');
729
732
 
730
733
  lp.extendWithWriteFilter(lp, options.role);
731
734
  lp.save(function(err, result) {
@@ -578,6 +578,12 @@ module.exports = function(mongoose, config) {
578
578
  // Another way to put it, these are funds from which this organization makes investments
579
579
  funds: [{ type: Schema.ObjectId, ref: 'Fund' }],
580
580
 
581
+ customFields: [{
582
+ _id: false,
583
+ customer: { type: Schema.ObjectId, ref: 'Organization' },
584
+ fields: { type: Schema.Types.Mixed }
585
+ }]
586
+
581
587
  });
582
588
 
583
589
 
@@ -1844,6 +1850,9 @@ module.exports = function(mongoose, config) {
1844
1850
  // Clean up missing references
1845
1851
  org.people = _.reject(org.people, function(item) { return !item.person; });
1846
1852
 
1853
+ // Required for mixed types
1854
+ org.markModified('customFields.fields');
1855
+
1847
1856
  org.save(cb);
1848
1857
 
1849
1858
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.83.0",
3
+ "version": "8.84.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",