{
  "name": "Flowprep · Summarize orders",
  "active": false,
  "nodes": [
    {
      "id": "summarize-orders-start",
      "name": "Start manually",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ],
      "parameters": {}
    },
    {
      "id": "summarize-orders-sample",
      "name": "Sample data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        300
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    \"amount\": 29.5,\n    \"currency\": \"USD\"\n  },\n  {\n    \"amount\": 10.5,\n    \"currency\": \"USD\"\n  },\n  {\n    \"amount\": 16,\n    \"currency\": \"EUR\"\n  }\n].map(json => ({ json }));"
      }
    },
    {
      "id": "summarize-orders-transform",
      "name": "Summarize orders",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        300
      ],
      "parameters": {
        "jsCode": "const groups = new Map();\nfor (const { json } of $input.all()) {\n  const amount = Number(json.amount);\n  if (!Number.isFinite(amount) || typeof json.currency !== 'string' || !json.currency.trim()) throw new Error('Each order needs a finite amount and currency.');\n  const currency = json.currency.trim().toUpperCase();\n  const group = groups.get(currency) || { currency, orders: 0, total: 0 };\n  group.orders++; group.total += amount; groups.set(currency, group);\n}\nreturn [...groups.values()].map(json => ({ json: { ...json, total: Number(json.total.toFixed(2)) } }));"
      }
    },
    {
      "id": "summarize-orders-note",
      "name": "Read first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -30
      ],
      "parameters": {
        "content": "## Summarize orders\nGroup order totals by currency without mixing different currencies.\n\n1. Import into n8n.\n2. Execute manually and inspect the output.\n3. Replace Sample data with your source after reviewing the Code node.\n\nNo currency conversion, tax calculation or accounting reconciliation is performed. Two-decimal rounding is a demo assumption.\n\nIndependent example from Flowprep. No credentials or external calls. Sample transformation tested; verify import and execution on your n8n version.",
        "width": 760,
        "height": 230
      }
    }
  ],
  "connections": {
    "Start manually": {
      "main": [
        [
          {
            "node": "Sample data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample data": {
      "main": [
        [
          {
            "node": "Summarize orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "tags": []
}