{
  "name": "Vorlux AI | Revenue Report",
  "active": false,
  "nodes": [
    { "parameters": { "rule": { "interval": [{ "field": "weeks", "weeksInterval": 1 }] } }, "id": "sched", "name": "Weekly Schedule", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [220, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/finance/stripe-sync", "method": "GET", "options": { "timeout": 30000 } }, "id": "fetch-stripe", "name": "Fetch Stripe Data", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 200] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/finance/stats", "method": "GET", "options": { "timeout": 15000 } }, "id": "fetch-stats", "name": "Fetch Finance Stats", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 400] },
    { "parameters": { "mode": "runOnceForAllItems", "jsCode": "const stripe = $('Fetch Stripe Data').first().json;\nconst stats = $('Fetch Finance Stats').first().json;\nconst report = {\n  period: 'Last 7 days',\n  totalRevenue: stats.totalRevenue || stripe.revenue || 0,\n  subscriptions: stats.activeSubscriptions || 0,\n  newSubscriptions: stats.newSubscriptions || 0,\n  churned: stats.churned || 0,\n  mrr: stats.mrr || 0,\n  generatedAt: new Date().toISOString()\n};\nreturn [{ json: report }];" }, "id": "build", "name": "Build Revenue Report", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [720, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/reports", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ type: 'revenue', title: 'Weekly Revenue Report', data: $json }) }}", "options": { "timeout": 15000 } }, "id": "save", "name": "Save Report", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 200] },
    { "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ content: '💰 **Weekly Revenue Report**\\nRevenue: $' + $json.totalRevenue + '\\nMRR: $' + $json.mrr + '\\nActive Subs: ' + $json.subscriptions + '\\nNew: ' + $json.newSubscriptions + ' | Churned: ' + $json.churned }) }}" }, "id": "notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 400] }
  ],
  "connections": {
    "Weekly Schedule": { "main": [[{ "node": "Fetch Stripe Data", "type": "main", "index": 0 }, { "node": "Fetch Finance Stats", "type": "main", "index": 0 }]] },
    "Fetch Stripe Data": { "main": [[{ "node": "Build Revenue Report", "type": "main", "index": 0 }]] },
    "Fetch Finance Stats": { "main": [[{ "node": "Build Revenue Report", "type": "main", "index": 0 }]] },
    "Build Revenue Report": { "main": [[{ "node": "Save Report", "type": "main", "index": 0 }, { "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
