Compare commits

..

No commits in common. "b4648db5f6940d860af1ddb92ae4232c5018e233" and "f344721a9e7e696e5ec3a39c570ac1b8c4f2c43b" have entirely different histories.

2 changed files with 44 additions and 143 deletions

View File

@ -25,7 +25,13 @@
}, },
"IF": { "IF": {
"main": [ "main": [
[] [
{
"node": "Postgres1",
"type": "main",
"index": 0
}
]
] ]
}, },
"Split Response Into Orders": { "Split Response Into Orders": {
@ -48,7 +54,7 @@
"main": [ "main": [
[ [
{ {
"node": "Merge1", "node": "Set Platform Ids",
"type": "main", "type": "main",
"index": 0 "index": 0
} }
@ -95,49 +101,11 @@
"node": "Postgres", "node": "Postgres",
"type": "main", "type": "main",
"index": 0 "index": 0
},
{
"node": "Merge1",
"type": "main",
"index": 1
} }
] ]
] ]
}, },
"Merge1": { "Set Platform Ids": {
"main": [
[
{
"node": "Item Lists",
"type": "main",
"index": 0
}
]
]
},
"Item Lists": {
"main": [
[
{
"node": "Code1",
"type": "main",
"index": 0
}
]
]
},
"Code1": {
"main": [
[
{
"node": "Postgres2",
"type": "main",
"index": 0
}
]
]
},
"Postgres2": {
"main": [ "main": [
[ [
{ {
@ -235,9 +203,7 @@
"value": { "value": {
"product_id": "={{ $json.Product.EAN }}", "product_id": "={{ $json.Product.EAN }}",
"quantity": "={{ $json.Quantity }}", "quantity": "={{ $json.Quantity }}",
"price_each": "={{ $json.TotalPrice / $json.Quantity}}", "price_each": "={{ $json.TotalPrice / $json.Quantity}}"
"order_detail_id": 0,
"order_id": 0
}, },
"matchingColumns": [], "matchingColumns": [],
"schema": [ "schema": [
@ -295,8 +261,8 @@
"type": "n8n-nodes-base.postgres", "type": "n8n-nodes-base.postgres",
"typeVersion": 2.3, "typeVersion": 2.3,
"position": [ "position": [
2600, 2020,
-1580 -1320
], ],
"credentials": { "credentials": {
"postgres": { "postgres": {
@ -372,7 +338,7 @@
"conditions": { "conditions": {
"boolean": [ "boolean": [
{ {
"value1": "={{ $json }} {{ $json.product_ean }}", "value1": "={{ $json.Product.EAN }}",
"operation": "notEqual", "operation": "notEqual",
"value2": "={{ null }}" "value2": "={{ null }}"
} }
@ -384,8 +350,8 @@
"type": "n8n-nodes-base.if", "type": "n8n-nodes-base.if",
"typeVersion": 1, "typeVersion": 1,
"position": [ "position": [
2320, 1760,
-1280 -1300
] ]
}, },
{ {
@ -407,9 +373,8 @@
"operation": "upsert", "operation": "upsert",
"schema": { "schema": {
"__rl": true, "__rl": true,
"value": "public",
"mode": "list", "mode": "list",
"cachedResultName": "public" "value": "public"
}, },
"table": { "table": {
"__rl": true, "__rl": true,
@ -421,15 +386,22 @@
"mappingMode": "defineBelow", "mappingMode": "defineBelow",
"value": { "value": {
"order_id": "={{ $json.order_hash }}", "order_id": "={{ $json.order_hash }}",
"platform_id": "={{ $json.platform }}", "order_ref": "={{ $json.OrderNumber }}",
"customer_id": "={{ $json.Customer.Number }}",
"order_date": "={{ $json.CreatedAt.toDate().format(\"yyyyMMdd\") }}", "order_date": "={{ $json.CreatedAt.toDate().format(\"yyyyMMdd\") }}",
"order_ref": "={{ $json.OrderNumber }}" "customer_id": "={{ $json.Customer.Number }}",
"platform_id": "={{ \nswitch ($json[\"ApiAccountName\"]) {\n case 'Otto':\n $json.platform = 6;\n default:\n $json.platform = 1;\n}\n}}"
}, },
"matchingColumns": [ "matchingColumns": [],
"order_id"
],
"schema": [ "schema": [
{
"id": "order_id",
"displayName": "order_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true
},
{ {
"id": "order_ref", "id": "order_ref",
"displayName": "order_ref", "displayName": "order_ref",
@ -467,14 +439,13 @@
"canBeUsedToMatch": false "canBeUsedToMatch": false
}, },
{ {
"id": "order_id", "id": "md5_hash",
"displayName": "order_id", "displayName": "md5_hash",
"required": true, "required": false,
"defaultMatch": false, "defaultMatch": false,
"display": true, "display": true,
"type": "string", "type": "string",
"canBeUsedToMatch": true, "canBeUsedToMatch": false
"removed": false
} }
] ]
}, },
@ -498,7 +469,8 @@
{ {
"parameters": { "parameters": {
"value": "={{ $json.OrderNumber.concat($json.CreatedAt.toDate().format(\"yyyy-MM-d\")) }}", "value": "={{ $json.OrderNumber.concat($json.CreatedAt.toDate().format(\"yyyy-MM-d\")) }}",
"dataPropertyName": "=order_hash" "dataPropertyName": "=order_hash",
"encoding": "base64"
}, },
"id": "67fd82c6-055a-41d7-bc5e-ca727b0f9777", "id": "67fd82c6-055a-41d7-bc5e-ca727b0f9777",
"name": "Crypto", "name": "Crypto",
@ -537,90 +509,19 @@
-1320 -1320
] ]
}, },
{
"parameters": {
"mode": "chooseBranch",
"output": "input2"
},
"id": "5d30f116-d392-4a34-9977-c9cb1bcaae07",
"name": "Merge1",
"type": "n8n-nodes-base.merge",
"typeVersion": 2.1,
"position": [
1300,
-1100
]
},
{ {
"parameters": { "parameters": {
"fieldToSplitOut": "OrderItems", "fieldToSplitOut": "OrderItems",
"include": "selectedOtherFields",
"fieldsToInclude": "order_hash",
"options": {} "options": {}
}, },
"id": "dc3a5418-691f-42a9-b09f-bb4c9d0e2155", "id": "48b91734-2dec-494e-8a8b-d260e5a5ff40",
"name": "Item Lists", "name": "Set Platform Ids",
"type": "n8n-nodes-base.itemLists", "type": "n8n-nodes-base.itemLists",
"typeVersion": 3, "typeVersion": 3,
"position": [ "position": [
1520, 1320,
-1100 -1320
] ]
},
{
"parameters": {
"language": "python",
"pythonCode": "# Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor item in _input.all():\n if item.json.OrderItems.Product.EAN is None:\n item.json.OrderItems.Product.EAN = \"1111111111111\"\n item.json.OrderItems.Product.order_detail_sku = item.json.OrderItems.Product.SKU\nreturn _input.all()\n"
},
"id": "2b2f4265-e3af-444e-81d6-61c976ead182",
"name": "Code1",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1740,
-1100
]
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "dim_products",
"mode": "list",
"cachedResultName": "dim_products"
},
"limit": 1,
"where": {
"values": [
{
"column": "product_ean",
"value": "={{ $json.OrderItems.Product.EAN }}"
}
]
},
"options": {}
},
"id": "54832aff-c8aa-476e-89ce-762f1d037ed3",
"name": "Postgres2",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.3,
"position": [
1960,
-1100
],
"alwaysOutputData": true,
"credentials": {
"postgres": {
"id": "JW5wwsSY4obQbCBb",
"name": "Postgres - warehouse"
}
}
} }
], ],
"pinData": {}, "pinData": {},
@ -630,6 +531,6 @@
"staticData": null, "staticData": null,
"tags": [], "tags": [],
"triggerCount": 0, "triggerCount": 0,
"updatedAt": "2023-12-12T14:20:06.000Z", "updatedAt": "2023-12-12T09:52:19.000Z",
"versionId": "bb86d85c-7be5-4ba4-aa35-59959e7386c3" "versionId": "0e731bc6-faf1-4e5e-a83e-f8dabe7f704d"
} }

View File

@ -474,13 +474,13 @@
"staticData": { "staticData": {
"node:Gmail Trigger": { "node:Gmail Trigger": {
"possibleDuplicates": [ "possibleDuplicates": [
"18c5e7bbb1dc101f" "18c5d25096d07c29"
], ],
"lastTimeChecked": 1702392204 "lastTimeChecked": 1702369757
} }
}, },
"tags": [], "tags": [],
"triggerCount": 1, "triggerCount": 1,
"updatedAt": "2023-12-12T14:44:37.000Z", "updatedAt": "2023-12-12T08:29:37.000Z",
"versionId": "d5336b9a-260a-4f88-862e-edbbb760acb2" "versionId": "d5336b9a-260a-4f88-862e-edbbb760acb2"
} }