@dhyasama/totem-models 9.25.1 → 9.25.2
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 +38 -1
- package/package.json +1 -1
package/lib/Financials.js
CHANGED
|
@@ -73,7 +73,7 @@ module.exports = function(mongoose, config) {
|
|
|
73
73
|
|
|
74
74
|
review: { type: Boolean, default: false },
|
|
75
75
|
|
|
76
|
-
status: { type: String, enum: ['Delivered', 'Opened', 'Overdue', 'In Review', 'Completed', 'Archived'] },
|
|
76
|
+
status: { type: String, enum: ['Upcoming', 'Delivered', 'Opened', 'Overdue', 'In Review', 'Completed', 'Archived'] },
|
|
77
77
|
|
|
78
78
|
year: { type: Number, default: 0 },
|
|
79
79
|
period: { type: String, enum: ['Annual', 'Q1', 'Q2', 'Q3', 'Q4', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] },
|
|
@@ -379,6 +379,43 @@ module.exports = function(mongoose, config) {
|
|
|
379
379
|
|
|
380
380
|
};
|
|
381
381
|
|
|
382
|
+
Financials.statics.getRecurringToSend = function getRecurringToSend(options, cb) {
|
|
383
|
+
|
|
384
|
+
const self = this;
|
|
385
|
+
const now = new Date();
|
|
386
|
+
|
|
387
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
388
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
389
|
+
if (!options.startTime) { return cb(new Error('options.startTime is required'), null); }
|
|
390
|
+
if (!options.endTime) { return cb(new Error('options.endTime is required'), null); }
|
|
391
|
+
|
|
392
|
+
let query = self.find({
|
|
393
|
+
'recurring.send.sendOn': { $lte: now },
|
|
394
|
+
'recurring.adminReminders.sent': false
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
// send: {
|
|
398
|
+
// daysAfter: { type: Number },
|
|
399
|
+
// period: { type: String, enum: [null, 'month', 'quarter', 'year']},
|
|
400
|
+
// time: {
|
|
401
|
+
// hour: { type: Number },
|
|
402
|
+
// minute: { type: Number, default: 0 },
|
|
403
|
+
// second: { type: Number, default: 0 }
|
|
404
|
+
// }
|
|
405
|
+
// },
|
|
406
|
+
|
|
407
|
+
query.exec(function(err, result) {
|
|
408
|
+
|
|
409
|
+
if (err) { return cb(err, null); }
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
return cb(null, result);
|
|
414
|
+
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
};
|
|
418
|
+
|
|
382
419
|
Financials.statics.getCompanyInitialToSend = function getCompanyInitialToSend(cb) {
|
|
383
420
|
|
|
384
421
|
var self = this;
|