app/worker/invoice_finalizer.pySchedule: Every 5 minutes
What It Does
- Finds scheduled invoices — Queries
DRAFTinvoices wherescheduled_finalize_at <= now() - Finalizes — Transitions
DRAFT→OPEN - Generates payment link — Creates a checkout URL if a payment gateway is configured
- Sends email — Emails the customer with the invoice and payment link
Grace Period Logic
Email Behavior
- Email failures do not prevent finalization — the invoice is marked
OPENregardless - Email failures are logged separately
- If SMTP is not configured, finalization still succeeds (no email sent)
Log Output
Troubleshooting
Invoices stuck in DRAFT?-
Check the finalizer is running:
-
Find overdue DRAFT invoices:
-
Check
scheduled_finalize_atis set (NULL means it won’t auto-finalize):