diff --git a/workflows/MyToys.json b/workflows/MyToys.json index 46b4b46..a79595d 100644 --- a/workflows/MyToys.json +++ b/workflows/MyToys.json @@ -1,7 +1,90 @@ { "active": false, "connections": { - "Code": { + "Auftragsdaten CSV einlesen": { + "main": [ + [ + { + "node": "Set1", + "type": "main", + "index": 0 + } + ] + ] + }, + "FTP": { + "main": [ + [ + { + "node": "FTP1", + "type": "main", + "index": 0 + } + ] + ] + }, + "PDF": { + "main": [ + [], + [ + { + "node": "Auftragsdaten CSV einlesen", + "type": "main", + "index": 0 + }, + { + "node": "Ins Archiv verschieben", + "type": "main", + "index": 0 + } + ] + ] + }, + "FTP1": { + "main": [ + [ + { + "node": "PDF", + "type": "main", + "index": 0 + } + ] + ] + }, + "Execute Command": { + "main": [ + [ + { + "node": "Billbee ShopID + Token", + "type": "main", + "index": 0 + } + ] + ] + }, + "Set1": { + "main": [ + [ + { + "node": "Bestellung an Billbee senden", + "type": "main", + "index": 0 + } + ] + ] + }, + "Billbee Order lesen": { + "main": [ + [ + { + "node": "Set2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Set2": { "main": [ [ { @@ -12,11 +95,11 @@ ] ] }, - "Auftragsdaten CSV einlesen": { + "Rückmeldung CSV erzeugen": { "main": [ [ { - "node": "Set", + "node": "FTP2", "type": "main", "index": 0 } @@ -31,15 +114,16 @@ { "parameters": { "protocol": "sftp", - "operation": "list" + "operation": "list", + "path": "/archiv" }, "id": "77792d6c-723a-4021-a25b-866c87195fea", "name": "FTP", "type": "n8n-nodes-base.ftp", "typeVersion": 1, "position": [ - 320, - -80 + 400, + -180 ], "credentials": { "sftp": { @@ -50,14 +134,14 @@ }, { "parameters": { - "jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.TB_ORDER_ID = \"order_id\";\n item.json.ORDER_PAID = 0;\n item.json.TYPE = \"ship\";\n item.json.PARCEL_TYPE = \"DPD_STD_NATIONAL\";\n item.json.SHIP_CODE = \"12345-track-me\";\n item.json.IDCODE_RETURN_PROP\nOSAL = \"\";\n item.json.COMMENT_INTERN = \"Hier könnte Dein INTERNER Kommentar interner stehen.\";\n item.json.COMMENT = \"Hier könnte Dein Kommentar interner stehen.\"\n}\n\nreturn $input.all();" + "jsCode": "// Loop over input items and add a new field\n// called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n item.json.TB_ORDER_ID = item.json.data.Data.OrderNumber;\n item.json.ORDER_PAID = 0;\n item.json.TYPE = \"ship\";\n item.json.PARCEL_TYPE = \"DPD_STD_NATIONAL\";\n item.json.SHIP_CODE = \"12345-track-me\";\n item.json.IDCODE_RETURN_PROP\nOSAL = \"\";\n item.json.COMMENT_INTERN = \"Hier könnte Dein INTERNER Kommentar interner stehen.\";\n item.json.COMMENT = \"Hier könnte Dein Kommentar interner stehen.\"\n}\n\nreturn $input.all();" }, "id": "fb6645ac-6ef7-46a8-92cd-67ecb9549c79", "name": "Code", "type": "n8n-nodes-base.code", "typeVersion": 1, "position": [ - 840, + 300, 480 ] }, @@ -72,7 +156,7 @@ }, { "name": "X-Billbee-Api-Key", - "value": "={{$env['BILLBEE_API_KEY']}}" + "value": "={{$json[\"stdout\"]}}" } ] }, @@ -97,7 +181,7 @@ "parameter": [ { "name": "={{$node[\"Billbee ShopID + Token\"].parameter[\"values\"][\"string\"][1][\"name\"]}}", - "value": "={{$env[\"BILLBEE_API_KEY\"}}" + "value": "=2855BE2C-1D67-4AB0-9DEB-3073E6D27B1C" } ] } @@ -106,8 +190,8 @@ "type": "n8n-nodes-base.httpRequest", "typeVersion": 1, "position": [ - 1540, - 140 + 1140, + 180 ], "id": "c81d1331-8653-4693-ada1-6697dc9ee038", "credentials": { @@ -132,11 +216,12 @@ "typeVersion": 1, "position": [ 1240, - 520 + 600 ] }, { "parameters": { + "binaryPropertyName": "=data", "options": { "headerRow": true } @@ -146,8 +231,8 @@ "type": "n8n-nodes-base.spreadsheetFile", "typeVersion": 1, "position": [ - 740, - 180 + 1160, + -160 ] }, { @@ -174,12 +259,28 @@ { "name": "InvoiceAddress.Country", "value": "={{ $json[\"CUST_SELL_COUNTRY_CODE\"] }}" + }, + { + "name": "InvoiceAddress.Zip", + "value": "={{$json[\"CUST_SHIP_ZIP\"]}}" + }, + { + "name": "InvoiceAddress.CountryISO2", + "value": "={{$json[\"CUST_SHIP_COUNTRY_CODE\"]}}" + }, + { + "name": "InvoiceAddress.FirstName", + "value": "={{$json[\"CUST_SHIP_FIRSTNAME\"]}}" } ], "number": [ { - "name": "OrderDate", - "value": "={{ $json[\"ORDER_DATE\"] }}" + "name": "CreatedAt", + "value": "={{ $today.toISODate()}}" + }, + { + "name": "InvoiceAddress.Country", + "value": "={{$json[\"CUST_SHIP_COUNTRY_CODE\"]}}" } ] }, @@ -192,103 +293,328 @@ "type": "n8n-nodes-base.set", "typeVersion": 1, "position": [ - 980, + 1400, + 820 + ] + }, + { + "parameters": { + "command": "cat $BILLBEE_API_KEY" + }, + "id": "65c16259-a7d8-453a-a542-3d840328f396", + "name": "Execute Command", + "type": "n8n-nodes-base.executeCommand", + "typeVersion": 1, + "position": [ + 180, 180 ] - } - ], - "pinData": { - "Auftragsdaten CSV einlesen": [ - { - "json": { - "TB_ORDER_ID": "orderid", - "CHANNEL_KEY": "", - "CHANNEL_ORDER_ID": "Kanal order id", - "CHANNEL_ORDER_NR": "", - "ORDER_DATE": "datum der Bestellung", - "IDCODE_SHIP": "", - "GPLCODE": "", - "TOTAL_AMOUNT": "", - "SHIPPING_COSTS": "", - "PAYMENT_TYPE": "", - "PAYMENT_COSTS": "", - "PAYMENT_TRANSACTION_ID": "", - "PAYMENT_TRANSACTION_NR": "", - "PAYMENT_TRANSACTION_NAME": "", - "DIRECTDEBIT_ACCOUNTNAME": "", - "DIRECTDEBIT_ACCOUNTNR": "", - "DIRECTDEBIT_BANKNAME": "", - "DIRECTDEBIT_BANKCODE": "", - "CUSTOMER_COMMENT": "", - "TB_CUST_SHIP_ID": "", - "CHANNEL_CUST_SHIP_ID": "", - "CUST_SHIP_SALUTATION": "Lieferadresse Anrede", - "CUST_SHIP_SURNAME": "", - "CUST_SHIP_FIRSTNAME": "Lieferadresse Vorname", - "CUST_SHIP_EXTENSION": "Lieferadresse Zusatz", - "CUST_SHIP_STREET_NO": "Lieferadresse Strasse Husnummer", - "CUST_SHIP_ZIP": "Lieferadresse PLZ", - "CUST_SHIP_CITY": "Lieferadresse Stadt", - "CUST_SHIP_COUNTRY_CODE": "Lieferadresse Land", - "CUST_SHIP_TEL_PRIV": "Lieferadresse Telefon Privat", - "CUST_SHIP_TEL_OFFICE": "Lieferadresse Telefon Büro", - "CUST_SHIP_EMAIL": "Lieferadresse Telefon Email", - "CUST_SHIP_BIRTHDATE": "", - "TB_SELL_CUST_ID": "", - "CHANNEL_SELL_CUST_ID": "", - "CUST_SELL_SALUTATION": "Anrede", - "CUST_SELL_SURNAME": "", - "CUST_SELL_FIRSTNAME": "Vorname", - "CUST_SELL_EXTENSION": "Zusatz", - "CUST_SELL_STREET_NO": "Strasse Hausnummer", - "CUST_SELL_ZIP": "PLZ", - "CUST_SELL_CITY": "Stadt", - "CUST_SELL_COUNTRY_CODE": "Land", - "CUST_SELL_TEL_PRIV": "Tele privat", - "CUST_SELL_TEL_OFFICE": "Tele büro", - "CUST_SELL_EMAIL": "Email", - "CUST_SELL_BIRTHDATE": "", - "CUST_BIRTHDATE": "", - "POS_LFDNR": "Nummer Artikelposition", - "POS_TB_ID": "", - "POS_CHANNEL_ID": "", - "POS_A_ID": "", - "POS_ANR": "Artikelnummer", - "POS_ANR2": "", - "POS_EAN": "EAN", - "POS_TEXT": "Produktbezeichnung", - "POS_QUANTITY": "Menge", - "POS_DELIVERY_TIME": "Lieferzeit", - "POS_SALESPRICE": "Verkaufspreis", - "POS_ANR_CHANNEL": "", - "DIRECTDEBIT_IBAN": "", - "DIRECTDEBIT_BIC": "", - "CUST_SHIP_TEL_MOBILE": "", - "CUST_SELL_TEL_MOBILE": "", - "ORDER_STATUS": "", - "POS_TRANSFER_PRICE": "Kanal EInkaufspreis", - "PAYMENT_DATA": "", - "SERVICE_Code{1}": "", - "SERVICE_Desc{1}": "", - "SERVICE_Price{1}": "", - "SERVICE_Code{2}": "", - "SERVICE_Desc{2}": "", - "SERVICE_Price{2}": "", - "SERVICE_Code{3}": "", - "SERVICE_Desc{3}": "", - "SERVICE_Price{3}": "" + }, + { + "parameters": { + "conditions": { + "string": [ + { + "value1": "={{$json[\"name\"]}}", + "operation": "endsWith", + "value2": "pdf" + } + ] } }, - { - "json": { - "name": "Second item", - "code": 2 + "id": "d54af494-70dc-46ac-ad19-91c90fa53f69", + "name": "PDF", + "type": "n8n-nodes-base.if", + "typeVersion": 1, + "position": [ + 840, + -180 + ] + }, + { + "parameters": { + "protocol": "sftp", + "path": "=/archiv/_done_with_errors_20230119_115617_ORDER_01mydk_lana.xml" + }, + "id": "ee40a4c2-d570-4a61-8373-e4e4c46536fd", + "name": "FTP1", + "type": "n8n-nodes-base.ftp", + "typeVersion": 1, + "position": [ + 620, + -180 + ], + "credentials": { + "sftp": { + "id": "1", + "name": "SFTP MyToys" } } - ] - }, + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "CreatedAt", + "value": "={{ $today.toISODate()}}" + }, + { + "name": "Ordernumber", + "value": "={{ $json[\"TB_ORDER_ID\"] }}" + }, + { + "name": "invoiceAddress.Company", + "value": "={{ $json[\"CUST_SHIP_EXTENSION\"] }}" + }, + { + "name": "invoiceAddress.Company", + "value": "={{ $json[\"CUST_SHIP_SURNAME\"] }}" + }, + { + "name": "invoiceAddress.Street", + "value": "={{ $json[\"CUST_SHIP_STREET_NO\"] }}" + }, + { + "name": "invoiceAddress.City", + "value": "={{ $json[\"CUST_SHIP_CITY\"] }}" + }, + { + "name": "invoiceAddress.Zip", + "value": "={{$json[\"CUST_SHIP_ZIP\"]}}" + }, + { + "name": "invoiceAddress.Country", + "value": "={{ $json[\"CUST_SHIP_COUNTRY_CODE\"] }}" + }, + { + "name": "invoiceAddress.CountryISO2", + "value": "={{$json[\"CUST_SHIP_COUNTRY_CODE\"]}}" + }, + { + "name": "invoiceAddress.FirstName", + "value": "={{$json[\"CUST_SHIP_FIRSTNAME\"]}}" + }, + { + "name": "invoiceAddress.LastName", + "value": "={{$json[\"CUST_SHIP_FIRSTNAME\"]}}" + }, + { + "name": "invoiceAddress.Email", + "value": "={{$json[\"CUST_SHIP_EMAIL\"]}}" + }, + { + "name": "shippingAddress.Company", + "value": "={{ $json[\"CUST_SHIP_EXTENSION\"] }}" + }, + { + "name": "shippingAddress.Company", + "value": "={{ $json[\"CUST_SHIP_SURNAME\"] }}" + }, + { + "name": "shippingAddress.Street", + "value": "={{ $json[\"CUST_SHIP_STREET_NO\"] }}" + }, + { + "name": "shippingAddress.City", + "value": "={{ $json[\"CUST_SHIP_CITY\"] }}" + }, + { + "name": "shippingAddress.Zip", + "value": "={{$json[\"CUST_SHIP_ZIP\"]}}" + }, + { + "name": "shippingAddress.Country", + "value": "={{ $json[\"CUST_SHIP_COUNTRY_CODE\"] }}" + }, + { + "name": "shippingAddress.CountryISO2", + "value": "={{$json[\"CUST_SHIP_COUNTRY_CODE\"]}}" + }, + { + "name": "shippingAddress.FirstName", + "value": "={{$json[\"CUST_SHIP_FIRSTNAME\"]}}" + }, + { + "name": "shippingAddress.LastName", + "value": "={{$json[\"CUST_SHIP_FIRSTNAME\"]}}" + }, + { + "name": "shippingAddress.Email", + "value": "={{$json[\"CUST_SHIP_EMAIL\"]}}" + }, + { + "name": "=orderItems[0].product.SKU", + "value": "={{$json[\"POS_ANR\"]}}" + }, + { + "name": "=orderItems[0].Quantity", + "value": "={{$json[\"POS_QUANTITY\"]}}" + }, + { + "name": "=orderItems[0].TotalPrice", + "value": "={{$json[\"POS_SALESPRICE\"]}}" + }, + { + "name": "Customer.Name", + "value": "MyToys Group" + }, + { + "name": "Customer.Email", + "value": "dev@lanakk.com" + } + ], + "number": [ + { + "name": "PaymentMethod", + "value": "3" + }, + { + "name": "Customer.Id", + "value": 163662708 + }, + { + "name": "Customer.Number", + "value": 20089 + } + ] + }, + "options": { + "dotNotation": true + } + }, + "id": "50b02a14-bac8-4748-be52-d2e789633254", + "name": "Set1", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 860, + 180 + ] + }, + { + "parameters": { + "protocol": "sftp", + "operation": "rename", + "oldPath": "={{$binary.data.directory}}/{{$binary.data.fileName}}", + "newPath": "=/archiv/{{$binary.data.fileName}}", + "options": {} + }, + "id": "8e265faa-72f6-4d78-92f2-d946aa866f2f", + "name": "Ins Archiv verschieben", + "type": "n8n-nodes-base.ftp", + "typeVersion": 1, + "position": [ + 1500, + 180 + ], + "credentials": { + "sftp": { + "id": "1", + "name": "SFTP MyToys" + } + } + }, + { + "parameters": { + "keepOnlySet": true, + "values": { + "string": [ + { + "name": "TB_ORDER_ID", + "value": "={{$json[\"Data\"][\"OrderNumber\"]}}" + }, + { + "name": "ORDER_PAID", + "value": "0" + }, + { + "name": "TYPE", + "value": "ship" + }, + { + "name": "PARCEL_TYPE", + "value": "DPD_STD_NATIONAL" + }, + { + "name": "SHIP_CODE", + "value": "=" + }, + { + "name": "COMMENT_INTERN", + "value": "Testorder" + }, + { + "name": "COMMENT" + } + ] + }, + "options": {} + }, + "id": "ff3bdda6-15bd-4799-9cc0-ea85b6b111d8", + "name": "Set2", + "type": "n8n-nodes-base.set", + "typeVersion": 1, + "position": [ + 2080, + 380 + ] + }, + { + "parameters": { + "authentication": "basicAuth", + "url": "=https://app.billbee.io/api/v1/orders/findbyextref/1", + "options": {}, + "headerParametersUi": { + "parameter": [ + { + "name": "={{$node[\"Billbee ShopID + Token\"].parameter[\"values\"][\"string\"][1][\"name\"]}}", + "value": "=2855BE2C-1D67-4AB0-9DEB-3073E6D27B1C" + } + ] + } + }, + "name": "Billbee Order lesen", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 1, + "position": [ + 1860, + 380 + ], + "id": "7cd76aab-c1f2-42e4-9de1-189a6fa0c136", + "credentials": { + "httpBasicAuth": { + "id": "2", + "name": "Billbee" + } + } + }, + { + "parameters": { + "protocol": "sftp", + "operation": "upload", + "path": "=/in/{{$binary.data.fileName}}" + }, + "id": "cd13302a-3bcf-4fdf-88a5-1ef5a40a725f", + "name": "FTP2", + "type": "n8n-nodes-base.ftp", + "typeVersion": 1, + "position": [ + 1620, + 620 + ], + "credentials": { + "sftp": { + "id": "1", + "name": "SFTP MyToys" + } + } + } + ], + "pinData": {}, "settings": {}, "staticData": null, "tags": [], - "updatedAt": "2023-01-18T17:56:42.913Z" + "updatedAt": "2023-01-19T13:53:17.913Z" } \ No newline at end of file