{
        "description": "Automatically submit POS sales receipts to TaxCore in real-time",
        "priority": 10,
        "max_retries": 3,
        "retry_delay": 60,
        "steps": [
            {
                "step": 1,
                "action": "query",
                "name": "validate_org_config",
                "query": "SELECT org_id, api_base_url, org_tin, certificate_file FROM taxcore_configurations WHERE org_id = ${record.org_id} AND is_active = true AND auto_submit_receipts = true",
                "required": true
            },
            {
                "step": 2,
                "action": "transform",
                "name": "transform_receipt",
                "source": "${record}",
                "mapping": {
                    "receiptNumber": "${record.receipt_number}",
                    "saleDate": "${record.sale_date}",
                    "customerName": "${record.customer_name || 'Anonymous'}",
                    "totalAmount": "${record.total_amount}",
                    "taxAmount": "${record.tax_amount}",
                    "lineItems": "${record.line_items}"
                }
            },
            {
                "step": 3,
                "action": "http_post",
                "name": "submit_to_taxcore",
                "url": "http://taxcore-service:3001/submit",
                "headers": {
                    "Content-Type": "application/json"
                },
                "body": "${step2.output}",
                "required": true
            },
            {
                "step": 4,
                "action": "update",
                "name": "update_receipt",
                "query": "UPDATE sales_receipts SET taxcore_receipt_number = ${step3.response.receiptNumber}, taxcore_submission_id = ${step3.response.submissionId} WHERE receipt_id = ${record.receipt_id}",
                "required": false
            },
            {
                "step": 5,
                "action": "trigger_event",
                "name": "trigger_success",
                "event": "taxcore:submission:success",
                "data": {
                    "reference_table": "sales_receipts",
                    "reference_id": "${record.receipt_id}",
                    "submission_id": "${step3.response.submissionId}"
                }
            }
        ]
    }