e-Document integration looks like a simple API call. In reality it's an operation that depends on an external service, has legal consequences and cannot be undone. The architecture must account for that.
01. Don't Make It Synchronous
The invoice save screen must not wait for the integrator's response. The document should first be written to your own database and the transmission queued. Otherwise a slowdown at the integrator locks the entire sales screen.
02. Queue and Retry
Transmission should run through a queue, with failed attempts retried at increasing intervals. Attempts must be capped to avoid an infinite loop, and a human alerted once the cap is reached.
03. Duplicate Protection
During a network drop the request may have gone out without a response coming back. Generating a unique reference per document and sending it to the integrator prevents the same invoice being issued twice. Without this protection, duplicates are inevitable.
04. Status Tracking
Draft, sent, delivered, accepted and rejected states must be visible in the ERP. A user should be able to answer "what happened to my invoice" without logging into the integrator's portal.
05. Reconciliation
The integrator's document list should be compared daily with the ERP's. Differences are noticed while small; noticed at month end, they delay the close.
06. Logging
The raw data sent and received should be kept for at least the statutory retention period. In a dispute, these records are the only thing that proves who sent what.