feat(workflows): per-quote booking-workflow picker + quote→invoice (no gallery) built-in

A quote can now choose which flow runs on acceptance instead of every enabled
quote.accepted flow firing. Migration 147 adds quotes.booking_workflow_id; the
editor shows a "Booking workflow (on acceptance)" dropdown listing the
quote.accepted flows (workflow-engine flag only); emitQuoteEvent passes it as
the new emitWorkflowEvent targetWorkflowId so ONLY the picked flow runs (still
gated on enabled + trigger match → a disabled/None selection runs nothing).

Adds the booking_invoice_only built-in (quote.accepted → prepare invoice →
review gate → send; no event/gallery, no wait), the variant requested for
shoots billed without an online gallery. Disabled stub like the other booking
flows until the prepare_*/send_document cutover.

Tests: targetWorkflowId runs only the selected flow; invoice-only built-in has
no wait/prepare_event.
This commit is contained in:
Luca
2026-06-23 23:15:31 +02:00
parent eec262b0a7
commit d14f1d850c
10 changed files with 170 additions and 2 deletions
@@ -0,0 +1,25 @@
/**
* Migration 147: let a quote pick the booking workflow it runs on acceptance.
*
* Today quote.accepted fans out to every enabled flow with that trigger. This
* column lets the admin choose ONE workflow per quote (e.g. "with contract" vs
* "invoice only, no gallery"); emitQuoteEvent passes it as targetWorkflowId so
* only the chosen flow runs. Plain nullable integer (not a hard FK) — the emit
* re-checks the workflow exists + is enabled + matches the trigger at fire time,
* so a deleted/disabled selection just runs nothing.
*/
exports.up = async function (knex) {
if (!(await knex.schema.hasTable('quotes'))) return;
if (!(await knex.schema.hasColumn('quotes', 'booking_workflow_id'))) {
await knex.schema.alterTable('quotes', (t) => {
t.integer('booking_workflow_id');
});
}
};
exports.down = async function (knex) {
if (!(await knex.schema.hasTable('quotes'))) return;
if (await knex.schema.hasColumn('quotes', 'booking_workflow_id')) {
await knex.schema.alterTable('quotes', (t) => t.dropColumn('booking_workflow_id'));
}
};