@dhyasama/totem-models 7.0.2 → 7.1.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 +16 -35
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -12,6 +12,11 @@ module.exports = function(mongoose, config) {
|
|
|
12
12
|
var Schema = mongoose.Schema;
|
|
13
13
|
var async = require('async');
|
|
14
14
|
var _ = require('underscore');
|
|
15
|
+
|
|
16
|
+
// scheduled
|
|
17
|
+
// not scheduled (skipped)
|
|
18
|
+
// submitted
|
|
19
|
+
|
|
15
20
|
|
|
16
21
|
var Financials = new Schema({
|
|
17
22
|
|
|
@@ -23,26 +28,12 @@ module.exports = function(mongoose, config) {
|
|
|
23
28
|
|
|
24
29
|
currency: { type: String, required: true, default: 'USD' },
|
|
25
30
|
|
|
26
|
-
notifications: {
|
|
27
|
-
|
|
28
|
-
company: {
|
|
29
|
-
|
|
30
|
-
contact: {
|
|
31
|
-
|
|
32
|
-
exclude: { type: Boolean, default: false, required: true },
|
|
33
|
-
email: { type: String, trim: true },
|
|
34
|
-
name: { type: String, trim: true }
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
|
|
42
31
|
snapshots: [{
|
|
43
32
|
|
|
44
33
|
uuid: { type: String },
|
|
45
34
|
|
|
35
|
+
status: { type: String },
|
|
36
|
+
|
|
46
37
|
year: { type: Number, default: 0 },
|
|
47
38
|
period: { type: String, enum: ['Annual', 'Q1', 'Q2', 'Q3', 'Q4', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] },
|
|
48
39
|
|
|
@@ -178,7 +169,7 @@ module.exports = function(mongoose, config) {
|
|
|
178
169
|
|
|
179
170
|
var names = _.map(this.snapshots, function(snapshot) {
|
|
180
171
|
if (snapshot.year && snapshot.period) { return snapshot.year.toString() + ' ' + snapshot.period; }
|
|
181
|
-
else if (snapshot.year) { return snapshot.year; }
|
|
172
|
+
else if (snapshot.year) { return snapshot.year.toString(); }
|
|
182
173
|
else if (snapshot.period) { return snapshot.period; }
|
|
183
174
|
else { return null; }
|
|
184
175
|
});
|
|
@@ -194,23 +185,6 @@ module.exports = function(mongoose, config) {
|
|
|
194
185
|
// Methods operate on a single document
|
|
195
186
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
196
187
|
|
|
197
|
-
Financials.methods.snapshotStatus = function(uuid) {
|
|
198
|
-
|
|
199
|
-
if (!uuid) { return null; }
|
|
200
|
-
|
|
201
|
-
var snapshot = _.find(this.snapshots, function(s) {
|
|
202
|
-
if (!s || !s.uuid) { return; }
|
|
203
|
-
return s.uuid.toLowerCase() === uuid.toLowerCase();
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
if (!snapshot) { return null; }
|
|
207
|
-
else if (snapshot.submittedOn) { return "Submitted"; }
|
|
208
|
-
else if (snapshot.notifications.company.reminder.status) { return snapshot.notifications.company.reminder.status; }
|
|
209
|
-
else if (snapshot.notifications.company.initial.status) { return snapshot.notifications.company.initial.status; }
|
|
210
|
-
else { return null; }
|
|
211
|
-
|
|
212
|
-
};
|
|
213
|
-
|
|
214
188
|
|
|
215
189
|
|
|
216
190
|
//////////////////////////////////////////////////////
|
|
@@ -402,7 +376,14 @@ module.exports = function(mongoose, config) {
|
|
|
402
376
|
|
|
403
377
|
var self = this;
|
|
404
378
|
|
|
405
|
-
|
|
379
|
+
_.each(self.snapshots, function(snapshot) {
|
|
380
|
+
|
|
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; }
|
|
385
|
+
|
|
386
|
+
});
|
|
406
387
|
|
|
407
388
|
return next();
|
|
408
389
|
|