Detect duplicate reference numbers

@lubos kindly check and send the latest update that is consistent with this new feature across all transactions. Thank you.

I have upgraded to the server edition 23.4.14.769 the problem still persists.

Duplicate reference numbers are not reported on all other transactions apart from Sales invoices.