Order to Invoice Data Flow — Navision Integration¶
Purpose: Document the complete data flow from customer order placement through invoice generation, showing all touch points with Navision/K3 and external systems.
Scope: Zwerfkei Old (legacy) order processing pipeline — from webshop order to Navision, to fulfillment, to invoice.
Complete Order Lifecycle Overview¶
graph TD
Start["Customer Initiates Order"]
Start -->|"Medewerkker or Klant
online plaatst bestelling"| OrderFlow
OrderFlow["Order Created in Webshop"]
OrderFlow --> MetaFile["Metafile door
webshop"]
MetaFile --> OrderCheck{"Order wordt
aangepast?"}
OrderCheck -->|"Ja: Medewerkker
aanpassing"| Adjustment["Adjustment of
volledig nieuw"]
Adjustment --> Backend1["BACKEND ORDER
Orderstatus: Concept
Nieuw plichttaar"]
OrderCheck -->|"Nee"| Backend1
Backend1 --> Payment["Betaling en
plaats via PayPal"]
Payment --> PayPalProcess["PAYPAL
Betaaldracht
post_dan wel negeer"]
PayPalProcess --> K3Sync["K3 Sync Controller"]
K3Sync --> Backend2["BACKEND
Order Status: Definitief
Zichtbaar"]
Backend2 --> Magazijn["TOUCH MAGAZIJNBON
overzicht van
operationande artikelen"]
Magazijn --> Werknemers["Werknemers
pakt in sterken"]
Werknemers --> Backend3["BACKEND UPDATE
VERWERK
Operaties aan
operationale order"]
Backend3 --> Webshop["Webshop verwerkt
order"]
Webshop --> PostNL["POSTNIL
Voorsammeling
zending"]
Webshop --> Factuur["Factuur generatie"]
Factuur --> FacError["DEZE FACTUUR IS 'WEG'!
Het is een PDF die voor uit
en een factuur en maili meer
dan dit"]
FacError --> Complete["Verzendabel/Betaalmidel"]
PostNL --> Complete
style Start fill:#fff3cd
style OrderFlow fill:#fff3cd
style MetaFile fill:#fff3cd
style Backend1 fill:#d4edda
style Backend2 fill:#d4edda
style Backend3 fill:#d4edda
style K3Sync fill:#e7f3ff
style PayPalProcess fill:#e3f2fd
style PostNL fill:#e3f2fd
style Magazijn fill:#f8f9fa
style Werknemers fill:#f8f9fa
style Complete fill:#d4edda
Detailed Data Flow Stages¶
Stage 1: Order Creation & Validation¶
Trigger: Customer places order or medewerkker creates order via backend Duration: Seconds Systems Involved: Webshop, MySQL (local), Cache
Process:¶
- Order initiated by customer or medewerkker
- Metafile created in webshop with order details
- Order verification checks if adjustments needed
- Status set to: CONCEPT — order is not yet final
Data Written to Zwerfkei Database:¶
Bestellingtable: Order details, customer, items, totalsBestelling_artikeltable: Line items with quantitiesStock_reservationtable (TYPE_USER): Reserve items in stock
No Navision interaction yet — orders queued locally¶
Stage 2: Payment Processing¶
Trigger: Customer confirms order → Payment validation
Duration: 2-5 minutes
Systems Involved: PayNL (external), Webshop, MySQL
Process:¶
- Payment details sent to PayNL (configured payment provider)
- PayNL processes payment (card, iDEAL, etc.)
- Callback from PayNL confirms payment status
- Order status updated to: DEFINITIEF (confirmed)
Data Written:¶
Bestellingtable: payment_status, payment_reference- Order moved from CONCEPT → DEFINITIEF status
Critical: Stock reservations confirmed at this stage¶
- Cart reservations (TYPE_USER) still active
- On payment success: kept as TYPE_ORDER
Stage 3: K3 Sync & Navision Order Submission¶
Trigger: Order marked DEFINITIEF → K3 Sync Cron (every 5 minutes)
Duration: 5 minutes (worst case) + SOAP call latency (2-10 sec)
Systems Involved: MySQL, K3 Sync Controller, Navision
Process:¶
-
Cron job
k3retail_syncfires (every 5 minutes)Query: SELECT * FROM k3_synchronization WHERE status = 'pending' AND model = 'order' -
For each pending order:
- Lock the sync queue:
GET_LOCK('k3_sync', 1) - Build SOAP request with order data
-
Call Navision
SubmitOrderoperation -
Navision processes order:
- Creates Sales Order in NAV
- Assigns order a nav_id (Navision order number)
- Updates NAV inventory
-
Returns confirmation
-
Success path:
- Update
k3_synchronization.status = 'ok' - Update
k3_synchronization.nav_id = <returned_id> -
Update
Bestelling.nav_idin webshop database -
Failure path (up to 10 retries):
- Log SOAP fault
- Increment retry counter
- Retry with exponential backoff
- If all 10 retries fail: Send alert to monitoring
Data Sent to Navision (SubmitOrder):¶
OrderNo → Unique order ID from Zwerfkei
CustomerNo → K3 customer number
OrderDate → Order creation date
RequestedDeliveryDate → Expected delivery date
CurrencyCode → EUR / USD
Lines[] → Array of order items
- ItemNo → K3 article number
- Quantity → Ordered quantity
- UnitPrice → Price from Zwerfkei at time of order
- LineDiscount → Applied discount percentage
TotalAmount → Order total
ShippingMethod → PostNL or other carrier
PaymentTerms → Payment method
Data Received from Navision:¶
SalesOrderNo → NAV order ID (stored as nav_id)
Status → OK / ERROR / WARNING
Messages[] → Any warnings or errors
Database Updates:¶
k3_synchronizationtable: status=ok, nav_id, date_okBestellingtable: nav_id updatedBestelling_artikeltable: nav_reference_id updated
Critical: If K3 sync fails, order is stuck → Manual intervention required
Stage 4: Warehouse Fulfillment¶
Trigger: Order confirmed in Navision
Duration: 1-24 hours (depends on warehouse hours)
Systems Involved: TOUCH (warehouse app), Navision, MySQL
Process:¶
- TOUCH Magazine (Warehouse) App
- Displays order in picking list (MAGAZIJNBON)
- Shows items to pick with:
- Item number & barcode
- Quantity required
- Location in warehouse
-
Warehouse staff scan barcodes and pick items
-
Quality Check:
- Staff verifies all items present
- If item missing: Marked as "manco" (short)
-
Updates order status for short items
-
Packing:
- Warehouse staff packs items
- Generates packing slip (PDF)
-
Associates tracking number (PostNL)
-
Backend Update:
- TOUCH sends fulfillment data back to Zwerfkei
- Updates order status to: VERWERKT (processed)
Data Sent to Navision (implicit via sync):¶
- Goods Issue/Receipt confirmation
- Updates NAV inventory (decrements available stock)
- Confirms shipment readiness
Stage 5: Shipment & PostNL Integration¶
Trigger: Order packed in warehouse
Duration: Same-day or next-day shipping
Systems Involved: PostNL (external), Navision, MySQL
Process:¶
- Shipment Details Created:
- Packing slip generated with tracking number
- PostNL barcode assigned
-
Shipping method confirmed (standard, express, etc.)
-
PostNL Updates:
- Webshop sends shipment info to PostNL via API
- PostNL returns tracking number
-
Tracking number stored in database
-
K3/Navision Update (async):
- Sync buffer queries:
GetOrderStatus(continuous polling) - Navision returns updated shipment status
- Webshop database updated with tracking info
- Customer notified via email with tracking link
Data Flows:¶
Zwerfkei → PostNL API:
- Order number
- Recipient address
- Package weight
- Insurance flag
PostNL → Zwerfkei Callback:
- Tracking number
- Estimated delivery date
- Barcode
Navision → Zwerfkei (Buffer sync):
- Shipment status: Pending → Shipped
- PostNL tracking number
- Estimated delivery date
Database Updates:¶
Bestellingtable: tracking_number, shipment_status, estimated_deliveryBestelling_artikeltable: Each line marked as shipped
Stage 6: Invoice Generation¶
Trigger: Order shipped (or based on payment success, depending on configuration)
Duration: Automatic (same-day or next-day)
Systems Involved: Navision, MySQL, PDF generator
Process:¶
- Navision Generates Invoice:
- After goods issue is confirmed
- Creates invoice number (Fax/Factuurnummer)
- Calculates totals with tax
-
Stores in value entries
-
Zwerfkei Retrieves Invoice:
- Sync buffer:
GetValueEntries(nightly cron, 3 AM) - Fetches latest invoices/GL entries
-
Stores in local database for reporting
-
Invoice PDF Generated:
- Template with Zwerfkei & Navision data
-
Includes:
- Order number (Navision order ID)
- Invoice number
- Customer details
- Line items with prices & taxes
- Total amount due
- Payment terms
-
Delivery to Customer:
- Email sent to customer with PDF attachment
- PDF stored on server for download
Known Issue: Missing Invoice Files¶
Note: According to the orderprocess diagram, there's a known issue:
"Deze factuur is 'weg'! Het is een PDF die voor uit
en een factuur en maili meer dan dit"
Translation: "This invoice is 'gone'! It's a PDF that is
before and an invoice and mail more than this"
Implication: Some invoices are not being properly stored or delivered. This requires investigation into: - PDF generation failures - Email delivery failures - Database storage failures - File system permissions issues
Data in Invoice:¶
- Invoice number (from Navision)
- Order number
- Order date & delivery date
- Customer name & address
- Line items: Article name, quantity, unit price, line total
- Subtotal, tax amount, total due
- Payment terms & reference
Stage 7: Settlement & Accounting¶
Trigger: Invoice generated
Duration: 1-30 days (payment terms)
Systems Involved: Navision GL, POSTNIL (accounting), MySQL
Process:¶
- Navision GL Entry Created:
- Debit: Accounts Receivable
- Credit: Sales Revenue
- Amount: Invoice total
-
Stored in G/L ledger
-
Accounting Sync:
- Nightly cron fetches GL entries:
GetValueEntries(3 AM) - All value entries from Navision synced to Zwerfkei
-
Used for reporting & reconciliation
-
Payment Receipt:
- Customer pays invoice (via bank transfer, card, etc.)
- Navision records payment
-
GL entry updated: A/R cleared, Cash credited
-
POSTNIL Accounting Export:
- Weekly/monthly export to accounting system
- Sales journal entries
- Used for financial reporting
Database Tables:¶
K3_value_entrytable: Accounting entries from Navision- Used for reporting, not business logic
System Integrations (All Touchpoints)¶
Navision/K3 (Core ERP)¶
| Data Flow | Direction | Frequency | Method | Status |
|---|---|---|---|---|
| Order submission | Web → NAV | Every 5 min (queue) | SOAP SubmitOrder |
✅ Live |
| Order status updates | NAV → Web | Every 1 min (buffer) | SOAP GetOrderStatus |
✅ Live |
| Stock decrement | NAV (automatic) | Immediate | Internal NAV logic | ✅ Live |
| Invoice generation | NAV (automatic) | Same-day | Internal NAV logic | ✅ Live |
| Accounting entries | NAV → Web | Every night (3 AM) | SOAP GetValueEntries |
✅ Live |
PayNL (Payment)¶
| Data Flow | Direction | Frequency | Method | Status |
|---|---|---|---|---|
| Payment processing | Web → PayNL | On checkout | HTTPS API | ✅ Live |
| Payment confirmation | PayNL → Web | Immediate | Callback webhook | ✅ Live |
| Transaction sync | NAV ← PayNL | Hourly | GetTransactions |
✅ Live |
PostNL (Shipping)¶
| Data Flow | Direction | Frequency | Method | Status |
|---|---|---|---|---|
| Shipment creation | Web → PostNL | On pack | HTTPS API | ✅ Live |
| Tracking number | PostNL → Web | Immediate | API response | ✅ Live |
| Delivery updates | PostNL → Web | Daily (polling) | HTTPS API | ✅ Live |
| Shipment sync | NAV ← PostNL | Every 1 min (buffer) | Via NAV sync | ✅ Live |
TOUCH (Warehouse)¶
| Data Flow | Direction | Frequency | Method | Status |
|---|---|---|---|---|
| Picking list | Web → TOUCH | On order confirm | Database sync | ✅ Live |
| Goods confirmation | TOUCH → Web | On pack | API/Database | ✅ Live |
| Order fulfillment | Web → NAV (implicit) | On goods issue | SOAP (automatic) | ✅ Live |
POS (Point of Sale)¶
| Data Flow | Direction | Frequency | Method | Status |
|---|---|---|---|---|
| Transactions | POS → NAV | Real-time | K3 Retail system | ✅ Live |
| Transaction sync | NAV → Web | Hourly | SOAP GetTransactions |
✅ Live |
Error Handling & Retry Logic¶
K3 Sync Failures¶
If SubmitOrder fails:
1. SOAP fault returned from Navision
2. Error logged with full details
3. Retry counter incremented (up to 10 retries)
4. Retry happens in next cron run (5-minute window)
5. Exponential backoff applied (1s, 2s, 4s, etc.)
6. Error lock file created to prevent retry storms (5-min cooldown)
If all 10 retries fail: - Order status: SYNC_ERROR - Alert sent to monitoring/ops team - Manual intervention required: - Check Navision availability - Verify order data is valid - Retry manually or create order in Navision directly
Payment Failures¶
If PayNL callback doesn't arrive: - Order remains in CONCEPT status - Background job checks for pending orders (old, unpaid) - Notifies customer to retry payment or abandon cart
Shipment Failures¶
If PostNL submission fails: - Order marked as "pending shipment" - Retry automatic (async) - Manual assignment available in backend if needed
Cron Jobs & Scheduling¶
| Job Name | Interval | Purpose | Status |
|---|---|---|---|
k3retail_webservices |
Every 1 minute | Poll Navision buffer for changes | ✅ |
k3retail_sync |
Every 5 minutes | Process outbound queue (orders, etc.) | ✅ |
checkK3Sync |
Every 30 minutes | Monitor queue health, send alerts | ✅ |
getTransactions |
Hourly | Sync POS transactions from Navision | ✅ |
getMemberPoints |
Scheduled (TBD) | Sync member loyalty points | ✅ |
getValueEntries |
Nightly (3 AM) | Sync accounting entries | ✅ |
getMissingOrders |
Hourly (TBD) | Find & retry failed orders | ✅ |
Data Validation Rules¶
Order Submission Validation¶
Before sending to Navision via SubmitOrder:
| Rule | Purpose | Action if Failed |
|---|---|---|
| Customer exists in K3 | Ensure valid customer account | Sync customer first (SetMemberAccount) |
| All items exist in K3 | Items are orderable | Block order, notify customer |
| Quantities > 0 | Logical validation | Block order |
| Total amount >= 0 | Must have positive value | Block order |
| Delivery address valid | Postal address rules | Block order |
| Payment confirmed | No COD orders (currently) | Block order until payment received |
| Stock available (OPAANVRAAG OK) | Item is orderable | Block order or mark as backorder |
Invoice Validation¶
Before marking order as completed:
| Rule | Purpose | Action if Failed |
|---|---|---|
| Goods issued in Navision | Physical inventory decremented | Order stuck in transit |
| Invoice number assigned | Required for accounting | Retry sync |
| Amount matches order | No accounting discrepancy | Manual review required |
Known Issues & Gaps¶
Invoice Storage Issue¶
Problem: Invoices are not being reliably stored or delivered to customers
Impact: Customers may not receive invoices; compliance/accounting issues
Status: Noted in orderprocess diagram — investigation needed
Suggested Fix: Audit PDF generation, email delivery logs, and file storage
Manco (Short Item) Handling¶
Problem: When warehouse finds item missing during picking, process for backfilling order unclear
Impact: Customer order may be incomplete; unclear whether partial shipment allowed
Status: TOUCH system handles it, but sync back to Navision/customer unclear
Negative Stock Handling¶
Problem: System allows negative stock in rare cases (overselling)
Impact: More orders than inventory; fulfillment issues
Status: K3 OPAANVRAAG status allows ordering from suppliers as workaround
Real-Time Stock Sync¶
Problem: Stock sync happens every 1 minute; no real-time visibility during high-traffic periods
Impact: Race conditions possible; customer orders may fail stock check after placing
Status: Acceptable for current load; will need optimization for high-volume periods
Future Improvements (Business Central Migration)¶
The current SOAP-based integration will be replaced with Business Central REST API for: - Simpler request/response format (JSON vs. XML) - Better error handling & status codes - Real-time webhooks instead of polling - Support for multi-tenant environments - Alignment with Microsoft's modern platform