Files
erp_naurua/docs/N8N_POSTGRES_NODE.json
T
gitea_admin 0d8353fb9c Implement Excel webhook integration
Features:
- Migration 0007: shipping_date column with automatic next-business-day calculation
- New function trigger_excel_webhook() in order-import.php
- SQL query for extracting Excel data from ERP database
- Integration after successful order import
- Documentation for n8n Postgres node configuration

Changes:
1. db/migrations/0007_phase1_excel_webhook.sql - adds shipping_date column, trigger, next-business-day function
2. order-import.php - adds trigger_excel_webhook() function and integration point
3. docs/EXAKTE_POSTGRES_QUERY.sql - exact SQL query for n8n Postgres node
4. docs/N8N_POSTGRES_QUERY.md - comprehensive documentation
5. docs/N8N_POSTGRES_NODE.* - n8n node configurations
6. docs/N8N_EXCEL_WORKFLOW.json - complete workflow JSON
7. docs/N8N_NODE_COPY_PASTE.md - copy-paste ready instructions

The implementation triggers an Excel webhook after every successful order import, sending all necessary data for Excel bookkeeping to n8n.
2026-04-06 21:23:50 +02:00

26 lines
2.4 KiB
JSON

{
"name": "Excel Daten aus ERP abfragen",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.1,
"position": [0, 0],
"credentials": {
"postgres": {
"id": "YOUR_CREDENTIAL_ID_HERE",
"name": "ERP Naurua Database"
}
},
"parameters": {
"operation": "executeQuery",
"query": "SELECT \n -- Bestellinformationen\n so.external_ref AS \"Bestellnummer\",\n TO_CHAR(so.order_date, 'YYYY-MM-DD\"T\"HH24:MI:SS') AS \"Bestelldatum\",\n TO_CHAR(so.shipping_date, 'YYYY-MM-DD') AS \"Versanddatum\",\n \n -- Kundenadresse (Lieferadresse)\n COALESCE(ad.first_name, '') AS \"Vorname\",\n COALESCE(ad.last_name, '') AS \"Nachname\",\n COALESCE(ad.street, '') AS \"Strasse\",\n COALESCE(ad.house_number, '') AS \"Hausnummer\",\n COALESCE(ad.zip, '') AS \"PLZ\",\n COALESCE(ad.city, '') AS \"Stadt\",\n COALESCE(ad.country_name, '') AS \"Land\",\n \n -- Zahlungs- und Betragsinformationen\n COALESCE(pm.code, '') AS \"Zahlungsart\",\n COALESCE(so.amount_net, 0) AS \"Gesamtbetrag_netto\",\n COALESCE(so.amount_shipping, 0) AS \"Versandkosten\",\n COALESCE(so.total_amount, 0) AS \"Gesamtbetrag_brutto\",\n COALESCE(so.amount_discount, 0) AS \"Rabatt\",\n \n -- Produktzählungen (nur aktive Produkte)\n COALESCE(SUM(CASE WHEN p.id = 8 THEN a.qty ELSE 0 END), 0) AS \"#_ChagaFlaschen\", -- CHAGA (ID 8)\n COALESCE(SUM(CASE WHEN p.id = 5 THEN a.qty ELSE 0 END), 0) AS \"#_ReishiFlaschen\", -- 003.01 (ID 5)\n COALESCE(SUM(CASE WHEN p.id = 9 THEN a.qty ELSE 0 END), 0) AS \"#_ShiitakeFlaschen\", -- SHIITAKE (ID 9)\n COALESCE(SUM(CASE WHEN p.id = 6 THEN a.qty ELSE 0 END), 0) AS \"#_LionsManeFlaschen\" -- 005.02 (ID 6)\n \nFROM sales_order so\n-- Lieferadresse\nLEFT JOIN address ad ON so.party_id = ad.party_id AND ad.type = 'shipping'\n-- Zahlungsart\nLEFT JOIN payment_method pm ON so.payment_method_id = pm.id\n-- Bestellpositionen und Allokationen\nLEFT JOIN sales_order_line sol ON so.id = sol.sales_order_id\nLEFT JOIN sales_order_line_lot_allocation a ON sol.id = a.sales_order_line_id\n-- Produkte (nur aktive)\nLEFT JOIN product p ON a.product_id = p.id AND p.status = 'active'\n\nWHERE so.external_ref = $1\nGROUP BY so.id, ad.id, pm.id",
"queryValues": {
"values": {
"value": "={{ $json.Bestellnummer }}",
"string": "={{ $json.Bestellnummer }}"
}
},
"options": {
"maxRows": 1
},
"additionalFields": {}
}
}