Duplicate invoice numbers

46 views
Skip to first unread message

Lutin

unread,
Nov 24, 2014, 4:34:39 AM11/24/14
to siwapp...@googlegroups.com
Has anyone ever had a situation where two invoices have exactly the same invoice number? 

This situation, although rare, has happened on my system 7 times over the last year. 

It seems to happen when two people (on different machines) are using the system at the same time and both create an invoice at around the same time (i.e. the invoice creation date are within seconds of each other). 

Looking at the code, the new invoice number is generated at part of a preSave method (it executes a sql select statement that simply gets the next number in the series). After the preSave is executed the invoice is inserted into the table more or less straight away. It seems, however that in my situation when the second invoice is created, it calls the presave method before the first invoice has actually been fully saved and as a result it will have the same invoice number. 

Not too sure yet how to resolve this. I suppose one way would be to have a unique constraint on a combination of the series_id and the number column so at least a duplicate would never get created. The user, would, however, get an error and have to press save again.


Just wondering if anyone else has seen this? I suspect that most people are only using siwapp on one machine where the above situation would never occur.

Thanks in advance.

Reply all
Reply to author
Forward
0 new messages