{
  "name": "ezgpt-expressions-orders-demo",
  "active": false,
  "nodes": [
    {
      "id": "7d822c56-fde7-4239-b914-ed9cfa7da171",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "74ce6937-b4ab-41de-bd5d-0f414ed38013",
      "name": "Test Orders",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        0
      ],
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"orders\": [\n    {\n      \"id\": \"A1\",\n      \"client\": {\n        \"name\": \"  Анна  \",\n        \"email\": \"ANNA@EXAMPLE.INVALID \"\n      },\n      \"quantity\": 2,\n      \"unit_price\": 750,\n      \"comment\": \"\"\n    },\n    {\n      \"id\": \"A2\",\n      \"client\": {\n        \"name\": \"Борис\",\n        \"email\": \"boris@example.invalid\"\n      },\n      \"quantity\": 3,\n      \"unit_price\": 800,\n      \"comment\": \"Нужен договор\"\n    },\n    {\n      \"id\": \"A3\",\n      \"client\": null,\n      \"quantity\": 1,\n      \"unit_price\": 1200\n    }\n  ]\n}",
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "35ecfa26-c070-49ba-a92d-55b8dc3eae15",
      "name": "Split Orders",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        480,
        0
      ],
      "parameters": {
        "fieldToSplitOut": "orders",
        "include": "noOtherFields",
        "options": {}
      }
    },
    {
      "id": "1cbd532d-7eef-4325-92e3-4d211b8c0637",
      "name": "Normalized",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        720,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "29136b50-26ce-4541-9baf-a34784497482",
              "name": "order_id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "id": "c6638ef0-9779-474e-ad40-b03e5e643b42",
              "name": "customer_name",
              "type": "string",
              "value": "={{ typeof $json.client?.name === 'string' && $json.client.name.trim() ? $json.client.name.trim() : 'Без имени' }}"
            },
            {
              "id": "17df7b52-779e-4725-9bdc-bc9d57859709",
              "name": "email_normalized",
              "type": "string",
              "value": "={{ typeof $json.client?.email === 'string' ? $json.client.email.trim().toLowerCase() : '' }}"
            },
            {
              "id": "18ff2e2e-78a3-4189-8c5c-77f22975f7f5",
              "name": "comment_text",
              "type": "string",
              "value": "={{ typeof $json.comment === 'string' && $json.comment.trim() ? $json.comment.trim() : 'Комментарий не указан' }}"
            },
            {
              "id": "745252e5-b06f-400c-9e6e-5841266c3b4b",
              "name": "subtotal_ready",
              "type": "boolean",
              "value": "={{ Number.isFinite($json.quantity) && Number.isFinite($json.unit_price) && $json.quantity >= 0 && $json.unit_price >= 0 }}"
            },
            {
              "id": "ad0a97f7-fa1a-4937-a308-ff0b185c1ce4",
              "name": "subtotal",
              "type": "number",
              "value": "={{ Number.isFinite($json.quantity) && Number.isFinite($json.unit_price) && $json.quantity >= 0 && $json.unit_price >= 0 ? $json.quantity * $json.unit_price : null }}"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Test Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test Orders": {
      "main": [
        [
          {
            "node": "Split Orders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Orders": {
      "main": [
        [
          {
            "node": "Normalized",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}
