{
        "description": "Automatically submit invoices to TaxCore when finalized",
        "priority": 5,
        "max_retries": 3,
        "retry_delay": 300,
        "steps": [
            {
                "step": 1,
                "action": "query",
                "name": "validate_org_config",
                "query": "SELECT config_id FROM taxcore_configurations WHERE org_id = ${record.org_id} AND is_active = true",
                "required": true
            },
            {
                "step": 2,
                "action": "query",
                "name": "check_idempotency",
                "query": "SELECT submission_id FROM taxcore_submissions WHERE reference_table = 'invoices' AND reference_id = ${record.invoice_id}",
                "skip_if_exists": true
            },
            {
                "step": 3,
                "action": "transform",
                "name": "transform_invoice",
                "mapper": "invoice_to_taxcore",
                "input": "${record}"
            },
            {
                "step": 4,
                "action": "http_post",
                "name": "submit_to_taxcore",
                "url": "http://taxcore-service:3001/invoice",
                "body": "${step3.output}",
                "timeout": 30
            },
            {
                "step": 5,
                "action": "update",
                "name": "update_invoice",
                "table": "invoices",
                "where": {"invoice_id": "${record.invoice_id}"},
                "data": {
                    "taxcore_submission_id": "${step4.submission_id}",
                    "taxcore_status": "submitted"
                }
            },
            {
                "step": 6,
                "action": "notify",
                "name": "notify_success",
                "channel": "websocket",
                "event": "taxcore:submission:success",
                "data": "${step4}"
            }
        ]
    }