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.
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
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
|
||||
-- Bestellinformationen
|
||||
so.external_ref AS "Bestellnummer",
|
||||
TO_CHAR(so.order_date, 'YYYY-MM-DD"T"HH24:MI:SS') AS "Bestelldatum",
|
||||
TO_CHAR(so.shipping_date, 'YYYY-MM-DD') AS "Versanddatum",
|
||||
|
||||
-- Kundenadresse (Lieferadresse)
|
||||
COALESCE(ad.first_name, '') AS "Vorname",
|
||||
COALESCE(ad.last_name, '') AS "Nachname",
|
||||
COALESCE(ad.street, '') AS "Strasse",
|
||||
COALESCE(ad.house_number, '') AS "Hausnummer",
|
||||
COALESCE(ad.zip, '') AS "PLZ",
|
||||
COALESCE(ad.city, '') AS "Stadt",
|
||||
COALESCE(ad.country_name, '') AS "Land",
|
||||
|
||||
-- Zahlungs- und Betragsinformationen
|
||||
COALESCE(pm.code, '') AS "Zahlungsart",
|
||||
COALESCE(so.amount_net, 0) AS "Gesamtbetrag_netto",
|
||||
COALESCE(so.amount_shipping, 0) AS "Versandkosten",
|
||||
COALESCE(so.total_amount, 0) AS "Gesamtbetrag_brutto",
|
||||
COALESCE(so.amount_discount, 0) AS "Rabatt",
|
||||
|
||||
-- Produktzählungen (nur aktive Produkte)
|
||||
COALESCE(SUM(CASE WHEN p.id = 8 THEN a.qty ELSE 0 END), 0) AS "#_ChagaFlaschen", -- CHAGA (ID 8)
|
||||
COALESCE(SUM(CASE WHEN p.id = 5 THEN a.qty ELSE 0 END), 0) AS "#_ReishiFlaschen", -- 003.01 (ID 5)
|
||||
COALESCE(SUM(CASE WHEN p.id = 9 THEN a.qty ELSE 0 END), 0) AS "#_ShiitakeFlaschen", -- SHIITAKE (ID 9)
|
||||
COALESCE(SUM(CASE WHEN p.id = 6 THEN a.qty ELSE 0 END), 0) AS "#_LionsManeFlaschen" -- 005.02 (ID 6)
|
||||
|
||||
FROM sales_order so
|
||||
-- Lieferadresse
|
||||
LEFT JOIN address ad ON so.party_id = ad.party_id AND ad.type = 'shipping'
|
||||
-- Zahlungsart
|
||||
LEFT JOIN payment_method pm ON so.payment_method_id = pm.id
|
||||
-- Bestellpositionen und Allokationen
|
||||
LEFT JOIN sales_order_line sol ON so.id = sol.sales_order_id
|
||||
LEFT JOIN sales_order_line_lot_allocation a ON sol.id = a.sales_order_line_id
|
||||
-- Produkte (nur aktive)
|
||||
LEFT JOIN product p ON a.product_id = p.id AND p.status = 'active'
|
||||
|
||||
WHERE so.external_ref = $1
|
||||
GROUP BY so.id, ad.id, pm.id
|
||||
queryValues:
|
||||
values:
|
||||
value: "={{ $json.Bestellnummer }}"
|
||||
string: "={{ $json.Bestellnummer }}"
|
||||
options:
|
||||
maxRows: 1
|
||||
Reference in New Issue
Block a user