@dhyasama/totem-models 6.30.3 → 6.32.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
@@ -83,8 +83,13 @@ module.exports = function(mongoose, config) {
83
83
  }]
84
84
  },
85
85
 
86
- // Catch-all for customer specific key-value pairs from sheet that aren't supported by our schema
87
- details: [{
86
+ metrics: [{
87
+ key: { type: String, trim: true },
88
+ value: { type: Number },
89
+ _id: false
90
+ }],
91
+
92
+ questions: [{
88
93
  key: { type: String, trim: true },
89
94
  value: { type: String, trim: true },
90
95
  _id: false
@@ -112,26 +117,26 @@ module.exports = function(mongoose, config) {
112
117
  // Statics operate on the entire collection
113
118
  //////////////////////////////////////////////////////
114
119
 
115
- Financials.statics.getByOrg = function getByOrg(orgId, cb) {
120
+ Financials.statics.getByOrg = function getByOrg(customerId, orgId, cb) {
116
121
 
117
122
  var self = this;
118
123
 
119
124
  var query = self.find({
120
- 'organization': orgId,
121
- 'customer': config.CUSTOMER_ID
125
+ 'customer': customerId,
126
+ 'organization': orgId
122
127
  });
123
128
 
124
129
  query.exec(cb);
125
130
 
126
131
  };
127
132
 
128
- Financials.statics.getByUUID = function getByUUID(uuid, cb) {
133
+ Financials.statics.getByUUID = function getByUUID(customerId, uuid, cb) {
129
134
 
130
135
  var self = this;
131
136
 
132
137
  var query = self.find({
133
- 'snapshots.uuid': uuid,
134
- 'customer': config.CUSTOMER_ID
138
+ 'customer': customerId,
139
+ 'snapshots.uuid': uuid
135
140
  });
136
141
 
137
142
  query.populate('organization', 'name logoUrl')
@@ -210,6 +210,11 @@ module.exports = function(mongoose, config) {
210
210
  active: { type: Boolean, default: false }
211
211
  },
212
212
 
213
+ financials : {
214
+ questions: [{ type: String, trim: true }],
215
+ metrics: [{ type: String, trim: true }],
216
+ },
217
+
213
218
  deals: {
214
219
 
215
220
  active: { type: Boolean, default: false },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "6.30.3",
3
+ "version": "6.32.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -89,9 +89,7 @@ describe.skip('Financials', function() {
89
89
 
90
90
  it('gets financials for an org', function(done) {
91
91
 
92
- config.CUSTOMER_ID = customerA;
93
-
94
- Financials.getByOrg(orgA, function(err, result) {
92
+ Financials.getByOrg(customerA, orgA, function(err, result) {
95
93
  should.not.exist(err);
96
94
  should.exist(result);
97
95
  result.length.should.equal(1);
@@ -103,9 +101,7 @@ describe.skip('Financials', function() {
103
101
 
104
102
  it('gets financials for the same org but different customer', function(done) {
105
103
 
106
- config.CUSTOMER_ID = customerB;
107
-
108
- Financials.getByOrg(orgA, function(err, result) {
104
+ Financials.getByOrg(customerA, orgA, function(err, result) {
109
105
  should.not.exist(err);
110
106
  should.exist(result);
111
107
  result.length.should.equal(1);