[
        {
            "step": 1,
            "name": "validate_org_config",
            "action": "query",
            "description": "Check if organization has TaxCore configuration",
            "query": "SELECT config_id FROM taxcore_configurations WHERE org_id = ${record.org_id} AND is_active = true LIMIT 1",
            "on_empty": "skip",
            "on_error": "fail"
        },
        {
            "step": 2,
            "name": "check_idempotency",
            "action": "query",
            "description": "Check if receipt already submitted",
            "query": "SELECT submission_id FROM taxcore_submissions WHERE reference_table = 'sales_receipts' AND reference_id = ${record.sales_receipt_id} LIMIT 1",
            "on_found": "skip",
            "on_error": "continue"
        },
        {
            "step": 3,
            "name": "transform_receipt_data",
            "action": "transform",
            "description": "Transform sales receipt to TaxCore format",
            "mapper": "sales_receipt_to_taxcore",
            "input": "${record}",
            "output": "taxcore_payload"
        },
        {
            "step": 4,
            "name": "submit_to_taxcore",
            "action": "http_post",
            "description": "Submit receipt to TaxCore service",
            "url": "http://taxcore-service:3001/sale",
            "headers": {
                "Content-Type": "application/json"
            },
            "body": "${taxcore_payload}",
            "timeout": 30,
            "on_success": "continue",
            "on_error": "retry"
        },
        {
            "step": 5,
            "name": "update_receipt",
            "action": "update",
            "description": "Update receipt with TaxCore data",
            "table": "sales_receipts",
            "where": {
                "sales_receipt_id": "${record.sales_receipt_id}"
            },
            "data": {
                "taxcore_submitted_at": "${now}",
                "updatedAt": "${now}"
            },
            "on_error": "log"
        }
    ]