Sometimes when processing orders it ends up with errors due to order importing issues. If you check the logs you will see below error message for the orders.


An error has occurred in 'Importing Order' - inner exception : 'Cannot insert duplicate key row in object 'dbo.Document' with unique index 'idx_InternalInvoiceNumber'. The duplicate key value is (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx, BUNNINGS, xxxxxxxxx).
The statement has been terminated.'


Internal invoice numbers are generated from TOE system. There is a count for the document internal invoice numbers and sometimes it is not creating new invoice numbers when that count has reached to its maximum. Due to this reason it ends up with issues in importing orders to the A/C system and the order status remains in READYTOIMPORT in TOE dashboard.


If you need to view the maximum internal invoice number you can use below SQL query;


select max(InternalInvoiceNumber) from document


To view the internal invoice counter


select * from SupplierRetailerSetting where RetailerSettingName = 'INVOICECOUNTER'


To update this value for the particular retailer to a larger value.


Update SupplierRetailerSetting

set value = <new larger value>

where RetailerSettingName = 'INVOICECOUNTER'

and RetailerCode = 'BUNNINGS'


Once this is executed you can try processing the documents again and the orders will be imported.