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 .…