Fixes problems with html entities in debtor code
Fix SQL issue
Add in the next lot number when creating a new item