@dhyasama/totem-models 7.1.0 → 7.2.3

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
@@ -32,6 +32,8 @@ module.exports = function(mongoose, config) {
32
32
 
33
33
  uuid: { type: String },
34
34
 
35
+ campaignId: { type: String },
36
+
35
37
  status: { type: String },
36
38
 
37
39
  year: { type: Number, default: 0 },
@@ -378,10 +380,22 @@ module.exports = function(mongoose, config) {
378
380
 
379
381
  _.each(self.snapshots, function(snapshot) {
380
382
 
381
- if (!snapshot) { return; }
382
- else if (snapshot.submittedOn) { snapshot.status = "Submitted"; }
383
- else if (snapshot.notifications.company.reminder.status) { snapshot.status = snapshot.notifications.company.reminder.status; }
384
- else if (snapshot.notifications.company.initial.status) { snapshot.status = snapshot.notifications.company.initial.status; }
383
+ if(!snapshot) return;
384
+
385
+ else if(!snapshot.uuid || snapshot.submittedOn) snapshot.status = 'Completed';
386
+
387
+ else if(snapshot.notifications.company.initial.sendOn) {
388
+
389
+ var isScheduled = moment().isBefore(moment(snapshot.notifications.company.initial.sendOn));
390
+ var isOverdue = moment().subtract(30, 'd').isAfter(moment(snapshot.notifications.company.reminder.sendOn || snapshot.notifications.company.initial.sendOn));
391
+
392
+ if(isScheduled) snapshot.status = 'Scheduled';
393
+ else if(isOverdue) snapshot.status = 'Overdue';
394
+ else snapshot.status = 'In Progress';
395
+
396
+ }
397
+
398
+ else snapshot.status = 'Not Scheduled';
385
399
 
386
400
  });
387
401
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "7.1.0",
3
+ "version": "7.2.3",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -14,7 +14,7 @@ var customerB = new mongoose.Types.ObjectId();
14
14
  var orgA = new mongoose.Types.ObjectId();
15
15
  var orgB = new mongoose.Types.ObjectId();
16
16
 
17
- describe.skip('Financials', function() {
17
+ describe('Financials', function() {
18
18
 
19
19
  before(function(done) {
20
20
  if (mongoose.connection.db) return done();
@@ -87,54 +87,77 @@ describe.skip('Financials', function() {
87
87
 
88
88
  });
89
89
 
90
- it('gets financials for an org', function(done) {
90
+ // getByOrg
91
+ // getByPostmarkMessageId
92
+ // getByUUID
93
+ // getForCampaign
94
+ // getForCustomer
95
+ // getToSend
96
+ // getUUIDsToSendInitial
97
+ // getUUIDsToSendReminder
98
+ // removeCustomerFinancials
99
+ // upsert
91
100
 
92
- Financials.getByOrg(customerA, orgA, function(err, result) {
93
- should.not.exist(err);
94
- should.exist(result);
95
- result.length.should.equal(1);
96
- result[0].monthsOfRunway.should.equal(1);
97
- done();
98
- });
101
+ it('creates a snapshot', function(done) {
102
+
103
+ // todo
104
+
105
+ done();
99
106
 
100
107
  });
101
108
 
102
- it('gets financials for the same org but different customer', function(done) {
109
+ describe.skip('old so skip for now', function() {
110
+
111
+ it('gets financials for an org', function(done) {
112
+
113
+ Financials.getByOrg(customerA, orgA, function(err, result) {
114
+ should.not.exist(err);
115
+ should.exist(result);
116
+ result.length.should.equal(1);
117
+ result[0].monthsOfRunway.should.equal(1);
118
+ done();
119
+ });
103
120
 
104
- Financials.getByOrg(customerA, orgA, function(err, result) {
105
- should.not.exist(err);
106
- should.exist(result);
107
- result.length.should.equal(1);
108
- result[0].monthsOfRunway.should.equal(4);
109
- done();
110
121
  });
111
122
 
112
- });
123
+ it('gets financials for the same org but different customer', function(done) {
113
124
 
114
- it('removes financials for a customer', function(done) {
125
+ Financials.getByOrg(customerA, orgA, function(err, result) {
126
+ should.not.exist(err);
127
+ should.exist(result);
128
+ result.length.should.equal(1);
129
+ result[0].monthsOfRunway.should.equal(4);
130
+ done();
131
+ });
115
132
 
116
- config.CUSTOMER_ID = customerA;
133
+ });
117
134
 
118
- Financials.find({}, function(err, result) {
135
+ it('removes financials for a customer', function(done) {
119
136
 
120
- should.not.exist(err);
121
- should.exist(result);
122
- result.length.should.equal(4);
137
+ config.CUSTOMER_ID = customerA;
123
138
 
124
- Financials.removeCustomerFinancials(config.CUSTOMER_ID, function(err, result) {
139
+ Financials.find({}, function(err, result) {
125
140
 
126
141
  should.not.exist(err);
127
142
  should.exist(result);
143
+ result.length.should.equal(4);
128
144
 
129
- Financials.find({}, function(err, result) {
145
+ Financials.removeCustomerFinancials(config.CUSTOMER_ID, function(err, result) {
130
146
 
131
147
  should.not.exist(err);
132
148
  should.exist(result);
133
- result.length.should.equal(2);
134
- result[0].monthsOfRunway.should.equal(3);
135
- result[1].monthsOfRunway.should.equal(4);
136
149
 
137
- done();
150
+ Financials.find({}, function(err, result) {
151
+
152
+ should.not.exist(err);
153
+ should.exist(result);
154
+ result.length.should.equal(2);
155
+ result[0].monthsOfRunway.should.equal(3);
156
+ result[1].monthsOfRunway.should.equal(4);
157
+
158
+ done();
159
+
160
+ });
138
161
 
139
162
  });
140
163