Reference number calc works and ref is also saved to db