-- Add workplace invoice type
INSERT INTO invoice_types (name)
SELECT 'workplace'
WHERE NOT EXISTS (
    SELECT 1 FROM invoice_types WHERE name='workplace'
);

-- Add invoice creation step to Workplace Registration Review workflow
INSERT INTO workflow_steps (workflow_id, step_order, step_type, config)
SELECT w.id, 3, 'create_invoice', '{}'
FROM workflows w
WHERE w.name='Workplace Registration Review'
  AND NOT EXISTS (
    SELECT 1 FROM workflow_steps ws
    WHERE ws.workflow_id = w.id AND ws.step_order = 3
);

-- Optionally open Workplace Notice Preview modal
INSERT INTO workflow_steps (workflow_id, step_order, step_type, config)
SELECT w.id, 4, 'open_modal', '{"modal":"Workplace Notice Preview"}'
FROM workflows w
WHERE w.name='Workplace Registration Review'
  AND NOT EXISTS (
    SELECT 1 FROM workflow_steps ws
    WHERE ws.workflow_id = w.id AND ws.step_order = 4
);
