Menu

Idempotent Imports: Avoiding Duplicate Vouchers
📰

Idempotent Imports: Avoiding Duplicate Vouchers

DEV Community: backend·solverteam·about 4 hours ago
#qSFPrgYN
#devtobackend#devto#dev#await#hash
Long article (664 words) — no AI summary yet.
Reading 0:00
15s threshold

Any import that runs over a network will eventually run twice: the user double-clicks, a timeout fires after the server already saved, or a retry job wakes up. If every run creates new rows, you get duplicate invoices, double stock and wrong ledgers. The fix is to make the import idempotent: running it twice has the same effect as running it once.

1. Give every document a stable external key

The source system must send a key that never changes for that document, for example a GUID created when the bill is saved, or (SourceId, DocumentNumber, FinancialYear) . Never use the auto-increment id of the receiving table as the identity.

CREATE TABLE dbo .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.