2023-12-11 23:00:22 +00:00
{
"active" : false ,
"connections" : {
"HTTP Request1" : {
"main" : [
[
{
"node" : "Split Response Into Orders" ,
"type" : "main" ,
"index" : 0
}
]
]
} ,
"Schedule Trigger" : {
"main" : [
[
{
"node" : "HTTP Request1" ,
"type" : "main" ,
"index" : 0
}
]
]
} ,
"IF" : {
"main" : [
2023-12-12 23:00:21 +00:00
[ ]
2023-12-11 23:00:22 +00:00
]
} ,
2023-12-12 11:00:21 +00:00
"Split Response Into Orders" : {
2023-12-11 23:00:22 +00:00
"main" : [
[
{
2023-12-12 11:00:21 +00:00
"node" : "Upsert Customer" ,
2023-12-11 23:00:22 +00:00
"type" : "main" ,
"index" : 0
2023-12-12 11:00:21 +00:00
} ,
{
"node" : "Merge" ,
"type" : "main" ,
"index" : 1
2023-12-11 23:00:22 +00:00
}
]
]
} ,
2023-12-12 11:00:21 +00:00
"Postgres" : {
2023-12-11 23:00:22 +00:00
"main" : [
[
{
2023-12-12 23:00:21 +00:00
"node" : "Merge1" ,
2023-12-11 23:00:22 +00:00
"type" : "main" ,
"index" : 0
2023-12-12 11:00:21 +00:00
}
]
]
} ,
"Crypto" : {
"main" : [
[
2023-12-11 23:00:22 +00:00
{
"node" : "Code" ,
"type" : "main" ,
"index" : 0
}
]
]
} ,
2023-12-12 11:00:21 +00:00
"Upsert Customer" : {
2023-12-11 23:00:22 +00:00
"main" : [
[
{
2023-12-12 11:00:21 +00:00
"node" : "Merge" ,
2023-12-11 23:00:22 +00:00
"type" : "main" ,
"index" : 0
}
]
]
} ,
2023-12-12 11:00:21 +00:00
"Merge" : {
2023-12-11 23:00:22 +00:00
"main" : [
[
{
"node" : "Crypto" ,
"type" : "main" ,
"index" : 0
}
]
]
} ,
2023-12-12 11:00:21 +00:00
"Code" : {
2023-12-11 23:00:22 +00:00
"main" : [
[
{
"node" : "Postgres" ,
"type" : "main" ,
"index" : 0
2023-12-12 23:00:21 +00:00
} ,
{
"node" : "Merge1" ,
"type" : "main" ,
"index" : 1
}
]
]
} ,
"Merge1" : {
"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
2023-12-11 23:00:22 +00:00
}
]
]
2023-12-12 11:00:21 +00:00
} ,
2023-12-12 23:00:21 +00:00
"Postgres2" : {
2023-12-12 11:00:21 +00:00
"main" : [
[
{
"node" : "IF" ,
"type" : "main" ,
"index" : 0
}
]
]
2023-12-11 23:00:22 +00:00
}
} ,
"createdAt" : "2023-12-11T17:25:14.909Z" ,
"id" : "55eZFqIMkqfMEtaC" ,
"meta" : null ,
"name" : "Billbee Aufträge -> Data Warehouse" ,
"nodes" : [
{
"parameters" : {
"url" : "https://app.billbee.io/api/v1/orders" ,
"authentication" : "genericCredentialType" ,
"genericAuthType" : "httpBasicAuth" ,
"sendQuery" : true ,
"queryParameters" : {
"parameters" : [
{
"name" : "minOrderDate" ,
"value" : "={{ $today.minus(1 $day) }}"
} ,
{
"name" : "pageSize" ,
"value" : "250"
}
]
} ,
"sendHeaders" : true ,
"headerParameters" : {
"parameters" : [
{
"name" : "X-Billbee-Api-Key" ,
"value" : "2855BE2C-1D67-4AB0-9DEB-3073E6D27B1C"
}
]
} ,
"options" : { }
} ,
"id" : "34781fe0-a66e-43a6-a616-45a1ad27f2e8" ,
"name" : "HTTP Request1" ,
"type" : "n8n-nodes-base.httpRequest" ,
"typeVersion" : 4.1 ,
"position" : [
-260 ,
-1340
] ,
"credentials" : {
"httpBasicAuth" : {
"id" : "xANPcw3p1Nh0wF9J" ,
"name" : "Billbee Basic"
}
}
} ,
{
"parameters" : {
"rule" : {
"interval" : [
{
"triggerAtMinute" : 5
}
]
}
} ,
"id" : "28e8e58e-aea3-4c88-b174-7f4a51c425bd" ,
"name" : "Schedule Trigger" ,
"type" : "n8n-nodes-base.scheduleTrigger" ,
"typeVersion" : 1.1 ,
"position" : [
-520 ,
-1340
]
} ,
{
"parameters" : {
"schema" : {
"__rl" : true ,
"mode" : "list" ,
"value" : "public"
} ,
"table" : {
"__rl" : true ,
"value" : "fact_order_details" ,
"mode" : "list" ,
"cachedResultName" : "fact_order_details"
} ,
"columns" : {
"mappingMode" : "defineBelow" ,
"value" : {
"product_id" : "={{ $json.Product.EAN }}" ,
"quantity" : "={{ $json.Quantity }}" ,
2023-12-12 23:00:21 +00:00
"price_each" : "={{ $json.TotalPrice / $json.Quantity}}" ,
"order_detail_id" : 0 ,
"order_id" : 0
2023-12-11 23:00:22 +00:00
} ,
"matchingColumns" : [ ] ,
"schema" : [
{
"id" : "order_detail_id" ,
"displayName" : "order_detail_id" ,
"required" : false ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : true
} ,
{
"id" : "order_id" ,
"displayName" : "order_id" ,
"required" : true ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : true
} ,
{
"id" : "product_id" ,
"displayName" : "product_id" ,
"required" : false ,
"defaultMatch" : false ,
"display" : true ,
"type" : "string" ,
"canBeUsedToMatch" : true
} ,
{
"id" : "quantity" ,
"displayName" : "quantity" ,
"required" : true ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : true
} ,
{
"id" : "price_each" ,
"displayName" : "price_each" ,
"required" : true ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : true
}
]
} ,
"options" : { }
} ,
"id" : "dab64316-4942-4207-b75a-dcd78704ab05" ,
"name" : "Postgres1" ,
"type" : "n8n-nodes-base.postgres" ,
"typeVersion" : 2.3 ,
"position" : [
2023-12-12 23:00:21 +00:00
2600 ,
-1580
2023-12-11 23:00:22 +00:00
] ,
"credentials" : {
"postgres" : {
"id" : "JW5wwsSY4obQbCBb" ,
"name" : "Postgres - warehouse"
}
}
} ,
{
"parameters" : {
"operation" : "upsert" ,
"schema" : {
"__rl" : true ,
"mode" : "list" ,
"value" : "public"
} ,
"table" : {
"__rl" : true ,
"value" : "dim_customers" ,
"mode" : "list" ,
"cachedResultName" : "dim_customers"
} ,
"columns" : {
"mappingMode" : "defineBelow" ,
"value" : {
"customer_id" : "={{ $json.Customer.Number }}" ,
"customer_country" : "={{ $json.ShippingAddress.CountryISO2 }}"
} ,
"matchingColumns" : [
"customer_id"
] ,
"schema" : [
{
"id" : "customer_id" ,
"displayName" : "customer_id" ,
"required" : false ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : true ,
"removed" : false
} ,
{
"id" : "customer_country" ,
"displayName" : "customer_country" ,
"required" : false ,
"defaultMatch" : false ,
"display" : true ,
"type" : "string" ,
"canBeUsedToMatch" : false
}
]
} ,
"options" : { }
} ,
"id" : "6bd22bb9-e978-436e-bfa0-5f7579dec8d0" ,
"name" : "Upsert Customer" ,
"type" : "n8n-nodes-base.postgres" ,
"typeVersion" : 2.3 ,
"position" : [
2023-12-12 11:00:21 +00:00
300 ,
-1480
2023-12-11 23:00:22 +00:00
] ,
"credentials" : {
"postgres" : {
"id" : "JW5wwsSY4obQbCBb" ,
"name" : "Postgres - warehouse"
}
}
} ,
{
"parameters" : {
"conditions" : {
"boolean" : [
{
2023-12-12 23:00:21 +00:00
"value1" : "={{ $json }} {{ $json.product_ean }}" ,
2023-12-11 23:00:22 +00:00
"operation" : "notEqual" ,
"value2" : "={{ null }}"
}
]
}
} ,
"id" : "7991fd99-8f2d-4911-bc42-98b1c78269b3" ,
"name" : "IF" ,
"type" : "n8n-nodes-base.if" ,
"typeVersion" : 1 ,
"position" : [
2023-12-12 23:00:21 +00:00
2320 ,
-1280
2023-12-11 23:00:22 +00:00
]
} ,
{
"parameters" : {
"fieldToSplitOut" : "Data" ,
"options" : { }
} ,
"id" : "f951938c-ca90-4f33-9dce-099084407196" ,
"name" : "Split Response Into Orders" ,
"type" : "n8n-nodes-base.itemLists" ,
"typeVersion" : 3 ,
"position" : [
40 ,
-1480
]
} ,
{
"parameters" : {
"operation" : "upsert" ,
"schema" : {
"__rl" : true ,
2023-12-12 23:00:21 +00:00
"value" : "public" ,
2023-12-11 23:00:22 +00:00
"mode" : "list" ,
2023-12-12 23:00:21 +00:00
"cachedResultName" : "public"
2023-12-11 23:00:22 +00:00
} ,
"table" : {
"__rl" : true ,
"value" : "dim_orders" ,
"mode" : "list" ,
"cachedResultName" : "dim_orders"
} ,
"columns" : {
"mappingMode" : "defineBelow" ,
"value" : {
2023-12-12 11:00:21 +00:00
"order_id" : "={{ $json.order_hash }}" ,
2023-12-12 23:00:21 +00:00
"platform_id" : "={{ $json.platform }}" ,
2023-12-12 11:00:21 +00:00
"customer_id" : "={{ $json.Customer.Number }}" ,
2023-12-12 23:00:21 +00:00
"order_date" : "={{ $json.CreatedAt.toDate().format(\"yyyyMMdd\") }}" ,
"order_ref" : "={{ $json.OrderNumber }}"
2023-12-11 23:00:22 +00:00
} ,
2023-12-12 23:00:21 +00:00
"matchingColumns" : [
"order_id"
] ,
2023-12-11 23:00:22 +00:00
"schema" : [
{
"id" : "order_ref" ,
"displayName" : "order_ref" ,
"required" : false ,
"defaultMatch" : false ,
"display" : true ,
"type" : "string" ,
"canBeUsedToMatch" : false
} ,
{
"id" : "order_date" ,
"displayName" : "order_date" ,
"required" : true ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : false
} ,
{
"id" : "customer_id" ,
"displayName" : "customer_id" ,
"required" : true ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : false
} ,
{
"id" : "platform_id" ,
"displayName" : "platform_id" ,
"required" : false ,
"defaultMatch" : false ,
"display" : true ,
"type" : "number" ,
"canBeUsedToMatch" : false
2023-12-12 11:00:21 +00:00
} ,
{
2023-12-12 23:00:21 +00:00
"id" : "order_id" ,
"displayName" : "order_id" ,
"required" : true ,
2023-12-12 11:00:21 +00:00
"defaultMatch" : false ,
"display" : true ,
"type" : "string" ,
2023-12-12 23:00:21 +00:00
"canBeUsedToMatch" : true ,
"removed" : false
2023-12-11 23:00:22 +00:00
}
]
} ,
"options" : { }
} ,
"id" : "716963ce-227c-470b-83d5-85c4af9442f3" ,
"name" : "Postgres" ,
"type" : "n8n-nodes-base.postgres" ,
"typeVersion" : 2.3 ,
"position" : [
2023-12-12 11:00:21 +00:00
1120 ,
-1320
2023-12-11 23:00:22 +00:00
] ,
"credentials" : {
"postgres" : {
"id" : "JW5wwsSY4obQbCBb" ,
"name" : "Postgres - warehouse"
}
}
} ,
{
"parameters" : {
"value" : "={{ $json.OrderNumber.concat($json.CreatedAt.toDate().format(\"yyyy-MM-d\")) }}" ,
2023-12-12 23:00:21 +00:00
"dataPropertyName" : "=order_hash"
2023-12-11 23:00:22 +00:00
} ,
"id" : "67fd82c6-055a-41d7-bc5e-ca727b0f9777" ,
"name" : "Crypto" ,
"type" : "n8n-nodes-base.crypto" ,
"typeVersion" : 1 ,
"position" : [
2023-12-12 11:00:21 +00:00
700 ,
-1320
2023-12-11 23:00:22 +00:00
]
} ,
{
"parameters" : {
2023-12-12 11:00:21 +00:00
"mode" : "chooseBranch" ,
"output" : "input2"
2023-12-11 23:00:22 +00:00
} ,
2023-12-12 11:00:21 +00:00
"id" : "8490a7f7-6f11-487b-8f81-4c97f56c638b" ,
"name" : "Merge" ,
"type" : "n8n-nodes-base.merge" ,
"typeVersion" : 2.1 ,
"position" : [
500 ,
-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\tmatch item.json.Seller.BillbeeShopName:\n\t\tcase 'eBay':\n item.json.platform = 12\n\t\tcase 'lana-kk':\n item.json.platform = 1\n\t\tcase 'Amazon':\n item.json.platform = 2\n\t\tcase 'Weltkarten24':\n item.json.platform = 3\n\t\tcase 'KAUFLAND':\n item.json.platform = 5\n\t\tcase 'Wayfair':\n item.json.platform = 4\n\t\tcase 'Böttcher AG':\n item.json.platform = 7\n\t\tcase 'Juramondo':\n item.json.platform = 9\n\t\tcase 'wild.lanakk.com':\n item.json.platform = 8\n\t\tcase 'Etsy':\n item.json.platform = 10\n\t\tcase 'Otto':\n item.json.platform = 6\n\t\tcase 'weltkarte-kinder':\n item.json.platform = 11\n\t\tcase _:\n item.json.platform = 1\nreturn _input.all()\n"
} ,
"id" : "2006b054-3147-4f8a-b8d1-6ce19554dfde" ,
"name" : "Code" ,
"type" : "n8n-nodes-base.code" ,
"typeVersion" : 2 ,
2023-12-11 23:00:22 +00:00
"position" : [
2023-12-12 11:00:21 +00:00
920 ,
-1320
]
} ,
2023-12-12 23:00:21 +00:00
{
"parameters" : {
"mode" : "chooseBranch" ,
"output" : "input2"
} ,
"id" : "5d30f116-d392-4a34-9977-c9cb1bcaae07" ,
"name" : "Merge1" ,
"type" : "n8n-nodes-base.merge" ,
"typeVersion" : 2.1 ,
"position" : [
1300 ,
-1100
]
} ,
2023-12-12 11:00:21 +00:00
{
"parameters" : {
"fieldToSplitOut" : "OrderItems" ,
2023-12-12 23:00:21 +00:00
"include" : "selectedOtherFields" ,
"fieldsToInclude" : "order_hash" ,
2023-12-12 11:00:21 +00:00
"options" : { }
} ,
2023-12-12 23:00:21 +00:00
"id" : "dc3a5418-691f-42a9-b09f-bb4c9d0e2155" ,
"name" : "Item Lists" ,
2023-12-12 11:00:21 +00:00
"type" : "n8n-nodes-base.itemLists" ,
"typeVersion" : 3 ,
"position" : [
2023-12-12 23:00:21 +00:00
1520 ,
-1100
2023-12-11 23:00:22 +00:00
]
2023-12-12 23:00:21 +00:00
} ,
{
"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"
}
}
2023-12-11 23:00:22 +00:00
}
] ,
"pinData" : { } ,
"settings" : {
"executionOrder" : "v1"
} ,
"staticData" : null ,
"tags" : [ ] ,
"triggerCount" : 0 ,
2023-12-12 23:00:21 +00:00
"updatedAt" : "2023-12-12T14:20:06.000Z" ,
"versionId" : "bb86d85c-7be5-4ba4-aa35-59959e7386c3"
2023-12-11 23:00:22 +00:00
}