{
        "description": "Update source document when TaxCore submission succeeds",
        "priority": 7,
        "condition": "status = 'success' AND taxcore_invoice_number IS NOT NULL",
        "steps": [
            {
                "step": 1,
                "action": "update",
                "name": "update_source_document",
                "table": "${record.reference_table}",
                "where": {"${record.reference_table}_id": "${record.reference_id}"},
                "data": {
                    "taxcore_invoice_number": "${record.taxcore_invoice_number}",
                    "taxcore_url": "${record.taxcore_url}",
                    "taxcore_submitted_at": "${record.submitted_at}"
                }
            },
            {
                "step": 2,
                "action": "trigger_event",
                "name": "generate_pdf",
                "event": "document:generate_pdf",
                "data": {
                    "table": "${record.reference_table}",
                    "id": "${record.reference_id}"
                }
            },
            {
                "step": 3,
                "action": "notify",
                "name": "notify_user",
                "channel": "websocket",
                "event": "taxcore:success",
                "data": "${record}"
            }
        ]
    }