45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
/**
|
|
* Invoice Module Cron Configuration
|
|
* Defines scheduled tasks for the invoice module
|
|
*/
|
|
|
|
import { processInvoiceReminders } from './reminders.js';
|
|
import { processAllInvoiceInterest } from './interest.js';
|
|
import { processRecurrences } from './recurrences/processor.js';
|
|
|
|
export default {
|
|
jobs: [
|
|
{
|
|
name: 'invoice-reminders',
|
|
description: 'Send invoice reminders for pending and overdue invoices',
|
|
// Every 5 minutes between 5 AM and 11 PM
|
|
schedule: '*/5 * * * *',
|
|
handler: processInvoiceReminders,
|
|
timezone: process.env.ZEN_TIMEZONE || 'America/Toronto',
|
|
},
|
|
{
|
|
name: 'invoice-interest',
|
|
description: 'Calculate and apply interest to overdue invoices',
|
|
// Every 5 minutes (interest calculation is debounced internally)
|
|
schedule: '*/5 * * * *',
|
|
handler: async () => {
|
|
const summary = await processAllInvoiceInterest();
|
|
// Only log if something was actually processed
|
|
if (summary.updated > 0 || summary.errors > 0) {
|
|
console.log('[Invoice Interest] Processed:', summary);
|
|
}
|
|
return summary;
|
|
},
|
|
timezone: process.env.ZEN_TIMEZONE || 'America/Toronto',
|
|
},
|
|
{
|
|
name: 'invoice-recurrences',
|
|
description: 'Process recurring invoices and create new invoices',
|
|
// Every 5 minutes between 5 AM and 5 PM
|
|
schedule: '*/5 8-17 * * *',
|
|
handler: processRecurrences,
|
|
timezone: process.env.ZEN_TIMEZONE || 'America/Toronto',
|
|
},
|
|
]
|
|
};
|