@dhyasama/totem-models 7.9.0 → 7.10.1
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/CalendarEvent.js +10 -0
- package/lib/Financials.js +20 -4
- package/package.json +1 -1
- package/test/CalendarEvent.js +17 -0
package/lib/CalendarEvent.js
CHANGED
|
@@ -54,6 +54,16 @@ module.exports = function(mongoose, config) {
|
|
|
54
54
|
return JSON.parse(this.raw);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
CalendarEvent.statics.delete = function(calendarEventId, cb) {
|
|
58
|
+
|
|
59
|
+
var self = this;
|
|
60
|
+
|
|
61
|
+
self
|
|
62
|
+
.findByIdAndRemove(calendarEventId)
|
|
63
|
+
.exec(cb);
|
|
64
|
+
|
|
65
|
+
};
|
|
66
|
+
|
|
57
67
|
CalendarEvent.statics.findByAccountId = function (accountId, cb) {
|
|
58
68
|
this
|
|
59
69
|
.find({ account: accountId })
|
package/lib/Financials.js
CHANGED
|
@@ -274,8 +274,10 @@ module.exports = function(mongoose, config) {
|
|
|
274
274
|
var now = new Date();
|
|
275
275
|
|
|
276
276
|
var query = self.find({
|
|
277
|
+
"snapshots.notifications.company.initial.sendTo": { $ne: null },
|
|
277
278
|
"snapshots.notifications.company.initial.sendOn": { $lte: now },
|
|
278
|
-
"snapshots.notifications.company.initial.sentOn": null
|
|
279
|
+
"snapshots.notifications.company.initial.sentOn": null,
|
|
280
|
+
"snapshots.submittedOn": null
|
|
279
281
|
});
|
|
280
282
|
|
|
281
283
|
query.exec(function(err, result) {
|
|
@@ -287,7 +289,13 @@ module.exports = function(mongoose, config) {
|
|
|
287
289
|
snapshots = _.flatten(snapshots);
|
|
288
290
|
|
|
289
291
|
snapshots = _.filter(snapshots, function(snapshot) {
|
|
290
|
-
|
|
292
|
+
|
|
293
|
+
var bool = !!snapshot.notifications.company.initial.sendTo;
|
|
294
|
+
bool = bool && snapshot.notifications.company.initial.sendOn < now;
|
|
295
|
+
bool = bool && !snapshot.notifications.company.initial.sentOn;
|
|
296
|
+
|
|
297
|
+
return bool;
|
|
298
|
+
|
|
291
299
|
});
|
|
292
300
|
|
|
293
301
|
return cb(null, _.pluck(snapshots, 'uuid'));
|
|
@@ -302,8 +310,10 @@ module.exports = function(mongoose, config) {
|
|
|
302
310
|
var now = new Date();
|
|
303
311
|
|
|
304
312
|
var query = self.find({
|
|
313
|
+
"snapshots.notifications.company.reminder.sendTo": { $ne: null },
|
|
305
314
|
"snapshots.notifications.company.reminder.sendOn": { $lte: now },
|
|
306
|
-
"snapshots.notifications.company.reminder.sentOn": null
|
|
315
|
+
"snapshots.notifications.company.reminder.sentOn": null,
|
|
316
|
+
"snapshots.submittedOn": null
|
|
307
317
|
});
|
|
308
318
|
|
|
309
319
|
query.exec(function(err, result) {
|
|
@@ -315,7 +325,13 @@ module.exports = function(mongoose, config) {
|
|
|
315
325
|
snapshots = _.flatten(snapshots);
|
|
316
326
|
|
|
317
327
|
snapshots = _.filter(snapshots, function(snapshot) {
|
|
318
|
-
|
|
328
|
+
|
|
329
|
+
var bool = !!snapshot.notifications.company.reminder.sendTo;
|
|
330
|
+
bool = bool && snapshot.notifications.company.reminder.sendOn < now;
|
|
331
|
+
bool = bool && !snapshot.notifications.company.reminder.sentOn;
|
|
332
|
+
|
|
333
|
+
return bool;
|
|
334
|
+
|
|
319
335
|
});
|
|
320
336
|
|
|
321
337
|
return cb(null, _.pluck(snapshots, 'uuid'));
|
package/package.json
CHANGED
package/test/CalendarEvent.js
CHANGED
|
@@ -8,6 +8,7 @@ var
|
|
|
8
8
|
clearDB = require('mocha-mongoose')(config.db.uri, {noClear: true}),
|
|
9
9
|
CalendarEvent = mongoose.model('CalendarEvent');
|
|
10
10
|
|
|
11
|
+
var calendarEventId;
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
describe('CalendarEvent', function() {
|
|
@@ -50,6 +51,22 @@ describe('CalendarEvent', function() {
|
|
|
50
51
|
should.not.exist(err);
|
|
51
52
|
should.exist(result);
|
|
52
53
|
|
|
54
|
+
calendarEventId = result._id;
|
|
55
|
+
|
|
56
|
+
return done();
|
|
57
|
+
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('deletes a calendar event', function(done) {
|
|
63
|
+
|
|
64
|
+
CalendarEvent.delete(calendarEventId, function(err, result) {
|
|
65
|
+
|
|
66
|
+
should.not.exist(err);
|
|
67
|
+
should.exist(result);
|
|
68
|
+
should.equal(result._id.toString(), calendarEventId.toString());
|
|
69
|
+
|
|
53
70
|
return done();
|
|
54
71
|
|
|
55
72
|
});
|