-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron.js
More file actions
38 lines (35 loc) · 1.19 KB
/
cron.js
File metadata and controls
38 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const cron = require('node-cron');
const taskController = require('./controllers/tasks');
exports.hourly = () => {
cron.schedule('0 0 * * * *', () => {
taskController.runHourlyTasks();
//cancelling unpaid orders
//cancelling unpaid farmer settlements
});
};
exports.daily = () => {
cron.schedule('0 15 0 * * *', () => {
taskController.runDailyTasks();
// - this starts at 12:15 am everyday to prevent conflicts with hourly
//clear funds for orders that are older than 3 days and completed
// - activate farmers with positive balance
// - suspend farmers with negative balance
// - adjust customer loyalty levels and send gifts
// - update farmer invoices
// - update the whole company invoice
//suspend farmers with negative balance for more than 30 days
});
};
exports.monthly1st = () => {
cron.schedule('0 30 0 0 * *', () => {
taskController.runMonthly1stTasks();
// - reset customer loyalay points to zero
});
};
exports.monthly5th = () => {
cron.schedule('0 30 0 5 * *', () => {
taskController.runMonthly5thTasks();
// - close farmer invoices for the past month
// - close the whole company invoice for the past month
});
};