feat(workflows): seed invoice-dunning ladder as an editable built-in flow
Boot self-heal seeds the corrected gate-in-loop dunning graph (wait→due, grace wait, invoice_paid check, confirm-no-payment gate, bounded reminder loop with re-check, final notice) keyed on builtin_key='invoice_dunning', sized from the reminder_first/second_days settings. Seeded DISABLED and is_builtin: live reminder behaviour is UNCHANGED (the hardcoded scheduler ladder still runs) — enabling it pre-cutover would double-send, so the engine cutover is a deliberate follow-up. Idempotent (preserves admin edits). Built-ins refuse delete (enforced in the CRUD route). Test covers seed shape + idempotency.
This commit is contained in:
@@ -897,6 +897,15 @@ async function startServer() {
|
||||
logger.warn('restore-settings self-heal failed at boot:', err.message);
|
||||
}
|
||||
|
||||
// Seed built-in workflows (the editable invoice-dunning flow). Disabled by
|
||||
// default — live reminder behaviour is unchanged. See _workflowSeedBoot.js.
|
||||
try {
|
||||
const { seedBuiltinWorkflowsAtBoot } = require('./src/services/_workflowSeedBoot');
|
||||
await seedBuiltinWorkflowsAtBoot(db, logger);
|
||||
} catch (err) {
|
||||
logger.warn('built-in workflow seed failed at boot:', err.message);
|
||||
}
|
||||
|
||||
// Install-from-backup trigger. If `RESTORE_ON_INSTALL` (or
|
||||
// `.txt`) exists in the /backup mount AND the DB is empty, run
|
||||
// the restore HERE before any admin UI surfaces. Lets admins
|
||||
|
||||
Reference in New Issue
Block a user