feat(erp): read-only invoice export for ERPNext

ERPNext (collab.vycept.com) now picks up every shop invoice with its PDF,
books it as a Wabenhain sales invoice and matches it to the Stripe payment
via the PaymentIntent, so fees, revenue and the invoice document sit on one
booking.

- GET /api/erp/rechnungen?seit=<ISO>&limit=<1-200>: invoices oldest first,
  with order, payment intent, customer address (no phone, no notes), items
  and the VAT split per rate exactly as printed (lib/vat.ts), including the
  shipping and discount share per rate, so ERPNext books the same cents.
- GET /api/erp/rechnungen/<RE-YYYY-NNNN>/pdf: the stored invoice PDF.
- Bearer token ERP_EXPORT_TOKEN (min. 32 chars, timing-safe compare);
  without it the export is off. Failed attempts are rate limited.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Nick SzaunigandClaude Opus 5.5 committed 2026-10-10 04:39:11 +02:00
1 parent 7698d4cef3
commit b246c9ff4e
6 files changed
+417

No files matched your search

+7
View File
@@ -107,6 +107,13 @@ APICORE_API_KEY=
# abgelehnt; der CronJob gleicht dann alle 10 Minuten ab.
APICORE_WEBHOOK_SECRET=
# Rechnungsexport fuer die Buchhaltung (ERPNext, collab.vycept.com): ERPNext
# holt damit stuendlich alle Rechnungen samt PDF ab und ordnet sie der
# Stripe-Zahlung zu (GET /api/erp/rechnungen, nur lesend, siehe
# src/lib/erp-export.ts). Mindestens 32 Zeichen, z. B. `openssl rand -hex 32`;
# derselbe Wert steht in ERPNext als WABENHAIN_ERP_TOKEN. Leer = Export aus.
ERP_EXPORT_TOKEN=
# DHL Parcel DE Shipping API ("Post & Parcel Germany", developer.dhl.com) —
# ermoeglicht das Erstellen von DHL-Versandmarken per Knopfdruck im
# Admin-Bestelldetail (siehe src/lib/dhl.ts). Ohne diese fuenf Werte zeigt