{
  "name": "Shopify orders to D365 Business Central sales orders / sales invoices",
  "nodes": [
    {
      "id": "92db12db-d96d-4076-a9cd-441c4bdfe212",
      "name": "GetFufillmentOrders",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        840,
        300
      ]
    },
    {
      "id": "60e0bd37-a2d1-48c5-8b47-830094d5e2ae",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        140
      ],
      "parameters": {
        "width": 730.3433300216063,
        "height": 394.8862809393426,
        "content": "## Shopify Line Locations\nFor multi-location Shopify accounts, these group of nodes get the active location id for each order line."
      }
    },
    {
      "id": "1e91817c-26bf-46f8-8185-696f07daa28c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        140
      ],
      "parameters": {
        "width": 354.40926061252037,
        "height": 398.9698970525732,
        "content": "## Get Shopify Orders\n1.- Get Shopify Orders created/updated since one day prior. The Flow will get every order created or updated on the last 24 hours.\n\n2.- Filter to get paid orders."
      }
    },
    {
      "id": "89f633a1-ac8f-4480-934b-e429717cb09f",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1557,
        140
      ],
      "parameters": {
        "width": 974.6786178827637,
        "height": 520.8878646073657,
        "content": "## Existing Customer Lookup (Business Central)\nLookup for existing customer in Business Central based on the logic defined in the URI, if a customer exist then that id is used, otherwhise a new custom"
      }
    },
    {
      "id": "c973b647-c1c6-43dc-9b80-46e34d051fc4",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        140
      ],
      "parameters": {
        "width": 509.9611651710956,
        "height": 705.3721586313337,
        "content": "## Workflow Information 📌\n\n### Purpose 🎯\nThe intention of this workflow is to integrate New Shopify Orders into MS Dynamics Business Central:\n\n- **Point-of-Sale (POS):** POS orders will be created in "
      }
    },
    {
      "id": "e7c4bf60-e040-4f41-9c8a-7729ffed88fd",
      "name": "Shopify",
      "type": "n8n-nodes-base.shopify",
      "position": [
        440,
        300
      ]
    },
    {
      "id": "274b710d-e642-4bc6-bf8d-5852a721f037",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1560,
        730.5378173588417
      ],
      "parameters": {
        "width": 978.7262207141349,
        "height": 502.3149881728773,
        "content": "## Existing Order Lookup (Business Central)\n\n1.- This logic will avoid duplication of Business Central Sales Orders/Sales Invoices validating if an order with the same external Id exist already.\n\n2.- "
      }
    },
    {
      "id": "ccf15ee2-b805-4fa7-88ab-12bf3c864415",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2600,
        700
      ],
      "parameters": {
        "width": 1330.0330040471722,
        "height": 434.94851154152406,
        "content": "## Sales Order Creation\n\n1.- Map on the \"Sales Order Mapping\" node any requiered fields to be integrated into Business Central.\n\n2- The HTTP Node will perform a POST call to Business Central REST API "
      }
    },
    {
      "id": "5a78d974-d950-4e26-87cf-a42e4633a5d8",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -68.32736133691077,
        140
      ],
      "parameters": {
        "width": 442.73662194943114,
        "height": 398.9698970525732,
        "content": "## Configure Business Central Environment Variables\n1.- Enter your BC tenantId,companyId, name.\n2.- Set the SKU number for the Items to be used for Taxes and Discounts."
      }
    },
    {
      "id": "95f15005-6c9b-46ae-9cb3-a89887189aed",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -20,
        340
      ]
    },
    {
      "id": "0c2ee7ac-3b27-4e6f-9e65-f1bba3ee494b",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1620,
        260
      ]
    },
    {
      "id": "58a528fe-f9f3-4522-bc4d-0fc91fbbf656",
      "name": "New Customer?",
      "type": "n8n-nodes-base.if",
      "position": [
        2020,
        260
      ]
    },
    {
      "id": "e5222a97-002c-4433-aa7a-dbc6426b2a25",
      "name": "Lookup Customers",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1840,
        260
      ]
    },
    {
      "id": "8d5ba820-04a7-413e-bb9e-8385dee5e78b",
      "name": "SelectFields",
      "type": "n8n-nodes-base.set",
      "position": [
        1080,
        300
      ]
    },
    {
      "id": "d5120009-2efe-4ef1-9450-eedd475f95c7",
      "name": "orderPreprocessing",
      "type": "n8n-nodes-base.code",
      "position": [
        1340,
        300
      ]
    },
    {
      "id": "28f0b15a-e1a6-4055-90ed-f3051f043792",
      "name": "Create Customer",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2240,
        320
      ]
    },
    {
      "id": "990fec80-30e3-44f8-a95d-f9afb2e495c5",
      "name": "Set Business Central Customer Id",
      "type": "n8n-nodes-base.set",
      "position": [
        1780,
        500
      ]
    },
    {
      "id": "313ac019-aedb-4d64-833d-c3582153e2c0",
      "name": "Create Order Lines",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3440,
        900
      ]
    },
    {
      "id": "e0d63859-a480-4f69-bb30-77c9615777b6",
      "name": "End",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3720,
        840
      ]
    },
    {
      "id": "8c756b31-0b7f-4f9a-a7a3-5fccdcfcf8b8",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        3260,
        900
      ]
    },
    {
      "id": "e2ddcd9a-7502-49ae-9d5c-50f6c3084570",
      "name": "DELETE Sales Order",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3720,
        980
      ]
    },
    {
      "id": "b5303dc5-bf56-4b1c-a231-15a322f26ac8",
      "name": "D365 BC Environment Settings",
      "type": "n8n-nodes-base.set",
      "position": [
        180,
        340
      ]
    },
    {
      "id": "e7925d36-5b30-4822-8eb1-a5a076a77669",
      "name": "Create Sales Order",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2880,
        920
      ]
    },
    {
      "id": "fce6d383-c372-4f65-83b5-d681dfa16323",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2600,
        140
      ],
      "parameters": {
        "width": 1330.0330040471722,
        "height": 434.94851154152406,
        "content": "## Sales Order Creation\n\n1. Map on the \"Sales Invoice Mapping\" node any requiered fields to be integrated into Business Central.\n\n2. The HTTP Node will perform a POST call to Business Central REST API"
      }
    },
    {
      "id": "29d43335-713f-4bfc-a416-be41f7cc1311",
      "name": "Set Lines Invoice",
      "type": "n8n-nodes-base.set",
      "position": [
        3100,
        360
      ]
    },
    {
      "id": "7d05a3d7-5bac-4099-8561-61b520c75e91",
      "name": "Set Lines SO",
      "type": "n8n-nodes-base.set",
      "position": [
        3100,
        900
      ]
    },
    {
      "id": "e39a775a-4c89-47f0-8da9-e5cb33d03228",
      "name": "Split Out Invoice",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        3260,
        360
      ]
    },
    {
      "id": "ff21ea27-091c-4ba7-bedb-1e26561ff042",
      "name": "Create Invoice Lines",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3440,
        360
      ]
    },
    {
      "id": "becfe8a8-9655-4386-b891-977271b26c7e",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        620,
        300
      ]
    },
    {
      "id": "48edfcb3-5864-4794-8876-40bb7bec31f6",
      "name": "Create Sales Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2900,
        380
      ]
    },
    {
      "id": "a2879c0f-55d2-442a-be5e-cb249af88561",
      "name": "End1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        3720,
        300
      ]
    },
    {
      "id": "4c979801-ab23-41a7-bc14-179d128c2bf7",
      "name": "Sales Invoice",
      "type": "n8n-nodes-base.set",
      "position": [
        2700,
        380
      ]
    },
    {
      "id": "022de50a-0030-434d-95b8-edef8eacb481",
      "name": "Lookup Sales Order",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2120,
        1080
      ]
    },
    {
      "id": "8e646fe3-5a28-4bf4-8cc1-d31a13294218",
      "name": "Sales Order Mapping",
      "type": "n8n-nodes-base.set",
      "position": [
        2660,
        920
      ]
    },
    {
      "id": "3839e2f2-54a2-4bbb-b0af-e10d5da0da82",
      "name": "New SO?",
      "type": "n8n-nodes-base.if",
      "position": [
        2300,
        1080
      ]
    },
    {
      "id": "54292ca1-8d99-4ef8-8f46-a17633bd8a9d",
      "name": "Lookup Sales Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2120,
        920
      ]
    },
    {
      "id": "6c531d1b-a605-4212-88c9-292b818ca5d4",
      "name": "New Invoice?",
      "type": "n8n-nodes-base.if",
      "position": [
        2300,
        920
      ]
    },
    {
      "id": "6d7517eb-b32d-471d-93e3-4bbee0b7f06a",
      "name": "POS?",
      "type": "n8n-nodes-base.if",
      "position": [
        1920,
        1000
      ]
    },
    {
      "id": "b17c61c4-ce32-4b0f-88ac-aad47e5d785d",
      "name": "DELETE Sales Invoice",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3720,
        440
      ]
    }
  ],
  "connections": {
    "POS?": {
      "main": [
        [
          {
            "node": "Lookup Sales Invoice",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Lookup Sales Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "GetFufillmentOrders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New SO?": {
      "main": [
        [
          {
            "node": "Sales Order Mapping",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Shopify": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Create Order Lines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Invoice?": {
      "main": [
        [
          {
            "node": "Sales Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SelectFields": {
      "main": [
        [
          {
            "node": "orderPreprocessing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Lines SO": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Customer?": {
      "main": [
        [
          {
            "node": "Create Customer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sales Invoice": {
      "main": [
        [
          {
            "node": "Create Sales Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Customer": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Set Business Central Customer Id",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Lookup Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Customers": {
      "main": [
        [
          {
            "node": "New Customer?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "D365 BC Environment Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Lines Invoice": {
      "main": [
        [
          {
            "node": "Split Out Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out Invoice": {
      "main": [
        [
          {
            "node": "Create Invoice Lines",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Order Lines": {
      "main": [
        [
          {
            "node": "End",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "DELETE Sales Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Sales Order": {
      "main": [
        [
          {
            "node": "Set Lines SO",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Sales Order": {
      "main": [
        [
          {
            "node": "New SO?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "orderPreprocessing": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetFufillmentOrders": {
      "main": [
        [
          {
            "node": "SelectFields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sales Order Mapping": {
      "main": [
        [
          {
            "node": "Create Sales Order",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Invoice Lines": {
      "main": [
        [
          {
            "node": "End1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "DELETE Sales Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Sales Invoice": {
      "main": [
        [
          {
            "node": "Set Lines Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Sales Invoice": {
      "main": [
        [
          {
            "node": "New Invoice?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "D365 BC Environment Settings": {
      "main": [
        [
          {
            "node": "Shopify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Business Central Customer Id": {
      "main": [
        [
          {
            "node": "POS?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}