{
  "name": "Vorlux AI | Invoice Generator",
  "active": false,
  "nodes": [
    { "parameters": { "httpMethod": "POST", "path": "generate-invoice", "options": { "responseMode": "lastNode" } }, "id": "webhook", "name": "Invoice Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2, "position": [220, 300] },
    { "parameters": { "mode": "runOnceForAllItems", "jsCode": "const data = $input.first().json.body || $input.first().json;\nreturn [{ json: { clientName: data.clientName || 'Client', items: data.items || [], total: (data.items || []).reduce((s, i) => s + (i.amount || 0), 0), currency: data.currency || 'USD', dueDate: data.dueDate || new Date(Date.now() + 30*86400000).toISOString().split('T')[0], invoiceNumber: 'INV-' + Date.now() } }];" }, "id": "format", "name": "Format Invoice", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [460, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/finance/invoices", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify($json) }}", "options": { "timeout": 15000 } }, "id": "create", "name": "Create Invoice", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [700, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/reports/pdf", "method": "POST", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ type: 'invoice', data: $('Format Invoice').first().json }) }}", "options": { "timeout": 30000 } }, "id": "gen-pdf", "name": "Generate PDF", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [940, 300] },
    { "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ content: '🧾 Invoice Generated: ' + $('Format Invoice').first().json.invoiceNumber + ' — $' + $('Format Invoice').first().json.total + ' for ' + $('Format Invoice').first().json.clientName }) }}" }, "id": "notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [1180, 300] }
  ],
  "connections": {
    "Invoice Webhook": { "main": [[{ "node": "Format Invoice", "type": "main", "index": 0 }]] },
    "Format Invoice": { "main": [[{ "node": "Create Invoice", "type": "main", "index": 0 }]] },
    "Create Invoice": { "main": [[{ "node": "Generate PDF", "type": "main", "index": 0 }]] },
    "Generate PDF": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
