@dhyasama/totem-models 6.26.2 → 6.29.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
@@ -12,9 +12,9 @@ module.exports = function(mongoose, config) {
12
12
  var Schema = mongoose.Schema;
13
13
  var async = require('async');
14
14
  var _ = require('underscore');
15
-
15
+
16
16
  var Financials = new Schema({
17
-
17
+
18
18
  organization: { type: Schema.ObjectId, ref: 'Organization', required: true, index: true },
19
19
 
20
20
  customer: { type: Schema.ObjectId, ref: 'Organization', required: true, index: true },
@@ -24,7 +24,9 @@ module.exports = function(mongoose, config) {
24
24
  currency: { type: String, required: true, default: 'USD' },
25
25
 
26
26
  snapshots: [{
27
-
27
+
28
+ uuid: { type: String },
29
+
28
30
  year: { type: Number, default: 0 },
29
31
  quarter: { type: String, enum: ['all', 'q1', 'q2', 'q3', 'q4'] },
30
32
 
@@ -49,7 +51,7 @@ module.exports = function(mongoose, config) {
49
51
  projected: { type: Number, default: 0 },
50
52
  breakdown: [{
51
53
  key: { type: String, trim: true },
52
- value: { type: String, trim: true },
54
+ value: { type: Number },
53
55
  _id: false
54
56
  }]
55
57
  },
@@ -58,7 +60,7 @@ module.exports = function(mongoose, config) {
58
60
  projected: { type: Number, default: 0 },
59
61
  breakdown: [{
60
62
  key: { type: String, trim: true },
61
- value: { type: String, trim: true },
63
+ value: { type: Number },
62
64
  _id: false
63
65
  }]
64
66
  },
@@ -67,7 +69,7 @@ module.exports = function(mongoose, config) {
67
69
  projected: { type: Number, default: 0 },
68
70
  breakdown: [{
69
71
  key: { type: String, trim: true },
70
- value: { type: String, trim: true },
72
+ value: { type: Number },
71
73
  _id: false
72
74
  }]
73
75
  },
@@ -76,7 +78,7 @@ module.exports = function(mongoose, config) {
76
78
  projected: { type: Number, default: 0 },
77
79
  breakdown: [{
78
80
  key: { type: String, trim: true },
79
- value: { type: String, trim: true },
81
+ value: { type: Number },
80
82
  _id: false
81
83
  }]
82
84
  },
@@ -84,12 +86,18 @@ module.exports = function(mongoose, config) {
84
86
  // Catch-all for customer specific key-value pairs from sheet that aren't supported by our schema
85
87
  details: [{
86
88
  key: { type: String, trim: true },
87
- value: { type: String, trim: true },
89
+ value: { type: Number },
88
90
  _id: false
89
- }]
90
-
91
- }],
91
+ }],
92
+
93
+ comment: { type: String, trim: true },
94
+ documents: [ { type: Schema.ObjectId, ref: 'Document' } ],
92
95
 
96
+ submittedOn: { type: Date, index: false },
97
+ submittedBy: { type: String, trim: true }
98
+
99
+ }],
100
+
93
101
  });
94
102
 
95
103
  ///////////////////////////////////////////////////////////////////////////////////////
@@ -117,6 +125,20 @@ module.exports = function(mongoose, config) {
117
125
 
118
126
  };
119
127
 
128
+ Financials.statics.getByUUID = function getByUUID(uuid, cb) {
129
+
130
+ var self = this;
131
+
132
+ var query = self.find({
133
+ 'snapshots.uuid': uuid,
134
+ 'customer': config.CUSTOMER_ID
135
+ });
136
+
137
+ query.populate('organization', 'name logoUrl')
138
+ query.exec(cb);
139
+
140
+ };
141
+
120
142
  Financials.statics.removeCustomerFinancials = function removeCustomerFinancials(customerId, cb) {
121
143
 
122
144
  var self = this;
@@ -129,11 +151,12 @@ module.exports = function(mongoose, config) {
129
151
 
130
152
  Financials.statics.upsert = function upsert(financials, cb) {
131
153
  if (!financials) { return cb(new Error('financials is required'), null); }
132
- financials.save(cb);
154
+ financials.save(function(err, result) {
155
+ return cb(null, result);
156
+ });
133
157
  };
134
158
 
135
159
 
136
-
137
160
  ///////////////////////////////////////////////////////////////////////////////////////
138
161
  // HOOKS
139
162
  // Pre-save: fired on every document before it is saved
@@ -175,5 +198,3 @@ module.exports = function(mongoose, config) {
175
198
  mongoose.model('Financials', Financials);
176
199
 
177
200
  };
178
-
179
-
@@ -135,6 +135,13 @@ module.exports = function(mongoose, config) {
135
135
  customer: { type: Schema.ObjectId, ref: 'Organization' }
136
136
  }],
137
137
 
138
+ valuations: [{
139
+ amount: { type: Number, default: 0 },
140
+ description: { type: String, trim: true },
141
+ date: { type: Date, default: null },
142
+ customer: { type: Schema.ObjectId, ref: 'Organization' },
143
+ }],
144
+
138
145
  clearbit: {
139
146
  uuid: { type: String, unique: true, partialFilterExpression : { type : "string" }, trim: true },
140
147
  lastEnrichmentRequestedOn: { type: Date, default: null }
@@ -2121,6 +2128,7 @@ module.exports = function(mongoose, config) {
2121
2128
 
2122
2129
  doc.lps = _.reject(doc.lps, function(item) { return !item.customer || item.customer.toString() != CUSTOMER_ID; });
2123
2130
  doc.filters = _.reject(doc.filters, function(item) { return !item.customer || item.customer.toString() != CUSTOMER_ID; });
2131
+ doc.valuations = _.reject(doc.valuations, function(item) { return !item.customer || item.customer.toString() != CUSTOMER_ID; });
2124
2132
  doc.iLevel = _.reject(doc.iLevel, function(item) { return !item.customer || item.customer.toString() != CUSTOMER_ID; });
2125
2133
  doc.chairs = _.reject(doc.chairs, function(item) { return !item.customer || item.customer.toString() != CUSTOMER_ID; });
2126
2134
  doc.operating.acquired.private = _.find(doc.operating.acquired.private, function(item) { return !item.customer || item.customer.toString() == CUSTOMER_ID; });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "6.26.2",
3
+ "version": "6.29.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",